WO2018028359A1 - Service processing method and device, and storage medium and electronic device - Google Patents

Service processing method and device, and storage medium and electronic device Download PDF

Info

Publication number
WO2018028359A1
WO2018028359A1 PCT/CN2017/091903 CN2017091903W WO2018028359A1 WO 2018028359 A1 WO2018028359 A1 WO 2018028359A1 CN 2017091903 W CN2017091903 W CN 2017091903W WO 2018028359 A1 WO2018028359 A1 WO 2018028359A1
Authority
WO
WIPO (PCT)
Prior art keywords
key
module
agent module
service
data
Prior art date
Application number
PCT/CN2017/091903
Other languages
French (fr)
Chinese (zh)
Inventor
杨藩
Original Assignee
腾讯科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN201610643327.XA external-priority patent/CN106302422B/en
Priority claimed from CN201611018871.1A external-priority patent/CN108076021B/en
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2018028359A1 publication Critical patent/WO2018028359A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications

Definitions

  • the present application relates to the field of computers, and in particular to a service processing method, apparatus, storage medium, and electronic device.
  • the encryption method used when encrypting a service, mainly includes three types: mode one, directly writing a fixed key in the code or configuration file; and second, directly saving or encrypting in plain text in the shared memory.
  • the save mode saves the key; mode 3: The key is saved on the server managed by the special manager, and the service can periodically call and obtain the key in the server through the network.
  • the related art provides a method for encrypting and decrypting by using a proxy module.
  • the service module may send a ciphertext processing request carrying the data to be encrypted to the key proxy module.
  • the key proxy module obtains the target key from the extracted key list, and then encrypts the data to be encrypted using the target key to obtain the encrypted data, and finally, the secret.
  • the key broker module sends the encrypted data to the business module.
  • the agent encryption and decryption is used instead of the business process to directly encrypt and decrypt. Once the agent issues a BUG, all the encryption and decryption operations may fail, causing a great loss to the business.
  • the BUG may be introduced by the change that the Agent continuously supports the new requirements in practice, or it may be a rather concealed, extremely difficult to be triggered BUG (or even the operating system kernel BUG) is finally triggered. Or because the other services on the hardware server occupy a large amount of CPU, the service agent encryption and decryption request times out. Once the above problem occurs, the encryption and decryption operation will fail.
  • the embodiment of the present application provides a service processing method, device, storage medium, and electronic device, so as to at least solve the technical problem that the stability of the key is low when the service is encrypted and decrypted in the related art.
  • a service processing method including: acquiring first information, where the first information is used to indicate an execution result of a first type of key agent module to perform a ciphertext processing request Detecting whether the first information meets a predetermined type switching condition, wherein the matching the predetermined type switching condition indicates that a vulnerability occurs in the first type of key agent module; and detecting that the first information meets the predetermined In the case of a type switching condition, the ciphertext processing request of the service module is executed by the second type of key broker module.
  • a service processing method including: a first type of key agent module receives and executes a ciphertext processing request of a service module, and obtains an execution result; and a second type of key agent The module receives and executes a ciphertext processing request of the service module, where the service module is configured to: when the first information generated based on the execution result meets the predetermined type switching condition, to the second type The key broker module sends a ciphertext processing request, wherein the predetermined type of switching condition is met to indicate that the first type of key broker module is vulnerable.
  • a service processing method including: The key agent module acquires an execution result of the execution of the ciphertext processing request; the key agent module detects whether the execution result meets a predetermined mode switching condition, wherein the matching the predetermined mode switching condition indicates that the key agent module is determined A vulnerability is generated; if it is detected that the execution result meets a predetermined mode switching condition, the key agent module sends the indication information to the service module, where the indication information is used to indicate that the service module switches to the service The module executes the mode of the ciphertext processing request.
  • a service processing apparatus including: a first acquiring unit, configured to acquire first information, wherein the first information is used to represent a first type of key agent The module performs an execution result of the ciphertext processing request; the first detecting unit is configured to detect whether the first information meets a predetermined type switching condition, wherein the matching the predetermined type switching condition indicates that the first type of key agent is determined The module has a vulnerability, that is, the predetermined type of switching condition is met, indicating that the first type of key agent module cannot stably perform the ciphertext processing request; the first executing unit is configured to detect the first information In the case that the predetermined type of switching condition is met, the ciphertext processing request of the service module is executed by the second type of key agent module.
  • a service processing apparatus including: a first processing unit, configured in a first type of key agent module, configured to receive and execute a ciphertext processing request of a service module Obtaining an execution result; a first processing unit, disposed in the second type of key broker module, configured to receive and execute a ciphertext processing request of the service module, wherein the service module is set to perform based on the execution And if the first information generated by the result meets the predetermined type switching condition, sending a ciphertext processing request to the second type of key proxy module, wherein the predetermined type switching condition is met to determine the first type A vulnerability has occurred in the key broker module.
  • a service processing apparatus including: a first acquiring unit, configured to acquire an execution result of performing a ciphertext processing request; and a first detecting unit configured to detect the execution result Whether the predetermined mode switching condition is met, wherein the pre-compliance is met
  • the mode switching condition indicates that a vulnerability exists in the key agent module
  • the first sending unit is configured to: send the indication information to the service module if the execution result is consistent with the predetermined mode switching condition, where the indication is sent
  • the information is used to indicate that the service module switches to a mode in which the ciphertext processing request is performed by the service module.
  • a storage medium is further provided, where the storage medium may store an execution instruction for executing the service processing method in the foregoing embodiment.
  • an electronic device includes a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein the processor passes the foregoing The computer program performs the above method.
  • the first information is obtained, where the first information is used to indicate that the first type of the key agent module performs the execution result of the ciphertext processing request; whether the first information meets the predetermined type switching condition; If the first information meets the predetermined type switching condition, the ciphertext processing request of the service module is executed by the second type of key proxy module.
  • the secret may be executed according to the first type of key proxy processing module.
  • the result of the file processing request determines whether the predetermined type switching condition is met, and if the switching condition is met, the ciphertext processing request is no longer performed by the first type of key agent processing module, but the second type of key agent is used.
  • the processing module executes the ciphertext processing request.
  • the first type of the key proxy processing module cannot continue to perform the ciphertext processing request stably, and the second type of the key proxy module is switched to stabilize the processing.
  • the text processing request solves the problem that the stability of the key is low when the service is encrypted and decrypted in the related art.
  • FIG. 1 is a schematic diagram of a hardware environment of a service processing method according to an embodiment of the present application
  • FIG. 2 is a flowchart of an optional service processing method according to an embodiment of the present application.
  • FIG. 3 is a schematic diagram of an optional service processing method according to an embodiment of the present application.
  • FIG. 5 is a flowchart of another optional service processing method according to an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a hardware environment of a service encryption method according to an embodiment of the present application.
  • FIG. 7 is a flowchart of an optional service encryption method according to an embodiment of the present application.
  • FIG. 8 is a flowchart of an optional service decryption method according to an embodiment of the present application.
  • FIG. 9 is a flowchart of another optional service encryption method according to an embodiment of the present application.
  • FIG. 10 is a flowchart of another optional service encryption method according to an embodiment of the present application.
  • FIG. 11 is a schematic diagram of an optional service processing apparatus according to an embodiment of the present application.
  • FIG. 12 is a schematic diagram of an optional service encryption apparatus according to an embodiment of the present application.
  • FIG. 13 is a schematic diagram of an optional service decryption apparatus according to an embodiment of the present application.
  • FIG. 14 is a structural block diagram of an electronic device according to an embodiment of the present application.
  • FIG. 15 is a structural block diagram of another electronic device according to an embodiment of the present application.
  • an embodiment of a method for service processing is provided.
  • the foregoing service processing method may be applied to a hardware environment formed by the server 102 and the terminal 104 as shown in FIG. 1.
  • the server 102 is connected to the terminal 104 through a network.
  • the network includes but is not limited to a wide area network, a metropolitan area network, or a local area network.
  • the terminal 104 is not limited to a PC, a mobile phone, a tablet, or the like.
  • the service processing method of the embodiment of the present application may be executed by the server 102, may be executed by the terminal 104, or may be jointly performed by the server 102 and the terminal 104.
  • the service processing method performed by the terminal 104 in the embodiment of the present application may also be performed by a client installed thereon.
  • the main working principle of the hardware environment system shown in FIG. 1 is that in the embodiment of the present application, the key agent module is installed in the terminal 104.
  • the ciphertext processing request carrying the data to be encrypted may be sent to the key agent module through the service module.
  • the key proxy module obtains the target key from the extracted key list, and then encrypts the data to be encrypted using the target key to obtain the encrypted data, and finally, the secret.
  • the key broker module sends the encrypted data to the business module.
  • the ciphertext processing request is a request to encrypt the data to be encrypted into ciphertext data.
  • the decryption data is similar to the encryption method in the above embodiment, and details are not described herein again.
  • the key list is a key list obtained by the key agent module from the server 104 (for example, a key server) when it is first turned on.
  • FIG. 2 is a flowchart of an optional service processing method according to an embodiment of the present application, as shown in FIG. As shown in 2, applied to the business module, the method may include the following steps:
  • Step S202 Acquire first information, where the first information is used to indicate that the key proxy module of the first type performs an execution result of the ciphertext processing request;
  • Step S204 detecting whether the first information meets a predetermined type switching condition
  • Step S206 The ciphertext processing request of the service module is executed by the second type of key proxy module in the case that the first information is detected to meet the predetermined type switching condition.
  • the first information is obtained by using the foregoing embodiment, where the first information is used to indicate that the first type of the key agent module performs the execution result of the ciphertext processing request; whether the first information meets the predetermined type switching condition; If the information meets the predetermined type switching condition, the ciphertext processing request of the service module is executed by the second type of key proxy module.
  • the ciphertext processing may be performed according to the first type of key proxy processing module.
  • the result of the request is used to determine whether the predetermined type of switching condition is met. If the switching condition is met, the ciphertext processing request is no longer performed by the first type of key agent processing module, but by the second type of key agent processing module. Executing a ciphertext processing request.
  • the second type of key proxy module is switched to stably process the ciphertext processing.
  • the request solves the problem that the stability of the key is low when the service is encrypted and decrypted in the related art.
  • the ciphertext processing request may be an encryption request or a decryption request
  • the execution result of the ciphertext processing request of the first type of key proxy module may be stored in the shared memory, and the service module may be shared from The execution result is read in the memory, and the execution result is counted to obtain the first information.
  • the key broker module can perform ciphertext processing requests as follows (take the encryption process as an example):
  • the key agent module receives the ciphertext processing request sent by the service module, where the ciphertext processing request carries data to be encrypted.
  • the key agent module (hereinafter referred to as the key agent) may be implemented in a single-process multi-thread manner; the service module is configured to send a ciphertext processing request to the key agent, wherein the key agent industry
  • the business modules are in the same physical single machine.
  • the service module may send a ciphertext processing request carrying the data to be encrypted to the key agent; after obtaining the ciphertext processing request, the key agent processes the request key according to the ciphertext processing. Get the target key in the list.
  • the key agent when the key agent module Agent is restarted, the key agent pulls the key list to the key server. It should be noted that the key agent only pulls the key list to the key server when restarting, and does not pull the key list at other times after startup.
  • the key agent may obtain the target key in the pre-pushed key list, where the target key is used to encrypt the data to be encrypted.
  • the data to be encrypted using the target key may be encrypted.
  • the key agent module encrypts the data to be encrypted using the target key, and after obtaining the encrypted data, the encrypted data can be sent to the service module.
  • the first public key may be sent to the key server by using the key proxy module, and the second public key is received from the key server, where
  • the key agent module has a pair of first public key and a first private key, and the key server has a pair of second public key and a second private key;
  • the key agent module sends a key list pull to the key server
  • the key agent module receives the encrypted key list sent by the key server, wherein the encrypted key list is obtained by encrypting the key list by using the first communication key on the key server side, first The communication key is generated by the key server according to the first public key and the second private key; the key agent module encrypts using the second communication key pair on the key agent module side
  • the subsequent key list is decrypted to obtain a key list, wherein the second communication key is generated by the key agent module according to the first private key and the second public key, and the first communication key and the second communication key are generated. the same.
  • the key list needs to be pulled from the key server, wherein the key list extracted from the key server is the encrypted key list. . Therefore, the key agent needs to decrypt the extracted key list.
  • the key list extracted by the key agent is obtained by encrypting the key list by using the first communication key on the key server side, and then the key agent module decrypts the key list.
  • the key list is decrypted using the same second communication key as the first communication key.
  • the first communication key is generated by the key server according to the first public key and the second private key
  • the second communication key is generated by the key agent module according to the first private key and the second public key.
  • the first public key and the second public key are a pair of public keys pubkey and key prikey generated by the key agent before sending the key list to the key server;
  • the first private key and the second private key are secret A pair of public keys pubkey and key prikey generated by the key server.
  • the second communication key is generated according to the first private key and the second public key. Therefore, before the key agent module sends the key list pull request to the key server, the key agent and the key server need to exchange the public key and the key of both parties. After the exchange, the key agent module may generate a second communication key for decrypting the key list after transmitting the key list pull request to the key server, and the key server may also generate the secret key.
  • the key list is encrypted with the first communication key.
  • the public key and the key of the exchanged parties are specifically: the agent sends the first public key to the key server SVR, and then the agent receives the second public key from the key server SVR. After the exchange, the agent can use the first The private key and the second public key encrypted key list are decrypted.
  • the key exchange protocol ie, the ECDH protocol
  • the key exchange protocol may be used to exchange the pubkeys of both parties. And the respective prikey.
  • the key list in the present application is encrypted using the first public key and the second private key, and decrypted using the first private key and the second public key.
  • the public key pubkey of the Agent and the key server is transmitted on the network. Therefore, by using the encryption method in the present application, even if the key is reversed by the tcp dump, the intranet is avoided. The phenomenon of key leakage caused by packet capture occurs.
  • the SVR should sign the ECDH public key with the private key, and verify the signature by deploying the public key in the agent, because the SVR is a high-density server managed by a dedicated person. It is difficult to steal the private key from there, and it effectively prevents others from forging SVR back packets.
  • the key agent After the key agent pulls the key list from the key server and decrypts the key list, the key agent needs to verify the legality of the business process, wherein the business process is a process represented by the data to be encrypted.
  • the key agent module sends the first public key to the key server, and receiving the second public key from the key server includes: when the key agent module is restarted, the key The proxy module sends the encrypted first public key to the key server, wherein the encrypted first public key is obtained by encrypting the first public key using the agreed key; the key proxy module receives the encryption from the key server a second public key, wherein the encrypted second public key is obtained by encrypting the second public key using the agreed key; the key proxy module decrypts the encrypted second public key by using the agreed key, A second public key is obtained; wherein the appointment key is set to be used only when the key broker module is restarted.
  • the key agent when the key agent is restarted, when the key agent sends the first public key to the key server, the first public key is encrypted by using the agreed key, and the first key is encrypted after using the agreed key. A public key is sent to the key server, and after the key server obtains the first public key, it can decrypt using the agreed key. Similarly, when the key server sends the second public key to the key agent, the second public key is also encrypted using the contract key and will be encrypted. The subsequent second public key is sent to the key agent, wherein after receiving the encrypted second public key, the key agent can decrypt the second public key using the agreed key.
  • the first public key and the second public key are encrypted and transmitted to each other only when the key agent is restarted, using the “contract key”. That is to say, only the maintainer of the key agent restarts the process when changing the key agent is the only time to legally use the agreed key, and any other situation is illegal. For example, the maintainer of the key agent uses the contract key to obtain the key list when the key agent is restarted. After that, if other users use the agreed key again to obtain the key list, the user is abused. By. Therefore, in the embodiment of the present application, the setting of the "contract key" is used only when the key agent is restarted, and the abuser can be detected quickly and effectively.
  • the key agent needs to decrypt the key list after pulling the key list.
  • the process PID of the service process may be acquired by the key agent module, where the service process sends the process of the data to be encrypted to the service module, and then The key agent module performs legality verification on the business process and the process PID; and in the case that the legality verification passes, the key agent module obtains the target key from the key list.
  • the process PID of the service process can be obtained through the key agent, and then the legality of the process PID and the service process is verified by the key agent. If the verification result of the process PID and the service process is legal, that is, if the verification is passed, the key agent module may obtain the target key from the key list, and encrypt the data to be encrypted by the target key. .
  • the key agent module may obtain a process PID that is authenticated by the kernel by the service process transmitted by the service module through the socket SCM_RIGHTS, and In the socket SCM_RIGHTS applies to the unix domain socket.
  • the key proxy module performs legality verification on the service process and the process PID, which is specifically as follows:
  • Step S1 the key agent module acquires a full path of the process corresponding to the process PID;
  • Step S2 The key agent module determines whether the full path of the process belongs to a path in a legal path acquired from the key server in advance;
  • Step S3 In the case that it is determined that the path of the process belongs to the path in the legal path, the key agent module performs an MD5 check operation on the service process to obtain a first MD5 check result; and determines that the process full path does not belong to the legal path. In the case of the path in the middle, it is judged that the validity check is not passed;
  • step S4 the key agent module determines whether the first MD5 check result is the same as the second MD5 check result corresponding to the service process acquired in advance;
  • Step S5 if the first MD5 check result is the same as the second MD5 check result, it is determined that the validity check is passed; if the first MD5 check result is different from the second MD5 check result, the legality is determined. The test will not pass.
  • the key agent module acquires the first file descriptor sent by the service module, where the first file descriptor is used for the secret
  • the key agent module identifies the data sent by the service module as legal data, and then the key agent module generates a second file descriptor, wherein the second file descriptor is used by the service module to identify the data sent by the key agent module as legal data.
  • the key agent module transmits the second file descriptor to the service module.
  • the file descriptor is exchanged between the key agent module and the service module.
  • the key agent module may first obtain the first file descriptor of the service module, and after obtaining the first file descriptor, the key agent module may identify the data sent by the service module as legal data.
  • the business module has been assigned to the key generation.
  • the module exchanges file descriptors, which then requires the key broker module to exchange file descriptors with the business module.
  • the key agent module may transmit the generated second file descriptor to the service module, and after receiving the second file descriptor, the service module may identify the data sent by the key agent module as legal data.
  • the first file descriptor and the second file descriptor correspond to data blocks of the shared memory, where the shared memory is used to store the data to be encrypted of the ciphertext processing request and the to-be-checked after the encryption.
  • the encrypted data will be described in detail in the following embodiments.
  • the service module stores the data to be encrypted in the shared memory
  • the data to be encrypted is stored in the area corresponding to the first file descriptor in the shared memory.
  • the key agent module can learn that the service module stores the data to be encrypted in the shared memory, and then the key agent module goes to the area to obtain the data to be encrypted.
  • multiple file descriptors eventfd can be exchanged at one time, and more eventfd is exchanged by verification again when not enough, so that the number of verification requests can be significantly reduced, and the applicant finds through testing.
  • the maximum number of fd for the next performance exchange of the Linux system is 255.
  • the key agent module may further set a target authority for the first file descriptor, where the target authority includes at least one of the following: The key agent module is allowed to encrypt the data to be encrypted requested by the service module, and the key agent module is allowed to decrypt the data to be decrypted requested by the service module.
  • the key agent module may set the target authority for the first file descriptor after exchanging the file descriptor, where The specified target rights include: allowing the key agent module to encrypt the data to be encrypted requested by the service module, and allowing the key agent module to request the service module.
  • the decrypted data is decrypted.
  • the key agent module After the key agent module sets the target permission for the first file descriptor, the key agent module can encrypt the data to be encrypted according to the received ciphertext processing request, and then send the encrypted data to the service module.
  • the key agent module receives the ciphertext processing request sent by the service module, where the key agent module obtains the data to be encrypted stored by the service module from the shared memory, and the key agent module sends the encrypted data to the service module.
  • the method includes: the key agent module stores the encrypted data into the shared memory, so that the service module obtains the encrypted data from the shared memory.
  • the service module sends a ciphertext processing request to the key broker module
  • the ciphertext processing request is stored in the shared memory.
  • the key broker module can retrieve the stored data to be encrypted from the shared memory.
  • the key agent module encrypts the data to be encrypted using the target key
  • the data to be encrypted after the encryption process may also be stored in the shared memory. Enables the business module to obtain encrypted data from shared memory.
  • the key agent module has previously set a target authority for the first file descriptor. In this case, if the validity check is passed, the key agent module is from the key list. Obtaining the target key, specifically: when the target authority includes the key agent module to encrypt the data to be encrypted requested by the service module, the key agent module obtains the target key package from the key list.
  • the target authority may only allow the key agent module to decrypt the data to be decrypted requested by the service module or allow the key agent module to encrypt the data to be encrypted requested by the service module. Therefore, the key agent module can obtain the target key from the key list only when it is determined that the target authority is to allow the key agent module to encrypt the data to be encrypted requested by the service module, and use the obtained target secret. The key encrypts the encrypted data.
  • the key agent module acquires a service process.
  • the process PID includes: the key agent module obtains the process PID of the business process through the unix domain socket in the non-root mode; or the key agent module configures the socket socket option as SO_PEERCRED, and passes the socket socket. Get the process PID of the business process.
  • the process PID is transmitted through the socket SCM_RIGHTS in the unix domain socket. Because the unix domain sockets pass the exact process PID is based on the non-root mode running process, the local root mode must be approved before the process PID is passed. That is, the process PID (process ID) of the business process needs to be obtained through the unix domain socket in the non-root mode. Further, the option of the socket socket can be configured as SO_PEERCRED through the key proxy module, and the process PID of the business process can be obtained through the socket socket.
  • the data to be encrypted is indirectly encrypted and decrypted by the key agent; at the same time, the communication between the service module and the key agent may be any standard linux IPC communication means, including but not limited to a pipeline, Unix Socket pair, local disk file, etc., the linux eventfd adopted by this scheme is the most efficient, and is most suitable for the selection of massive encryption and decryption requests.
  • the method realizes the encryption and decryption program by fully utilizing the standard mechanism provided by the modern Linux operating system kernel, which not only improves the security of the key, but also minimizes the loss of encryption and decryption performance, and ensures the effectiveness in practice.
  • FIG. 3 is a flowchart of an optional service processing method according to an embodiment of the present application.
  • a key agent ie, a key agent module
  • a service module are in the same physical single machine.
  • the key agent when the key agent is restarted, the key agent encrypts the first public key by using the contract key, and sends the encrypted first public key to the key server, and the key agent module can also Receiving the encrypted second public key sent by the key server, wherein the second public key is also encrypted by using the agreed key.
  • the key agent After obtaining the second public key, the key agent decrypts the second public key by using the agreed key, and the key server also uses the first public key after obtaining the first public key.
  • the appointment key decrypts the first public key.
  • the key agent may send a pull request of the key list to the key server, and after receiving the key pull request, the key server transmits the encrypted key list to the key agent, where the key is encrypted.
  • the subsequent key list is obtained by encrypting the key list using the first communication key on the key server side, and the first communication key is generated by the key server according to the first public key and the second private key.
  • the key agent may decrypt using the same second communication key as the first communication key, wherein the second communication key is the key agent module according to the first private key. And the second public key is generated.
  • the first public key and the second public key are encrypted and transmitted to each other only when the key agent is restarted, using the “contract key”.
  • the service encryption provided in the embodiment of the present application decrypts the encrypted key list using the first private key and the second public key, so even the key list The key is not reversed by tcpdump, which avoids the key leakage caused by intranet capture.
  • the memory of the key agent and the key server may also be protected. Specifically, the binary of the key agent and the key server can be directly stripped off (ie, all debugging information is deleted), and then the code of the key agent and the key server is securely isolated, so that gdb is almost Dice, at least it is impossible to simply modify the variables.
  • the service module After decrypting the key list, the key agent needs to verify the PID legality of the business process and the business process.
  • the service module first establishes a unix domain socket, and establishes a first file descriptor, and then transmits the first file descriptor to the key agent by using the socket SCM_RIGHTS in the unix domain socket. And using the socket SCM_CREDENTIA to transfer the PID of the process authenticated by the kernel to the key agent.
  • SCM_RIGHTS and SCM_CREDENTIA are applicable to unix domain socket, SCM_RIGHTS is used to transfer descriptors in one process to another process.
  • This method can extend some IPCs that can only communicate between relative processes to non-affinity processes ( For example, linux eventfd); SCM_CREDENTIA is used to transfer the process PID whose process is authenticated by the kernel.
  • the key agent module may further send a first file descriptor eventfda to the service module, and the key agent module generates a second file after acquiring the first file descriptor eventfda.
  • Descriptor eventfdb and send the second file descriptor eventfdb to the business module to implement the exchange of file descriptors between the key agent module and the business module.
  • the key agent module may further set a target authority for the first file descriptor, where the target authority includes at least one of the following: allowing the key agent module to request the service module The encrypted data is encrypted, allowing the key agent module to decrypt the data to be decrypted requested by the service module.
  • the business module can go to the first file descriptor eventfda in shared memory.
  • the operation of writing data in the space is performed, that is, the data to be encrypted is written into the corresponding area of the first file descriptor eventfda in the shared memory (write eventfda).
  • the key agent module can know that the service module has written data.
  • the key agent module will read the data to be encrypted from the shared memory (ie, read the second file descriptor, read eventfdb). And read the target permissions previously configured for the first file descriptor eventfda.
  • the key agent module can obtain the target key from the key list, and then the key agent module can A ciphertext processing request is performed on the data to be encrypted according to the obtained target key.
  • the premise of the unix domain socket passing the accurate process PID is the process running in the non-root mode, so the requirement of the root mode of the key agent must be approved.
  • the key broker module can also configure the socket socket option as SO_PEERCRED and obtain the process PID of the business process through the socket socket.
  • test environment is the following environment:
  • Key Agent 10 processes; in which the business process and the key agent are free to run, and no CPU priority is set.
  • Bill main ticket + slave ticket
  • Bill main ticket + slave ticket
  • the requests of the five external test machines for the test business reached about 30W/S, of which 17% for the empty service, 31%-33% for the local decryption, and 33%-34% for the agent decryption.
  • the method may further include: sending a ciphertext processing request to the first type of key proxy module; acquiring the first type of the key proxy module to perform the ciphertext processing request As a result of the execution, the execution result can optionally be read from the shared memory.
  • a dual key proxy module can be run in the system, and the dual key proxy module can be two types of key proxy modules.
  • the two types are a first type and a second type.
  • the first type of key agent module is a development type key agent module
  • the second type key agent module is a stable type table key agent module
  • the stable key agent module is executed within a predetermined time period.
  • the ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
  • development type key agent module may be, but not limited to, an unauthenticated agent module, and the verification process is performed to obtain the stable stable key agent module.
  • the stable stable key proxy module is a key proxy module that has been determined to be able to run correctly for a period of time, and the developed developer key proxy module does not determine that the ciphertext processing is performed within a predetermined time period.
  • the key broker module whose request rate is higher than the predetermined correct rate.
  • the obtaining the first information may include: counting, according to the execution result, a success rate of the first type of the key agent module performing the ciphertext processing request, wherein the first information includes a success rate.
  • the total number of ciphertext processing requests performed by the first type of key proxy module is used as a denominator, and the total number of successful ciphertext processing requests of the first type of key proxy module is used as a numerator. Calculate the success rate.
  • the predetermined type switching condition includes the success rate being lower than the first predetermined threshold
  • detecting whether the first information meets the predetermined type switching condition may include: detecting whether the success rate is lower than a first predetermined threshold; if detecting If the success rate is lower than the first predetermined threshold, it is determined that the first information meets the predetermined type switching condition; if the detected success rate is not lower than the first predetermined threshold, it is determined that the first information does not meet the predetermined type switching condition.
  • the service module preferentially performs the encryption and decryption operation through the developed key proxy module (ie, the first type of key proxy module), and directly monitors the success of the developed key proxy module to perform the ciphertext processing request locally.
  • Rate when the success rate falls below a pre-configured first predetermined threshold (for example, 98%), then automatically switches to the second type of key agent module to perform a ciphertext processing request, which can ensure that the entire system processes the ciphertext processing request. stability.
  • the method before acquiring the first information, may further include: after updating the file in the key agent module in the system, recording the key agent module performing the update operation as the first a type of key agent module; if it is detected within a predetermined time period that the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate, the first type of key agent module is recorded as The second type of key broker module.
  • the key proxy module that has been set may be fully tested and slowly run in the network.
  • the key agent module is recorded as a stable type. If the dual key agent module in the system meets the condition (for example, if the correct execution time is sufficient), the key agent module in the system can be recorded as a stable type.
  • the service module selects a stable agent with a modified time later, and needs to be changed. At the time, the changed stable agent becomes a development agent.
  • the dual agent is a dual stable agent
  • the stable agent whose file modification time is earlier that is, the modification time is earlier
  • the development agent During the development of the development agent, if the change is required, the development agent will continue to be released. Further, the development agent can be set to the stableAgent (ie, the second type of key broker module) only if the development agent is properly executed for a sufficiently long period of time (eg, 2 months) without any changes.
  • the stableAgent ie, the second type of key broker module
  • the method may further include: if the file in the key proxy module is updated during the running of the first type of the key proxy module in the system, The files in a type of key broker module are updated.
  • the development agent if the change is still needed, the development agent is continuously released, and the developer agent can execute correctly without any change. For a long enough time (such as 2 months), you can set its type to stable agent (the second type of key agent module).
  • the ciphertext processing request requested by the service module by the second type of key proxy module includes: if the system includes multiple second type key proxy modules (such as two), The second type of key agent module that obtains the latest update time in the two types of key agent modules performs the ciphertext processing request by the second type of key agent module that updates the latest time.
  • the service module may select an agent with a newer file modification time from the two stable agents, and the service module You can use this file to modify the agent with a newer time (that is, later modification time) to perform encryption and decryption operations.
  • the service is performed by the second type of key agent module
  • the method further includes: after receiving the input switching instruction, executing the ciphertext processing request by the first type of key proxy module in response to the switching instruction.
  • the input switching instruction is a manually input instruction. After the business module is switched from the developer agent to the stable agent, it can be manually restored to use the developer agent. This way, you can continue to use the developer agent after the manual 100% confirmation that the developer agent problem has been fixed, thus avoiding the random stalling. Switching from type to develop type, causing further loss of business.
  • the service module performs the disaster recovery process, and the encryption and decryption can be performed normally in the case of system upgrade, and when the system has a bug, the different types of key agent modules can be switched in time to perform the ciphertext processing request. To ensure the stability of the system.
  • the method further includes: after the validity of the validity check of the service process by the key proxy module, in the case that the validity check is passed, the service module Transmitting, to the key agent module, a first file descriptor, wherein the first file descriptor is used by the key agent module to identify data sent by the service module as legal data; and acquiring a plurality of second file descriptors generated by the key agent module The second file descriptor is used by the service module to identify the data sent by the key agent module as legal data.
  • the method further includes: saving the obtained plurality of second file descriptors into the queue; sequentially using the second stored in the queue The file descriptor communicates with the key broker module.
  • the number of the plurality of second file descriptors corresponds to the number of threads in the key broker module for executing the ciphertext processing request.
  • the services are in units of threads, each independently exchanges descriptors with the Agent, and the descriptors are independently managed in a queue manner, and the threads do not interfere with each other.
  • Each service thread independently passes the Agent to verify the identity, and then exchanges multiple second file descriptors (for example, an integer multiple of the number of Agent encryption and decryption threads), and the Agent side distributes the descriptors completely uniformly to each
  • the Agent encrypts and decrypts threads (so the number of descriptors managed by each thread is equal), so that load balancing of services can be achieved.
  • the key agent module acquires 100 first file descriptors sent by the service module, and then the key agent module generates 100 second file descriptors, and transmits the 100 second file descriptors to the service module, 100
  • the first file descriptor and the 100 second file descriptors are paired one by one to obtain 100 sets of descriptors.
  • the key agent module evenly distributes the 100 sets of descriptors to 10 encryption and decryption threads, and can be tried as follows:
  • the descriptor is assigned to the encryption and decryption thread 1
  • the second group of descriptors is assigned to the encryption and decryption thread 2
  • the tenth group of descriptors is assigned to the encryption and decryption thread 10
  • the eleventh group of descriptors is assigned to the encryption and decryption Thread 1
  • the twelfth group of descriptors are assigned to the encryption and decryption thread 2 and so on
  • the first hundred sets of descriptors are assigned to the encryption and decryption thread 10.
  • each business thread saves the exchanged plurality of descriptors into its own thread-level queue, and each time the business thread encrypts and decrypts the request, it first retrieves the descriptor from the queue to communicate with the agent, and after the communication is completed, The descriptor is placed back at the end of the queue; if the descriptor is taken from the first queue and the discovery queue is empty, then more descriptors are exchanged as described above.
  • the number of identity authentication is greatly reduced, and the MD5 (or other HASH algorithm) for identity verification is less efficient, so that it is not necessary to verify the identity of each request; each service thread Extremely even access to each Agent thread, completely avoiding the problem of uneven load of each Agent thread, and balancing the resources of multiple CPUs; the encryption and decryption request processing between the service and the Agent is highly independent, and the request-level lock is not required to ensure the exclusive use of resources. Improve the ability to concurrently throughput.
  • FIG. 5 shows an alternative embodiment. As shown in FIG. 5, the embodiment can be implemented by the following steps:
  • Step S502 The key agent module acquires an execution result of the execution of the ciphertext processing request.
  • Step S504 The key agent module detects whether the execution result meets a predetermined mode switching condition
  • Step S506 If it is detected that the execution result meets the predetermined mode switching condition, the key agent The module sends the indication information to the service module, where the indication information is used to indicate that the service module switches to a mode in which the ciphertext processing request is performed by the service module.
  • the mode of executing the ciphertext processing request by the key agent module is continued.
  • the key agent module acquires an execution result of the execution of the ciphertext processing request; the key agent module detects whether the execution result meets the predetermined mode switching condition; and if it detects that the execution result meets the predetermined mode switching condition, the key agent module The service module sends indication information, where the indication information is used to indicate that the service module switches to a mode in which the ciphertext processing request is performed by the service module.
  • the key agent module detects whether the execution result of the execution of the ciphertext processing request meets the predetermined mode switching condition, and if the predetermined mode switching condition is met, determining that the key agent module cannot continue to stably perform the ciphertext processing request. Then, the mode is switched, so that the service module can perform the ciphertext processing request by itself, so as to solve the problem that the related technology cannot be stably operated when the business data is encrypted and decrypted, and the stable operation of the system is realized.
  • the method of using the agent can be restored by manually (such as receiving a manual input recovery instruction).
  • the service automatically cleans up the key M at this time), this is for the manual 100% confirmation that the problem has been fixed, and the service will not be further suffered because of the random switching.
  • the maximum security loss can be guaranteed with minimal security loss. normal operation.
  • the agent generates a random key M (ie, key data) by the key server SVR to return to the Agent each time the latest key list is pulled, and the agent encrypts the key list using M. After saving to a piece of shared memory N.
  • M ie, key data
  • the method further The method includes: generating, by the service thread, a first end descriptor and a second end descriptor of the communication pipeline, wherein the first end descriptor is used by the key proxy module to identify the data sent by the service module as legal data, and the second end descriptor The service module identifies the data sent by the key agent module as legal data; and transmits the second end descriptor to the key agent module through the communication pipeline.
  • the service thread independently generates two pipeline descriptors, which are a read end descriptor and a write end descriptor (such as the first end descriptor and the second end descriptor described above), and the business thread passes the write end to the identity verification. Agent, Agent If the identity is passed, the write end is retained. At this time, the service thread closes the write end held by the service thread. At this time, the service thread holds the pipeline read end, and the agent holds the pipeline write end corresponding to the thread.
  • the request time A is filled in the request packet (for example, the time can be accurate to the millisecond).
  • the obtaining, by the key agent module, the execution result of the execution of the ciphertext processing request includes: after the ciphertext processing request is executed, the key proxy module determines, according to the request time and the current time in the ciphertext processing request, the execution of the current secret Whether the file processing request times out; if it is determined that the execution of the current ciphertext processing request times out, the key agent module determines that the execution of the current ciphertext processing request fails; the key agent module is based on the number of ciphertext processing requests that failed to be executed, and the statistics are dense.
  • the success rate of the key agent module performing the ciphertext processing request, and the execution result includes the success rate.
  • the key agent module detects whether the execution result meets the predetermined mode switching condition, including: the key agent module detects whether the success rate is lower than a second predetermined threshold; and if the success rate of executing the ciphertext processing request is lower than the second The predetermined threshold is determined, and it is determined that the execution result conforms to the predetermined mode switching condition.
  • the agent determines the current time (accurate to milliseconds), and sets the encryption and decryption timeout of the service setting to B ms, if the current time When the time difference C of A is more than (Bx) ms, the request is marked as failed.
  • the success rate falls below the second predetermined threshold (for example, 98%) of the implementation configuration, the key M is automatically written through each pipe. Sent to all business threads.
  • x can Thought it is 3.
  • the key agent module sends the indication information to the service module, where the key agent module sends the key data to the service module, where the key data is used to decrypt the key list stored in the shared memory, and the decrypted The key list, the service module is further configured to perform a ciphertext processing request through the decrypted key list.
  • the service module obtains the key data of the key agent module through the service thread, including: periodically reading data from the read end of the communication pipe through the service thread; if the data is read from the read end of the communication pipe, determining Get the key data.
  • the business thread periodically (for example, 3 seconds) determines whether its own pipeline reader has data readable. Once the data is read, it is considered to be the key M, and then each time M is used to decrypt the N memory.
  • the key list obtains the key of the encryption and decryption request, and degenerates into a local encryption and decryption mode of the business thread, completely ignoring the Agent.
  • the method before the key agent module receives and executes the ciphertext processing request of the service module, the method further includes: after updating the file in the key agent module, recording the key agent module that performs the update operation as a first type of key agent module; after the first type of key agent module receives and executes the ciphertext processing request of the service module, and obtains the execution result, the method further includes: detecting the first type within a predetermined time period The key broker module performs a ciphertext processing request with a higher correct rate than the predetermined correct rate, and records the first type of key proxy module as the second type of key proxy module.
  • the method further includes: if the file in the key agent module is to be updated, the first type of the key is The files in the agent module are updated.
  • the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
  • the communication pipeline is further configured to detect whether the service module and the key agent module are restarted.
  • the pipeline (that is, the communication pipeline mentioned above) is also a powerful tool for the agent and the service to judge each other whether the other party restarts, and the service thread can transmit the pipeline descriptor to the agent once more, and the service holds the write end, and the agent holds There is a reader, once the business process is closed, the Agent can immediately find out through the EPOLLHUP error of epoll_wait(), and then immediately start cleaning up to prevent resource leakage; and the service can be triggered by the request, when the encryption and decryption request times out, by writing to the pipeline The write end writes a byte. If the Agent restarts, it will return EPIPE. At this time, it can also trigger resource cleanup and re-identify the identity with the newly started Agent.
  • the security may be sacrificed.
  • the method is to maintain the normal operation of the service, that is, to minimize the loss of security under the premise of ensuring normal business.
  • the agent determines whether to enter the disaster recovery mode; the security protection of the agent itself (root operation, difficult to be debugged, etc.) is far more than the general service. Usually, the service still does not hold the key, nor can it pass the simple DUMP. The encrypted key list shares the memory N to steal the key list, which improves the security. Further, the agent determines that the disaster tolerance mode is very reasonable. Since the descriptors of the two parties are shared, as long as the agent writes the return packet data.
  • the communication shared memory and communication descriptor buffer the business thread must be able to read unconditionally, and the Agent also reserved 3 milliseconds for the business to read the results, the time is very sufficient, if the business is still timed out, prove other parts It takes too long, and the performance problem has little relationship with the Agent; this way avoids the problem of non-shared descriptors, that is, the service and the agent use different descriptors to communicate, and the Agent writes the result to the own descriptor buffer. , but also rely on the kernel to "handle" this data into the buffer of the service descriptor, otherwise the business still can not read the result, so the Agent comes Disaster recovery system is not necessarily reasonable to open up.
  • N still maintains the encryption state, and the key list cannot be stolen by the simple DUMP encrypted key list shared memory N, but must be down-played to attack the service (such as debugging service).
  • Get M then steal the secret
  • the key list the erroneous person wants to steal the key list through the disaster recovery mode, and also has to make a relatively large movement, that is, at least one physical single machine manufacturing business failure or smashing the fault to steal, due to this time
  • the business has problems, it is more eye-catching, and its risk is higher.
  • the method further includes: acquiring the key data of the key proxy module by using the service thread, where And the key agent module is configured to: after detecting that the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, transmitting the key data; decrypting the key list stored in the shared memory by using the key data, and obtaining the decrypted a list of keys; performing a ciphertext processing request through the service module using the decrypted key list.
  • the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
  • the service processing method can also be applied in a system where the key agent module is located, and the solution can be implemented as follows: the first type of key agent module receives and executes the ciphertext processing of the service module. Requesting, obtaining an execution result; the second type of key agent module receives and executes a ciphertext processing request of the service module, wherein the service module is configured to: if the first information generated based on the execution result meets a predetermined type switching condition, The second type of key broker module sends a ciphertext processing request.
  • the first type of key agent module is a development type key agent module
  • the second type of key agent module is a stable key agent module
  • the stable key agent module is executed within a predetermined time period.
  • the ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
  • the method further includes: after updating the file in the key proxy module in the system, The key agent module that performs the update operation records as the first type of key agent module; after the first type of the key agent module receives and executes the ciphertext processing request of the service module, and obtains the execution result, the method further includes: Detecting that the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate during the predetermined time period, The first type of key broker module is recorded as a second type of key broker module.
  • the method further includes: if the file in the key agent module is to be updated, the first type of the key is The files in the agent module are updated.
  • the method further includes: the key proxy module detecting whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold; if the ciphertext processing is detected If the success rate of the request is lower than the second predetermined threshold, the key data is sent to the service module, where the key data is used to decrypt the key list stored in the shared memory, and the decrypted key list is obtained, and the service module further uses The ciphertext processing request is performed through the decrypted key list.
  • the method further includes: after the ciphertext processing request is executed, the key proxy module processes the request based on the ciphertext The request time and the current time determine whether the execution of the current ciphertext processing request has timed out; if it is determined that the execution of the current ciphertext processing request timeout, it is determined that the execution of the current ciphertext processing request fails; Quantity, the success rate of the statistics key agent module to perform ciphertext processing requests.
  • the method further includes: receiving a second end descriptor of the communication pipeline transmitted by the service thread, where the service thread And configured to generate a first end descriptor for the key proxy module to identify data sent by the service module as legal data, and a second end descriptor for the service module to be dense The data sent by the key broker module is identified as legal data.
  • sending the key data to the service module includes: transmitting key data by using a write end of a communication pipeline of each service thread.
  • the method further includes: after the key proxy module performs the validity check on the service process, the validity check is passed.
  • the key agent module receives the first file descriptor sent by the service module, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal data; the key agent module generates multiple And a second file descriptor, wherein the second file descriptor is used by the service module to identify the data sent by the key agent module as legal data; and the key agent module transmits the plurality of second file descriptors to the service module.
  • the number of the plurality of second file descriptors corresponds to the number of threads in the key broker module for executing the ciphertext processing request.
  • the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
  • the ciphertext processing is a request for encrypting data to be encrypted into ciphertext data
  • an embodiment of a method for service encryption is provided.
  • the foregoing service encryption method may be applied to a hardware environment formed by the server 602 and the terminal 604 as shown in FIG. 6.
  • the server 602 is connected to the terminal 604 through a network.
  • the network includes but is not limited to a wide area network, a metropolitan area network, or a local area network.
  • the terminal 604 is not limited to a PC, a mobile phone, a tablet, or the like.
  • the service encryption method in the embodiment of the present application may be executed by the server 602, may be executed by the terminal 604, or may be jointly performed by the server 602 and the terminal 604.
  • the service encryption method performed by the terminal 604 in the embodiment of the present application may also be performed by a client installed thereon.
  • the key agent module is installed in the terminal 604.
  • an encryption request carrying the data to be encrypted may be sent to the key agent module through the service module.
  • the key agent module obtains the target key from the extracted key list, and then encrypts the data to be encrypted using the target key to obtain the encrypted data, and finally, the key agent.
  • the module sends the encrypted data to the business module.
  • the key list is the key agent module for the first time.
  • the list of keys retrieved from the server 604 eg, a key server
  • the server 604 e.g. a key server
  • FIG. 7 is a flowchart of an optional service encryption method according to an embodiment of the present application. As shown in FIG. 7, the method may include the following steps:
  • Step S702 The key agent module receives an encryption request sent by the service module, where the encryption request carries data to be encrypted.
  • the key agent module (hereinafter referred to as the key agent) may be implemented in a single-process multi-thread manner; the service module is configured to send an encryption request to the key agent, wherein the key agent industry service module In the same physical stand-alone machine.
  • the service module may send an encryption request carrying the data to be encrypted to the key agent; after acquiring the encryption request, the key agent may perform the following step S704, that is, according to the encryption request. Get the target key in the key list.
  • Step S704 the key agent module acquires the target key from the key list, wherein the key list is previously extracted from the key server.
  • the key agent when the key agent module Agent is restarted, the key agent pulls the key list to the key server. It should be noted that the key agent only pulls the key list to the key server when restarting, and does not pull the key list at other times after startup.
  • the key agent may acquire the target key in the pre-pushed key list, where the target key is used to encrypt the data to be encrypted.
  • Step S706 the key agent module encrypts the data to be encrypted using the target key to obtain the encrypted data.
  • the data to be encrypted using the target key may be encrypted.
  • Step S708 the key agent module sends the encrypted data to the service module.
  • the key agent module encrypts the data to be encrypted using the target key, and after obtaining the encrypted data, the encrypted data can be sent to the service module.
  • the encryption request is received by the key agent module, and then the target key is acquired according to the key request.
  • the data to be encrypted is encrypted by the target key, and the service provided in the embodiment of the present application is provided.
  • the encryption method achieves the purpose of encrypting the service more securely, thereby realizing the technical effect of improving the key security when encrypting the service, thereby solving the security of the key when encrypting the service in the related art. Lower technical issues.
  • the first public key may be sent to the key server by using the key proxy module, and the second public key is received from the key server, where
  • the key agent module has a pair of first public key and a first private key, and the key server has a pair of second public key and a second private key;
  • the key agent module sends a key list pull request to the key server;
  • the key agent module receives the encrypted key list sent by the key server, wherein the encrypted key list is obtained by encrypting the key list by using the first communication key on the key server side, and the first communication secret is obtained.
  • the key is generated by the key server according to the first public key and the second private key; the key agent module decrypts the encrypted key list by using the second communication key on the key agent module side to obtain a key list.
  • the second communication key is generated by the key agent module according to the first private key and the second public key, and the first communication key is the same as the second communication key.
  • the key list needs to be pulled from the key server, wherein the key list pulled from the key server is the encrypted key list. Therefore, the key agent needs to decrypt the extracted key list.
  • the key list extracted by the key agent is obtained by encrypting the key list by using the first communication key on the key server side, and then the key agent module decrypts the key list.
  • the key list is decrypted using the same second communication key as the first communication key.
  • the first communication key is a key server according to the first public key and the second private key
  • the generated second communication key is generated by the key agent module according to the first private key and the second public key.
  • the first public key and the second public key are a pair of public keys pubkey and key prikey generated by the key agent before sending the key list to the key server; the first private key and the second private key are secret A pair of public keys pubkey and key prikey generated by the key server.
  • the second communication key is generated according to the first private key and the second public key. Therefore, before the key agent module sends the key list pull request to the key server, the key agent and the key server need to exchange the public key and the key of both parties. After the exchange, the key agent module may generate a second communication key for decrypting the key list after transmitting the key list pull request to the key server, and the key server may also generate the secret key.
  • the key list is encrypted with the first communication key.
  • the public key and the key of the exchanged parties are specifically: the agent sends the first public key to the key server SVR, and then the agent receives the second public key from the key server SVR. After the exchange, the agent can use the first The private key and the second public key encrypted key list are decrypted.
  • the agent and the key server may exchange the pubkeys of the two parties and the respective prikeys by using a key exchange protocol (ie, an ECDH protocol).
  • a key exchange protocol ie, an ECDH protocol
  • the key list in the present application is encrypted using the first public key and the second private key, and decrypted using the first private key and the second public key.
  • the public key pubkey of the Agent and the key server is transmitted on the network. Therefore, by using the encryption method in the present application, even if the key is reversed by the tcpdump, the intranet is avoided. The phenomenon of key leakage caused by the packet occurs.
  • the key agent After the key agent pulls the key list from the key server and decrypts the key list, the key agent needs to verify the legality of the business process, wherein the business process is a process represented by the data to be encrypted.
  • the key agent module sends the first public key to the key server, and receiving the second public key from the key server includes: when the key agent module is restarted, the key The proxy module sends the encrypted first public key to the key server, wherein the encrypted first public key is obtained by encrypting the first public key using the agreed key; the key proxy module receives the encryption from the key server a second public key, wherein the encrypted second public key is obtained by encrypting the second public key using the agreed key; the key proxy module decrypts the encrypted second public key by using the agreed key, A second public key is obtained; wherein the appointment key is set to be used only when the key broker module is restarted.
  • the key agent when the key agent is restarted, when the key agent sends the first public key to the key server, the first public key is encrypted by using the agreed key, and the first key is encrypted after using the agreed key. A public key is sent to the key server, and after the key server obtains the first public key, it can decrypt using the agreed key.
  • the key server sends the second public key to the key agent, the second public key is also encrypted using the agreed key, and the encrypted second public key is sent to the key agent, where the key After receiving the second public key after encryption, the agent can decrypt the second public key using the agreed key.
  • the first public key and the second public key are encrypted and transmitted to each other only when the key agent is restarted, using the “contract key”. That is to say, only the maintainer of the key agent restarts the process when changing the key agent is the only time to legally use the agreed key, and any other situation is illegal. For example, the maintainer of the key agent uses the contract key to obtain the key list when the key agent is restarted. After that, if other users use the agreed key again to obtain the key list, the user is abused. By. Therefore, in the embodiment of the present application, the setting of the "contract key" is used only when the key agent is restarted, and the abuser can be detected quickly and effectively.
  • the key agent needs to decrypt the key list after pulling the key list.
  • the key proxy module obtains the target key from the key list.
  • the process PID of the service process can be obtained through the key agent, and then the legality of the process PID and the service process is verified by the key agent. If the verification result of the process PID and the service process is legal, that is, if the verification is passed, the key agent module may obtain the target key from the key list, and encrypt the data to be encrypted by the target key. .
  • the key proxy module may obtain the process PID that is authenticated by the kernel by the service module transmitted by the service module through the socket SCM_RIGHTS, wherein the socket SCM_RIGHTS is applicable to the unix domain socket.
  • the key proxy module performs legality verification on the service process and the process PID, which is specifically as follows:
  • Step S1 the key agent module acquires a full path of the process corresponding to the process PID;
  • Step S2 The key agent module determines whether the full path of the process belongs to a path in a legal path acquired from the key server in advance;
  • Step S3 In the case that it is determined that the path of the process belongs to the path in the legal path, the key agent module performs an MD5 check operation on the service process to obtain a first MD5 check result; and determines that the process full path does not belong to the legal path. In the case of the path in the middle, it is judged that the validity check is not passed;
  • step S4 the key agent module determines whether the first MD5 check result is the same as the second MD5 check result corresponding to the service process acquired in advance;
  • Step S5 if the first MD5 check result is the same as the second MD5 check result, it is determined that the validity check is passed; if the first MD5 check result is different from the second MD5 check result, the legality is determined. The test will not pass.
  • the specific verification process is as follows: the key agent module first obtains the full path of the process corresponding to the process PID, and then determines the path of the process and the path in the legal path obtained from the key server in advance. If it is determined that the path of the process belongs to the path in the legal path, the MD5 of the service process is verified by the key agent module to obtain the first MD5 check result; if it is determined that the path of the process does not belong to the path in the legal path Then, the validity check of the business process and process PID does not pass. Next, it is determined whether the first MD5 check result is the same as the pre-acquired second MD5 check result, wherein if the same, the legality check passes, and if not, the legality check fails.
  • the key agent module acquires the first file descriptor sent by the service module, where the first file descriptor is used for the secret
  • the key agent module identifies the data sent by the service module as legal data, and then the key agent module generates a second file descriptor, wherein the second file descriptor is used by the service module to identify the data sent by the key agent module as legal data.
  • the key agent module transmits the second file descriptor to the service module.
  • the file descriptor is exchanged between the key agent module and the service module.
  • the key agent module may first obtain the first file descriptor of the service module, and after obtaining the first file descriptor, the key agent module may identify the data sent by the service module as legal data.
  • the business module has exchanged file descriptors with the key broker module, then the key broker module is required to exchange file descriptors with the business module.
  • the key agent module may transmit the generated second file descriptor to the service module, and after receiving the second file descriptor, the service module may identify the data sent by the key agent module as legal data.
  • the first file descriptor and the second file descriptor correspond to the shared memory.
  • the data block in which the data is stored, wherein the shared memory is used to store the data to be encrypted for the encryption request and the data to be checked after the encryption which will be described in detail in the following embodiments.
  • the service module stores the data to be encrypted in the shared memory
  • the data to be encrypted is stored in the area corresponding to the first file descriptor in the shared memory.
  • the key agent module can learn that the service module stores the data to be encrypted in the shared memory, and then the key agent module goes to the area to obtain the data to be encrypted.
  • multiple file descriptors eventfd can be exchanged at one time, and more eventfd is exchanged by verification again when not enough, so that the number of verification requests can be significantly reduced, and the applicant finds through testing.
  • the maximum number of fd for the next performance exchange of the Linux system is 255.
  • the key agent module may further set a target authority for the first file descriptor, where the target authority includes at least one of the following: The key agent module is allowed to encrypt the data to be encrypted requested by the service module, and the key agent module is allowed to decrypt the data to be decrypted requested by the service module.
  • the key agent module may set the target authority for the first file descriptor after exchanging the file descriptor, where The specified target rights include: allowing the key agent module to encrypt the data to be encrypted requested by the service module, and allowing the key agent module to decrypt the data to be decrypted requested by the service module.
  • the key agent module After the key agent module sets the target permission for the first file descriptor, the key agent module can encrypt the data to be encrypted according to the received encryption request, and then send the encrypted data to the service module.
  • the key agent module receives the encryption request sent by the service module, including: a key proxy module.
  • the block obtains the data to be encrypted stored by the service module from the shared memory; and the key agent module sends the encrypted data to the service module, including: the key agent module stores the encrypted data into the shared memory, so that The business module obtains the encrypted data from the shared memory.
  • the encryption request is stored in the shared memory.
  • the key broker module can retrieve the stored data to be encrypted from the shared memory.
  • the key agent module encrypts the data to be encrypted using the target key
  • the data to be encrypted after the encryption process may also be stored in the shared memory. Enables the business module to obtain encrypted data from shared memory.
  • the key agent module has previously set a target authority for the first file descriptor. In this case, if the validity check is passed, the key agent module is from the key list. Obtaining the target key, specifically: when the target authority includes the key agent module to encrypt the data to be encrypted requested by the service module, the key agent module obtains the target key package from the key list.
  • the target authority may only allow the key agent module to decrypt the data to be decrypted requested by the service module or allow the key agent module to encrypt the data to be encrypted requested by the service module. Therefore, the key agent module can obtain the target key from the key list only when it is determined that the target authority is to allow the key agent module to encrypt the data to be encrypted requested by the service module, and use the obtained target secret. The key encrypts the encrypted data.
  • the process PID of the key agent module acquiring the service process includes: obtaining, by the key agent module, the process PID of the service process through the unix domain socket in the non-root operation mode; or The key proxy module configures the socket socket option as SO_PEERCRED and obtains the process PID of the business process through the socket socket.
  • the process PID is transmitted through the socket SCM_RIGHTS in the unix domain socket. Because the unix domain sockets pass the exact process PID is based on the non-root mode running process, therefore, before the process PID is passed, the local root mode must be required. Seek approval. That is, the process PID of the business process needs to be obtained through the unix domain socket in the non-root mode. Further, the option of the socket socket can be configured as SO_PEERCRED through the key proxy module, and the process PID of the business process can be obtained through the socket socket.
  • the data to be encrypted is indirectly encrypted and decrypted by the key agent; at the same time, the communication between the service module and the key agent may be any standard linux IPC communication means, including but not limited to a pipeline, Unix Socket pair, local disk file, etc., the linux eventfd adopted by this scheme is the most efficient, and is most suitable for the selection of massive encryption and decryption requests.
  • the method realizes the encryption and decryption program by fully utilizing the standard mechanism provided by the modern Linux operating system kernel, which not only improves the security of the key, but also minimizes the loss of encryption and decryption performance, and ensures the effectiveness in practice.
  • the ciphertext processing is a request for decrypting ciphertext data into decrypted data
  • an embodiment of a method of service decryption is provided.
  • FIG. 8 is a flowchart of an optional service decryption method according to an embodiment of the present application. As shown in FIG. 8, the method may include the following steps:
  • Step S802 the key agent module receives the decryption request sent by the service module, where the decryption request carries data to be decrypted.
  • the key agent module (hereinafter referred to as an agent) may be implemented in a single-process multi-thread manner; the service module is configured to send a decryption request to the agent, wherein the agent industry service module is in the same physical single machine. .
  • the service module may send a decryption request carrying the data to be decrypted to the agent; after acquiring the decryption request, the agent may perform the following step S804, that is, according to the decryption request in the key list. Get the target key.
  • Step S804 the key agent module acquires the target key from the key list, wherein the key list is previously extracted from the key server.
  • the agent when the key agent module Agent is restarted, the agent pulls the key list to the key server. It should be noted that the agent only pulls the key list to the key server when restarting, and does not pull the key list at other times after startup.
  • the agent may acquire the target key in the pre-pushed key list, where the target key is used to decrypt the data to be decrypted.
  • Step S806 the key agent module decrypts the data to be decrypted using the target key to obtain the decrypted data.
  • the Agent may decrypt the data to be decrypted using the target key.
  • Step S808 the key agent module sends the decrypted data to the service module.
  • the key agent module decrypts the data to be decrypted using the target key, and after obtaining the decrypted data, the decrypted data can be sent to the service module.
  • the decryption request is received by the key agent module, and then the target key is acquired according to the key request, and then the data to be decrypted by the target key is decrypted, and the service provided in the embodiment of the present application is provided.
  • the decryption method achieves the purpose of decrypting the service more securely, thereby realizing the technical effect of improving the key security when decrypting the service, thereby solving the security of the key in decrypting the service in the related art. Lower technical issues.
  • the method further includes: the key proxy module sending the first public key to the key server, and receiving the second public key from the key server, where The key agent module has a pair of first public key and a first private key, and the key server has a pair of second public key and a second private key; the key agent module sends a key list pull request to the key server; The key agent module receives the encrypted key list sent by the key server, where The encrypted key list is obtained by encrypting the key list by using the first communication key on the key server side, and the first communication key is generated by the key server according to the first public key and the second private key; The key agent module decrypts the encrypted key list by using the second communication key on the key agent module side to obtain a key list, wherein the second communication key is a key agent module according to the first private key and the first The second public key is generated by the second public key, and the first communication key is the same as the second communication key.
  • the key list needs to be pulled from the key server, wherein the key list pulled from the key server is the encrypted key list. Therefore, the key agent needs to decrypt the extracted key list.
  • the key list extracted by the key agent is obtained by encrypting the key list by using the first communication key on the key server side, and then the key agent module decrypts the key list.
  • the key list is decrypted using the same second communication key as the first communication key.
  • the first communication key is generated by the key server according to the first public key and the second private key
  • the second communication key is generated by the key agent module according to the first private key and the second public key.
  • the first public key and the second public key are a pair of public keys pubkey and key prikey generated by the key agent before sending the key list to the key server;
  • the first private key and the second private key are secret A pair of public keys pubkey and key prikey generated by the key server.
  • the second communication key is generated according to the first private key and the second public key. Therefore, before the key agent module sends the key list pull request to the key server, the key agent and the key server need to exchange the public key and the key of both parties. After the exchange, the key agent module may generate a second communication key for decrypting the key list after transmitting the key list pull request to the key server, and the key server may also generate the secret key.
  • the key list is encrypted with the first communication key.
  • the public key and the key of the exchanged parties are specifically: the agent sends the first public key to the key server SVR, and then the agent receives the second public key from the key server SVR. After the exchange, the agent can use the first The private key and the second public key encrypted key list are decrypted.
  • the agent and the key server may exchange the pubkeys of the two parties and the respective prikeys by using a key exchange protocol (ie, an ECDH protocol).
  • a key exchange protocol ie, an ECDH protocol
  • the key list in the present application is encrypted using the first public key and the second private key, and decrypted using the first private key and the second public key.
  • the public key pubkey of the Agent and the key server is transmitted on the network. Therefore, by using the encryption method in the present application, even if the key is reversed by the tcpdump, the intranet is avoided. The phenomenon of key leakage caused by the packet occurs.
  • the key agent After the key agent pulls the key list from the key server and decrypts the key list, the key agent needs to verify the legality of the business process, wherein the business process is the process represented by the data to be decrypted.
  • the key agent module sends the first public key to the key server, and receiving the second public key from the key server includes: when the key agent module is restarted, the key agent module Sending the encrypted first public key to the key server, wherein the encrypted first public key is obtained by encrypting the first public key by using the agreed key; the key agent module receives the encrypted version from the key server a second public key, wherein the encrypted second public key is obtained by encrypting the second public key by using the contract key; the key proxy module decrypts the encrypted second public key by using the agreed key, and obtains the first A public key; wherein the appointment key is set to be used only when the key broker module is restarted.
  • the key agent when the key agent is restarted, when the key agent sends the first public key to the key server, the first public key is encrypted by using the agreed key, and the first key is encrypted after using the agreed key. A public key is sent to the key server, and after the key server obtains the first public key, it can decrypt using the agreed key.
  • the key server sends the second public key to the key agent, the second public key is also encrypted using the agreed key, and the encrypted second public key is sent to the key agent, where the key After receiving the second public key after encryption, the agent can decrypt the second public key using the agreed key.
  • the first public key and the second public key are encrypted and transmitted to each other only when the key agent is restarted, using the “contract key”. That is to say, only the maintainer of the key agent restarts the process when changing the key agent is the only time to legally use the agreed key, and any other situation is illegal. For example, the maintainer of the key agent uses the contract key to obtain the key list when the key agent is restarted. After that, if other users use the agreed key again to obtain the key list, the user is abused. By. Therefore, in the embodiment of the present application, the setting of the "contract key" is used only when the key agent is restarted, and the abuser can be detected quickly and effectively.
  • the key agent needs to decrypt the key list after pulling the key list.
  • the method before the key proxy module receives the decryption request sent by the service module, the method further includes: the key proxy module acquiring the process PID of the service process, where the service process sends the service module to be decrypted.
  • the process of the data the key agent module checks the legality of the business process and the process PID; the key agent module obtains the target key from the key list, including: in the case that the legality check passes, the key agent module Get the target key in the key list.
  • the process PID of the service process can be obtained through the key agent, and then the legality of the process PID and the service process is verified by the key agent. If the verification result of the process PID and the service process is legal, that is, if the verification is passed, the key agent module may obtain the target key from the key list, and decrypt the data to be decrypted by the target key. .
  • the key proxy module may obtain the process PID that is authenticated by the kernel by the service module transmitted by the service module through the socket SCM_RIGHTS, wherein the socket SCM_RIGHTS is applicable to the unix domain socket.
  • the key agent module performs legality verification on the service process and the process PID, including: the key agent module acquires a full path of the process corresponding to the process PID; and the key agent module determines the full path of the process. Whether it belongs to the path in the legal path obtained from the key server in advance; if it is determined that the path of the process belongs to the path in the legal path, the key agent module performs the MD5 check operation on the service process to obtain the first MD5 school. If the process full path does not belong to the path in the legal path, it is determined that the validity check fails; the key agent module determines whether the first MD5 check result is corresponding to the pre-acquired service process.
  • the second MD5 check result is the same; if the first MD5 check result is the same as the second MD5 check result, it is determined that the validity check is passed; if the first MD5 check result is different from the second MD5 check result, then It is judged that the legality check fails.
  • the specific verification process is as follows: the key agent module first obtains the full path of the process corresponding to the process PID, and then determines the path of the process and the path in the legal path obtained from the key server in advance. If it is determined that the path of the process belongs to the path in the legal path, the MD5 of the service process is verified by the key agent module to obtain the first MD5 check result; if it is determined that the path of the process does not belong to the path in the legal path Then, the validity check of the business process and process PID does not pass. Next, it is determined whether the first MD5 check result is the same as the pre-acquired second MD5 check result, wherein if the same, the legality check passes, and if not, the legality check fails.
  • the method further includes: When the verification passes, the key agent module acquires the first file descriptor sent by the service module, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal data; the key agent module Generating a second file descriptor, wherein the second file descriptor is used by the service module to identify data sent by the key agent module as legitimate data; and the key agent module transmits the second file descriptor to the service module.
  • the key agent module and the service module are required. Exchange file descriptors between. Specifically, the key agent module may first obtain the first file descriptor of the service module, and after obtaining the first file descriptor, the key agent module may identify the data sent by the service module as legal data. At this point, the business module has exchanged file descriptors with the key broker module, then the key broker module is required to exchange file descriptors with the business module. At this time, the key agent module may transmit the generated second file descriptor to the service module, and after receiving the second file descriptor, the service module may identify the data sent by the key agent module as legal data.
  • the first file descriptor and the second file descriptor correspond to a data block that stores data in the shared memory, where the shared memory is used to store the data to be decrypted of the decryption request and the to-be-decrypted after decryption.
  • the data will be described in detail in the following examples.
  • the service module stores the data to be decrypted in the shared memory
  • the data to be decrypted is stored in the area corresponding to the first file descriptor in the shared memory.
  • the key agent module can learn that the service module stores the data to be decrypted in the shared memory, and then the key agent module goes to the area to obtain the data to be decrypted.
  • multiple file descriptors eventfd can be exchanged at one time, and more eventfd is exchanged by verification again when not enough, so that the number of verification requests can be significantly reduced, and the applicant finds through testing.
  • the maximum number of fd for the next performance exchange of the Linux system is 255.
  • the key agent module may further set a target authority for the first file descriptor, where the target authority includes at least one of the following: The key agent module is allowed to decrypt the data to be decrypted requested by the service module, and the key agent module is allowed to decrypt the data to be decrypted requested by the service module.
  • the key agent module performs legality verification on the service process and the process PID.
  • the key agent module can set the target authority for the first file descriptor after exchanging the file descriptor, the set target authority includes: the data to be decrypted requested by the key agent module to the service module. Decryption is performed to allow the key agent module to decrypt the data to be decrypted requested by the service module.
  • the key agent module After the key agent module sets the target permission for the first file descriptor, the key agent module can decrypt the data to be decrypted according to the received decryption request, and then send the decrypted data to the service module.
  • the key agent module receives the decryption request sent by the service module, and the key agent module obtains the data to be decrypted stored by the service module from the shared memory, and the key agent module sends the decrypted data to the service module, including: The key agent module stores the decrypted data into the shared memory, so that the service module obtains the decrypted data from the shared memory.
  • the decryption request is stored in the shared memory.
  • the key agent module can retrieve the stored data to be decrypted from the shared memory.
  • the key agent module decrypts the data to be decrypted using the target key
  • the data to be decrypted after the decryption process can also be stored in the shared memory. Enables the business module to retrieve the decrypted data from the shared memory.
  • the key agent module has previously set a target authority for the first file descriptor. In this case, if the validity check is passed, the key agent module is from the key list. Obtaining the target key, specifically: when the target authority includes the key agent module to decrypt the data to be decrypted requested by the service module, the key agent module obtains the target key package from the key list.
  • the target authority may only allow the key agent module to decrypt the data to be decrypted requested by the service module or allow the key agent module to decrypt the data to be decrypted requested by the service module. Therefore, the key agent module can obtain the target key from the key list only when determining that the target authority is to allow the key agent module to decrypt the data to be decrypted requested by the service module, and use the obtained target secret. Key to solve the decrypted data dense.
  • the process PID of the key agent module acquiring the service process includes: obtaining, by the key agent module, the process PID of the service process through the unix domain socket in the non-root operation mode; or, the key The proxy module configures the socket socket option as SO_PEERCRED and obtains the process PID of the business process through the socket socket.
  • the process PID is transmitted through the socket SCM_RIGHTS in the unix domain socket. Because the unix domain sockets pass the exact process PID is based on the non-root mode running process, the local root mode must be approved before the process PID is passed. That is, the process PID of the business process needs to be obtained through the unix domain socket in the non-root mode. Further, the option of the socket socket can be configured as SO_PEERCRED through the key proxy module, and the process PID of the business process can be obtained through the socket socket.
  • FIG. 9 is a flowchart of an optional service encryption method according to an embodiment of the present application. As shown in FIG. 9, the key agent and the service module are in the same physical single machine.
  • the key agent when the key agent is restarted, the key agent encrypts the first public key by using the contract key, and sends the encrypted first public key to the key server, and the key agent module can also Receiving the encrypted second public key sent by the key server, wherein the second public key is also encrypted by using the agreed key. After obtaining the second public key, the key agent decrypts the second public key by using the agreed key. After obtaining the first public key, the key server also decrypts the first public key by using the agreed key.
  • the key agent can send a pull request of the key list to the key server.
  • the key server transmits the encrypted key list to the key agent, where the encrypted key list is the first communication key pair key list using the key server side.
  • the first communication key obtained by the encryption is generated by the key server according to the first public key and the second private key.
  • the key agent may decrypt using the same second communication key as the first communication key, wherein the second communication key is the key agent module according to the first private key. And the second public key is generated.
  • the first public key and the second public key are encrypted and transmitted to each other only when the key agent is restarted, using the “contract key”.
  • the service encryption provided in the embodiment of the present application decrypts the encrypted key list using the first private key and the second public key, so even the key list The key is not reversed by tcpdump, which avoids the key leakage caused by intranet capture.
  • the memory of the key agent and the key server may also be protected. Specifically, the binary of the key agent and the key server can be directly stripped off (ie, all debugging information is deleted), and then the code of the key agent and the key server is securely isolated, so that gdb is almost Dice, at least it is impossible to simply modify the variables.
  • the service module After decrypting the key list, the key agent needs to verify the PID legality of the business process and the business process.
  • the service module first establishes a unix domain socket and establishes a first file descriptor, and then uses the socket in the unix domain socket.
  • SCM_RIGHTS transfers the first file descriptor to the key agent, and uses the socket SCM_CREDENTIA to transfer the process PID that the process is authenticated by the kernel to the key agent.
  • SCM_RIGHTS and SCM_CREDENTIA are applicable to unix domain socket
  • SCM_RIGHTS is used to transfer descriptors in one process to another process.
  • This method can extend some IPCs that can only communicate between relative processes to non-affinity processes ( For example, linux eventfd); SCM_CREDENTIA is used to transfer the process PID whose process is authenticated by the kernel.
  • the key agent module may further send a first file descriptor eventfda to the service module, and the key agent module generates a second file after acquiring the first file descriptor eventfda.
  • Descriptor eventfdb and send the second file descriptor eventfdb to the business module to implement the exchange of file descriptors between the key agent module and the business module.
  • the key agent module may further set a target authority for the first file descriptor, where the target authority includes at least one of the following: allowing the key agent module to request the service module The encrypted data is encrypted, allowing the key agent module to decrypt the data to be decrypted requested by the service module.
  • the service module can perform the operation of writing data to the first file descriptor eventfda in the corresponding space in the shared memory, that is, the data to be encrypted is written into the corresponding area of the first file descriptor eventfda in the shared memory.
  • Medium write eventfda
  • the key agent module can know that the business module has written data. At this time, the key agent module will be shared.
  • the data to be encrypted is read in memory (ie, the second file descriptor is read, read eventfdb), and the target permissions previously configured for the first file descriptor eventfda are read.
  • the key agent module can obtain the target key from the key list, and then the key agent module can Encrypt the data to be encrypted according to the obtained target key.
  • the premise of the unix domain socket passing the accurate process PID is the process running in the non-root mode, so the requirement of the root mode of the key agent must be approved.
  • the key broker module can also configure the socket socket option as SO_PEERCRED and obtain the process PID of the business process through the socket socket.
  • test environment is the following environment:
  • Key Agent 10 processes; in which the business process and the key agent are free to run, and no CPU priority is set.
  • Bill main ticket + slave ticket
  • Bill main ticket + slave ticket
  • the requests of the five external test machines for the test business reached about 30W/S, of which 17% for the empty service, 31%-33% for the local decryption, and 33%-34% for the agent decryption.
  • the requests of the 8 external test machines for the test business reached about 40W/S, of which 27-28% for the empty service, 55%-56% for the local decryption, and 60%-61% for the agent decryption.
  • the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware, but in many cases, the former is A better implementation.
  • the technical solution of the present application which is essential or contributes to the related art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk, CD-ROM).
  • the instructions include a number of instructions for causing a terminal device (which may be a cell phone, a computer, a server, or a network device, etc.) to perform the methods described in various embodiments of the present application.
  • FIG. 11 is a schematic diagram of an optional service processing apparatus according to an embodiment of the present application. As shown in FIG. 11, the apparatus may include:
  • the first obtaining unit 1101 is configured to acquire first information, where the first information is used to indicate that the first type of the key agent module performs an execution result of the ciphertext processing request;
  • the first detecting unit 1103 is configured to detect whether the first information meets a predetermined type switching condition, wherein the predetermined type switching condition indicates that the configuration of the first type of the key agent module cannot stably perform the ciphertext processing request;
  • the first execution unit 1105 is configured to execute the ciphertext processing request of the service module by the second type of key proxy module in the case that the first information is detected to meet the predetermined type switching condition.
  • the first processing unit is configured to be to the first type before acquiring the first information
  • the key agent module sends a ciphertext processing request, and obtains an execution result of the first type of the key agent module to perform the ciphertext processing request; the first obtaining unit includes: performing, according to the execution result, the first type of the key agent module to perform ciphertext processing The success rate of the request, wherein the first information includes a success rate.
  • the predetermined type switching condition includes: the success rate is lower than the first predetermined threshold, and the detecting unit is specifically configured to: determine whether the success rate is lower than the first predetermined threshold; if the detected success rate is lower than the first predetermined threshold, determine The first information meets the predetermined type switching condition; if the detected success rate is not lower than the first predetermined threshold, it is determined that the first information does not meet the predetermined type switching condition.
  • the first type of key agent module is a development type key agent module
  • the second type of key agent module is a stable key agent module
  • the stable key agent module is executed within a predetermined time period.
  • the ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
  • development type key agent module may be, but not limited to, an unauthenticated agent module, and the verification process is performed to obtain the stable stable key agent module.
  • the second processing unit is configured to record the key agent module that performs the update operation as the first type after updating the file in the key agent module in the system before acquiring the first information.
  • a key agent module if it is detected that the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate within a predetermined time period, the first type of the key agent module is recorded as the second A type of key broker module.
  • the third processing unit is configured to: before the first information of the first type of the key agent module in the system is running, if the file in the key agent module is updated, Update the files in the first type of key broker module.
  • the first execution unit includes: if a plurality of second type of key agent modules are included in the system, obtaining a second type of key with the latest update time from the plurality of second type of key agent modules
  • the proxy module performs the ciphertext processing request by the second type of key proxy module that updates the latest time.
  • the fourth processing unit is configured to, after receiving the ciphertext processing request of the service module by the second type of key proxy module, after receiving the input switching instruction, respond to the switching instruction, by using the first type
  • the key broker module performs a ciphertext processing request.
  • the fifth processing unit is configured to obtain the key of the key proxy module through the service thread in the process of performing the ciphertext processing request by the first type of key proxy module or the second type of key proxy module Data, wherein the key agent module is configured to transmit key data when detecting that the success rate of executing the ciphertext processing request is lower than a second predetermined threshold; decrypting the key list stored in the shared memory by using the key data, Obtaining a decrypted key list; performing a ciphertext processing request through the service module by using the decrypted key list.
  • the sixth processing unit is configured to generate, by the service thread, a first end descriptor and a second end descriptor of the communication pipeline before acquiring the key data of the key proxy module by the service thread, where the first end The descriptor is used by the key agent module to identify the data sent by the service module as legal data, and the second end descriptor is used by the service module to identify the data sent by the key agent module as legal data; the second end descriptor is sent through the communication pipeline. Transfer to the key broker module.
  • obtaining, by the service thread, the key data of the key agent module includes: periodically reading data from the read end of the communication pipe through the service thread; if the data is read from the read end of the communication pipe, determining to obtain Key data.
  • the communication pipeline is further configured to detect whether the service module and the key agent module are restarted.
  • the seventh processing unit is configured to, after performing the ciphertext processing request by the key proxy module, after the validity of the validity verification by the key proxy module,
  • the service module sends a first file descriptor to the key proxy module, where the first file descriptor is used by the key proxy module to identify the data sent by the service module as legal data; and the second key generated by the key proxy module is obtained.
  • a file descriptor wherein the second file descriptor is used by the service module to identify data sent by the key agent module as legitimate data.
  • the seventh processing unit is configured to acquire multiple seconds generated by the key agent module After the file descriptor, the obtained second file descriptors are saved in the queue; the second file descriptor stored in the queue is used to communicate with the key agent module.
  • the number of the plurality of second file descriptors corresponds to the number of threads in the key broker module for executing the ciphertext processing request.
  • the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
  • the apparatus is applied in a key broker module, the apparatus comprising: a first processing unit, disposed in the first type of key broker module, configured to receive and execute the secret of the service module Processing the request, obtaining an execution result; the first processing unit is disposed in the second type of key agent module, configured to receive and execute the ciphertext processing request of the service module, wherein the service module is set to be generated based on the execution result When the first information conforms to the predetermined type switching condition, the ciphertext processing request is sent to the second type of key agent module.
  • the first type of key agent module is a development type key agent module
  • the second type of key agent module is a stable key agent module
  • the stable key agent module is executed within a predetermined time period.
  • the ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
  • the third processing unit is configured to: in the first type of the key agent module, receive and execute the ciphertext processing request of the service module, and update the file in the key agent module in the system before obtaining the execution result.
  • the key agent module that performs the update operation is recorded as the first type of key agent module; after the first type of the key agent module receives and executes the ciphertext processing request of the service module, and after obtaining the execution result, if The first type of key agent module is recorded as the second type of key agent module by detecting that the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate within the predetermined time period.
  • the updating unit is configured to: when the first type of the key agent module performs the ciphertext processing request of the service module, if the file in the key agent module needs to be updated, the first type of the secret is The files in the key broker module are updated.
  • the detecting unit is configured to: when the key agent module performs the ciphertext processing request, the key agent module detects whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold; if the execution ciphertext is detected If the success rate of the processing request is lower than the second predetermined threshold, the key data is sent to the service module, where the key data is used to decrypt the key list stored in the shared memory, and the decrypted key list is obtained, and the service module further Used to perform a ciphertext processing request through the decrypted key list.
  • the fourth processing unit is configured to: after the key agent module detects whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, the key agent module is based on the ciphertext after executing the ciphertext processing request The processing time in the request is compared with the current time, and it is determined whether the current ciphertext processing request is timed out; if it is determined that the current ciphertext processing request is timed out, it is determined that the execution of the current ciphertext processing request fails; The number of requests processed, and the success rate of the statistics key agent module to perform ciphertext processing requests.
  • the sixth processing unit is configured to receive the second end descriptor of the communication pipeline transmitted by the service thread before the key proxy module detects whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, where
  • the service thread is configured to generate a first end descriptor and a second end descriptor, wherein the first end descriptor is used by the key proxy module to identify the data sent by the service module as legal data, and the second end descriptor is used for the service.
  • the module identifies the data sent by the key broker module as legitimate data.
  • sending the key data to the service module includes: transmitting key data by using a write end of a communication pipeline of each service thread.
  • the communication pipeline is further configured to detect whether the service module and the key agent module are restarted.
  • the sixth processing unit is configured to, after performing the ciphertext processing request by the key proxy module, after the validity of the validity verification by the key proxy module,
  • the key agent module receives the first file descriptor sent by the service module, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal data; the key agent module generates multiple second files. Descriptor, where the second file descriptor
  • the service module identifies the data sent by the key agent module as legal data; the key agent module transmits a plurality of second file descriptors to the service module.
  • the number of the plurality of second file descriptors corresponds to the number of threads in the key broker module for executing the ciphertext processing request.
  • the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
  • the service processing device is applied in a key agent module, the device includes: a first obtaining unit configured to acquire an execution result of the execution of the ciphertext processing request; and a first detecting unit configured to detect execution Whether the result meets the predetermined mode switching condition, wherein the matching the predetermined type switching condition indicates that the first type of the key agent module is vulnerable, that is, the first type of the key agent module cannot stably execute the ciphertext Processing the request; the first sending unit is configured to: if the detection result is that the execution result meets the predetermined mode switching condition, send the indication information to the service module, where the indication information is used to indicate that the service module switches to the mode of performing the ciphertext processing request by the service module .
  • the first obtaining unit is configured to: after the ciphertext processing request is executed, determine, according to the request time and the current time in the ciphertext processing request, whether the current ciphertext processing request is timed out; If the execution of the current ciphertext processing request timeout occurs, the key agent module determines that the execution of the current ciphertext processing request fails; the key agent module performs the ciphertext processing request based on the number of ciphertext processing requests that failed to execute.
  • the success rate, the execution results include the success rate.
  • the first detecting unit is configured to: the key agent module detects whether the success rate is lower than a second predetermined threshold; if it is detected whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, determining that the execution result is consistent Scheduled mode switching conditions.
  • the first sending unit is configured to: the key agent module sends the key data to the service module, where the key data is used to decrypt the key list stored in the shared memory, and obtain the decryption.
  • the service module is further configured to perform a ciphertext processing request through the decrypted key list.
  • the key agent module includes a first type of key agent module and a second type of key agent module, wherein the first type of key agent module is a development type key agent module, and the second type of secret
  • the key agent module is a stable key agent module, and the stable key agent module is a key agent module that performs a ciphertext processing request with a correct rate higher than a predetermined correct rate within a predetermined time period.
  • the first processing unit is configured to: after the key agent module receives and executes the ciphertext processing request of the service module, after the file in the key agent module is updated, the key agent that performs the update operation is set
  • the module records as a first type of key agent module; after the first type of key agent module receives and executes the ciphertext processing request of the service module, and obtains the execution result, the method further includes: if the predetermined time period is detected When the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate, the first type of key agent module is recorded as the second type of key agent module.
  • the second processing unit is configured to: when the first type of the key agent module performs the ciphertext processing request of the service module, if the file in the key agent module needs to be updated, the first type is The files in the key broker module are updated.
  • the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
  • FIG. 12 is a schematic diagram of an optional service encryption apparatus according to an embodiment of the present application.
  • the apparatus may include: a first encryption receiving unit 1201, a first encryption obtaining unit 1203, and a first encryption unit 1205. And a first encryption transmitting unit 1207, wherein:
  • the first encryption receiving unit 1201 is disposed in the key agent module and configured to receive an encryption request sent by the service module, where the encryption request carries data to be encrypted.
  • the first encryption obtaining unit 1203 is disposed in the key agent module and configured to acquire the target key from the key list, wherein the key list is previously extracted from the key server.
  • the first encryption unit 1205 sets the key agent module to encrypt the data to be encrypted using the target key to obtain the encrypted data.
  • the first encryption sending unit 1207 is disposed in the key agent module and configured to send the encrypted data to the service module.
  • the encryption request is received by the key agent module, and then the target key is obtained according to the key request, and then the data to be encrypted is encrypted by the target key, and the service encryption provided in the embodiment of the present application is encrypted.
  • the method achieves the purpose of encrypting the service more securely, thereby achieving the technical effect of improving the key security when encrypting the service, thereby solving the security of the key when decrypting the service in the related art. Low technical issues.
  • the second encryption sending unit is disposed in the key agent module, and is configured to send the first public key to the key server and receive the key server before receiving the encryption request sent by the service module by the key agent module.
  • Receiving a second public key wherein the key agent module has a pair of first public key and a first private key, the key server has a pair of second public key and a second private key; and the third encrypted sending unit sets In the key agent module, configured to send a key list pull request to the key server; the second encryption receiving unit is set in the key agent module, and is configured to receive the encrypted key list sent by the key server,
  • the encrypted key list is obtained by encrypting the key list by using the first communication key on the key server side, and the first communication key is generated by the key server according to the first public key and the second private key.
  • a decryption unit configured in the key agent module, configured to decrypt the encrypted key list using the second communication key on the side of the key agent module to obtain a key list, wherein Communication module generates the proxy key is a key obtained by the first private key and a second public key, same as the first key and a second communication communication key.
  • the second encryption sending unit includes: a first sending module, configured to send the encrypted first public key to the key server when the key agent module is restarted, where the encrypted first public key is The first public key is encrypted by using a contract key; the receiving module is set to be connected Receiving the encrypted second public key, wherein the encrypted second public key is obtained by encrypting the second public key using the agreed key; and the decrypting module is set to use the agreed key pair to encrypt the second public key Decrypting is performed to obtain a second public key; wherein the appointment key is set to be used only when the key broker module is restarted.
  • a first sending module configured to send the encrypted first public key to the key server when the key agent module is restarted, where the encrypted first public key is The first public key is encrypted by using a contract key
  • the receiving module is set to be connected Receiving the encrypted second public key, wherein the encrypted second public key is obtained by encrypting the second public key using the agreed key
  • the decrypting module is set to use the agreed key pair to
  • the device includes: a second encryption acquiring unit, configured in the key agent module, configured to acquire a process PID of the service process, where the service process is a process, before the key agent module receives the encryption request sent by the service module a process of sending the data to be encrypted by the service module; the verification unit is set in the key agent module, and is set to perform legality verification on the service process and the process PID; and the first encryption acquisition unit includes: a first acquisition module, and a setting In the key proxy module, the key proxy module obtains the target key from the key list if the validity check is passed.
  • the verification unit includes: a second obtaining module, configured to acquire a full path of the process corresponding to the process PID; and a first determining module, configured to determine whether the full path of the process belongs to a legal path obtained from the key server in advance
  • the path of the verification module is set to perform the MD5 verification operation on the service process to obtain the first MD5 verification result when the path of the process is determined to belong to the path in the legal path;
  • the first determining module is set to If it is determined that the path of the process does not belong to the path in the legal path, it is determined that the validity check fails;
  • the second determining module is configured to determine whether the first MD5 check result is corresponding to the pre-acquired service process.
  • the second MD5 check result is the same; the second determining module is configured to determine that the validity check is passed when it is determined that the first MD5 check result is the same as the second MD5 check result; and the third determining module is set to When it is determined that the first MD5 check result is different from the second MD5 check result, it is determined that the validity check fails.
  • the device further includes: a third encryption acquiring unit, configured in the key agent module, configured to perform the validity check on the service process and the process PID after the key agent module, and receive the service in the key agent module Before the encryption request sent by the module, in the case that the validity check is passed, the first file descriptor sent by the service module is obtained, where the first file descriptor is used for
  • the key agent module identifies the data sent by the service module as legal data;
  • the generating unit is disposed in the key agent module and configured to generate a second file descriptor, wherein the second file descriptor is used by the service module to use the key agent
  • the data sent by the module is identified as legal data;
  • the transmission unit is disposed in the key agent module and configured to transmit the second file descriptor to the service module.
  • the first encryption receiving unit includes: a third acquiring module, configured in the key proxy module, and configured to receive the encryption request sent by the service module, where the key proxy module obtains the service module from the shared memory
  • the encrypted data includes: a second sending module, configured in the key proxy module, configured to store the encrypted data in the shared memory, so that the service module obtains the encrypted content from the shared memory. data.
  • the device further includes: a setting unit, configured in the key agent module, configured to perform a validity check on the service process and the process PID of the key agent module, and receive the service module sent by the key agent module Before the encryption request, in the case that the legality verification is passed, the key agent module sets the target authority for the first file descriptor, wherein the target authority includes at least one of the following: the key agent module is requested to encrypt the service module.
  • the data is encrypted, allowing the key agent module to decrypt the data to be decrypted requested by the service module.
  • the first obtaining module includes: an obtaining submodule, configured to allow the key proxy module to encrypt the data to be encrypted requested by the service module, and the key proxy module obtains the target key from the key list.
  • the second encryption obtaining unit includes: a fourth obtaining module, configured to acquire a process PID of the service process through the unix domain socket in the non-root running mode; or, the fifth obtaining module is configured to socket the socket
  • the word option is configured as SO_PEERCRED, and the process PID of the business process is obtained through the socket socket.
  • the first encryption receiving unit 1201 in this embodiment may be configured to perform step S702 in the first embodiment of the present application.
  • the first encryption obtaining unit 1203 in this embodiment may be configured to perform the first embodiment of the present application.
  • the first encryption unit 1205 in this embodiment may be configured to perform step S706 in Embodiment 1 of the present application, in this embodiment
  • the first encryption transmitting unit 1207 may be configured to perform step S708 in Embodiment 1 of the present application.
  • FIG. 13 is a schematic diagram of an optional service decryption apparatus according to an embodiment of the present application.
  • the apparatus may include: a first decryption receiving unit 1301, a first decryption acquisition unit 1303, and a first decryption unit 1305. And a first decryption transmitting unit 1307, wherein:
  • the first decryption receiving unit is disposed in the key proxy module and configured to receive the decryption request sent by the service module, where the decryption request carries data to be decrypted.
  • the first decryption obtaining unit is disposed in the key agent module and configured to obtain the target key from the key list, wherein the key list is previously extracted from the key server.
  • the first decryption unit sets the key agent module to decrypt the data to be decrypted using the target key to obtain the decrypted data.
  • the first decryption sending unit is disposed in the key agent module and configured to send the decrypted data to the service module.
  • the decryption request is received by the key agent module, and then the target key is obtained according to the key request, and then the data to be decrypted is decrypted by the target key, and the service decryption provided in the embodiment of the present application is decrypted.
  • the method achieves the purpose of decrypting the service more securely, thereby realizing the technical effect of improving the security of the key when decrypting the service, thereby solving the security of the key when decrypting the service in the related art. Low technical issues.
  • the second decryption sending unit is disposed in the key agent module, and configured to send the first public key to the key server and receive the key server before the key agent module receives the decryption request sent by the service module Receiving a second public key, wherein the key agent module has a pair of first public key and a first private key, the key server has a pair of second public key and a second private key; and the third decryption sending unit sets In the key agent module, configured to send a key list pull request to the key server; the second decryption receiving unit is set in the key agent module, and is configured to receive the encrypted key list sent by the key server, Where the encrypted key list is a key service The first communication key of the device side is obtained by encrypting the key list, and the first communication key is generated by the key server according to the first public key and the second private key; and the second decryption unit is set in the key agent.
  • the second key of the key agent module is used to decrypt the encrypted key list to obtain a key list, wherein the second communication key is a key agent module according to the first private key and The second public key is generated, and the first communication key is the same as the second communication key.
  • the second decryption sending unit includes: a first sending module, configured to send the encrypted first public key to the key server when the key agent module is restarted, where the encrypted first public key is The first public key is obtained by encrypting the first public key; the receiving module is configured to receive the encrypted second public key from the key server, wherein the encrypted second public key is the second key using the agreed key The key is encrypted; the decryption module is configured to decrypt the encrypted second public key by using the contract key to obtain a second public key; wherein the appointment key is set to be only in the key agent module Used when restarting.
  • the device includes: a second decryption acquiring unit, configured to be configured in the key agent module, configured to acquire a process PID of the service process, where the key process module receives the decryption request sent by the service module, where the service process is The process of sending the data to be decrypted by the service module;
  • the verification unit is set in the key agent module, and is set to perform legality verification on the service process and the process PID;
  • the first decryption acquisition unit includes: a first acquisition module, which is set in In the key agent module, it is set that the key agent module obtains the target key from the key list if the validity check is passed.
  • the verification unit includes: a second obtaining module, configured to acquire a full path of the process corresponding to the process PID; and a first determining module, configured to determine whether the full path of the process belongs to a legal path obtained from the key server in advance
  • the path of the verification module is set to perform the MD5 verification operation on the service process to obtain the first MD5 verification result when the path of the process is determined to belong to the path in the legal path;
  • the first determining module is set to If it is determined that the path of the process does not belong to the path in the legal path, it is determined that the validity check fails;
  • the second determining module is configured to determine whether the first MD5 check result is corresponding to the pre-acquired service process.
  • the second MD5 check result is the same; the second determining module is configured to determine that the validity check is passed when it is determined that the first MD5 check result is the same as the second MD5 check result; the third determining module sets In order to determine that the first MD5 check result is different from the second MD5 check result, it is determined that the validity check fails.
  • the device further includes: a third decryption acquiring unit, configured in the key agent module, configured to receive the service after the key agent module performs the validity check on the service process and the process PID, and in the key agent module Before the decryption request sent by the module, if the validity check is passed, the first file descriptor sent by the service module is obtained, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal.
  • a data generating unit configured to generate a second file descriptor, wherein the second file descriptor is used by the service module to identify the data sent by the key proxy module as legal data; the transmission unit, setting In the key broker module, it is set to transmit the second file descriptor to the service module.
  • the first decryption receiving unit includes: a third obtaining module, configured in the key proxy module, configured to receive the decryption request sent by the service module, where the key proxy module obtains the service module from the shared memory Decrypted data;
  • the first decryption sending unit comprises: a second sending module, disposed in the key proxy module, configured to store the decrypted data in the shared memory, so that the service module obtains the decrypted data from the shared memory data.
  • the device further includes: a setting unit, configured in the key agent module, configured to perform a validity check on the service process and the process PID of the key agent module, and receive the service module sent by the key agent module Before the decryption request, in the case that the legality verification is passed, the key agent module sets the target authority for the first file descriptor, wherein the target authority includes at least one of the following: the key agent module is allowed to encrypt the service module request The data is encrypted, allowing the key agent module to decrypt the data to be decrypted requested by the service module.
  • a setting unit configured in the key agent module, configured to perform a validity check on the service process and the process PID of the key agent module, and receive the service module sent by the key agent module Before the case that the legality verification is passed, the key agent module sets the target authority for the first file descriptor, wherein the target authority includes at least one of the following: the key agent module is allowed to encrypt the service module request The data is encrypted, allowing the key agent module to decrypt
  • the first obtaining module includes: an obtaining submodule, configured to allow the key proxy module to decrypt the data to be decrypted requested by the service module, and the key proxy module obtains the target key from the key list.
  • the second decryption acquiring unit includes: a fourth acquiring module, configured to acquire a process PID of the service process through the unix domain socket in the non-root running mode; or, the fifth acquiring module is configured to socket the socket
  • the word option is configured as SO_PEERCRED, and the process PID of the business process is obtained through the socket socket.
  • the first decryption receiving unit 701 in this embodiment may be configured to perform step S302 in the first embodiment of the present application.
  • the first decryption obtaining unit 703 in this embodiment may be configured to perform the first embodiment of the present application.
  • the first decryption unit 705 in this embodiment may be configured to perform step S306 in the first embodiment of the present application
  • the first decryption sending unit 707 in this embodiment may be configured to perform the first embodiment in the present application. Step S308.
  • the above modules are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the contents disclosed in the above embodiment 1. It should be noted that the foregoing module may be implemented in a hardware environment as shown in FIG. 1 as part of the device, and may be implemented by software or by hardware, where the hardware environment includes a network environment.
  • an electronic device for implementing the foregoing service processing method is also provided.
  • FIG. 14 is a structural block diagram of an electronic device according to an embodiment of the present application.
  • the electronic device may include: one or more (only one is shown) processor 1401 (as in the above embodiment) The key agent module), the memory 1403, and the transmission device 1405 (such as the transmitting device in the above embodiment), as shown in FIG. 14, the electronic device may further include an input/output device 1407.
  • the memory 1403 can be configured to store software programs and modules, as implemented in the present application.
  • the processor 1401 executes various functional applications and data processing by executing the software program and the module stored in the memory 1403, that is, implementing the above-described business processing method.
  • Memory 1403 can include high speed random access memory, and can also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory.
  • memory 1403 can further include memory remotely located relative to processor 1401, which can be connected to the terminal over a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • the above-described transmission device 1405 is configured to receive or transmit data via a network, and may also be configured as data transmission between the processor and the memory. Specific examples of the above network may include a wired network and a wireless network.
  • the transmission device 1405 includes a Network Interface Controller (NIC) that can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network.
  • the transmission device 1405 is a Radio Frequency (RF) module configured to communicate with the Internet wirelessly.
  • NIC Network Interface Controller
  • RF Radio Frequency
  • the memory 1403 is configured to store an application.
  • the processor 1401 may invoke the application stored in the memory 1403 via the transmission device 1405 to perform the step of: acquiring first information, wherein the first information is used to indicate that the first type of key agent module performs execution of the ciphertext processing request a result of detecting whether the first information meets a predetermined type switching condition, wherein the matching the predetermined type switching condition indicates that a vulnerability occurs in the first type of key agent module; and when detecting that the first information meets the predetermined type switching condition, The second type of key agent module executes the ciphertext processing request of the service module.
  • the processor 1401 may invoke the application stored in the memory 1403 by the transmission device 1405 to perform the following steps: before acquiring the first information, sending a ciphertext processing request to the first type of key proxy module; acquiring the first type of key
  • the proxy module executes the execution result of the ciphertext processing request; obtaining the first information includes: counting the first type of the key proxy module based on the execution result The success rate of the ciphertext processing request, wherein the first information includes a success rate.
  • the predetermined type switching condition includes the success rate being lower than the first predetermined threshold
  • the processor 1401 may invoke the application stored in the memory 1403 by the transmitting device 1405 to perform the step of: detecting whether the success rate is lower than the first predetermined threshold. And if the detected success rate is lower than the first predetermined threshold, determining that the first information meets the predetermined type switching condition; and if the detected success rate is not lower than the first predetermined threshold, determining that the first information does not meet the predetermined type switching condition.
  • the first type of key agent module is a development type key agent module
  • the second type of key agent module is a stable key agent module
  • the stable key agent module is executed within a predetermined time period.
  • the ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
  • the processor 1401 may call the application stored in the memory 1403 through the transmission device 1405 to perform the following steps, and after updating the file in the key agent module in the system before the first information is acquired, the update operation will be performed.
  • the key agent module is recorded as a first type of key agent module; if it is detected within a predetermined time period that the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate, then A type of key broker module is recorded as a second type of key broker module.
  • the processor 1401 may invoke the application stored in the memory 1403 through the transmission device 1405 to perform the following steps.
  • the files in the key broker module are updated to update the files in the first type of key broker module.
  • the processor 1401 may invoke the application stored in the memory 1403 through the transmission device 1405 to perform the following steps. If the system includes multiple second type of key agent modules, from the plurality of second type of key agent modules Obtaining the second type of key agent module with the latest update time, and executing the ciphertext processing request by the second type of key agent module with the latest update time.
  • the processor 1401 may call the application stored in the memory 1403 through the transmission device 1405 to perform the following steps: performing the confidentiality of the service module by using the second type of key agent module After processing the request, after receiving the input switching instruction, the ciphertext processing request is executed by the first type of key agent module in response to the switching instruction.
  • the processor 1401 may call the application stored in the memory 1403 through the transmission device 1405 to perform the following steps, in the process of executing the ciphertext processing request by the first type of key agent module or the second type of key agent module, Obtaining key data of the key agent module by the service thread, wherein the key agent module is configured to send the key data when detecting that the success rate of executing the ciphertext processing request is lower than a second predetermined threshold; using the key
  • the data decrypts the key list stored in the shared memory to obtain a decrypted key list; and uses the decrypted key list to execute the ciphertext processing request through the service module.
  • the processor 1401 may invoke the application stored in the memory 1403 by the transmission device 1405 to perform the following steps: before acquiring the key data of the key agent module by the service thread, generating the first end descriptor of the communication pipe through the service thread and a second end descriptor, wherein the first end descriptor is used by the key proxy module to identify the data sent by the service module as legal data, and the second end descriptor is used by the service module to identify the data sent by the key proxy module as legal Data; the second end descriptor is transmitted to the key broker module through the communication pipe.
  • the processor 1401 can call the application stored in the memory 1403 through the transmission device 1405 to perform the steps of periodically reading data from the read end of the communication pipe through the service thread; if the data is read from the read end of the communication pipe, Make sure to get the key data.
  • the communication pipeline is further configured to detect whether the service module and the key agent module are restarted.
  • the processor 1401 may call the application stored in the memory 1403 by the transmission device 1405 to perform the following steps: during the execution of the ciphertext processing request by the key agent module, the validity of the business process is verified by the key agent module. Then, in the case that the validity check is passed, the service module sends a first file descriptor to the key proxy module, where the first file descriptor is used by the key proxy module to identify the data sent by the service module as legal data; Obtaining a plurality of second file descriptors generated by the key agent module, wherein the second file descriptor is used by the service module to identify the data sent by the key agent module as legal data.
  • the processor 1401 may call the application stored by the memory 1403 through the transmission device 1405 to perform the following steps, after acquiring the plurality of second file descriptors generated by the key agent module, the acquired second file descriptors Save to the queue; sequentially communicate with the key broker module using the second file descriptor stored in the queue.
  • the processor 1401 may call the application stored in the memory 1403 via the transmission device 1405 to perform the following steps, the number of the plurality of second file descriptors corresponding to the number of threads in the key agent module for executing the ciphertext processing request.
  • the ciphertext processing request includes: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into the decrypted data.
  • the processor 1401 may invoke the application stored in the memory 1403 by the transmission device 1405 to perform the following steps.
  • the first type of key agent module receives and executes the ciphertext processing request of the service module to obtain an execution result; the second type of secret
  • the key agent module receives and executes the ciphertext processing request of the service module, wherein the service module is configured to send the ciphertext to the second type of key agent module if the first information generated based on the execution result meets the predetermined type switching condition Processing the request, wherein conforming to the predetermined type of switching condition indicates determining that the first type of key agent module is vulnerable.
  • the first type of key agent module is a development type key agent module
  • the second type of key agent module is a stable key agent module
  • the stable key agent module is executed within a predetermined time period.
  • the ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
  • the processor 1401 may call the application stored in the memory 1403 through the transmission device 1405 to perform the following steps, the key agent module acquires an execution result of executing the ciphertext processing request; and the key agent module detects whether the execution result meets the predetermined mode switching condition, Wherein, meeting the predetermined mode switching condition indicates that the key agent module is vulnerable;
  • the key agent module sends the indication information to the service module, where the indication information is used to indicate that the service module switches to the service module.
  • the processor 1401 may invoke the application stored in the memory 1403 by the transmission device 1405 to perform the following steps.
  • the key agent module obtains the execution result of the execution of the ciphertext processing request, including: after the cryptographic processing request is executed by the key agent module, Determining whether to execute the current ciphertext processing request timeout based on the request time and the current time in the ciphertext processing request; if it is determined that the current ciphertext processing request is timed out, the key agent module determines that the execution of the current ciphertext processing request fails.
  • the key agent module calculates the success rate of the ciphertext processing request based on the number of ciphertext processing requests that fail to execute, and the execution result includes the success rate.
  • the processor 1401 may invoke the application stored in the memory 1403 by the transmission device 1405 to perform the following steps.
  • the key agent module detects whether the execution result meets the predetermined mode switching condition, including: the key agent module detects whether the success rate is lower than the second predetermined a threshold; if it is detected whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, determining that the execution result conforms to the predetermined mode switching condition.
  • the processor 1401 may invoke an application stored in the memory 1403 via the transmission device 1405 to perform the following steps.
  • the key agent module transmits key data to the service module, wherein the key data is used to decrypt the key list stored in the shared memory.
  • the decrypted key list is obtained, and the service module is further configured to execute the ciphertext processing request through the decrypted key list.
  • an electronic device for implementing the above-described service encryption (or service decryption) method is also provided.
  • FIG. 15 is a structural block diagram of an electronic device according to an embodiment of the present application.
  • the electronic device may include: one or more (only one is shown) processor 1501 (as in the above embodiment) The key agent module), the memory 1503, and the transmission device 1505 (such as the transmitting device in the above embodiment), as shown in FIG. 15, the electronic device may further include an input/output device 1507.
  • the memory 1503 can store software programs and modules, as in the embodiment of the present application.
  • the service encryption (or service decryption) method and the program instruction/module corresponding to the device, the processor 1501 performs various function applications and data processing by executing the software program and the module stored in the memory 1503, that is, implementing the above-mentioned service encryption ( Or business decryption) method.
  • the memory 1503 may include a high speed random access memory, and may also include non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory.
  • memory 1503 can further include memory remotely located relative to processor 1501, which can be connected to the terminal over a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • the above-mentioned transmission device 1505 receives or transmits data via a network, and can also transfer data between the processor and the memory.
  • Specific examples of the above network may include a wired network and a wireless network.
  • the transmission device 1505 includes a Network Interface Controller (NIC) that can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network.
  • the transmission device 1505 is a Radio Frequency (RF) module for communicating with the Internet wirelessly.
  • NIC Network Interface Controller
  • RF Radio Frequency
  • the memory 1503 is used to store an application.
  • the processor 1501 can call the application stored in the memory 1503 through the transmission device 1505 to perform the following steps:
  • the processor 1501 is further configured to perform the following steps in the service encryption method provided by the application:
  • the encryption request carries data to be encrypted; obtaining a target key from the key list, wherein the key list is previously extracted from the key server; using the target key
  • the encrypted data is encrypted to obtain the encrypted data; the key agent module sends the encrypted data to the service module.
  • the processor 1501 is further configured to: send a first public key to the key server, and receive a second public key from the key server, where the key agent module has a pair of a first public key and a first private key, the key server having a pair of the second public key And a second private key; transmitting a key list pull request to the key server; the key proxy module receiving the encrypted key list sent by the key server, wherein the encrypted key The list is obtained by encrypting the key list using a first communication key on the key server side, the first communication key being the key server according to the first public key and the first Generating the second private key; decrypting the encrypted key list using the second communication key on the key proxy module side to obtain the key list, wherein the second communication key is The key agent module generates the first communication key and the second public key according to the first private key and the second public key.
  • the processor 1501 is further configured to: when the key agent module is restarted, send the encrypted first public key to the key server, where the encrypted first The public key is obtained by encrypting the first public key using a contract key; receiving the encrypted second public key from the key server, wherein the encrypted second public key is Obtaining the second public key by using the agreement key; decrypting the encrypted second public key by using the agreement key to obtain the second public key; wherein the agreement The key is set to be used only when the key broker module is restarted.
  • the processor 1501 is further configured to: before the key proxy module receives the encryption request sent by the service module, acquire a process PID of the service process, where the service process sends a process of the data to be encrypted to the service module; The legality check is performed with the process PID; obtaining the target key from the key list includes: when the validity check is passed, the key agent module obtains the target key from the key list.
  • the processor 1501 is further configured to: obtain a process full path corresponding to the process PID; determine whether the process full path belongs to a path in a legal path obtained from the key server in advance; and determine that the process full path belongs to the legal path.
  • the MD5 check operation is performed on the service process to obtain the first MD5 check result; if it is determined that the process full path does not belong to the path in the legal path, it is determined that the validity check fails; Determining whether the first MD5 check result is the same as the second MD5 check result corresponding to the pre-acquired service process; If the first MD5 check result is the same as the second MD5 check result, it is determined that the validity check is passed; if the first MD5 check result is different from the second MD5 check result, it is determined that the validity check fails.
  • the processor 1501 further performs the following steps: after the key agent module performs the validity check on the service process and the process PID, and before the key agent module receives the encryption request sent by the service module, and passes the validity check.
  • the first file descriptor sent by the service module is obtained, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal data; and the second file descriptor is generated, where the second file is generated.
  • the descriptor is used by the service module to identify the data sent by the key proxy module as legal data; the second file descriptor is transmitted to the service module.
  • the processor 1501 is further configured to: perform the following steps: receiving the encryption request sent by the service module includes: acquiring data to be encrypted stored by the service module from the shared memory; and transmitting the encrypted data to the service module, including: encrypting The data is stored in the shared memory so that the business module obtains the encrypted data from the shared memory.
  • the processor 1501 is further configured to perform the following steps: after the key agent module performs the validity check on the service process and the process PID, and before the key agent module receives the encryption request sent by the service module, and the validity check
  • the target permission is set, wherein the target authority includes at least one of the following: the key agent module is allowed to encrypt the data to be encrypted requested by the service module, and the key agent module is allowed to the service module. The requested data to be decrypted is decrypted.
  • the processor 1501 is further configured to perform the following steps: in the case that the legality verification is passed, when the target authority includes allowing the key proxy module to encrypt the data to be encrypted requested by the service module, the key proxy module is from the key Get the target key in the list.
  • the processor 1501 is further configured to: the key proxy module acquires the process PID of the service process through the unix domain socket in the non-root operation mode; or the key proxy module configures the option of the socket socket as the SO_PEERCRED And through the socket socket acquisition industry Process PID of the process.
  • the processor 1501 is further configured to perform the following steps in the service decryption method provided by the application:
  • the decryption request carries data to be decrypted; obtaining a target key from the key list, wherein the key list is previously extracted from the key server; using the target key
  • the decrypted data is decrypted to obtain the decrypted data; the key agent module sends the decrypted data to the service module.
  • the processor 1501 is further configured to: send a first public key to the key server, and receive a second public key from the key server, where the key agent module has a pair of a first public key having a pair of the second public key and a second private key; and a key list pull request sent to the key server; the key The proxy module receives the encrypted key list sent by the key server, wherein the encrypted key list is obtained by encrypting the key list by using the first communication key on the key server side.
  • the first communication key is generated by the key server according to the first public key and the second private key; using the second communication key on the key proxy module side Decrypting the encrypted key list to obtain the key list, wherein the second communication key is generated by the key agent module according to the first private key and the second public key, The first communication key is the same as the second communication key.
  • the processor 1501 is further configured to: when the key agent module is restarted, send the encrypted first public key to the key server, where the encrypted first The public key is obtained by encrypting the first public key using a contract key; receiving the encrypted second public key from the key server, wherein the encrypted second public key is Obtaining the second public key by using the agreement key; decrypting the encrypted second public key by using the agreement key to obtain the second public key; wherein the agreement The key is set to be used only when the key broker module is restarted.
  • the processor 1501 is further configured to: obtain the process PID of the service process, where the service process is a service mode, before the key agent module receives the decryption request sent by the service module.
  • the process of sending the data to be decrypted by the block; verifying the legality of the business process and the process PID; and obtaining the target key from the key list includes: in the case that the legality verification is passed, the key agent module is from the key list Get the target key.
  • the processor 1501 is further configured to: obtain a process full path corresponding to the process PID; determine whether the process full path belongs to a path in a legal path obtained from the key server in advance; and determine that the process full path belongs to the legal path.
  • the MD5 check operation is performed on the service process to obtain the first MD5 check result; if it is determined that the process full path does not belong to the path in the legal path, it is determined that the validity check fails; Determining whether the first MD5 check result is the same as the second MD5 check result corresponding to the service process obtained in advance; if the first MD5 check result is the same as the second MD5 check result, determining that the validity check is passed; If the first MD5 check result is different from the second MD5 check result, it is determined that the validity check fails.
  • the processor 1501 is further configured to perform the following steps: after the key agent module performs the validity check on the service process and the process PID, and before the key agent module receives the decryption request sent by the service module, and the validity check And obtaining, by the first file descriptor sent by the service module, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal data; and the second file descriptor is generated, where The second file descriptor is used by the service module to identify the data sent by the key agent module as legal data; and the second file descriptor is transmitted to the service module.
  • the processor 1501 is further configured to: perform the following steps: the receiving the decryption request sent by the service module comprises: acquiring data to be decrypted stored by the service module from the shared memory; and sending the decrypted data to the service module comprises: decrypting the decrypted The data is stored in the shared memory so that the business module obtains the decrypted data from the shared memory.
  • the processor 1501 is further configured to perform the following steps: after the key agent module performs the validity check on the service process and the process PID, and before the key agent module receives the decryption request sent by the service module, and the validity check In the case of passing, set the target right for the first file descriptor
  • the target authority includes at least one of the following: the key proxy module is allowed to decrypt the data to be decrypted requested by the service module, and the key proxy module is allowed to decrypt the data to be decrypted requested by the service module.
  • the processor 1501 is further configured to perform the following steps: in the case that the legality verification is passed, when the target authority includes the key agent module to decrypt the data to be decrypted requested by the service module, the key agent module slave key Get the target key in the list.
  • the processor 1501 is further configured to: the key proxy module acquires the process PID of the service process through the unix domain socket in the non-root operation mode; or the key proxy module configures the option of the socket socket as the SO_PEERCRED And get the process PID of the business process through the socket socket.
  • a scheme of service encryption (or service decryption) is provided.
  • Receiving an encryption (or decryption) request by the key agent module, and then acquiring the target key according to the key request, and then encrypting the data to be encrypted (or to be decrypted) by the target key which is provided in the embodiment of the present application.
  • the service encryption (or decryption) method achieves the purpose of encrypting (or decrypting) the service more securely, thereby realizing the technical effect of improving the key security when encrypting (or decrypting) the service, thereby solving the present problem.
  • Embodiments of the present application also provide a storage medium.
  • the foregoing storage medium may be used to execute program code of a service processing method.
  • the foregoing storage medium may be located on at least one of the plurality of network devices in the network shown in the foregoing embodiment.
  • the storage medium is arranged to store program code for performing the following steps:
  • first information wherein the first information is used to indicate that the first type of key agent module performs an execution result of the ciphertext processing request; and detecting whether the first information meets a predetermined type switching condition, wherein the predetermined type switching condition is determined to be determined
  • a vulnerability occurs in the first type of key agent module; in the case where it is detected that the first information conforms to the predetermined type of switching condition, the ciphertext processing request of the service module is executed by the second type of key agent module.
  • the storage medium is arranged to store program code for performing the following steps:
  • the key agent module receives an encryption request sent by the service module, where the encryption request carries data to be encrypted.
  • the key agent module obtains a target key from a key list, where the key list is previously extracted from the key server;
  • the key agent module encrypts the data to be encrypted by using the target key, and obtains the encrypted data.
  • the key agent module sends the encrypted data to the service module.
  • the storage medium is arranged to store program code for performing the following steps:
  • the key agent module receives a decryption request sent by the service module, where the decryption request Carrying data to be decrypted;
  • the key agent module obtains a target key from a key list, where the key list is previously extracted from the key server.
  • the key agent module decrypts the data to be decrypted by using the target key to obtain the decrypted data.
  • the key agent module sends the decrypted data to the service module.
  • the foregoing storage medium may include, but not limited to, a USB flash drive, a Read-Only Memory (ROM), a Random Access Memory (RAM), a mobile hard disk, and a magnetic memory.
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • a mobile hard disk e.g., a hard disk
  • magnetic memory e.g., a hard disk
  • the integrated unit in the above embodiment if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in the above-described computer readable storage medium.
  • the technical solution of the present application in essence or the contribution to the prior art, or all or part of the technical solution may be embodied in the form of a software product, which is stored in a storage medium.
  • a number of instructions are included to cause one or more computer devices (which may be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application.
  • the disclosed client may be implemented in other manners.
  • the device embodiments described above are only schematic, for example, the division of the unit is only a logical function division, and the actual implementation may have another The manner of division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, unit or module, and may be electrical or otherwise.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the first information is obtained, where the first information is used to indicate that the first type of the key agent module performs the execution result of the ciphertext processing request; whether the first information meets the predetermined type switching condition; If the first information meets the predetermined type switching condition, the ciphertext processing request of the service module is executed by the second type of key proxy module.
  • the secret may be executed according to the first type of key proxy processing module.
  • the result of the file processing request determines whether the predetermined type switching condition is met, and if the switching condition is met, the ciphertext processing request is no longer performed by the first type of key agent processing module, but the second type of key agent is used.
  • the processing module executes the ciphertext processing request.
  • the first type of the key proxy processing module cannot continue to perform the ciphertext processing request stably, and the second type of the key proxy module is switched to stabilize the processing.
  • the text processing request solves the prior art and is in the business The problem of low key stability during encryption and decryption.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Storage Device Security (AREA)

Abstract

Disclosed are a service processing method and device, and a storage medium and an electronic device. The method comprises: acquiring first information, wherein the first information is used for representing an execution result obtained by a first-type key proxy module executing a ciphertext processing request; detecting whether the first information meets a pre-determined-type switching condition, wherein meeting the pre-determined-type switching condition represents detecting that the first-type key proxy module has a bug; and where it is detected that the first information meets the pre-determined-type switching condition, executing the ciphertext processing request of the service module by means of a second-type key proxy module. The present application solves the technical problem of the relatively low stability of a key when encryption and decryption are performed on a service in the prior art.

Description

业务处理方法、装置、存储介质及电子装置Business processing method, device, storage medium and electronic device
本申请要求于2016年08月08日提交中国专利局、优先权号为201610643327X、申请名称为“业务加密、解密方法和装置”和2016年11月18日提交中国专利局、优先权号为201611018871.1、申请名称为“业务处理方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application is required to be submitted to the China Patent Office on August 8, 2016, with the priority number 201610643327X, the application name is “Business Encryption, Decryption Method and Device” and submitted to the Chinese Patent Office on November 18, 2016, the priority number is 201611018871.1 The priority of the Chinese Patent Application entitled "Service Processing Method and Apparatus" is hereby incorporated by reference.
技术领域Technical field
本申请涉及计算机领域,具体而言,涉及一种业务处理方法、装置、存储介质及电子装置。The present application relates to the field of computers, and in particular to a service processing method, apparatus, storage medium, and electronic device.
背景技术Background technique
相关技术中,在对业务进行加密时,所使用的加密方式主要包括三种:方式一、直接在代码或者配置文件里面编写固定的密钥;方式二、在共享内存中直接以明文保存或加密保存的方式保存密钥;方式三、密钥保存在特殊管理人员所管理的服务器上,业务可以定期地通过网络在该服务器中调用并获取密钥。In the related art, when encrypting a service, the encryption method used mainly includes three types: mode one, directly writing a fixed key in the code or configuration file; and second, directly saving or encrypting in plain text in the shared memory. The save mode saves the key; mode 3: The key is saved on the server managed by the special manager, and the service can periodically call and obtain the key in the server through the network.
相关技术中提供了一种通过代理模块进行加解密的方式,当有业务需要进行加密时,可以通过业务模块向密钥代理模块发送携带有待加密数据的密文处理请求。密钥代理模块在获取到密文处理请求之后,将从拉取到的密钥列表中获取目标密钥,然后,使用目标密钥对待加密的数据进行加密,得到加密后的数据,最后,密钥代理模块将加密后的数据发送给业务模块。The related art provides a method for encrypting and decrypting by using a proxy module. When a service needs to be encrypted, the service module may send a ciphertext processing request carrying the data to be encrypted to the key proxy module. After obtaining the ciphertext processing request, the key proxy module obtains the target key from the extracted key list, and then encrypts the data to be encrypted using the target key to obtain the encrypted data, and finally, the secret. The key broker module sends the encrypted data to the business module.
在上述方案中,使用Agent加解密代替业务进程直接加解密,一旦Agent出BUG就可能导致所有加解密操作全部失败,给业务造成重大损失。 In the above solution, the agent encryption and decryption is used instead of the business process to directly encrypt and decrypt. Once the agent issues a BUG, all the encryption and decryption operations may fail, causing a great loss to the business.
其中,BUG可能给是Agent在实践中不断支持新需求而产生的变更而引入的,也可能是一个相当隐晦,极难被触发的BUG(甚至可能是操作系统内核BUG)最终被触发导致的,或者由于本硬件服务器上的其它业务大量占用CPU导致本业务Agent加解密请求大量超时。一旦出现上述问题会导致加解密操作失败。Among them, the BUG may be introduced by the change that the Agent continuously supports the new requirements in practice, or it may be a rather concealed, extremely difficult to be triggered BUG (or even the operating system kernel BUG) is finally triggered. Or because the other services on the hardware server occupy a large amount of CPU, the service agent encryption and decryption request times out. Once the above problem occurs, the encryption and decryption operation will fail.
针对上述的在对业务进行加解密时密钥的稳定性较低的问题,目前尚未提出有效的解决方案。In view of the above problem of low stability of the key when encrypting and decrypting the service, an effective solution has not been proposed yet.
发明内容Summary of the invention
本申请实施例提供了一种业务处理方法、装置、存储介质及电子装置,以至少解决相关技术中在对业务进行加解密时密钥的稳定性较低的技术问题。The embodiment of the present application provides a service processing method, device, storage medium, and electronic device, so as to at least solve the technical problem that the stability of the key is low when the service is encrypted and decrypted in the related art.
根据本申请实施例的一个方面,提供了一种业务处理方法,包括:获取第一信息,其中,所述第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;检测所述第一信息是否符合预定类型切换条件,其中,符合所述预定类型切换条件表示确定所述第一类型的密钥代理模块出现漏洞;在检测出所述第一信息符合所述预定类型切换条件的情况下,通过第二类型的密钥代理模块执行所述业务模块的密文处理请求。According to an aspect of the embodiments of the present application, a service processing method is provided, including: acquiring first information, where the first information is used to indicate an execution result of a first type of key agent module to perform a ciphertext processing request Detecting whether the first information meets a predetermined type switching condition, wherein the matching the predetermined type switching condition indicates that a vulnerability occurs in the first type of key agent module; and detecting that the first information meets the predetermined In the case of a type switching condition, the ciphertext processing request of the service module is executed by the second type of key broker module.
根据本申请实施例的一个方面,还提供了一种业务处理方法,包括:第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果;第二类型的密钥代理模块接收并执行所述业务模块的密文处理请求,其中,所述业务模块设置为在基于所述执行结果生成的第一信息符合所述预定类型切换条件的情况下,向所述第二类型的密钥代理模块发送密文处理请求,其中,符合所述预定类型切换条件表示确定所述第一类型的密钥代理模块出现漏洞。According to an aspect of the embodiments of the present application, a service processing method is further provided, including: a first type of key agent module receives and executes a ciphertext processing request of a service module, and obtains an execution result; and a second type of key agent The module receives and executes a ciphertext processing request of the service module, where the service module is configured to: when the first information generated based on the execution result meets the predetermined type switching condition, to the second type The key broker module sends a ciphertext processing request, wherein the predetermined type of switching condition is met to indicate that the first type of key broker module is vulnerable.
根据本申请实施例的另一方面,还提供了一种业务处理方法,包括: 密钥代理模块获取执行密文处理请求的执行结果;所述密钥代理模块检测所述执行结果是否符合预定模式切换条件,其中,符合所述预定模式切换条件表示确定所述密钥代理模块中出现了漏洞;若检测出所述执行结果符合预定模式切换条件,则所述密钥代理模块向业务模块发送指示信息,其中,所述指示信息用于指示所述业务模块切换到通过所述业务模块执行所述密文处理请求的模式。According to another aspect of the embodiments of the present application, a service processing method is further provided, including: The key agent module acquires an execution result of the execution of the ciphertext processing request; the key agent module detects whether the execution result meets a predetermined mode switching condition, wherein the matching the predetermined mode switching condition indicates that the key agent module is determined A vulnerability is generated; if it is detected that the execution result meets a predetermined mode switching condition, the key agent module sends the indication information to the service module, where the indication information is used to indicate that the service module switches to the service The module executes the mode of the ciphertext processing request.
根据本申请实施例的另一方面,还提供了一种业务处理装置,包括:第一获取单元,设置为获取第一信息,其中,所述第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;第一检测单元,设置为检测所述第一信息是否符合预定类型切换条件,其中,符合所述预定类型切换条件表示确定所述第一类型的密钥代理模块出现漏洞,也即,符合所述预定类型切换条件表示所述第一类型的密钥代理模块无法稳定执行所述密文处理请求;第一执行单元,设置为在检测出所述第一信息符合所述预定类型切换条件的情况下,通过第二类型的密钥代理模块执行所述业务模块的密文处理请求。According to another aspect of the embodiments of the present application, a service processing apparatus is further provided, including: a first acquiring unit, configured to acquire first information, wherein the first information is used to represent a first type of key agent The module performs an execution result of the ciphertext processing request; the first detecting unit is configured to detect whether the first information meets a predetermined type switching condition, wherein the matching the predetermined type switching condition indicates that the first type of key agent is determined The module has a vulnerability, that is, the predetermined type of switching condition is met, indicating that the first type of key agent module cannot stably perform the ciphertext processing request; the first executing unit is configured to detect the first information In the case that the predetermined type of switching condition is met, the ciphertext processing request of the service module is executed by the second type of key agent module.
根据本申请实施例的另一方面,还提供了一种业务处理装置,包括:第一处理单元,设置在第一类型的密钥代理模块中,设置为接收并执行业务模块的密文处理请求,得到执行结果;第一处理单元,设置在第二类型的密钥代理模块中,设置为接收并执行所述业务模块的密文处理请求,其中,所述业务模块设置为在基于所述执行结果生成的第一信息符合所述预定类型切换条件的情况下,向所述第二类型的密钥代理模块发送密文处理请求,其中,符合所述预定类型切换条件表示确定所述第一类型的密钥代理模块出现漏洞。According to another aspect of the embodiments of the present application, there is also provided a service processing apparatus, including: a first processing unit, configured in a first type of key agent module, configured to receive and execute a ciphertext processing request of a service module Obtaining an execution result; a first processing unit, disposed in the second type of key broker module, configured to receive and execute a ciphertext processing request of the service module, wherein the service module is set to perform based on the execution And if the first information generated by the result meets the predetermined type switching condition, sending a ciphertext processing request to the second type of key proxy module, wherein the predetermined type switching condition is met to determine the first type A vulnerability has occurred in the key broker module.
根据本申请实施例的另一方面,还提供了一种业务处理装置,包括:第一获取单元,设置为获取执行密文处理请求的执行结果;第一检测单元,设置为检测所述执行结果是否符合预定模式切换条件,其中,符合所述预 定模式切换条件表示确定所述密钥代理模块中出现了漏洞;第一发送单元,设置为若检测出所述执行结果符合预定模式切换条件,则向业务模块发送指示信息,其中,所述指示信息用于指示所述业务模块切换到通过所述业务模块执行所述密文处理请求的模式。According to another aspect of the embodiments of the present application, a service processing apparatus is further provided, including: a first acquiring unit, configured to acquire an execution result of performing a ciphertext processing request; and a first detecting unit configured to detect the execution result Whether the predetermined mode switching condition is met, wherein the pre-compliance is met The mode switching condition indicates that a vulnerability exists in the key agent module, and the first sending unit is configured to: send the indication information to the service module if the execution result is consistent with the predetermined mode switching condition, where the indication is sent The information is used to indicate that the service module switches to a mode in which the ciphertext processing request is performed by the service module.
根据本申请实施例的又一方面,还提供了一种存储介质,该存储介质可以存储有执行指令,该执行指令用于执行上述实施例中的业务处理方法。According to still another aspect of the embodiments of the present application, a storage medium is further provided, where the storage medium may store an execution instruction for executing the service processing method in the foregoing embodiment.
根据本申请实施例的又一方面,还提供了一种电子装置,包括存储器、处理器及存储在上述存储器上并可在上述处理器上运行的计算机程序,其特征在于,上述处理器通过上述计算机程序执行上述的方法。According to still another aspect of the embodiments of the present application, an electronic device includes a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein the processor passes the foregoing The computer program performs the above method.
在本申请实施例中,获取第一信息,其中,第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;检测第一信息是否符合预定类型切换条件;在检测出第一信息符合预定类型切换条件的情况下,通过第二类型的密钥代理模块执行业务模块的密文处理请求,在上述实施例中,可以根据第一类型的密钥代理处理模块执行密文处理请求的结果来确定是否符合预定类型切换条件,在符合切换条件的情况下,不再通过第一类型的密钥代理处理模块执行密文处理请求,而是通过第二类型的密钥代理处理模块执行密文处理请求,在该方案中,可以在第一类型的密钥代理处理模块无法继续稳定的执行密文处理请求,则将切换第二类型的密钥代理模块,以稳定处理密文处理请求,解决了相关技术中,在对业务进行加解密时密钥的稳定性较低的问题。In the embodiment of the present application, the first information is obtained, where the first information is used to indicate that the first type of the key agent module performs the execution result of the ciphertext processing request; whether the first information meets the predetermined type switching condition; If the first information meets the predetermined type switching condition, the ciphertext processing request of the service module is executed by the second type of key proxy module. In the above embodiment, the secret may be executed according to the first type of key proxy processing module. The result of the file processing request determines whether the predetermined type switching condition is met, and if the switching condition is met, the ciphertext processing request is no longer performed by the first type of key agent processing module, but the second type of key agent is used. The processing module executes the ciphertext processing request. In the solution, the first type of the key proxy processing module cannot continue to perform the ciphertext processing request stably, and the second type of the key proxy module is switched to stabilize the processing. The text processing request solves the problem that the stability of the key is low when the service is encrypted and decrypted in the related art.
附图说明DRAWINGS
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described herein are intended to provide a further understanding of the present application, and are intended to be a part of this application. In the drawing:
图1是根据本申请实施例的业务处理方法的硬件环境的示意图; 1 is a schematic diagram of a hardware environment of a service processing method according to an embodiment of the present application;
图2是根据本申请实施例的一种可选的业务处理方法的流程图;2 is a flowchart of an optional service processing method according to an embodiment of the present application;
图3是根据本申请实施例的一种可选的业务处理方法的原理图;3 is a schematic diagram of an optional service processing method according to an embodiment of the present application;
图4是根据本申请实施例的另一种可选的业务处理方法的流程图;4 is a flowchart of another optional service processing method according to an embodiment of the present application;
图5是根据本申请实施例的另一种可选的业务处理方法的流程图;FIG. 5 is a flowchart of another optional service processing method according to an embodiment of the present application; FIG.
图6是根据本申请实施例的业务加密方法的硬件环境的示意图;6 is a schematic diagram of a hardware environment of a service encryption method according to an embodiment of the present application;
图7是根据本申请实施例的一种可选的业务加密方法的流程图;7 is a flowchart of an optional service encryption method according to an embodiment of the present application;
图8是根据本申请实施例的一种可选的业务解密方法的流程图;FIG. 8 is a flowchart of an optional service decryption method according to an embodiment of the present application; FIG.
图9是根据本申请实施例的另一种可选的业务加密方法的流程图;9 is a flowchart of another optional service encryption method according to an embodiment of the present application;
图10是根据本申请实施例的另一种可选的业务加密方法的流程图;FIG. 10 is a flowchart of another optional service encryption method according to an embodiment of the present application; FIG.
图11是根据本申请实施例的一种可选的业务处理装置的示意图;以及11 is a schematic diagram of an optional service processing apparatus according to an embodiment of the present application;
图12是根据本申请实施例的一种可选的业务加密装置的示意图;FIG. 12 is a schematic diagram of an optional service encryption apparatus according to an embodiment of the present application; FIG.
图13是根据本申请实施例的一种可选的业务解密装置的示意图;FIG. 13 is a schematic diagram of an optional service decryption apparatus according to an embodiment of the present application; FIG.
图14是根据本申请实施例的一种电子装置的结构框图;以及FIG. 14 is a structural block diagram of an electronic device according to an embodiment of the present application;
图15是根据本申请实施例的另一种电子装置的结构框图。FIG. 15 is a structural block diagram of another electronic device according to an embodiment of the present application.
具体实施方式detailed description
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present application. It is an embodiment of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without departing from the inventive scope shall fall within the scope of the application.
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或 先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms “first”, “second” and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or Prioritization. It is to be understood that the data so used may be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "comprises" and "comprises" and "the" and "the" are intended to cover a non-exclusive inclusion, for example, a process, method, system, product, or device that comprises a series of steps or units is not necessarily limited to Those steps or units may include other steps or units not explicitly listed or inherent to such processes, methods, products or devices.
实施例1Example 1
根据本申请实施例,提供了一种业务处理的方法实施例。可选地,在本实施例中,上述业务处理方法可以应用于如图1所示的由服务器102和终端104所构成的硬件环境中。如图1所示,服务器102通过网络与终端104进行连接,上述网络包括但不限于:广域网、城域网或局域网,终端104并不限定于PC、手机、平板电脑等。本申请实施例的业务处理方法可以由服务器102来执行,也可以由终端104来执行,还可以是由服务器102和终端104共同执行。其中,终端104执行本申请实施例的业务处理方法也可以是由安装在其上的客户端来执行。According to an embodiment of the present application, an embodiment of a method for service processing is provided. Optionally, in this embodiment, the foregoing service processing method may be applied to a hardware environment formed by the server 102 and the terminal 104 as shown in FIG. 1. As shown in FIG. 1, the server 102 is connected to the terminal 104 through a network. The network includes but is not limited to a wide area network, a metropolitan area network, or a local area network. The terminal 104 is not limited to a PC, a mobile phone, a tablet, or the like. The service processing method of the embodiment of the present application may be executed by the server 102, may be executed by the terminal 104, or may be jointly performed by the server 102 and the terminal 104. The service processing method performed by the terminal 104 in the embodiment of the present application may also be performed by a client installed thereon.
图1中示出的硬件环境系统的主要工作原理是:在本申请实施例中,密钥代理模块安装在终端104中。当有业务需要进行加密时,可以通过业务模块向密钥代理模块发送携带有待加密数据的密文处理请求。密钥代理模块在获取到密文处理请求之后,将从拉取到的密钥列表中获取目标密钥,然后,使用目标密钥对待加密的数据进行加密,得到加密后的数据,最后,密钥代理模块将加密后的数据发送给业务模块。在该示例中,密文处理请求为将待加密数据加密为密文数据的请求。解密数据与上述实施例中的加密方式相似,在此不再赘述。The main working principle of the hardware environment system shown in FIG. 1 is that in the embodiment of the present application, the key agent module is installed in the terminal 104. When there is a service that needs to be encrypted, the ciphertext processing request carrying the data to be encrypted may be sent to the key agent module through the service module. After obtaining the ciphertext processing request, the key proxy module obtains the target key from the extracted key list, and then encrypts the data to be encrypted using the target key to obtain the encrypted data, and finally, the secret. The key broker module sends the encrypted data to the business module. In this example, the ciphertext processing request is a request to encrypt the data to be encrypted into ciphertext data. The decryption data is similar to the encryption method in the above embodiment, and details are not described herein again.
需要说明的是,在本申请实施例中,密钥列表为密钥代理模块在首次开启时,从服务器104(例如,密钥服务器)中所拉取得到的密钥列表。It should be noted that, in the embodiment of the present application, the key list is a key list obtained by the key agent module from the server 104 (for example, a key server) when it is first turned on.
图2是根据本申请实施例的一种可选的业务处理方法的流程图,如图 2所示,应用于业务模块,该方法可以包括以下步骤:FIG. 2 is a flowchart of an optional service processing method according to an embodiment of the present application, as shown in FIG. As shown in 2, applied to the business module, the method may include the following steps:
步骤S202:获取第一信息,其中,第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;Step S202: Acquire first information, where the first information is used to indicate that the key proxy module of the first type performs an execution result of the ciphertext processing request;
步骤S204:检测第一信息是否符合预定类型切换条件;Step S204: detecting whether the first information meets a predetermined type switching condition;
步骤S206:在检测出第一信息符合预定类型切换条件的情况下,通过第二类型的密钥代理模块执行业务模块的密文处理请求。Step S206: The ciphertext processing request of the service module is executed by the second type of key proxy module in the case that the first information is detected to meet the predetermined type switching condition.
通过上述实施例,获取第一信息,其中,第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;检测第一信息是否符合预定类型切换条件;在检测出第一信息符合预定类型切换条件的情况下,通过第二类型的密钥代理模块执行业务模块的密文处理请求,在上述实施例中,可以根据第一类型的密钥代理处理模块执行密文处理请求的结果来确定是否符合预定类型切换条件,在符合切换条件的情况下,不再通过第一类型的密钥代理处理模块执行密文处理请求,而是通过第二类型的密钥代理处理模块执行密文处理请求,在该方案中,可以在第一类型的密钥代理处理模块无法继续稳定的执行密文处理请求,则将切换第二类型的密钥代理模块,以稳定处理密文处理请求,解决了相关技术中,在对业务进行加解密时密钥的稳定性较低的问题。The first information is obtained by using the foregoing embodiment, where the first information is used to indicate that the first type of the key agent module performs the execution result of the ciphertext processing request; whether the first information meets the predetermined type switching condition; If the information meets the predetermined type switching condition, the ciphertext processing request of the service module is executed by the second type of key proxy module. In the above embodiment, the ciphertext processing may be performed according to the first type of key proxy processing module. The result of the request is used to determine whether the predetermined type of switching condition is met. If the switching condition is met, the ciphertext processing request is no longer performed by the first type of key agent processing module, but by the second type of key agent processing module. Executing a ciphertext processing request. In this scheme, if the first type of key proxy processing module cannot continue to perform the ciphertext processing request stably, the second type of key proxy module is switched to stably process the ciphertext processing. The request solves the problem that the stability of the key is low when the service is encrypted and decrypted in the related art.
在步骤S202的技术方案中,密文处理请求可以为加密请求或解密请求,该第一类型的密钥代理模块执行密文处理请求的执行结果,可以存储在共享内存中,业务模块可以从共享内存中读取该执行结果,并统计该执行结果得到第一信息。In the technical solution of step S202, the ciphertext processing request may be an encryption request or a decryption request, and the execution result of the ciphertext processing request of the first type of key proxy module may be stored in the shared memory, and the service module may be shared from The execution result is read in the memory, and the execution result is counted to obtain the first information.
密钥代理模块执行密文处理请求可以通过如下方式实现(以加密过程为例):The key broker module can perform ciphertext processing requests as follows (take the encryption process as an example):
密钥代理模块接收业务模块发送的密文处理请求,其中,所述密文处理请求中携带有待加密的数据。 The key agent module receives the ciphertext processing request sent by the service module, where the ciphertext processing request carries data to be encrypted.
在本申请实施例中,密钥代理模块(以下均称为密钥Agent)可以采用单进程多线程的方式实现;业务模块设置为向密钥Agent发送密文处理请求,其中,密钥Agent行业业务模块处于同一个物理单机中。In the embodiment of the present application, the key agent module (hereinafter referred to as the key agent) may be implemented in a single-process multi-thread manner; the service module is configured to send a ciphertext processing request to the key agent, wherein the key agent industry The business modules are in the same physical single machine.
具体地,当有业务需要进行加密时,业务模块可以向密钥Agent发送携带待加密的数据的密文处理请求;密钥Agent在获取到密文处理请求之后,根据密文处理请求在密钥列表中获取目标密钥。Specifically, when there is a service that needs to be encrypted, the service module may send a ciphertext processing request carrying the data to be encrypted to the key agent; after obtaining the ciphertext processing request, the key agent processes the request key according to the ciphertext processing. Get the target key in the list.
在本申请实施例中,当密钥代理模块Agent重启时,密钥Agent会向密钥服务器拉取密钥列表。需要说明的是,密钥Agent仅在重新启动时,向密钥服务器拉取密钥列表,在启动后的其他时间内不再拉取密钥列表。In the embodiment of the present application, when the key agent module Agent is restarted, the key agent pulls the key list to the key server. It should be noted that the key agent only pulls the key list to the key server when restarting, and does not pull the key list at other times after startup.
密钥Agent在获取到业务模块发送的密文处理请求之后,就可以在预先拉取的密钥列表中获取目标密钥,其中,该目标密钥用于对待加密的数据进行加密。After obtaining the ciphertext processing request sent by the service module, the key agent may obtain the target key in the pre-pushed key list, where the target key is used to encrypt the data to be encrypted.
在本申请实施例中,密钥Agent在从密钥列表中获取到目标密钥之后,就可以对使用目标密钥对待加密的数据进行加密。In the embodiment of the present application, after the key Agent obtains the target key from the key list, the data to be encrypted using the target key may be encrypted.
在本申请实施例中,密钥代理模块在使用目标密钥对待加密的数据进行加密,得到加密之后的数据之后,就可以将加密后的数据发送给业务模块。In the embodiment of the present application, the key agent module encrypts the data to be encrypted using the target key, and after obtaining the encrypted data, the encrypted data can be sent to the service module.
可选地,在密钥代理模块接收业务模块发送的密文处理请求之前,还可以通过密钥代理模块将第一公钥发送给密钥服务器,并从密钥服务器接收第二公钥,其中,密钥代理模块上具有一对第一公钥和第一私钥,密钥服务器上具有一对第二公钥和第二私钥;密钥代理模块向密钥服务器发送密钥列表拉取请求;密钥代理模块接收密钥服务器发送的加密后的密钥列表,其中,加密后的密钥列表是使用密钥服务器侧的第一通讯密钥对密钥列表进行加密得到的,第一通讯密钥是密钥服务器根据第一公钥和第二私钥生成得到的;密钥代理模块使用密钥代理模块侧的第二通讯密钥对加密 后的密钥列表进行解密,得到密钥列表,其中,第二通讯密钥是密钥代理模块根据第一私钥和第二公钥生成得到的,第一通讯密钥与第二通讯密钥相同。Optionally, before the key proxy module receives the ciphertext processing request sent by the service module, the first public key may be sent to the key server by using the key proxy module, and the second public key is received from the key server, where The key agent module has a pair of first public key and a first private key, and the key server has a pair of second public key and a second private key; the key agent module sends a key list pull to the key server The key agent module receives the encrypted key list sent by the key server, wherein the encrypted key list is obtained by encrypting the key list by using the first communication key on the key server side, first The communication key is generated by the key server according to the first public key and the second private key; the key agent module encrypts using the second communication key pair on the key agent module side The subsequent key list is decrypted to obtain a key list, wherein the second communication key is generated by the key agent module according to the first private key and the second public key, and the first communication key and the second communication key are generated. the same.
在本申请实施例中,在密钥Agent接收密文处理请求之前,需要从密钥服务器拉取密钥列表,其中,由于从密钥服务器拉取到的密钥列表为加密之后的密钥列表。因此,密钥Agent需要对拉取到的密钥列表进行解密。In the embodiment of the present application, before the key agent receives the ciphertext processing request, the key list needs to be pulled from the key server, wherein the key list extracted from the key server is the encrypted key list. . Therefore, the key agent needs to decrypt the extracted key list.
在本申请实施例中,密钥Agent拉取到的密钥列表是使用密钥服务器侧的第一通讯密钥对密钥列表进行加密得到的,那么密钥代理模块在对密钥列表进行解密时,需使用与第一通讯密钥相同的第二通讯密钥对密钥列表进行解密。其中,第一通讯密钥是密钥服务器根据第一公钥和第二私钥生成得到的,第二通讯密钥是密钥代理模块根据第一私钥和第二公钥生成得到的。第一公钥和第二公钥是密钥Agent在向密钥服务器发送密钥列表的拉取请求之前,生成的一对公钥pubkey和密钥prikey;第一私钥和第二私是密钥服务器生成的一对公钥pubkey和密钥prikey。In the embodiment of the present application, the key list extracted by the key agent is obtained by encrypting the key list by using the first communication key on the key server side, and then the key agent module decrypts the key list. The key list is decrypted using the same second communication key as the first communication key. The first communication key is generated by the key server according to the first public key and the second private key, and the second communication key is generated by the key agent module according to the first private key and the second public key. The first public key and the second public key are a pair of public keys pubkey and key prikey generated by the key agent before sending the key list to the key server; the first private key and the second private key are secret A pair of public keys pubkey and key prikey generated by the key server.
需要说明的是,由于第一通讯密钥根据第一公钥和第二私钥生成得到的,第二通讯密钥是根据第一私钥和第二公钥生成得到的。因此,在密钥代理模块向密钥服务器发送密钥列表拉取请求之前,密钥Agent和密钥服务器之间需要交换双方的公钥和密钥。在交换之后,密钥代理模块就可以在向密钥服务器发送密钥列表拉取请求之后,生成用于对密钥列表进行解密的第二通讯密钥,密钥服务器也可以生成用于对密钥列表进行加密的第一通讯密钥。It should be noted that, since the first communication key is generated according to the first public key and the second private key, the second communication key is generated according to the first private key and the second public key. Therefore, before the key agent module sends the key list pull request to the key server, the key agent and the key server need to exchange the public key and the key of both parties. After the exchange, the key agent module may generate a second communication key for decrypting the key list after transmitting the key list pull request to the key server, and the key server may also generate the secret key. The key list is encrypted with the first communication key.
其中,交换双方的公钥和密钥具体为:Agent将第一公钥发送给密钥服务器SVR,然后,Agent从密钥服务器SVR中接收第二公钥,交换之后,Agent就可以使用第一私钥和第二公钥加密后的密钥列表进行解密。The public key and the key of the exchanged parties are specifically: the agent sends the first public key to the key server SVR, and then the agent receives the second public key from the key server SVR. After the exchange, the agent can use the first The private key and the second public key encrypted key list are decrypted.
需要说明的是,在本申请实施例中,Agent和密钥服务器在进行密钥交换时,可以采用密钥交换协议(即,ECDH协议)交换双方的pubkey 和各自的prikey。It should be noted that, in the embodiment of the present application, when the key exchange is performed by the agent and the key server, the key exchange protocol (ie, the ECDH protocol) may be used to exchange the pubkeys of both parties. And the respective prikey.
通过上述描述可知,本申请中的密钥列表使用第一公钥和第二私钥进行加密,并使用第一私钥和第二公钥进行解密。然而,在相关技术中,网络上传递的只有Agent和密钥服务器的公钥pubkey,因此,采用本申请中的加密方式,即使被tcp dump也反推不出密钥,这样就避免了内网抓包导致的密钥泄漏的现象发生。As can be seen from the above description, the key list in the present application is encrypted using the first public key and the second private key, and decrypted using the first private key and the second public key. However, in the related art, only the public key pubkey of the Agent and the key server is transmitted on the network. Therefore, by using the encryption method in the present application, even if the key is reversed by the tcp dump, the intranet is avoided. The phenomenon of key leakage caused by packet capture occurs.
进一步可选地,为了防止密钥SVR/密钥Agent间的中间人攻击,SVR应该用私钥将ECDH公钥签名,并在Agent部署公钥验证此签名,因为SVR是专人管理的高密级服务器,很难从那里窃取私钥,也就有效的在Agent防止了他人伪造SVR回包。Further, in order to prevent a man-in-the-middle attack between the key SVR/key agent, the SVR should sign the ECDH public key with the private key, and verify the signature by deploying the public key in the agent, because the SVR is a high-density server managed by a dedicated person. It is difficult to steal the private key from there, and it effectively prevents others from forging SVR back packets.
密钥Agent在从密钥服务器中拉取到密钥列表,并对密钥列表进行解密之后,密钥Agent需要验证业务进程的合法性,其中,业务进程为待加密的数据所表示的进程。After the key agent pulls the key list from the key server and decrypts the key list, the key agent needs to verify the legality of the business process, wherein the business process is a process represented by the data to be encrypted.
在本申请的另一个可选的实施方式中,密钥代理模块将第一公钥发送给密钥服务器,并从密钥服务器接收第二公钥包括:在密钥代理模块重启时,密钥代理模块将加密后的第一公钥发送给密钥服务器,其中,加密后的第一公钥是使用约定密钥对第一公钥进行加密得到的;密钥代理模块从密钥服务器接收加密后的第二公钥,其中,加密后的第二公钥是使用约定密钥对第二公钥进行加密得到的;密钥代理模块使用约定密钥对加密后的第二公钥进行解密,得到第二公钥;其中,约定密钥被设置为仅在密钥代理模块重启时使用。In another optional implementation manner of the present application, the key agent module sends the first public key to the key server, and receiving the second public key from the key server includes: when the key agent module is restarted, the key The proxy module sends the encrypted first public key to the key server, wherein the encrypted first public key is obtained by encrypting the first public key using the agreed key; the key proxy module receives the encryption from the key server a second public key, wherein the encrypted second public key is obtained by encrypting the second public key using the agreed key; the key proxy module decrypts the encrypted second public key by using the agreed key, A second public key is obtained; wherein the appointment key is set to be used only when the key broker module is restarted.
需要说明的是,当密钥Agent重启时,在密钥Agent向密钥服务器发送第一公钥时,需使用约定密钥对第一公钥进行加密,并将使用约定密钥加密之后的第一公钥发送给密钥服务器,其中,密钥服务器在获取到第一公钥之后,就可以使用约定密钥进行解密。相同地,密钥服务器在向密钥Agent发送第二公钥时,也使用约定密钥对第二公钥进行加密,并将加密 之后的第二公钥发送至密钥Agent,其中,密钥Agent在接收到加密之后的第二公钥之后,就可以使用约定密钥对第二公钥进行解密。It should be noted that when the key agent is restarted, when the key agent sends the first public key to the key server, the first public key is encrypted by using the agreed key, and the first key is encrypted after using the agreed key. A public key is sent to the key server, and after the key server obtains the first public key, it can decrypt using the agreed key. Similarly, when the key server sends the second public key to the key agent, the second public key is also encrypted using the contract key and will be encrypted. The subsequent second public key is sent to the key agent, wherein after receiving the encrypted second public key, the key agent can decrypt the second public key using the agreed key.
需要说明的是,在本申请实施例中,只有在密钥Agent重启时才会使用“约定密钥”对第一公钥和第二公钥进行加密,并互相传输。也就是说,只有密钥Agent的维护者在变更密钥Agent时重启进程才是唯一合法使用约定密钥的时机,其它任何情形都是非法使用。例如,密钥Agent的维护者在密钥Agent重启时,使用了约定密钥获取密钥列表,在此之后,如果其他使用者再次使用约定密钥获取密钥列表时,表明该使用者为滥用者。因此,在本申请实施例中,仅在密钥Agent重启时才会使用一次“约定密钥”的设置,能够快速并有效地检测出滥用者。It should be noted that, in the embodiment of the present application, the first public key and the second public key are encrypted and transmitted to each other only when the key agent is restarted, using the “contract key”. That is to say, only the maintainer of the key agent restarts the process when changing the key agent is the only time to legally use the agreed key, and any other situation is illegal. For example, the maintainer of the key agent uses the contract key to obtain the key list when the key agent is restarted. After that, if other users use the agreed key again to obtain the key list, the user is abused. By. Therefore, in the embodiment of the present application, the setting of the "contract key" is used only when the key agent is restarted, and the abuser can be detected quickly and effectively.
由于从密钥服务器中获取到的密钥列表为加密的密钥列表,因此密钥Agent在拉取到密钥列表之后,需要对密钥列表进行解密。Since the key list obtained from the key server is an encrypted key list, the key agent needs to decrypt the key list after pulling the key list.
可选地,在密钥代理模块接收业务模块发送的密文处理请求之前,还可以通过密钥代理模块获取业务进程的进程PID,其中,业务进程为业务模块发送待加密的数据的进程,然后,密钥代理模块对业务进程和进程PID进行合法性校验;以及在合法性校验通过的情况下,密钥代理模块从密钥列表中获取目标密钥。Optionally, before the key agent module receives the ciphertext processing request sent by the service module, the process PID of the service process may be acquired by the key agent module, where the service process sends the process of the data to be encrypted to the service module, and then The key agent module performs legality verification on the business process and the process PID; and in the case that the legality verification passes, the key agent module obtains the target key from the key list.
在本申请实施例中,在对业务模块中待加密的数据所表示的业务进程进行加密之前,首先需要确定该业务进程的合法性。在对业务进程的合法性进行确定时,可以通过密钥Agent获取业务进程的进程PID,然后,通过密钥Agent对进程PID和业务进程的合法性进行校验。如果进程PID和业务进程的校验结果为合法时,即校验通过的情况下,密钥代理模块就可以从密钥列表中获取目标密钥,并通过该目标密钥对待加密的数据进行加密。In the embodiment of the present application, before encrypting the service process indicated by the data to be encrypted in the service module, it is first necessary to determine the legality of the service process. When the legality of the service process is determined, the process PID of the service process can be obtained through the key agent, and then the legality of the process PID and the service process is verified by the key agent. If the verification result of the process PID and the service process is legal, that is, if the verification is passed, the key agent module may obtain the target key from the key list, and encrypt the data to be encrypted by the target key. .
需要说明的是,在本申请实施例中,密钥代理模块可以获取业务模块通过套接字SCM_RIGHTS传输的业务进程被内核所认证的进程PID,其 中,套接字SCM_RIGHTS适用于unix domain socket。It should be noted that, in the embodiment of the present application, the key agent module may obtain a process PID that is authenticated by the kernel by the service process transmitted by the service module through the socket SCM_RIGHTS, and In the socket SCM_RIGHTS applies to the unix domain socket.
进一步地,上述密钥代理模块对业务进程和进程PID进行合法性校验,具体为如下步骤:Further, the key proxy module performs legality verification on the service process and the process PID, which is specifically as follows:
步骤S1,密钥代理模块获取与进程PID对应的进程全路径;Step S1, the key agent module acquires a full path of the process corresponding to the process PID;
步骤S2,密钥代理模块判断进程全路径是否属于预先从密钥服务器获取到的合法路径中的路径;Step S2: The key agent module determines whether the full path of the process belongs to a path in a legal path acquired from the key server in advance;
步骤S3,在判断出进程全路径属于合法路径中的路径的情况下,密钥代理模块对业务进程进行MD5校验操作,得到第一MD5校验结果;在判断出进程全路径不属于合法路径中的路径的情况下,判断出合法性校验不通过;Step S3: In the case that it is determined that the path of the process belongs to the path in the legal path, the key agent module performs an MD5 check operation on the service process to obtain a first MD5 check result; and determines that the process full path does not belong to the legal path. In the case of the path in the middle, it is judged that the validity check is not passed;
步骤S4,密钥代理模块判断第一MD5校验结果是否与预先获取的与业务进程对应的第二MD5校验结果相同;In step S4, the key agent module determines whether the first MD5 check result is the same as the second MD5 check result corresponding to the service process acquired in advance;
步骤S5,若第一MD5校验结果与第二MD5校验结果相同,则判断出合法性校验通过;若第一MD5校验结果与第二MD5校验结果不同,则判断出合法性校验不通过。Step S5, if the first MD5 check result is the same as the second MD5 check result, it is determined that the validity check is passed; if the first MD5 check result is different from the second MD5 check result, the legality is determined. The test will not pass.
可选地,在密钥代理模块对业务进程和进程PID进行合法性校验通过的情况下,密钥代理模块获取业务模块发送的第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据,然后,密钥代理模块生成第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据,最后,密钥代理模块将第二文件描述符传输给业务模块。Optionally, in a case that the key agent module passes the validity check of the service process and the process PID, the key agent module acquires the first file descriptor sent by the service module, where the first file descriptor is used for the secret The key agent module identifies the data sent by the service module as legal data, and then the key agent module generates a second file descriptor, wherein the second file descriptor is used by the service module to identify the data sent by the key agent module as legal data. Finally, the key agent module transmits the second file descriptor to the service module.
在校验业务进程合法性通过的情况下,需要密钥代理模块和业务模块之间交换文件描述符。具体地,密钥代理模块可以首先获取业务模块的第一文件描述符,在获取到第一文件描述符之后,密钥代理模块就可以对业务模块发送的数据进行识别为合法数据。到此为止,业务模块已向密钥代 理模块交换文件描述符,那么就需要密钥代理模块向业务模块交换文件描述符。此时,密钥代理模块可以将生成的第二文件描述符传输给业务模块,业务模块在接收到第二文件描述符之后,就可以对密钥代理模块发送的数据进行识别为合法数据。In the case that the validity of the service process is verified, the file descriptor is exchanged between the key agent module and the service module. Specifically, the key agent module may first obtain the first file descriptor of the service module, and after obtaining the first file descriptor, the key agent module may identify the data sent by the service module as legal data. At this point, the business module has been assigned to the key generation. The module exchanges file descriptors, which then requires the key broker module to exchange file descriptors with the business module. At this time, the key agent module may transmit the generated second file descriptor to the service module, and after receiving the second file descriptor, the service module may identify the data sent by the key agent module as legal data.
在本申请实施例中,第一文件描述符和第二文件描述符对应共享内存中存储数据的数据块,其中,共享内存用于存储密文处理请求的待加密的数据和加密之后的待检加密的数据,将在下述实施例中进行详细描述。例如,当业务模块在共享内存存储待加密的数据时,是在第一文件描述符在共享内存中所对应的区域内存储待加密的数据。存储待加密的数据之后,密钥代理模块就能够获知业务模块在共享内存存储了待加密的数据,然后,密钥代理模块就会去该区域内获取待加密的数据。In the embodiment of the present application, the first file descriptor and the second file descriptor correspond to data blocks of the shared memory, where the shared memory is used to store the data to be encrypted of the ciphertext processing request and the to-be-checked after the encryption. The encrypted data will be described in detail in the following embodiments. For example, when the service module stores the data to be encrypted in the shared memory, the data to be encrypted is stored in the area corresponding to the first file descriptor in the shared memory. After storing the data to be encrypted, the key agent module can learn that the service module stores the data to be encrypted in the shared memory, and then the key agent module goes to the area to obtain the data to be encrypted.
需要说明的是,在本申请实施例中,可以一次性交换多个文件描述符eventfd,不够用时再次通过校验交换更多eventfd,这样就能明显减少校验请求的数目,申请人通过测试发现linux系统下一次性能交换的最大fd数目是255。在密钥代理模块和业务模块完成文件描述符的交换之后,就可以接收业务模块发送的密文处理请求,以对密文处理请求中的待加密的数据进行加密。It should be noted that, in the embodiment of the present application, multiple file descriptors eventfd can be exchanged at one time, and more eventfd is exchanged by verification again when not enough, so that the number of verification requests can be significantly reduced, and the applicant finds through testing. The maximum number of fd for the next performance exchange of the Linux system is 255. After the key agent module and the service module complete the exchange of the file descriptor, the ciphertext processing request sent by the service module may be received to encrypt the data to be encrypted in the ciphertext processing request.
进一步地,在密钥代理模块对业务进程和进程PID进行合法性校验通过的情况下,密钥代理模块还可以为第一文件描述符设置目标权限,其中,目标权限包括以下至少之一:允许密钥代理模块对业务模块请求的待加密的数据进行加密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。Further, in a case where the key agent module passes the validity check of the service process and the process PID, the key agent module may further set a target authority for the first file descriptor, where the target authority includes at least one of the following: The key agent module is allowed to encrypt the data to be encrypted requested by the service module, and the key agent module is allowed to decrypt the data to be decrypted requested by the service module.
具体地,在密钥代理模块对业务进程和进程PID进行合法性校验通过的情况下,密钥代理模块可以在交换文件描述符之后,为第一文件描述符设定目标权限,其中,设定的目标权限包括:允许密钥代理模块对业务模块请求的待加密的数据进行加密,允许密钥代理模块对业务模块请求的待 解密的数据进行解密。Specifically, in the case that the key agent module passes the validity check of the service process and the process PID, the key agent module may set the target authority for the first file descriptor after exchanging the file descriptor, where The specified target rights include: allowing the key agent module to encrypt the data to be encrypted requested by the service module, and allowing the key agent module to request the service module. The decrypted data is decrypted.
在密钥代理模块对第一文件描述符设置完成目标权限之后,密钥代理模块就可以根据接收到的密文处理请求对待加密的数据进行加密,然后,将加密之后的数据发送给业务模块。After the key agent module sets the target permission for the first file descriptor, the key agent module can encrypt the data to be encrypted according to the received ciphertext processing request, and then send the encrypted data to the service module.
其中,密钥代理模块接收业务模块发送的密文处理请求包括:密钥代理模块从共享内存中获取业务模块存入的待加密的数据;以及密钥代理模块将加密后的数据发送给业务模块包括:密钥代理模块将加密后的数据存入到共享内存中,以使得业务模块从共享内存中获取加密后的数据。The key agent module receives the ciphertext processing request sent by the service module, where the key agent module obtains the data to be encrypted stored by the service module from the shared memory, and the key agent module sends the encrypted data to the service module. The method includes: the key agent module stores the encrypted data into the shared memory, so that the service module obtains the encrypted data from the shared memory.
业务模块在向密钥代理模块发送密文处理请求时,会将密文处理请求存入到共享内存中。在此之后,密钥代理模块就可以从共享内存中获取已存储的待加密的数据。相同地,当密钥代理模块使用目标密钥对待加密的数据的进行加密处理之后,还可以将加密处理之后的待加密的数据同样存入共享内存中。使得业务模块可以从共享内存中获取加密后的数据。When the service module sends a ciphertext processing request to the key broker module, the ciphertext processing request is stored in the shared memory. After that, the key broker module can retrieve the stored data to be encrypted from the shared memory. Similarly, after the key agent module encrypts the data to be encrypted using the target key, the data to be encrypted after the encryption process may also be stored in the shared memory. Enables the business module to obtain encrypted data from shared memory.
通过上述描述可知,在本申请实施例中,密钥代理模块已预先为第一文件描述符设置目标权限,在此情况下,如果合法性校验通过,那么密钥代理模块从密钥列表中获取目标密钥,具体为:在目标权限包括允许密钥代理模块对业务模块请求的待加密的数据进行加密时,密钥代理模块从密钥列表中获取目标密钥包。As can be seen from the above description, in the embodiment of the present application, the key agent module has previously set a target authority for the first file descriptor. In this case, if the validity check is passed, the key agent module is from the key list. Obtaining the target key, specifically: when the target authority includes the key agent module to encrypt the data to be encrypted requested by the service module, the key agent module obtains the target key package from the key list.
需要说明的是,由于目标权限可以为仅允许密钥代理模块对业务模块请求的待解密的数据进行解密或者允许密钥代理模块对业务模块请求的待加密的数据进行加密。因此,密钥代理模块只有在确定出目标权限为允许密钥代理模块对业务模块请求的待加密的数据进行加密时,才可以从密钥列表中获取目标密钥,并使用获取到的目标密钥对待加密的数据进行加密。It should be noted that, because the target authority may only allow the key agent module to decrypt the data to be decrypted requested by the service module or allow the key agent module to encrypt the data to be encrypted requested by the service module. Therefore, the key agent module can obtain the target key from the key list only when it is determined that the target authority is to allow the key agent module to encrypt the data to be encrypted requested by the service module, and use the obtained target secret. The key encrypts the encrypted data.
在本申请实施例的一个可选实施方式中,密钥代理模块获取业务进程 的进程PID包括:密钥代理模块在非root运行模式下通过unix域套接字获取业务进程的进程PID;或者密钥代理模块将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的进程PID。In an optional implementation manner of the embodiment of the present application, the key agent module acquires a service process. The process PID includes: the key agent module obtains the process PID of the business process through the unix domain socket in the non-root mode; or the key agent module configures the socket socket option as SO_PEERCRED, and passes the socket socket. Get the process PID of the business process.
在本申请实施例中,进程PID是通过unix域套接字中的套接字SCM_RIGHTS传输。由于unix域套接字传递准确进程PID的前提是非root模式运行的进程,因此,在传递进程PID之前,必须对本机root模式的需求进行审批。也即,需要在非root运行模式下通过unix域套接字获取业务进程的进程PID(进程标识)。进一步地,还可以通过密钥代理模块将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的进程PID。In the embodiment of the present application, the process PID is transmitted through the socket SCM_RIGHTS in the unix domain socket. Because the unix domain sockets pass the exact process PID is based on the non-root mode running process, the local root mode must be approved before the process PID is passed. That is, the process PID (process ID) of the business process needs to be obtained through the unix domain socket in the non-root mode. Further, the option of the socket socket can be configured as SO_PEERCRED through the key proxy module, and the process PID of the business process can be obtained through the socket socket.
综上,在本申请实施例中,通过密钥Agent间接加解密待加密的数据;同时,业务模块和密钥Agent之间的通讯可以是任何标准linux IPC通讯手段,包括但不限于管道,unix socket pair,本地磁盘文件等,本方案采取的linux eventfd是效率最高,最适合于海量加解密请求的选择。本方法通过充分利用现代linux操作系统内核提供的标准机制来实现加解密程序,既提高了密钥的安全性,同时又最大限度的减少了加解密性能损失,确保在实践中的有效性。In summary, in the embodiment of the present application, the data to be encrypted is indirectly encrypted and decrypted by the key agent; at the same time, the communication between the service module and the key agent may be any standard linux IPC communication means, including but not limited to a pipeline, Unix Socket pair, local disk file, etc., the linux eventfd adopted by this scheme is the most efficient, and is most suitable for the selection of massive encryption and decryption requests. The method realizes the encryption and decryption program by fully utilizing the standard mechanism provided by the modern Linux operating system kernel, which not only improves the security of the key, but also minimizes the loss of encryption and decryption performance, and ensures the effectiveness in practice.
下面将结合具体实施例对本申请提供的业务加密的方法进行说明。The method for encrypting the service provided by the present application will be described below in conjunction with specific embodiments.
图3是根据本申请实施例的一种可选的业务处理方法的流程图,如图3所示,密钥Agent(即密钥代理模块)和业务模块处于同一个物理单机中。FIG. 3 is a flowchart of an optional service processing method according to an embodiment of the present application. As shown in FIG. 3, a key agent (ie, a key agent module) and a service module are in the same physical single machine.
在本申请实施例中,在密钥Agent重启时,密钥Agent使用约定密钥对第一公钥进行加密,并将加密之后的第一公钥发送至密钥服务器,密钥代理模块还可以接收密钥服务器发送的已加密的第二公钥,其中,第二公钥也采用约定密钥进行加密。密钥Agent在获取到第二公钥之后,使用约定密钥对第二公钥进行解密,密钥服务器在获取到第一公钥之后,也使用 约定密钥对第一公钥进行解密。In the embodiment of the present application, when the key agent is restarted, the key agent encrypts the first public key by using the contract key, and sends the encrypted first public key to the key server, and the key agent module can also Receiving the encrypted second public key sent by the key server, wherein the second public key is also encrypted by using the agreed key. After obtaining the second public key, the key agent decrypts the second public key by using the agreed key, and the key server also uses the first public key after obtaining the first public key. The appointment key decrypts the first public key.
接下来,密钥Agent就可以向密钥服务器发送密钥列表的拉取请求,密钥服务器在接收到密钥拉取请求之后,将向密钥Agent传输加密后的密钥列表,其中,加密后的密钥列表是使用密钥服务器侧的第一通讯密钥对密钥列表进行加密得到的,第一通讯密钥是密钥服务器根据第一公钥和第二私钥生成得到的。密钥Agent在接收到加密之后的密钥列表之后,就可以使用与第一通讯密钥相同的第二通讯密钥进行解密,其中,第二通讯密钥是密钥代理模块根据第一私钥和第二公钥生成得到的。Next, the key agent may send a pull request of the key list to the key server, and after receiving the key pull request, the key server transmits the encrypted key list to the key agent, where the key is encrypted. The subsequent key list is obtained by encrypting the key list using the first communication key on the key server side, and the first communication key is generated by the key server according to the first public key and the second private key. After receiving the encrypted key list, the key agent may decrypt using the same second communication key as the first communication key, wherein the second communication key is the key agent module according to the first private key. And the second public key is generated.
需要说明的是,在本申请实施例中,只有在密钥Agent重启时才会使用“约定密钥”对第一公钥和第二公钥进行加密,并互相传输。It should be noted that, in the embodiment of the present application, the first public key and the second public key are encrypted and transmitted to each other only when the key agent is restarted, using the “contract key”.
也就是说,只有Agent的维护者在变更Agent时重启进程才是唯一合法使用约定密钥的时机,其它任何情形都是非法使用。例如,Agent的维护者在Agent重启时,使用了约定密钥获取密钥列表,在此之后,如果其他使用者再次使用约定密钥获取密钥列表时,表明该使用者为滥用者。因此,在本申请实施例中,仅在密钥Agent重启时才会使用一次“约定密钥”的设置,能够快速并有效地检测出滥用者。That is to say, only the maintainer of the Agent restarts the process when changing the Agent is the only time to legally use the agreed key, and any other situation is illegal. For example, when the agent maintains the Agent, the contract key is used to obtain the key list. After that, if the other user uses the agreed key to obtain the key list again, it indicates that the user is an abuser. Therefore, in the embodiment of the present application, the setting of the "contract key" is used only when the key agent is restarted, and the abuser can be detected quickly and effectively.
由于网络上传递的只有各自的公钥pubkey,然而,本申请实施例中提供的业务加密是使用第一私钥和第二公钥对加密后的密钥列表进行解密,因此,即使密钥列表被tcpdump也不会反推出密钥,这就避免了内网抓包导致的密钥泄漏的现象出现。Since only the respective public key pubkey is transmitted on the network, the service encryption provided in the embodiment of the present application decrypts the encrypted key list using the first private key and the second public key, so even the key list The key is not reversed by tcpdump, which avoids the key leakage caused by intranet capture.
需要说明的是,在本申请实施例中,还可以保护密钥Agent和密钥服务器的内存。具体地,可以直接把密钥Agent和密钥服务器的二进制strip掉(即,删除一切调试信息),然后再把密钥Agent和密钥服务器的代码安全隔离保存起来,这么一来gdb几乎成了瞎子,至少想简单修改变量是不可能了。 It should be noted that, in the embodiment of the present application, the memory of the key agent and the key server may also be protected. Specifically, the binary of the key agent and the key server can be directly stripped off (ie, all debugging information is deleted), and then the code of the key agent and the key server is securely isolated, so that gdb is almost Dice, at least it is impossible to simply modify the variables.
在对密钥列表进行解密之后,密钥Agent需要对业务进程和业务进程的PID合法性进行校验。如图4所示,业务模块首先建立unix域套接字,并建立第一文件描述符,然后,使用unix域套接字中的套接字SCM_RIGHTS将第一文件描述符传输至密钥Agent,以及利用套接字SCM_CREDENTIA向密钥Agent传输进程被内核所认证的进程PID。其中,SCM_RIGHTS和SCM_CREDENTIA均适用于unix domain socket,SCM_RIGHTS用于将一个进程中的描述符传输到另一个进程中,这种方法可以让一些只能在亲缘进程间通信的IPC扩展到非亲缘进程(如linux eventfd);SCM_CREDENTIA用于传输进程被内核所认证的进程PID。After decrypting the key list, the key agent needs to verify the PID legality of the business process and the business process. As shown in FIG. 4, the service module first establishes a unix domain socket, and establishes a first file descriptor, and then transmits the first file descriptor to the key agent by using the socket SCM_RIGHTS in the unix domain socket. And using the socket SCM_CREDENTIA to transfer the PID of the process authenticated by the kernel to the key agent. Among them, SCM_RIGHTS and SCM_CREDENTIA are applicable to unix domain socket, SCM_RIGHTS is used to transfer descriptors in one process to another process. This method can extend some IPCs that can only communicate between relative processes to non-affinity processes ( For example, linux eventfd); SCM_CREDENTIA is used to transfer the process PID whose process is authenticated by the kernel.
申请人通过相关实验发现,在尝试过的所有方法(例如,异步IO,本地网络socket,unix域套接字,管道,边缘触发,一次recv/send多个请求,eventfd)和看到的所有文档中,加密效率仅次于共享内存的IPC,并明显快过管道和通常的unix域套接字,更不用提网络socket,实用性最好。Applicants found through the relevant experiments that all the methods tried (for example, asynchronous IO, local network socket, unix domain socket, pipe, edge trigger, one recv/send multiple requests, eventfd) and all documents seen In addition, the encryption efficiency is second only to the shared memory IPC, and significantly faster than the pipeline and the usual unix domain sockets, not to mention the network socket, the most practical.
此时,在获取到进程PID之后,就可以对业务进程和进程PID的合法性进行校验,具体校验过程在上述步骤S1至步骤S5中进行详细描述,此处不再赘述。At this time, after the process PID is obtained, the legality of the service process and the process PID can be verified. The specific verification process is described in detail in the above steps S1 to S5, and details are not described herein.
进一步地,在合法性校验通过的情况下,密钥代理模块还可以向业务模块发送第一文件描述符eventfda,密钥代理模块在获取到第一文件描述符eventfda之后,将生成第二文件描述符eventfdb,并将第二文件描述符eventfdb发送至业务模块,以实现密钥代理模块和业务模块之间文件描述符的交换。Further, in the case that the validity check is passed, the key agent module may further send a first file descriptor eventfda to the service module, and the key agent module generates a second file after acquiring the first file descriptor eventfda. Descriptor eventfdb, and send the second file descriptor eventfdb to the business module to implement the exchange of file descriptors between the key agent module and the business module.
进一步地,在合法性校验通过的情况下,密钥代理模块还可以为第一文件描述符设置目标权限,其中,目标权限包括以下至少之一:允许密钥代理模块对业务模块请求的待加密的数据进行加密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。Further, in the case that the legality verification is passed, the key agent module may further set a target authority for the first file descriptor, where the target authority includes at least one of the following: allowing the key agent module to request the service module The encrypted data is encrypted, allowing the key agent module to decrypt the data to be decrypted requested by the service module.
接下来,业务模块就可以向第一文件描述符eventfda在共享内存中对 应的空间中进行写数据的操作,即,将待加密的数据写入第一文件描述符eventfda在共享内存中对应的区域中(write eventfda)。在写入之后,密钥代理模块就能够获知业务模块写入了数据,此时,密钥代理模块将从共享内存中读取待加密的数据(即,读第二文件描述符,read eventfdb),并读取之前为第一文件描述符eventfda配置的目标权限。Next, the business module can go to the first file descriptor eventfda in shared memory. The operation of writing data in the space is performed, that is, the data to be encrypted is written into the corresponding area of the first file descriptor eventfda in the shared memory (write eventfda). After writing, the key agent module can know that the service module has written data. At this time, the key agent module will read the data to be encrypted from the shared memory (ie, read the second file descriptor, read eventfdb). And read the target permissions previously configured for the first file descriptor eventfda.
最后,在目标权限包括允许密钥代理模块对所述业务模块请求的待加密的数据进行加密时,密钥代理模块就可以从密钥列表中获取目标密钥,进而,密钥代理模块就可以根据获取到的目标密钥对待加密的数据进行密文处理请求。Finally, when the target authority includes allowing the key agent module to encrypt the data to be encrypted requested by the service module, the key agent module can obtain the target key from the key list, and then the key agent module can A ciphertext processing request is performed on the data to be encrypted according to the obtained target key.
需要说明的是,在本申请实施例中,只能通过eventfd直接传递8Bytes的数据,所以请求包(即,请求对待加密的数据进行加密的数据包)/响应包(即,已完成加密的待加密的数据的数据包)的主体会保存在共享内存中。It should be noted that, in the embodiment of the present application, only 8 bytes of data can be directly transmitted through eventfd, so the request packet (that is, the data packet requesting encryption to be encrypted)/response packet (that is, the encrypted packet is to be completed) The body of the encrypted data packet is stored in shared memory.
进一步地需要说明的是,把密钥保存在共享内存中是不安全,但是,把明文和密文保存在共享内存确是安全的。因为eventfd的8Byte可用来传输关键部分,这样攻击者就不能获取完整的密钥信息。It should be further noted that it is not safe to store the key in the shared memory, but it is safe to store the plaintext and ciphertext in the shared memory. Because eventfd's 8Byte can be used to transfer key parts, the attacker can't get the complete key information.
进一步地,如果SCM_CREDENTIA传递的PID出现错误时,表明此时sendmsg会返回-1,errno会被设置为3(表示进程不存在)或1(表示伪造其它进程)。Further, if the PID passed by SCM_CREDENTIA has an error, it indicates that sendmsg will return -1 at this time, and errno will be set to 3 (indicating that the process does not exist) or 1 (indicating that other processes are forged).
即:#define ESRCH 3/*No such process*/Namely: #define ESRCH 3/*No such process*/
#define EPERM 1/*Operation not permitted*/#define EPERM 1/*Operation not permitted*/
进一步地,unix域套接字传递准确进程PID的前提是非root模式运行的进程,所以必须对密钥Agent的root模式的需求进行审批。Further, the premise of the unix domain socket passing the accurate process PID is the process running in the non-root mode, so the requirement of the root mode of the key agent must be approved.
密钥代理模块还可以将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的所述进程PID。 The key broker module can also configure the socket socket option as SO_PEERCRED and obtain the process PID of the business process through the socket socket.
下面将就具体实施例对本申请实施例进行说明。The embodiments of the present application will be described below with reference to specific embodiments.
假设,测试环境为以下环境:Assume that the test environment is the following environment:
机器:空闲机器、48核@2.6GHZ;Machine: idle machine, 48 core @2.6GHZ;
业务进程:60进程,4700协程,仅和Agent打交道;Business process: 60 processes, 4700 coroutines, only dealing with Agent;
密钥Agent:10进程;其中,业务进程和密钥Agent均自由运行,没有设置CPU优先级。Key Agent: 10 processes; in which the business process and the key agent are free to run, and no CPU priority is set.
测试方式:test method:
空服务:没有任何逻辑,测试网络框架本身的基础效率;Empty service: without any logic, testing the basic efficiency of the network framework itself;
本地解密:直接解密微信票据;Local decryption: directly decrypt the WeChat bill;
票据=主票+从票;Bill = main ticket + slave ticket;
主票:AES+非对称加密,16Bytes;Main ticket: AES+ asymmetric encryption, 16Bytes;
从票:对称加密+非对称加密,12Bytes;From ticket: symmetric encryption + asymmetric encryption, 12Bytes;
密钥Agent解密:直接解密微信票据;Key Agent decryption: directly decrypt the WeChat ticket;
票据=主票+从票;Bill = main ticket + slave ticket;
主票:AES加密,16Bytes;Main ticket: AES encryption, 16Bytes;
从票:对称加密,12Bytes;From ticket: symmetric encryption, 12Bytes;
说明:由于密钥Agent大幅度强化了密钥安全,因此不再需要非对称加密。Note: Because key agents greatly enhance key security, asymmetric encryption is no longer needed.
压力测试结果:(整体CPU峰值)。Stress test results: (overall CPU peak).
通过测试可知,5台外部测试机对测试业务的请求均达到约30W/S,其中,空服务为17%、本地解密为31%-33%、Agent解密为33%-34%。According to the test, the requests of the five external test machines for the test business reached about 30W/S, of which 17% for the empty service, 31%-33% for the local decryption, and 33%-34% for the agent decryption.
8台外部测试机对测试业务的请求均达到约40W/S,其中,空服务为 27-28%、本地解密为55%-56%、Agent解密为60%-61%。The requests from the 8 external test machines for the test business reached about 40W/S, of which the empty service was 27-28%, local decryption is 55%-56%, Agent decryption is 60%-61%.
由此可见,在极端情形下,密钥Agent方式相对于相关业务直接验证票据的方式增加的额外CPU负载很轻,极具实战价值。It can be seen that in the extreme case, the additional CPU load added by the key agent method to directly verify the ticket relative to the related service is very light and extremely practical.
在一个可选的实施例中,在获取第一信息之前,方法还可以包括:向第一类型的密钥代理模块发送密文处理请求;获取第一类型的密钥代理模块执行密文处理请求的执行结果,可选地,可以从共享内存中读取该执行结果。In an optional embodiment, before acquiring the first information, the method may further include: sending a ciphertext processing request to the first type of key proxy module; acquiring the first type of the key proxy module to perform the ciphertext processing request As a result of the execution, the execution result can optionally be read from the shared memory.
在该实施例中,系统中可以运行双密钥代理模块,该双密钥代理模块可以为两种类型的密钥代理模块,可选地,该两种类型为第一类型和第二类型,其中,第一类型的密钥代理模块为开发型develop密钥代理模块,第二类型的密钥代理模块为稳定型stable密钥代理模块,稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。In this embodiment, a dual key proxy module can be run in the system, and the dual key proxy module can be two types of key proxy modules. Optionally, the two types are a first type and a second type. The first type of key agent module is a development type key agent module, the second type key agent module is a stable type table key agent module, and the stable key agent module is executed within a predetermined time period. The ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
需要说明的是,上述开发型develop密钥代理模块可以但不限于为未经过验证的代理模块,通过验证处理,以得到上述稳定型stable密钥代理模块。It should be noted that the above-mentioned development type key agent module may be, but not limited to, an unauthenticated agent module, and the verification process is performed to obtain the stable stable key agent module.
可选地,该稳定型stable密钥代理模块为已经确定为可以正确运行一段时间的密钥代理模块,而开发型develop密钥代理模块则为未确定出在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。Optionally, the stable stable key proxy module is a key proxy module that has been determined to be able to run correctly for a period of time, and the developed developer key proxy module does not determine that the ciphertext processing is performed within a predetermined time period. The key broker module whose request rate is higher than the predetermined correct rate.
根据本申请的上述实施例,获取第一信息可以包括:基于执行结果统计第一类型的密钥代理模块执行密文处理请求的成功率,其中,第一信息包括成功率。According to the above embodiment of the present application, the obtaining the first information may include: counting, according to the execution result, a success rate of the first type of the key agent module performing the ciphertext processing request, wherein the first information includes a success rate.
可选地,将第一类型的密钥代理模块执行密文处理请求的总数作为分母,将第一类型的密钥代理模块执行密文处理请求的成功的总数作为分子, 计算成功率。Optionally, the total number of ciphertext processing requests performed by the first type of key proxy module is used as a denominator, and the total number of successful ciphertext processing requests of the first type of key proxy module is used as a numerator. Calculate the success rate.
在一个可选的实施例中,预定类型切换条件包括成功率低于第一预定阈值,检测第一信息是否符合预定类型切换条件可以包括:检测成功率是否低于第一预定阈值;若检测出成功率低于第一预定阈值,则确定第一信息符合预定类型切换条件;若检测出成功率不低于第一预定阈值,则确定第一信息不符合预定类型切换条件。In an optional embodiment, the predetermined type switching condition includes the success rate being lower than the first predetermined threshold, and detecting whether the first information meets the predetermined type switching condition may include: detecting whether the success rate is lower than a first predetermined threshold; if detecting If the success rate is lower than the first predetermined threshold, it is determined that the first information meets the predetermined type switching condition; if the detected success rate is not lower than the first predetermined threshold, it is determined that the first information does not meet the predetermined type switching condition.
通过上述实施例,业务模块优先通过develop的密钥代理模块(即第一类型的密钥代理模块)执行加解密的操作,并在本地直接监控develop的密钥代理模块执行密文处理请求的成功率,当成功率跌到预先配置的第一预定阈值(例如,98%)以下时,则自动切换到第二类型的密钥代理模块执行密文处理请求,可以保证整个系统处理密文处理请求的稳定性。Through the above embodiment, the service module preferentially performs the encryption and decryption operation through the developed key proxy module (ie, the first type of key proxy module), and directly monitors the success of the developed key proxy module to perform the ciphertext processing request locally. Rate, when the success rate falls below a pre-configured first predetermined threshold (for example, 98%), then automatically switches to the second type of key agent module to perform a ciphertext processing request, which can ensure that the entire system processes the ciphertext processing request. stability.
根据本申请的上述实施例,在获取第一信息之前,方法还可以包括:在对系统中的密钥代理模块中的文件进行更新之后,将执行了更新操作的密钥代理模块记录为第一类型的密钥代理模块;若在预定时间段内均检测出第一类型的密钥代理模块执行密文处理请求的正确率高于预定正确率,则将第一类型的密钥代理模块记录为第二类型的密钥代理模块。According to the above embodiment of the present application, before acquiring the first information, the method may further include: after updating the file in the key agent module in the system, recording the key agent module performing the update operation as the first a type of key agent module; if it is detected within a predetermined time period that the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate, the first type of key agent module is recorded as The second type of key broker module.
可选地,可以对已经设置好的密钥代理模块经过充分测试,且缓慢在网络中运行,在确定密钥代理模块可以正确执行足够长的时间(比如2个月)的情况下,则可以将该密钥代理模块记录为stable类型,若系统中的双密钥代理模块均符合该条件(如正确执行足够长的时间),则系统内的密钥代理模块均可以被记录为stable类型。Optionally, the key proxy module that has been set may be fully tested and slowly run in the network. When it is determined that the key proxy module can perform correctly for a long enough time (for example, 2 months), The key agent module is recorded as a stable type. If the dual key agent module in the system meets the condition (for example, if the correct execution time is sufficient), the key agent module in the system can be recorded as a stable type.
需要说明的是,在需要对Agent进行变更时,变更后的Agent的类型记录为develop类型。It should be noted that when the agent needs to be changed, the type of the changed Agent is recorded as the develop type.
在采用双Agent的方式来运行的实施例中,若该双Agent为双stable Agent,则业务模块选取修改时间较晚的stable Agent,在需要进行变更的 时候,变更后的stable Agent变为develop Agent。In the embodiment running by using the dual agent mode, if the dual agent is a dual stable agent, the service module selects a stable agent with a modified time later, and needs to be changed. At the time, the changed stable agent becomes a development agent.
在一个可选的实施例中,若该双Agent为双stable Agent,则在需进行变更时,对文件修改时间较旧(即修改时间较早)的stable Agent进行变更。In an optional embodiment, if the dual agent is a dual stable agent, when the change needs to be made, the stable agent whose file modification time is earlier (that is, the modification time is earlier) is changed.
在develop Agent运行期间,若需要变更,则继续发布该develop Agent。进一步地,只有当develop Agent在无任何变更的情况下,正确执行足够长的时间(比如2个月)可以将其类型设置为stableAgent(即第二类型的密钥代理模块)。During the development of the development agent, if the change is required, the development agent will continue to be released. Further, the development agent can be set to the stableAgent (ie, the second type of key broker module) only if the development agent is properly executed for a sufficiently long period of time (eg, 2 months) without any changes.
可选地,在获取第一信息之前,方法还可以包括:在系统中的第一类型的密钥代理模块正在运行的过程中,若需对密钥代理模块中的文件进行更新,则对第一类型的密钥代理模块中的文件进行更新。Optionally, before acquiring the first information, the method may further include: if the file in the key proxy module is updated during the running of the first type of the key proxy module in the system, The files in a type of key broker module are updated.
在上述实施例中,在第一类型的密钥代理模块(即develop Agent)运行期间,如果还需要进行变更,则继续发布此develop Agent,当develop Agent在无任何变更的情况下,可以正确执行足够长的时间(比如2个月)可以将其类型设置为stable Agent(即第二类型的密钥代理模块)。In the above embodiment, during the operation of the first type of key agent module (ie, the development agent), if the change is still needed, the development agent is continuously released, and the developer agent can execute correctly without any change. For a long enough time (such as 2 months), you can set its type to stable agent (the second type of key agent module).
需要说明的是,通过第二类型的密钥代理模块执行业务模块请求的密文处理请求包括:若系统中包括多个第二类型的密钥代理模块(如两个),则从多个第二类型的密钥代理模块中获取更新时间最晚的第二类型的密钥代理模块,通过更新时间最晚的第二类型的密钥代理模块执行密文处理请求。It should be noted that the ciphertext processing request requested by the service module by the second type of key proxy module includes: if the system includes multiple second type key proxy modules (such as two), The second type of key agent module that obtains the latest update time in the two types of key agent modules performs the ciphertext processing request by the second type of key agent module that updates the latest time.
根据本申请的上述实施例,若系统中的密钥代理模块均被设置为第二类型的密钥代理模块,则业务模块可以从两个stable Agent中选取文件修改时间较新的Agent,业务模块可以使用该文件修改时间较新(即修改时间较晚)的Agent进行加解密的操作。According to the above embodiment of the present application, if the key agent modules in the system are all set to the second type of key agent module, the service module may select an agent with a newer file modification time from the two stable agents, and the service module You can use this file to modify the agent with a newer time (that is, later modification time) to perform encryption and decryption operations.
根据本申请的上述实施例,在通过第二类型的密钥代理模块执行业务 模块的密文处理请求之后,方法还包括:在接收到输入的切换指令之后,响应于切换指令,通过第一类型的密钥代理模块执行密文处理请求。According to the above embodiment of the present application, the service is performed by the second type of key agent module After the ciphertext processing request of the module, the method further includes: after receiving the input switching instruction, executing the ciphertext processing request by the first type of key proxy module in response to the switching instruction.
在上述实施例中,输入的切换指令为人工输入的指令。在业务模块从develop Agent切换到stable Agent之后,通过手工恢复成使用develop Agent的方式,这样可以在人工100%确认develop Agent的问题已经修复的情况下继续使用develop Agent,从而可以避免因为随意进行stable类型到develop类型的切换,而使得业务进一步蒙受损失。In the above embodiment, the input switching instruction is a manually input instruction. After the business module is switched from the developer agent to the stable agent, it can be manually restored to use the developer agent. This way, you can continue to use the developer agent after the manual 100% confirmation that the developer agent problem has been fixed, thus avoiding the random stalling. Switching from type to develop type, causing further loss of business.
通过上述实施例,通过业务模块进行容灾处理,可以在系统升级的情况下,保证加解密正常进行,并且在系统有bug的时候,可以及时切换不同类型的密钥代理模块执行密文处理请求,保证了系统的稳定性。Through the foregoing embodiment, the service module performs the disaster recovery process, and the encryption and decryption can be performed normally in the case of system upgrade, and when the system has a bug, the different types of key agent modules can be switched in time to perform the ciphertext processing request. To ensure the stability of the system.
可选地,在通过密钥代理模块执行密文处理请求的过程中,方法还包括:在密钥代理模块对业务进程进行合法性校验之后,在合法性校验通过的情况下,业务模块向密钥代理模块发送第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据;获取密钥代理模块生成的多个第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据。Optionally, in the process of performing the ciphertext processing request by the key proxy module, the method further includes: after the validity of the validity check of the service process by the key proxy module, in the case that the validity check is passed, the service module Transmitting, to the key agent module, a first file descriptor, wherein the first file descriptor is used by the key agent module to identify data sent by the service module as legal data; and acquiring a plurality of second file descriptors generated by the key agent module The second file descriptor is used by the service module to identify the data sent by the key agent module as legal data.
可选地,在获取密钥代理模块生成的多个第二文件描述符之后,方法还包括:将获取到的多个第二文件描述符保存至队列中;依序利用队列中存储的第二文件描述符与密钥代理模块进行通信。Optionally, after acquiring the plurality of second file descriptors generated by the key agent module, the method further includes: saving the obtained plurality of second file descriptors into the queue; sequentially using the second stored in the queue The file descriptor communicates with the key broker module.
可选地,多个第二文件描述符的数目与密钥代理模块中用于执行密文处理请求的线程数目相对应。Optionally, the number of the plurality of second file descriptors corresponds to the number of threads in the key broker module for executing the ciphertext processing request.
在该实施例中,业务以线程为单位,各自独立同Agent交换描述符,并以队列的方式独立管理描述符,线程之间互不干扰。每个业务线程独立的通过了Agent校验过身份后,一次交换出多个第二文件描述符(例如,Agent加解密线程数目的整数倍),Agent端将描述符完全均匀的分配给各 Agent加解密线程(因此每个线程管理的描述符数目相等),从而可以实现业务的负载均衡。In this embodiment, the services are in units of threads, each independently exchanges descriptors with the Agent, and the descriptors are independently managed in a queue manner, and the threads do not interfere with each other. Each service thread independently passes the Agent to verify the identity, and then exchanges multiple second file descriptors (for example, an integer multiple of the number of Agent encryption and decryption threads), and the Agent side distributes the descriptors completely uniformly to each The Agent encrypts and decrypts threads (so the number of descriptors managed by each thread is equal), so that load balancing of services can be achieved.
例如,密钥代理模块获取业务模块发送的100个第一文件描述符,然后密钥代理模块生成100个第二文件描述符,并将该100个第二文件描述符传输给业务模块,100个第一文件描述符和100个第二文件描述符一一配对得到100组描述符,密钥代理模块将该100组描述符平均分配给10个加解密线程可以通过如下方式试下:第一组描述符分配给加解密线程1,第二组描述符分配给加解密线程2,......,第十组描述符分配给加解密线程10,第十一组描述符分配给加解密线程1,第十二组描述符分配给加解密线程2,以此类推,第一百组描述符分配给加解密线程10。For example, the key agent module acquires 100 first file descriptors sent by the service module, and then the key agent module generates 100 second file descriptors, and transmits the 100 second file descriptors to the service module, 100 The first file descriptor and the 100 second file descriptors are paired one by one to obtain 100 sets of descriptors. The key agent module evenly distributes the 100 sets of descriptors to 10 encryption and decryption threads, and can be tried as follows: The descriptor is assigned to the encryption and decryption thread 1, the second group of descriptors is assigned to the encryption and decryption thread 2, ..., the tenth group of descriptors is assigned to the encryption and decryption thread 10, and the eleventh group of descriptors is assigned to the encryption and decryption Thread 1, the twelfth group of descriptors are assigned to the encryption and decryption thread 2, and so on, and the first hundred sets of descriptors are assigned to the encryption and decryption thread 10.
在上述实施例中,每个业务线程将交换出来的多个描述符保存到自身的线程级队列中,业务线程每次加解密请求就从队列首取描述符来和Agent通讯,通讯完成后将描述符放回队列尾;如果从队列首取描述符是发现队列为空,就再次按上述的方法交换出更多描述符。In the above embodiment, each business thread saves the exchanged plurality of descriptors into its own thread-level queue, and each time the business thread encrypts and decrypts the request, it first retrieves the descriptor from the queue to communicate with the agent, and after the communication is completed, The descriptor is placed back at the end of the queue; if the descriptor is taken from the first queue and the discovery queue is empty, then more descriptors are exchanged as described above.
通过上述实施例,极大的减少了身份认证的次数,由于身份认证的身份校验的MD5(或者其它HASH算法)计算效率较低,这样可以不必每个请求都验证身份;每个业务线程都极其均匀的访问各Agent线程,完全避免各Agent线程负载不均匀的问题,均衡利用多CPU的资源;业务和Agent之间的各加解密请求处理高度独立,不用加请求级的锁来保证资源独占,提高并发吞吐能力。Through the above embodiments, the number of identity authentication is greatly reduced, and the MD5 (or other HASH algorithm) for identity verification is less efficient, so that it is not necessary to verify the identity of each request; each service thread Extremely even access to each Agent thread, completely avoiding the problem of uneven load of each Agent thread, and balancing the resources of multiple CPUs; the encryption and decryption request processing between the service and the Agent is highly independent, and the request-level lock is not required to ensure the exclusive use of resources. Improve the ability to concurrently throughput.
在另一个可选的实施例中,通过密钥代理模块进行容灾处理。图5示出了一种可选的实施例,如图5所示,该实施例可以通过如下步骤实现:In another optional embodiment, the disaster recovery process is performed by the key agent module. FIG. 5 shows an alternative embodiment. As shown in FIG. 5, the embodiment can be implemented by the following steps:
步骤S502:密钥代理模块获取执行密文处理请求的执行结果;Step S502: The key agent module acquires an execution result of the execution of the ciphertext processing request.
步骤S504:密钥代理模块检测执行结果是否符合预定模式切换条件;Step S504: The key agent module detects whether the execution result meets a predetermined mode switching condition;
步骤S506:若检测出执行结果符合预定模式切换条件,则密钥代理 模块向业务模块发送指示信息,其中,指示信息用于指示业务模块切换到通过业务模块执行密文处理请求的模式。Step S506: If it is detected that the execution result meets the predetermined mode switching condition, the key agent The module sends the indication information to the service module, where the indication information is used to indicate that the service module switches to a mode in which the ciphertext processing request is performed by the service module.
可选地,若检测出执行结果不符合预定模式切换条件,则继续运行在由密钥代理模块执行密文处理请求的模式。Optionally, if it is detected that the execution result does not meet the predetermined mode switching condition, the mode of executing the ciphertext processing request by the key agent module is continued.
通过上述实施例,密钥代理模块获取执行密文处理请求的执行结果;密钥代理模块检测执行结果是否符合预定模式切换条件;若检测出执行结果符合预定模式切换条件,则密钥代理模块向业务模块发送指示信息,其中,指示信息用于指示业务模块切换到通过业务模块执行密文处理请求的模式。在上述实施例中,密钥代理模块检测其执行密文处理请求的执行结果是否符合预定模式切换条件,若符合预定模式切换条件,则确定该密钥代理模块无法继续稳定执行密文处理请求,则转换模式,以使得业务模块可以自行执行密文处理请求,以解决相关技术中在对业务数据进行加解密时无法稳定运行的问题,实现了系统的稳定运行。Through the above embodiment, the key agent module acquires an execution result of the execution of the ciphertext processing request; the key agent module detects whether the execution result meets the predetermined mode switching condition; and if it detects that the execution result meets the predetermined mode switching condition, the key agent module The service module sends indication information, where the indication information is used to indicate that the service module switches to a mode in which the ciphertext processing request is performed by the service module. In the above embodiment, the key agent module detects whether the execution result of the execution of the ciphertext processing request meets the predetermined mode switching condition, and if the predetermined mode switching condition is met, determining that the key agent module cannot continue to stably perform the ciphertext processing request. Then, the mode is switched, so that the service module can perform the ciphertext processing request by itself, so as to solve the problem that the related technology cannot be stably operated when the business data is encrypted and decrypted, and the stable operation of the system is realized.
可选地,业务模块在切换到本地加解密模式后(即业务模块切换到通过业务模块执行密文处理请求的模式),通过手工(如接收人工输入的恢复指令)才能恢复成使用Agent的方式(业务此时自动清理密钥M),这是为了人工100%确认问题已经修复,不会进一步因为随意切换使得业务进一步蒙受损失,通过该实施例,可以最小的安全性损失最大限度的保障业务正常运行。Optionally, after the service module switches to the local encryption and decryption mode (that is, the service module switches to the mode in which the ciphertext processing request is executed through the service module), the method of using the agent can be restored by manually (such as receiving a manual input recovery instruction). (The service automatically cleans up the key M at this time), this is for the manual 100% confirmation that the problem has been fixed, and the service will not be further suffered because of the random switching. With this embodiment, the maximum security loss can be guaranteed with minimal security loss. normal operation.
在上述实施例中,密钥代理模块执行密文处理请求的方式与上述实施例中所述的方式一致,在此不再赘述。In the above embodiment, the manner in which the key agent module performs the ciphertext processing request is the same as that described in the foregoing embodiment, and details are not described herein again.
在一个可选的实施例中,Agent在每次拉取最新密钥列表时,由密钥服务器SVR生成一个随机密钥M(即密钥数据)返回给Agent,Agent将密钥列表使用M加密后保存到某块共享内存N中。In an optional embodiment, the agent generates a random key M (ie, key data) by the key server SVR to return to the Agent each time the latest key list is pulled, and the agent encrypts the key list using M. After saving to a piece of shared memory N.
可选地,在通过业务线程获取密钥代理模块的密钥数据之前,方法还 包括:通过业务线程生成通信管道的第一端描述符和第二端描述符,其中,第一端描述符用于密钥代理模块将业务模块发送的数据识别为合法数据,第二端描述符用于业务模块将密钥代理模块发送的数据识别为合法数据;通过通信管道将第二端描述符传输给密钥代理模块。Optionally, before the key data of the key agent module is obtained through the service thread, the method further The method includes: generating, by the service thread, a first end descriptor and a second end descriptor of the communication pipeline, wherein the first end descriptor is used by the key proxy module to identify the data sent by the service module as legal data, and the second end descriptor The service module identifies the data sent by the key agent module as legal data; and transmits the second end descriptor to the key agent module through the communication pipeline.
业务线程独立生成两个管道描述符,分别为读端描述符和写端描述符(如上述的第一端描述符和第二端描述符),业务线程在身份校验时把写端传递给Agent,Agent若是校验身份通过,则保留该写端,此时业务线程将自己持有的写端关闭,此时业务线程持有管道读端,Agent持对应该线程的管道写端。The service thread independently generates two pipeline descriptors, which are a read end descriptor and a write end descriptor (such as the first end descriptor and the second end descriptor described above), and the business thread passes the write end to the identity verification. Agent, Agent If the identity is passed, the write end is retained. At this time, the service thread closes the write end held by the service thread. At this time, the service thread holds the pipeline read end, and the agent holds the pipeline write end corresponding to the thread.
进一步地,业务在执行加解密请求时,将请求时间A填入请求包中(例如,可以将时间精确到毫秒)。Further, when the service performs the encryption and decryption request, the request time A is filled in the request packet (for example, the time can be accurate to the millisecond).
可选地,密钥代理模块获取执行密文处理请求的执行结果包括:密钥代理模块在执行完密文处理请求之后,基于密文处理请求中的请求时间与当前时间,判断执行当前的密文处理请求是否超时;若判断出执行当前的密文处理请求超时,则密钥代理模块确定执行当前的密文处理请求失败;密钥代理模块基于执行失败的密文处理请求的数量,统计密钥代理模块执行密文处理请求的成功率,执行结果包括成功率。Optionally, the obtaining, by the key agent module, the execution result of the execution of the ciphertext processing request includes: after the ciphertext processing request is executed, the key proxy module determines, according to the request time and the current time in the ciphertext processing request, the execution of the current secret Whether the file processing request times out; if it is determined that the execution of the current ciphertext processing request times out, the key agent module determines that the execution of the current ciphertext processing request fails; the key agent module is based on the number of ciphertext processing requests that failed to be executed, and the statistics are dense. The success rate of the key agent module performing the ciphertext processing request, and the execution result includes the success rate.
可选地,密钥代理模块检测执行结果是否符合预定模式切换条件包括:密钥代理模块检测成功率是否低于第二预定阈值;若检测出执行密文处理请求的成功率是否低于第二预定阈值,则确定执行结果符合预定模式切换条件。Optionally, the key agent module detects whether the execution result meets the predetermined mode switching condition, including: the key agent module detects whether the success rate is lower than a second predetermined threshold; and if the success rate of executing the ciphertext processing request is lower than the second The predetermined threshold is determined, and it is determined that the execution result conforms to the predetermined mode switching condition.
可选地,Agent在完成执行请求并且将结果数据写入共享内存和通信的描述符缓冲之后,判断当前时间(精确到毫秒),设业务设定的加解密超时为B ms,则如果当前时间同时间A的时差C超过(B-x)ms时,就将此请求标记为失败,当成功率跌到实现配置的第二预定阈值(比如98%)以下时,自动通过各管道写端将密钥M发送到所有业务线程。可选地,x可 以为3。Optionally, after completing the execution request and writing the result data to the descriptor buffer of the shared memory and the communication, the agent determines the current time (accurate to milliseconds), and sets the encryption and decryption timeout of the service setting to B ms, if the current time When the time difference C of A is more than (Bx) ms, the request is marked as failed. When the success rate falls below the second predetermined threshold (for example, 98%) of the implementation configuration, the key M is automatically written through each pipe. Sent to all business threads. Optionally, x can Thought it is 3.
进一步可选地,密钥代理模块向业务模块发送指示信息包括:密钥代理模块向业务模块发送密钥数据,其中,密钥数据用于解密共享内存中存储的密钥列表,得到解密后的密钥列表,业务模块还设置为通过解密后的密钥列表执行密文处理请求。Further optionally, the key agent module sends the indication information to the service module, where the key agent module sends the key data to the service module, where the key data is used to decrypt the key list stored in the shared memory, and the decrypted The key list, the service module is further configured to perform a ciphertext processing request through the decrypted key list.
需要说明的是,业务模块通过业务线程获取密钥代理模块的密钥数据包括:通过业务线程周期性从通信管道的读端读取数据;若从通信管道的读端读取到数据,则确定获取到密钥数据。It should be noted that the service module obtains the key data of the key agent module through the service thread, including: periodically reading data from the read end of the communication pipe through the service thread; if the data is read from the read end of the communication pipe, determining Get the key data.
在该示例中,业务线程周期性(比如3秒)判断自己的管道读端是否有数据可读,一旦读出数据,则认为是密钥M,然后每次都使用M来解密N内存中的密钥列表获取加解密请求的密钥,从容退化成业务线程本地加解密模式,完全忽略Agent。In this example, the business thread periodically (for example, 3 seconds) determines whether its own pipeline reader has data readable. Once the data is read, it is considered to be the key M, and then each time M is used to decrypt the N memory. The key list obtains the key of the encryption and decryption request, and degenerates into a local encryption and decryption mode of the business thread, completely ignoring the Agent.
可选地,在密钥代理模块接收并执行业务模块的密文处理请求之前,方法还包括:在对密钥代理模块中的文件进行更新之后,将执行了更新操作的密钥代理模块记录为第一类型的密钥代理模块;在第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果之后,方法还包括:若在预定时间段内均检测出第一类型的密钥代理模块执行密文处理请求的正确率高于预定正确率,则将第一类型的密钥代理模块记录为第二类型的密钥代理模块。Optionally, before the key agent module receives and executes the ciphertext processing request of the service module, the method further includes: after updating the file in the key agent module, recording the key agent module that performs the update operation as a first type of key agent module; after the first type of key agent module receives and executes the ciphertext processing request of the service module, and obtains the execution result, the method further includes: detecting the first type within a predetermined time period The key broker module performs a ciphertext processing request with a higher correct rate than the predetermined correct rate, and records the first type of key proxy module as the second type of key proxy module.
可选地,在第一类型的密钥代理模块执行业务模块的密文处理请求的过程中,方法还包括:若需对密钥代理模块中的文件进行更新,则对第一类型的密钥代理模块中的文件进行更新。Optionally, in the process that the first type of the key agent module performs the ciphertext processing request of the service module, the method further includes: if the file in the key agent module is to be updated, the first type of the key is The files in the agent module are updated.
可选地,密文处理请求包括:用于将待加密数据加密为密文数据的请求和/或用于将密文数据解密为解密数据的请求。Optionally, the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
可选地,通信管道还用于检测业务模块、以及密钥代理模块是否重启。 Optionally, the communication pipeline is further configured to detect whether the service module and the key agent module are restarted.
在上述实施例中,管道(即上述的通信管道)还是Agent和业务互相判断对方是否重启的有力工具,业务线程可以和Agent再多传送一次管道描述符,此时业务持有写端,Agent持有读端,一旦业务进程关闭,Agent立刻能通过epoll_wait()的EPOLLHUP错误发现,然后立刻启动清理,防止资源泄露;而业务则可以通过由请求触发,当加解密请求超时时,通过写入管道写端写入一个字节,如果Agent重启,则会返回EPIPE,此时也能立刻触发资源清理,并重新和新启动的Agent验证身份。In the above embodiment, the pipeline (that is, the communication pipeline mentioned above) is also a powerful tool for the agent and the service to judge each other whether the other party restarts, and the service thread can transmit the pipeline descriptor to the agent once more, and the service holds the write end, and the agent holds There is a reader, once the business process is closed, the Agent can immediately find out through the EPOLLHUP error of epoll_wait(), and then immediately start cleaning up to prevent resource leakage; and the service can be triggered by the request, when the encryption and decryption request times out, by writing to the pipeline The write end writes a byte. If the Agent restarts, it will return EPIPE. At this time, it can also trigger resource cleanup and re-identify the identity with the newly started Agent.
通过上述实施例,在Agent(如第二类型的密钥代理模块)的BUG(也就是长期潜伏的隐晦BUG)被意外触发时或者本硬件服务器资源绝对不足时,可以采取以牺牲一定安全性的方法来维持业务继续正常运行,即在保证业务正常的前提下,尽可能减少安全性的损失。Through the above embodiment, when the bug of the Agent (such as the second type of key agent module) is accidentally triggered or when the hardware server resources are absolutely insufficient, the security may be sacrificed. The method is to maintain the normal operation of the service, that is, to minimize the loss of security under the premise of ensuring normal business.
具体地,由Agent来判断是否进入容灾模式;Agent本身的安全防护(root运行,难以被调试等特性)远多于一般业务,平时正常时业务依然不持有密钥,也不能通过简单DUMP加密的密钥列表共享内存N来盗取密钥列表,提高了安全性;进一步地,由Agent判断容灾模式十分合理,由于双方通信的描述符是共享的,只要Agent将回包数据写入了通讯共享内存和通信描述符的缓冲区,业务线程就一定能无条件读出来,且Agent还预留了3毫秒给业务来读取结果,时间十分充足,业务这样都还超时的话,证明其它部分耗时太长,性能问题和Agent关系不大;这种方式就避免了非共享描述符的问题,即业务和Agent使用不同的描述符来通信,Agent将结果写入己方的描述符缓冲区之后,还要依赖内核将此数据“搬运”到业务描述符的缓冲区中,否则业务依旧读取不到结果,这样由Agent来控制容灾开启就不见得合理了。Specifically, the agent determines whether to enter the disaster recovery mode; the security protection of the agent itself (root operation, difficult to be debugged, etc.) is far more than the general service. Usually, the service still does not hold the key, nor can it pass the simple DUMP. The encrypted key list shares the memory N to steal the key list, which improves the security. Further, the agent determines that the disaster tolerance mode is very reasonable. Since the descriptors of the two parties are shared, as long as the agent writes the return packet data. The communication shared memory and communication descriptor buffer, the business thread must be able to read unconditionally, and the Agent also reserved 3 milliseconds for the business to read the results, the time is very sufficient, if the business is still timed out, prove other parts It takes too long, and the performance problem has little relationship with the Agent; this way avoids the problem of non-shared descriptors, that is, the service and the agent use different descriptors to communicate, and the Agent writes the result to the own descriptor buffer. , but also rely on the kernel to "handle" this data into the buffer of the service descriptor, otherwise the business still can not read the result, so the Agent comes Disaster recovery system is not necessarily reasonable to open up.
进一步需要说明的是即使处于管道容灾模式,N依旧保持加密状态,还是不能通过简单DUMP加密的密钥列表共享内存N来盗取密钥列表,而必须趁机以攻击业务的方式(如调试业务)获取M,然后才能盗取到密 钥列表,架设恶意者想通过容灾模式盗取密钥列表,也得闹出比较大的动静才行,即至少在一台物理单机上制造业务故障或者趁着故障来盗取,由于此时业务有问题,比较引人注目,对其风险较高。It should be further noted that even in the pipeline disaster recovery mode, N still maintains the encryption state, and the key list cannot be stolen by the simple DUMP encrypted key list shared memory N, but must be down-played to attack the service (such as debugging service). ) Get M, then steal the secret The key list, the erroneous person wants to steal the key list through the disaster recovery mode, and also has to make a relatively large movement, that is, at least one physical single machine manufacturing business failure or smashing the fault to steal, due to this time The business has problems, it is more eye-catching, and its risk is higher.
可选地,在通过第一类型的密钥代理模块或第二类型的密钥代理模块执行密文处理请求的过程中,方法还包括:通过业务线程获取密钥代理模块的密钥数据,其中,密钥代理模块设置为在检测出执行密文处理请求的成功率低于第二预定阈值的情况下,发送密钥数据;利用密钥数据解密共享内存中存储的密钥列表,得到解密后的密钥列表;利用解密后的密钥列表通过业务模块执行密文处理请求。Optionally, in the process of performing the ciphertext processing request by the first type of the key proxy module or the second type of the key proxy module, the method further includes: acquiring the key data of the key proxy module by using the service thread, where And the key agent module is configured to: after detecting that the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, transmitting the key data; decrypting the key list stored in the shared memory by using the key data, and obtaining the decrypted a list of keys; performing a ciphertext processing request through the service module using the decrypted key list.
可选地,密文处理请求包括:用于将待加密数据加密为密文数据的请求和/或用于将密文数据解密为解密数据的请求。Optionally, the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
在一个可选的实施例中,业务处理方法还可以应用在密钥代理模块所在的系统中,该方案可以通过如下方式实现:第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果;第二类型的密钥代理模块接收并执行业务模块的密文处理请求,其中,业务模块设置为在基于执行结果生成的第一信息符合预定类型切换条件的情况下,向第二类型的密钥代理模块发送密文处理请求。In an optional embodiment, the service processing method can also be applied in a system where the key agent module is located, and the solution can be implemented as follows: the first type of key agent module receives and executes the ciphertext processing of the service module. Requesting, obtaining an execution result; the second type of key agent module receives and executes a ciphertext processing request of the service module, wherein the service module is configured to: if the first information generated based on the execution result meets a predetermined type switching condition, The second type of key broker module sends a ciphertext processing request.
可选地,第一类型的密钥代理模块为开发型密钥代理模块,第二类型的密钥代理模块为稳定型密钥代理模块,稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。Optionally, the first type of key agent module is a development type key agent module, the second type of key agent module is a stable key agent module, and the stable key agent module is executed within a predetermined time period. The ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
可选地,在第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果之前,方法还包括:在对系统中的密钥代理模块中的文件进行更新之后,将执行了更新操作的密钥代理模块记录为第一类型的密钥代理模块;在第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果之后,方法还包括:若在预定时间段内均检测出第一类型的密钥代理模块执行密文处理请求的正确率高于预定正确率,则将 第一类型的密钥代理模块记录为第二类型的密钥代理模块。Optionally, before the first type of the key proxy module receives and executes the ciphertext processing request of the service module, and obtains the execution result, the method further includes: after updating the file in the key proxy module in the system, The key agent module that performs the update operation records as the first type of key agent module; after the first type of the key agent module receives and executes the ciphertext processing request of the service module, and obtains the execution result, the method further includes: Detecting that the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate during the predetermined time period, The first type of key broker module is recorded as a second type of key broker module.
可选地,在第一类型的密钥代理模块执行业务模块的密文处理请求的过程中,方法还包括:若需对密钥代理模块中的文件进行更新,则对第一类型的密钥代理模块中的文件进行更新。Optionally, in the process that the first type of the key agent module performs the ciphertext processing request of the service module, the method further includes: if the file in the key agent module is to be updated, the first type of the key is The files in the agent module are updated.
可选地,在密钥代理模块执行密文处理请求的过程中,方法还包括:密钥代理模块检测执行密文处理请求的成功率是否低于第二预定阈值;若检测出执行密文处理请求的成功率是否低于第二预定阈值,则向业务模块发送密钥数据,其中,密钥数据用于解密共享内存中存储的密钥列表,得到解密后的密钥列表,业务模块还用于通过解密后的密钥列表执行密文处理请求。Optionally, in the process of the ciphertext processing module performing the ciphertext processing request, the method further includes: the key proxy module detecting whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold; if the ciphertext processing is detected If the success rate of the request is lower than the second predetermined threshold, the key data is sent to the service module, where the key data is used to decrypt the key list stored in the shared memory, and the decrypted key list is obtained, and the service module further uses The ciphertext processing request is performed through the decrypted key list.
可选地,在密钥代理模块检测执行密文处理请求的成功率是否低于第二预定阈值之前,方法还包括:密钥代理模块在执行完密文处理请求之后,基于密文处理请求中的请求时间与当前时间,判断执行当前的密文处理请求是否超时;若判断出执行当前的密文处理请求超时,则确定执行当前的密文处理请求失败;基于执行失败的密文处理请求的数量,统计密钥代理模块执行密文处理请求的成功率。Optionally, before the key proxy module detects whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, the method further includes: after the ciphertext processing request is executed, the key proxy module processes the request based on the ciphertext The request time and the current time determine whether the execution of the current ciphertext processing request has timed out; if it is determined that the execution of the current ciphertext processing request timeout, it is determined that the execution of the current ciphertext processing request fails; Quantity, the success rate of the statistics key agent module to perform ciphertext processing requests.
可选地,在密钥代理模块检测执行密文处理请求的成功率是否低于第二预定阈值之前,方法还包括:接收通过业务线程传输的通信管道的第二端描述符,其中,业务线程用于生成第一端描述符和第二端描述符,其中,第一端描述符用于密钥代理模块将业务模块发送的数据识别为合法数据,第二端描述符用于业务模块将密钥代理模块发送的数据识别为合法数据。Optionally, before the key proxy module detects whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, the method further includes: receiving a second end descriptor of the communication pipeline transmitted by the service thread, where the service thread And configured to generate a first end descriptor for the key proxy module to identify data sent by the service module as legal data, and a second end descriptor for the service module to be dense The data sent by the key broker module is identified as legal data.
可选地,向业务模块发送密钥数据包括:通过各个业务线程的通信管道的写端,发送密钥数据。Optionally, sending the key data to the service module includes: transmitting key data by using a write end of a communication pipeline of each service thread.
可选地,在通过密钥代理模块执行密文处理请求的过程中,方法还包括:在密钥代理模块对业务进程进行合法性校验之后,在合法性校验通过 的情况下,密钥代理模块接收业务模块发送的第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据;密钥代理模块生成多个第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据;密钥代理模块向业务模块传输多个第二文件描述符。Optionally, in the process of performing the ciphertext processing request by the key proxy module, the method further includes: after the key proxy module performs the validity check on the service process, the validity check is passed. The key agent module receives the first file descriptor sent by the service module, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal data; the key agent module generates multiple And a second file descriptor, wherein the second file descriptor is used by the service module to identify the data sent by the key agent module as legal data; and the key agent module transmits the plurality of second file descriptors to the service module.
可选地,多个第二文件描述符的数目与密钥代理模块中用于执行密文处理请求的线程数目相对应。Optionally, the number of the plurality of second file descriptors corresponds to the number of threads in the key broker module for executing the ciphertext processing request.
可选地,密文处理请求包括:用于将待加密数据加密为密文数据的请求和/或用于将密文数据解密为解密数据的请求。Optionally, the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
根据本申请实施例,在密文处理请为用于将待加密数据加密为密文数据的请求的情况下,提供了一种业务加密的方法实施例。According to the embodiment of the present application, in the case that the ciphertext processing is a request for encrypting data to be encrypted into ciphertext data, an embodiment of a method for service encryption is provided.
可选地,在本实施例中,上述业务加密方法可以应用于如图6所示的由服务器602和终端604所构成的硬件环境中。如图6所示,服务器602通过网络与终端604进行连接,上述网络包括但不限于:广域网、城域网或局域网,终端604并不限定于PC、手机、平板电脑等。本申请实施例的业务加密方法可以由服务器602来执行,也可以由终端604来执行,还可以是由服务器602和终端604共同执行。其中,终端604执行本申请实施例的业务加密方法也可以是由安装在其上的客户端来执行。Optionally, in this embodiment, the foregoing service encryption method may be applied to a hardware environment formed by the server 602 and the terminal 604 as shown in FIG. 6. As shown in FIG. 6, the server 602 is connected to the terminal 604 through a network. The network includes but is not limited to a wide area network, a metropolitan area network, or a local area network. The terminal 604 is not limited to a PC, a mobile phone, a tablet, or the like. The service encryption method in the embodiment of the present application may be executed by the server 602, may be executed by the terminal 604, or may be jointly performed by the server 602 and the terminal 604. The service encryption method performed by the terminal 604 in the embodiment of the present application may also be performed by a client installed thereon.
图6中示出的硬件环境系统的主要工作原理是:The main working principle of the hardware environment system shown in Figure 6 is:
在本申请实施例中,密钥代理模块安装在终端604中。当有业务需要进行加密时,可以通过业务模块向密钥代理模块发送携带有待加密数据的加密请求。密钥代理模块在获取到加密请求之后,将从拉取到的密钥列表中获取目标密钥,然后,使用目标密钥对待加密的数据进行加密,得到加密后的数据,最后,密钥代理模块将加密后的数据发送给业务模块。In the embodiment of the present application, the key agent module is installed in the terminal 604. When there is a service that needs to be encrypted, an encryption request carrying the data to be encrypted may be sent to the key agent module through the service module. After obtaining the encryption request, the key agent module obtains the target key from the extracted key list, and then encrypts the data to be encrypted using the target key to obtain the encrypted data, and finally, the key agent. The module sends the encrypted data to the business module.
需要说明的是,在本申请实施例中,密钥列表为密钥代理模块在首次 开启时,从服务器604(例如,密钥服务器)中所拉取得到的密钥列表。It should be noted that, in the embodiment of the present application, the key list is the key agent module for the first time. When enabled, the list of keys retrieved from the server 604 (eg, a key server) is pulled.
图7是根据本申请实施例的一种可选的业务加密方法的流程图,如图7所示,该方法可以包括以下步骤:FIG. 7 is a flowchart of an optional service encryption method according to an embodiment of the present application. As shown in FIG. 7, the method may include the following steps:
步骤S702,密钥代理模块接收业务模块发送的加密请求,其中,所述加密请求中携带有待加密的数据。Step S702: The key agent module receives an encryption request sent by the service module, where the encryption request carries data to be encrypted.
在本申请实施例中,密钥代理模块(以下均称为密钥Agent)可以采用单进程多线程的方式实现;业务模块设置为向密钥Agent发送加密请求,其中,密钥Agent行业业务模块处于同一个物理单机中。In the embodiment of the present application, the key agent module (hereinafter referred to as the key agent) may be implemented in a single-process multi-thread manner; the service module is configured to send an encryption request to the key agent, wherein the key agent industry service module In the same physical stand-alone machine.
具体地,当有业务需要进行加密时,业务模块可以向密钥Agent发送携带待加密的数据的加密请求;密钥Agent在获取到加密请求之后,就可以执行下述步骤S704,即根据加密请求在密钥列表中获取目标密钥。Specifically, when there is a service that needs to be encrypted, the service module may send an encryption request carrying the data to be encrypted to the key agent; after acquiring the encryption request, the key agent may perform the following step S704, that is, according to the encryption request. Get the target key in the key list.
步骤S704,密钥代理模块从密钥列表中获取目标密钥,其中,密钥列表是预先从密钥服务器中拉取到的。Step S704, the key agent module acquires the target key from the key list, wherein the key list is previously extracted from the key server.
在本申请实施例中,当密钥代理模块Agent重启时,密钥Agent会向密钥服务器拉取密钥列表。需要说明的是,密钥Agent仅在重新启动时,向密钥服务器拉取密钥列表,在启动后的其他时间内不再拉取密钥列表。In the embodiment of the present application, when the key agent module Agent is restarted, the key agent pulls the key list to the key server. It should be noted that the key agent only pulls the key list to the key server when restarting, and does not pull the key list at other times after startup.
密钥Agent在获取到业务模块发送的加密请求之后,就可以在预先拉取的密钥列表中获取目标密钥,其中,该目标密钥用于对待加密的数据进行加密。After obtaining the encryption request sent by the service module, the key agent may acquire the target key in the pre-pushed key list, where the target key is used to encrypt the data to be encrypted.
步骤S706,密钥代理模块使用目标密钥对待加密的数据进行加密,得到加密后的数据。Step S706, the key agent module encrypts the data to be encrypted using the target key to obtain the encrypted data.
在本申请实施例中,密钥Agent在从密钥列表中获取到目标密钥之后,就可以对使用目标密钥对待加密的数据进行加密。In the embodiment of the present application, after the key Agent obtains the target key from the key list, the data to be encrypted using the target key may be encrypted.
步骤S708,密钥代理模块将加密后的数据发送给业务模块。 Step S708, the key agent module sends the encrypted data to the service module.
在本申请实施例中,密钥代理模块在使用目标密钥对待加密的数据进行加密,得到加密之后的数据之后,就可以将加密后的数据发送给业务模块。In the embodiment of the present application, the key agent module encrypts the data to be encrypted using the target key, and after obtaining the encrypted data, the encrypted data can be sent to the service module.
通过上述步骤S702至步骤S708,通过密钥代理模块接收加密请求,然后,根据密钥请求获取目标密钥,接下来,通过目标密钥对待加密的数据进行加密,本申请实施例中提供的业务加密方式,达到了更加安全地为业务进行加密的目的,从而实现了提高了对业务进行加密时密钥安全性的技术效果,进而解决了相关技术中在对业务进行加密时密钥的安全性较低的技术问题。Through the above steps S702 to S708, the encryption request is received by the key agent module, and then the target key is acquired according to the key request. Next, the data to be encrypted is encrypted by the target key, and the service provided in the embodiment of the present application is provided. The encryption method achieves the purpose of encrypting the service more securely, thereby realizing the technical effect of improving the key security when encrypting the service, thereby solving the security of the key when encrypting the service in the related art. Lower technical issues.
可选地,在密钥代理模块接收业务模块发送的加密请求之前,还可以通过密钥代理模块将第一公钥发送给密钥服务器,并从密钥服务器接收第二公钥,其中,密钥代理模块上具有一对第一公钥和第一私钥,密钥服务器上具有一对第二公钥和第二私钥;密钥代理模块向密钥服务器发送密钥列表拉取请求;密钥代理模块接收密钥服务器发送的加密后的密钥列表,其中,加密后的密钥列表是使用密钥服务器侧的第一通讯密钥对密钥列表进行加密得到的,第一通讯密钥是密钥服务器根据第一公钥和第二私钥生成得到的;密钥代理模块使用密钥代理模块侧的第二通讯密钥对加密后的密钥列表进行解密,得到密钥列表,其中,第二通讯密钥是密钥代理模块根据第一私钥和第二公钥生成得到的,第一通讯密钥与第二通讯密钥相同。Optionally, before the key proxy module receives the encryption request sent by the service module, the first public key may be sent to the key server by using the key proxy module, and the second public key is received from the key server, where The key agent module has a pair of first public key and a first private key, and the key server has a pair of second public key and a second private key; the key agent module sends a key list pull request to the key server; The key agent module receives the encrypted key list sent by the key server, wherein the encrypted key list is obtained by encrypting the key list by using the first communication key on the key server side, and the first communication secret is obtained. The key is generated by the key server according to the first public key and the second private key; the key agent module decrypts the encrypted key list by using the second communication key on the key agent module side to obtain a key list. The second communication key is generated by the key agent module according to the first private key and the second public key, and the first communication key is the same as the second communication key.
在本申请实施例中,在密钥Agent接收加密请求之前,需要从密钥服务器拉取密钥列表,其中,由于从密钥服务器拉取到的密钥列表为加密之后的密钥列表。因此,密钥Agent需要对拉取到的密钥列表进行解密。In the embodiment of the present application, before the key Agent receives the encryption request, the key list needs to be pulled from the key server, wherein the key list pulled from the key server is the encrypted key list. Therefore, the key agent needs to decrypt the extracted key list.
在本申请实施例中,密钥Agent拉取到的密钥列表是使用密钥服务器侧的第一通讯密钥对密钥列表进行加密得到的,那么密钥代理模块在对密钥列表进行解密时,需使用与第一通讯密钥相同的第二通讯密钥对密钥列表进行解密。其中,第一通讯密钥是密钥服务器根据第一公钥和第二私钥 生成得到的,第二通讯密钥是密钥代理模块根据第一私钥和第二公钥生成得到的。第一公钥和第二公钥是密钥Agent在向密钥服务器发送密钥列表的拉取请求之前,生成的一对公钥pubkey和密钥prikey;第一私钥和第二私是密钥服务器生成的一对公钥pubkey和密钥prikey。In the embodiment of the present application, the key list extracted by the key agent is obtained by encrypting the key list by using the first communication key on the key server side, and then the key agent module decrypts the key list. The key list is decrypted using the same second communication key as the first communication key. Wherein the first communication key is a key server according to the first public key and the second private key The generated second communication key is generated by the key agent module according to the first private key and the second public key. The first public key and the second public key are a pair of public keys pubkey and key prikey generated by the key agent before sending the key list to the key server; the first private key and the second private key are secret A pair of public keys pubkey and key prikey generated by the key server.
需要说明的是,由于第一通讯密钥根据第一公钥和第二私钥生成得到的,第二通讯密钥是根据第一私钥和第二公钥生成得到的。因此,在密钥代理模块向密钥服务器发送密钥列表拉取请求之前,密钥Agent和密钥服务器之间需要交换双方的公钥和密钥。在交换之后,密钥代理模块就可以在向密钥服务器发送密钥列表拉取请求之后,生成用于对密钥列表进行解密的第二通讯密钥,密钥服务器也可以生成用于对密钥列表进行加密的第一通讯密钥。It should be noted that, since the first communication key is generated according to the first public key and the second private key, the second communication key is generated according to the first private key and the second public key. Therefore, before the key agent module sends the key list pull request to the key server, the key agent and the key server need to exchange the public key and the key of both parties. After the exchange, the key agent module may generate a second communication key for decrypting the key list after transmitting the key list pull request to the key server, and the key server may also generate the secret key. The key list is encrypted with the first communication key.
其中,交换双方的公钥和密钥具体为:Agent将第一公钥发送给密钥服务器SVR,然后,Agent从密钥服务器SVR中接收第二公钥,交换之后,Agent就可以使用第一私钥和第二公钥加密后的密钥列表进行解密。The public key and the key of the exchanged parties are specifically: the agent sends the first public key to the key server SVR, and then the agent receives the second public key from the key server SVR. After the exchange, the agent can use the first The private key and the second public key encrypted key list are decrypted.
需要说明的是,在本申请实施例中,Agent和密钥服务器在进行密钥交换时,可以采用密钥交换协议(即,ECDH协议)交换双方的pubkey和各自的prikey。It should be noted that, in the embodiment of the present application, when performing key exchange, the agent and the key server may exchange the pubkeys of the two parties and the respective prikeys by using a key exchange protocol (ie, an ECDH protocol).
通过上述描述可知,本申请中的密钥列表使用第一公钥和第二私钥进行加密,并使用第一私钥和第二公钥进行解密。然而,在相关技术中,网络上传递的只有Agent和密钥服务器的公钥pubkey,因此,采用本申请中的加密方式,即使被tcpdump也反推不出密钥,这样就避免了内网抓包导致的密钥泄漏的现象发生。As can be seen from the above description, the key list in the present application is encrypted using the first public key and the second private key, and decrypted using the first private key and the second public key. However, in the related art, only the public key pubkey of the Agent and the key server is transmitted on the network. Therefore, by using the encryption method in the present application, even if the key is reversed by the tcpdump, the intranet is avoided. The phenomenon of key leakage caused by the packet occurs.
密钥Agent在从密钥服务器中拉取到密钥列表,并对密钥列表进行解密之后,密钥Agent需要验证业务进程的合法性,其中,业务进程为待加密的数据所表示的进程。 After the key agent pulls the key list from the key server and decrypts the key list, the key agent needs to verify the legality of the business process, wherein the business process is a process represented by the data to be encrypted.
在本申请的另一个可选的实施方式中,密钥代理模块将第一公钥发送给密钥服务器,并从密钥服务器接收第二公钥包括:在密钥代理模块重启时,密钥代理模块将加密后的第一公钥发送给密钥服务器,其中,加密后的第一公钥是使用约定密钥对第一公钥进行加密得到的;密钥代理模块从密钥服务器接收加密后的第二公钥,其中,加密后的第二公钥是使用约定密钥对第二公钥进行加密得到的;密钥代理模块使用约定密钥对加密后的第二公钥进行解密,得到第二公钥;其中,约定密钥被设置为仅在密钥代理模块重启时使用。In another optional implementation manner of the present application, the key agent module sends the first public key to the key server, and receiving the second public key from the key server includes: when the key agent module is restarted, the key The proxy module sends the encrypted first public key to the key server, wherein the encrypted first public key is obtained by encrypting the first public key using the agreed key; the key proxy module receives the encryption from the key server a second public key, wherein the encrypted second public key is obtained by encrypting the second public key using the agreed key; the key proxy module decrypts the encrypted second public key by using the agreed key, A second public key is obtained; wherein the appointment key is set to be used only when the key broker module is restarted.
需要说明的是,当密钥Agent重启时,在密钥Agent向密钥服务器发送第一公钥时,需使用约定密钥对第一公钥进行加密,并将使用约定密钥加密之后的第一公钥发送给密钥服务器,其中,密钥服务器在获取到第一公钥之后,就可以使用约定密钥进行解密。相同地,密钥服务器在向密钥Agent发送第二公钥时,也使用约定密钥对第二公钥进行加密,并将加密之后的第二公钥发送至密钥Agent,其中,密钥Agent在接收到加密之后的第二公钥之后,就可以使用约定密钥对第二公钥进行解密。It should be noted that when the key agent is restarted, when the key agent sends the first public key to the key server, the first public key is encrypted by using the agreed key, and the first key is encrypted after using the agreed key. A public key is sent to the key server, and after the key server obtains the first public key, it can decrypt using the agreed key. Similarly, when the key server sends the second public key to the key agent, the second public key is also encrypted using the agreed key, and the encrypted second public key is sent to the key agent, where the key After receiving the second public key after encryption, the agent can decrypt the second public key using the agreed key.
需要说明的是,在本申请实施例中,只有在密钥Agent重启时才会使用“约定密钥”对第一公钥和第二公钥进行加密,并互相传输。也就是说,只有密钥Agent的维护者在变更密钥Agent时重启进程才是唯一合法使用约定密钥的时机,其它任何情形都是非法使用。例如,密钥Agent的维护者在密钥Agent重启时,使用了约定密钥获取密钥列表,在此之后,如果其他使用者再次使用约定密钥获取密钥列表时,表明该使用者为滥用者。因此,在本申请实施例中,仅在密钥Agent重启时才会使用一次“约定密钥”的设置,能够快速并有效地检测出滥用者。It should be noted that, in the embodiment of the present application, the first public key and the second public key are encrypted and transmitted to each other only when the key agent is restarted, using the “contract key”. That is to say, only the maintainer of the key agent restarts the process when changing the key agent is the only time to legally use the agreed key, and any other situation is illegal. For example, the maintainer of the key agent uses the contract key to obtain the key list when the key agent is restarted. After that, if other users use the agreed key again to obtain the key list, the user is abused. By. Therefore, in the embodiment of the present application, the setting of the "contract key" is used only when the key agent is restarted, and the abuser can be detected quickly and effectively.
由于从密钥服务器中获取到的密钥列表为加密的密钥列表,因此密钥Agent在拉取到密钥列表之后,需要对密钥列表进行解密。Since the key list obtained from the key server is an encrypted key list, the key agent needs to decrypt the key list after pulling the key list.
可选地,在密钥代理模块接收业务模块发送的加密请求之前,还可以 通过密钥代理模块获取业务进程的进程PID,其中,业务进程为业务模块发送待加密的数据的进程,然后,密钥代理模块对业务进程和进程PID进行合法性校验;以及在合法性校验通过的情况下,密钥代理模块从密钥列表中获取目标密钥。Optionally, before the key proxy module receives the encryption request sent by the service module, Obtaining, by the key agent module, a process PID of the business process, where the business process sends a process of the data to be encrypted for the service module, and then the key agent module performs legality verification on the business process and the process PID; and in the legality school In the case of passing, the key agent module obtains the target key from the key list.
在本申请实施例中,在对业务模块中待加密的数据所表示的业务进程进行加密之前,首先需要确定该业务进程的合法性。在对业务进程的合法性进行确定时,可以通过密钥Agent获取业务进程的进程PID,然后,通过密钥Agent对进程PID和业务进程的合法性进行校验。如果进程PID和业务进程的校验结果为合法时,即校验通过的情况下,密钥代理模块就可以从密钥列表中获取目标密钥,并通过该目标密钥对待加密的数据进行加密。In the embodiment of the present application, before encrypting the service process indicated by the data to be encrypted in the service module, it is first necessary to determine the legality of the service process. When the legality of the service process is determined, the process PID of the service process can be obtained through the key agent, and then the legality of the process PID and the service process is verified by the key agent. If the verification result of the process PID and the service process is legal, that is, if the verification is passed, the key agent module may obtain the target key from the key list, and encrypt the data to be encrypted by the target key. .
需要说明的是,在本申请实施例中,密钥代理模块可以获取业务模块通过套接字SCM_RIGHTS传输的业务进程被内核所认证的进程PID,其中,套接字SCM_RIGHTS适用于unix domain socket。It should be noted that, in the embodiment of the present application, the key proxy module may obtain the process PID that is authenticated by the kernel by the service module transmitted by the service module through the socket SCM_RIGHTS, wherein the socket SCM_RIGHTS is applicable to the unix domain socket.
进一步地,上述密钥代理模块对业务进程和进程PID进行合法性校验,具体为如下步骤:Further, the key proxy module performs legality verification on the service process and the process PID, which is specifically as follows:
步骤S1,密钥代理模块获取与进程PID对应的进程全路径;Step S1, the key agent module acquires a full path of the process corresponding to the process PID;
步骤S2,密钥代理模块判断进程全路径是否属于预先从密钥服务器获取到的合法路径中的路径;Step S2: The key agent module determines whether the full path of the process belongs to a path in a legal path acquired from the key server in advance;
步骤S3,在判断出进程全路径属于合法路径中的路径的情况下,密钥代理模块对业务进程进行MD5校验操作,得到第一MD5校验结果;在判断出进程全路径不属于合法路径中的路径的情况下,判断出合法性校验不通过;Step S3: In the case that it is determined that the path of the process belongs to the path in the legal path, the key agent module performs an MD5 check operation on the service process to obtain a first MD5 check result; and determines that the process full path does not belong to the legal path. In the case of the path in the middle, it is judged that the validity check is not passed;
步骤S4,密钥代理模块判断第一MD5校验结果是否与预先获取的与业务进程对应的第二MD5校验结果相同; In step S4, the key agent module determines whether the first MD5 check result is the same as the second MD5 check result corresponding to the service process acquired in advance;
步骤S5,若第一MD5校验结果与第二MD5校验结果相同,则判断出合法性校验通过;若第一MD5校验结果与第二MD5校验结果不同,则判断出合法性校验不通过。Step S5, if the first MD5 check result is the same as the second MD5 check result, it is determined that the validity check is passed; if the first MD5 check result is different from the second MD5 check result, the legality is determined. The test will not pass.
具体校验过程为:密钥代理模块首先获取与进程PID对应的进程全路径,然后,将进程全路径与预先从密钥服务器中获取到的合法路径中的路径进行判断。如果判断出进程全路径属于合法路径中的路径,那么继续通过密钥代理模块对业务进程的MD5进行校验,得到第一MD5校验结果;如果判断出进程全路径不属于合法路径中的路径,那么业务进程和进程PID的合法性校验不通过。接下来,继续判断第一MD5校验结果与预先获取到的第二MD5校验结果是否相同,其中,如果相同,那么合法性校验通过,如果不相同,合法性校验不通过。The specific verification process is as follows: the key agent module first obtains the full path of the process corresponding to the process PID, and then determines the path of the process and the path in the legal path obtained from the key server in advance. If it is determined that the path of the process belongs to the path in the legal path, the MD5 of the service process is verified by the key agent module to obtain the first MD5 check result; if it is determined that the path of the process does not belong to the path in the legal path Then, the validity check of the business process and process PID does not pass. Next, it is determined whether the first MD5 check result is the same as the pre-acquired second MD5 check result, wherein if the same, the legality check passes, and if not, the legality check fails.
可选地,在密钥代理模块对业务进程和进程PID进行合法性校验通过的情况下,密钥代理模块获取业务模块发送的第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据,然后,密钥代理模块生成第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据,最后,密钥代理模块将第二文件描述符传输给业务模块。Optionally, in a case that the key agent module passes the validity check of the service process and the process PID, the key agent module acquires the first file descriptor sent by the service module, where the first file descriptor is used for the secret The key agent module identifies the data sent by the service module as legal data, and then the key agent module generates a second file descriptor, wherein the second file descriptor is used by the service module to identify the data sent by the key agent module as legal data. Finally, the key agent module transmits the second file descriptor to the service module.
在校验业务进程合法性通过的情况下,需要密钥代理模块和业务模块之间交换文件描述符。具体地,密钥代理模块可以首先获取业务模块的第一文件描述符,在获取到第一文件描述符之后,密钥代理模块就可以对业务模块发送的数据进行识别为合法数据。到此为止,业务模块已向密钥代理模块交换文件描述符,那么就需要密钥代理模块向业务模块交换文件描述符。此时,密钥代理模块可以将生成的第二文件描述符传输给业务模块,业务模块在接收到第二文件描述符之后,就可以对密钥代理模块发送的数据进行识别为合法数据。In the case that the validity of the service process is verified, the file descriptor is exchanged between the key agent module and the service module. Specifically, the key agent module may first obtain the first file descriptor of the service module, and after obtaining the first file descriptor, the key agent module may identify the data sent by the service module as legal data. At this point, the business module has exchanged file descriptors with the key broker module, then the key broker module is required to exchange file descriptors with the business module. At this time, the key agent module may transmit the generated second file descriptor to the service module, and after receiving the second file descriptor, the service module may identify the data sent by the key agent module as legal data.
在本申请实施例中,第一文件描述符和第二文件描述符对应共享内存 中存储数据的数据块,其中,共享内存用于存储加密请求的待加密的数据和加密之后的待检加密的数据,将在下述实施例中进行详细描述。例如,当业务模块在共享内存存储待加密的数据时,是在第一文件描述符在共享内存中所对应的区域内存储待加密的数据。存储待加密的数据之后,密钥代理模块就能够获知业务模块在共享内存存储了待加密的数据,然后,密钥代理模块就会去该区域内获取待加密的数据。In the embodiment of the present application, the first file descriptor and the second file descriptor correspond to the shared memory. The data block in which the data is stored, wherein the shared memory is used to store the data to be encrypted for the encryption request and the data to be checked after the encryption, which will be described in detail in the following embodiments. For example, when the service module stores the data to be encrypted in the shared memory, the data to be encrypted is stored in the area corresponding to the first file descriptor in the shared memory. After storing the data to be encrypted, the key agent module can learn that the service module stores the data to be encrypted in the shared memory, and then the key agent module goes to the area to obtain the data to be encrypted.
需要说明的是,在本申请实施例中,可以一次性交换多个文件描述符eventfd,不够用时再次通过校验交换更多eventfd,这样就能明显减少校验请求的数目,申请人通过测试发现linux系统下一次性能交换的最大fd数目是255。在密钥代理模块和业务模块完成文件描述符的交换之后,就可以接收业务模块发送的加密请求,以对加密请求中的待加密的数据进行加密。It should be noted that, in the embodiment of the present application, multiple file descriptors eventfd can be exchanged at one time, and more eventfd is exchanged by verification again when not enough, so that the number of verification requests can be significantly reduced, and the applicant finds through testing. The maximum number of fd for the next performance exchange of the Linux system is 255. After the key agent module and the service module complete the exchange of the file descriptor, the encryption request sent by the service module may be received to encrypt the data to be encrypted in the encryption request.
进一步地,在密钥代理模块对业务进程和进程PID进行合法性校验通过的情况下,密钥代理模块还可以为第一文件描述符设置目标权限,其中,目标权限包括以下至少之一:允许密钥代理模块对业务模块请求的待加密的数据进行加密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。Further, in a case where the key agent module passes the validity check of the service process and the process PID, the key agent module may further set a target authority for the first file descriptor, where the target authority includes at least one of the following: The key agent module is allowed to encrypt the data to be encrypted requested by the service module, and the key agent module is allowed to decrypt the data to be decrypted requested by the service module.
具体地,在密钥代理模块对业务进程和进程PID进行合法性校验通过的情况下,密钥代理模块可以在交换文件描述符之后,为第一文件描述符设定目标权限,其中,设定的目标权限包括:允许密钥代理模块对业务模块请求的待加密的数据进行加密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。Specifically, in the case that the key agent module passes the validity check of the service process and the process PID, the key agent module may set the target authority for the first file descriptor after exchanging the file descriptor, where The specified target rights include: allowing the key agent module to encrypt the data to be encrypted requested by the service module, and allowing the key agent module to decrypt the data to be decrypted requested by the service module.
在密钥代理模块对第一文件描述符设置完成目标权限之后,密钥代理模块就可以根据接收到的加密请求对待加密的数据进行加密,然后,将加密之后的数据发送给业务模块。After the key agent module sets the target permission for the first file descriptor, the key agent module can encrypt the data to be encrypted according to the received encryption request, and then send the encrypted data to the service module.
其中,密钥代理模块接收业务模块发送的加密请求包括:密钥代理模 块从共享内存中获取业务模块存入的待加密的数据;以及密钥代理模块将加密后的数据发送给业务模块包括:密钥代理模块将加密后的数据存入到共享内存中,以使得业务模块从共享内存中获取加密后的数据。The key agent module receives the encryption request sent by the service module, including: a key proxy module. The block obtains the data to be encrypted stored by the service module from the shared memory; and the key agent module sends the encrypted data to the service module, including: the key agent module stores the encrypted data into the shared memory, so that The business module obtains the encrypted data from the shared memory.
业务模块在向密钥代理模块发送加密请求时,会将加密请求存入到共享内存中。在此之后,密钥代理模块就可以从共享内存中获取已存储的待加密的数据。相同地,当密钥代理模块使用目标密钥对待加密的数据的进行加密处理之后,还可以将加密处理之后的待加密的数据同样存入共享内存中。使得业务模块可以从共享内存中获取加密后的数据。When the business module sends an encryption request to the key broker module, the encryption request is stored in the shared memory. After that, the key broker module can retrieve the stored data to be encrypted from the shared memory. Similarly, after the key agent module encrypts the data to be encrypted using the target key, the data to be encrypted after the encryption process may also be stored in the shared memory. Enables the business module to obtain encrypted data from shared memory.
通过上述描述可知,在本申请实施例中,密钥代理模块已预先为第一文件描述符设置目标权限,在此情况下,如果合法性校验通过,那么密钥代理模块从密钥列表中获取目标密钥,具体为:在目标权限包括允许密钥代理模块对业务模块请求的待加密的数据进行加密时,密钥代理模块从密钥列表中获取目标密钥包。As can be seen from the above description, in the embodiment of the present application, the key agent module has previously set a target authority for the first file descriptor. In this case, if the validity check is passed, the key agent module is from the key list. Obtaining the target key, specifically: when the target authority includes the key agent module to encrypt the data to be encrypted requested by the service module, the key agent module obtains the target key package from the key list.
需要说明的是,由于目标权限可以为仅允许密钥代理模块对业务模块请求的待解密的数据进行解密或者允许密钥代理模块对业务模块请求的待加密的数据进行加密。因此,密钥代理模块只有在确定出目标权限为允许密钥代理模块对业务模块请求的待加密的数据进行加密时,才可以从密钥列表中获取目标密钥,并使用获取到的目标密钥对待加密的数据进行加密。It should be noted that, because the target authority may only allow the key agent module to decrypt the data to be decrypted requested by the service module or allow the key agent module to encrypt the data to be encrypted requested by the service module. Therefore, the key agent module can obtain the target key from the key list only when it is determined that the target authority is to allow the key agent module to encrypt the data to be encrypted requested by the service module, and use the obtained target secret. The key encrypts the encrypted data.
在本申请实施例的一个可选实施方式中,密钥代理模块获取业务进程的进程PID包括:密钥代理模块在非root运行模式下通过unix域套接字获取业务进程的进程PID;或者密钥代理模块将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的进程PID。In an optional implementation manner of the embodiment of the present application, the process PID of the key agent module acquiring the service process includes: obtaining, by the key agent module, the process PID of the service process through the unix domain socket in the non-root operation mode; or The key proxy module configures the socket socket option as SO_PEERCRED and obtains the process PID of the business process through the socket socket.
在本申请实施例中,进程PID是通过unix域套接字中的套接字SCM_RIGHTS传输。由于unix域套接字传递准确进程PID的前提是非root模式运行的进程,因此,在传递进程PID之前,必须对本机root模式的需 求进行审批。也即,需要在非root运行模式下通过unix域套接字获取业务进程的进程PID。进一步地,还可以通过密钥代理模块将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的进程PID。In the embodiment of the present application, the process PID is transmitted through the socket SCM_RIGHTS in the unix domain socket. Because the unix domain sockets pass the exact process PID is based on the non-root mode running process, therefore, before the process PID is passed, the local root mode must be required. Seek approval. That is, the process PID of the business process needs to be obtained through the unix domain socket in the non-root mode. Further, the option of the socket socket can be configured as SO_PEERCRED through the key proxy module, and the process PID of the business process can be obtained through the socket socket.
综上,在本申请实施例中,通过密钥Agent间接加解密待加密的数据;同时,业务模块和密钥Agent之间的通讯可以是任何标准linux IPC通讯手段,包括但不限于管道,unix socket pair,本地磁盘文件等,本方案采取的linux eventfd是效率最高,最适合于海量加解密请求的选择。本方法通过充分利用现代linux操作系统内核提供的标准机制来实现加解密程序,既提高了密钥的安全性,同时又最大限度的减少了加解密性能损失,确保在实践中的有效性。In summary, in the embodiment of the present application, the data to be encrypted is indirectly encrypted and decrypted by the key agent; at the same time, the communication between the service module and the key agent may be any standard linux IPC communication means, including but not limited to a pipeline, Unix Socket pair, local disk file, etc., the linux eventfd adopted by this scheme is the most efficient, and is most suitable for the selection of massive encryption and decryption requests. The method realizes the encryption and decryption program by fully utilizing the standard mechanism provided by the modern Linux operating system kernel, which not only improves the security of the key, but also minimizes the loss of encryption and decryption performance, and ensures the effectiveness in practice.
根据本申请实施例,在密文处理请为用于将密文数据解密为解密数据的请求的情况下,提供了一种业务解密的方法实施例。According to an embodiment of the present application, in the case where the ciphertext processing is a request for decrypting ciphertext data into decrypted data, an embodiment of a method of service decryption is provided.
图8是根据本申请实施例的一种可选的业务解密方法的流程图,如图8所示,该方法可以包括以下步骤:FIG. 8 is a flowchart of an optional service decryption method according to an embodiment of the present application. As shown in FIG. 8, the method may include the following steps:
步骤S802,密钥代理模块接收业务模块发送的解密请求,其中,解密请求中携带有待解密的数据。Step S802, the key agent module receives the decryption request sent by the service module, where the decryption request carries data to be decrypted.
在本申请实施例中,密钥代理模块(以下均称为Agent)可以采用单进程多线程的方式实现;业务模块设置为向Agent发送解密请求,其中,Agent行业业务模块处于同一个物理单机中。In the embodiment of the present application, the key agent module (hereinafter referred to as an agent) may be implemented in a single-process multi-thread manner; the service module is configured to send a decryption request to the agent, wherein the agent industry service module is in the same physical single machine. .
具体地,当有业务需要进行解密时,业务模块可以向Agent发送携带待解密的数据的解密请求;Agent在获取到解密请求之后,就可以执行下述步骤S804,即根据解密请求在密钥列表中获取目标密钥。Specifically, when there is a service that needs to be decrypted, the service module may send a decryption request carrying the data to be decrypted to the agent; after acquiring the decryption request, the agent may perform the following step S804, that is, according to the decryption request in the key list. Get the target key.
步骤S804,密钥代理模块从密钥列表中获取目标密钥,其中,密钥列表是预先从密钥服务器中拉取到的。 Step S804, the key agent module acquires the target key from the key list, wherein the key list is previously extracted from the key server.
在本申请实施例中,当密钥代理模块Agent重启时,Agent会向密钥服务器拉取密钥列表。需要说明的是,Agent仅在重新启动时,向密钥服务器拉取密钥列表,在启动后的其他时间内不再拉取密钥列表。In the embodiment of the present application, when the key agent module Agent is restarted, the agent pulls the key list to the key server. It should be noted that the agent only pulls the key list to the key server when restarting, and does not pull the key list at other times after startup.
Agent在获取到业务模块发送的解密请求之后,就可以在预先拉取的密钥列表中获取目标密钥,其中,该目标密钥用于对待解密的数据进行解密。After obtaining the decryption request sent by the service module, the agent may acquire the target key in the pre-pushed key list, where the target key is used to decrypt the data to be decrypted.
步骤S806,密钥代理模块使用目标密钥对待解密的数据进行解密,得到解密后的数据。Step S806, the key agent module decrypts the data to be decrypted using the target key to obtain the decrypted data.
在本申请实施例中,Agent在从密钥列表中获取到目标密钥之后,就可以对使用目标密钥对待解密的数据进行解密。In the embodiment of the present application, after acquiring the target key from the key list, the Agent may decrypt the data to be decrypted using the target key.
步骤S808,密钥代理模块将解密后的数据发送给业务模块。Step S808, the key agent module sends the decrypted data to the service module.
在本申请实施例中,密钥代理模块在使用目标密钥对待解密的数据进行解密,得到解密之后的数据之后,就可以将解密后的数据发送给业务模块。In the embodiment of the present application, the key agent module decrypts the data to be decrypted using the target key, and after obtaining the decrypted data, the decrypted data can be sent to the service module.
通过上述步骤S802至步骤S808,通过密钥代理模块接收解密请求,然后,根据密钥请求获取目标密钥,接下来,通过目标密钥对待解密的数据进行解密,本申请实施例中提供的业务解密方式,达到了更加安全地为业务进行解密的目的,从而实现了提高了对业务进行解密时密钥安全性的技术效果,进而解决了相关技术中在对业务进行解密时密钥的安全性较低的技术问题。Through the above steps S802 to S808, the decryption request is received by the key agent module, and then the target key is acquired according to the key request, and then the data to be decrypted by the target key is decrypted, and the service provided in the embodiment of the present application is provided. The decryption method achieves the purpose of decrypting the service more securely, thereby realizing the technical effect of improving the key security when decrypting the service, thereby solving the security of the key in decrypting the service in the related art. Lower technical issues.
可选地,在密钥代理模块接收业务模块发送的解密请求之前,还包括:密钥代理模块将第一公钥发送给密钥服务器,并从密钥服务器接收第二公钥,其中,密钥代理模块上具有一对第一公钥和第一私钥,密钥服务器上具有一对第二公钥和第二私钥;密钥代理模块向密钥服务器发送密钥列表拉取请求;密钥代理模块接收密钥服务器发送的加密后的密钥列表,其中, 加密后的密钥列表是使用密钥服务器侧的第一通讯密钥对密钥列表进行加密得到的,第一通讯密钥是密钥服务器根据第一公钥和第二私钥生成得到的;密钥代理模块使用密钥代理模块侧的第二通讯密钥对加密后的密钥列表进行解密,得到密钥列表,其中,第二通讯密钥是密钥代理模块根据第一私钥和第二公钥生成得到的,第一通讯密钥与第二通讯密钥相同。Optionally, before the key proxy module receives the decryption request sent by the service module, the method further includes: the key proxy module sending the first public key to the key server, and receiving the second public key from the key server, where The key agent module has a pair of first public key and a first private key, and the key server has a pair of second public key and a second private key; the key agent module sends a key list pull request to the key server; The key agent module receives the encrypted key list sent by the key server, where The encrypted key list is obtained by encrypting the key list by using the first communication key on the key server side, and the first communication key is generated by the key server according to the first public key and the second private key; The key agent module decrypts the encrypted key list by using the second communication key on the key agent module side to obtain a key list, wherein the second communication key is a key agent module according to the first private key and the first The second public key is generated by the second public key, and the first communication key is the same as the second communication key.
在本申请实施例中,在密钥Agent接收解密请求之前,需要从密钥服务器拉取密钥列表,其中,由于从密钥服务器拉取到的密钥列表为加密之后的密钥列表。因此,密钥Agent需要对拉取到的密钥列表进行解密。In the embodiment of the present application, before the key Agent receives the decryption request, the key list needs to be pulled from the key server, wherein the key list pulled from the key server is the encrypted key list. Therefore, the key agent needs to decrypt the extracted key list.
在本申请实施例中,密钥Agent拉取到的密钥列表是使用密钥服务器侧的第一通讯密钥对密钥列表进行加密得到的,那么密钥代理模块在对密钥列表进行解密时,需使用与第一通讯密钥相同的第二通讯密钥对密钥列表进行解密。其中,第一通讯密钥是密钥服务器根据第一公钥和第二私钥生成得到的,第二通讯密钥是密钥代理模块根据第一私钥和第二公钥生成得到的。第一公钥和第二公钥是密钥Agent在向密钥服务器发送密钥列表的拉取请求之前,生成的一对公钥pubkey和密钥prikey;第一私钥和第二私是密钥服务器生成的一对公钥pubkey和密钥prikey。In the embodiment of the present application, the key list extracted by the key agent is obtained by encrypting the key list by using the first communication key on the key server side, and then the key agent module decrypts the key list. The key list is decrypted using the same second communication key as the first communication key. The first communication key is generated by the key server according to the first public key and the second private key, and the second communication key is generated by the key agent module according to the first private key and the second public key. The first public key and the second public key are a pair of public keys pubkey and key prikey generated by the key agent before sending the key list to the key server; the first private key and the second private key are secret A pair of public keys pubkey and key prikey generated by the key server.
需要说明的是,由于第一通讯密钥根据第一公钥和第二私钥生成得到的,第二通讯密钥是根据第一私钥和第二公钥生成得到的。因此,在密钥代理模块向密钥服务器发送密钥列表拉取请求之前,密钥Agent和密钥服务器之间需要交换双方的公钥和密钥。在交换之后,密钥代理模块就可以在向密钥服务器发送密钥列表拉取请求之后,生成用于对密钥列表进行解密的第二通讯密钥,密钥服务器也可以生成用于对密钥列表进行加密的第一通讯密钥。It should be noted that, since the first communication key is generated according to the first public key and the second private key, the second communication key is generated according to the first private key and the second public key. Therefore, before the key agent module sends the key list pull request to the key server, the key agent and the key server need to exchange the public key and the key of both parties. After the exchange, the key agent module may generate a second communication key for decrypting the key list after transmitting the key list pull request to the key server, and the key server may also generate the secret key. The key list is encrypted with the first communication key.
其中,交换双方的公钥和密钥具体为:Agent将第一公钥发送给密钥服务器SVR,然后,Agent从密钥服务器SVR中接收第二公钥,交换之后,Agent就可以使用第一私钥和第二公钥加密后的密钥列表进行解密。 The public key and the key of the exchanged parties are specifically: the agent sends the first public key to the key server SVR, and then the agent receives the second public key from the key server SVR. After the exchange, the agent can use the first The private key and the second public key encrypted key list are decrypted.
需要说明的是,在本申请实施例中,Agent和密钥服务器在进行密钥交换时,可以采用密钥交换协议(即,ECDH协议)交换双方的pubkey和各自的prikey。It should be noted that, in the embodiment of the present application, when performing key exchange, the agent and the key server may exchange the pubkeys of the two parties and the respective prikeys by using a key exchange protocol (ie, an ECDH protocol).
通过上述描述可知,本申请中的密钥列表使用第一公钥和第二私钥进行加密,并使用第一私钥和第二公钥进行解密。然而,在相关技术中,网络上传递的只有Agent和密钥服务器的公钥pubkey,因此,采用本申请中的加密方式,即使被tcpdump也反推不出密钥,这样就避免了内网抓包导致的密钥泄漏的现象发生。As can be seen from the above description, the key list in the present application is encrypted using the first public key and the second private key, and decrypted using the first private key and the second public key. However, in the related art, only the public key pubkey of the Agent and the key server is transmitted on the network. Therefore, by using the encryption method in the present application, even if the key is reversed by the tcpdump, the intranet is avoided. The phenomenon of key leakage caused by the packet occurs.
密钥Agent在从密钥服务器中拉取到密钥列表,并对密钥列表进行解密之后,密钥Agent需要验证业务进程的合法性,其中,业务进程为待解密的数据所表示的进程。After the key agent pulls the key list from the key server and decrypts the key list, the key agent needs to verify the legality of the business process, wherein the business process is the process represented by the data to be decrypted.
在本申请的一个可选实施方式中,密钥代理模块将第一公钥发送给密钥服务器,并从密钥服务器接收第二公钥包括:在密钥代理模块重启时,密钥代理模块将加密后的第一公钥发送给密钥服务器,其中,加密后的第一公钥是使用约定密钥对第一公钥进行加密得到的;密钥代理模块从密钥服务器接收加密后的第二公钥,其中,加密后的第二公钥是使用约定密钥对第二公钥进行加密得到的;密钥代理模块使用约定密钥对加密后的第二公钥进行解密,得到第二公钥;其中,约定密钥被设置为仅在密钥代理模块重启时使用。In an optional implementation manner of the present application, the key agent module sends the first public key to the key server, and receiving the second public key from the key server includes: when the key agent module is restarted, the key agent module Sending the encrypted first public key to the key server, wherein the encrypted first public key is obtained by encrypting the first public key by using the agreed key; the key agent module receives the encrypted version from the key server a second public key, wherein the encrypted second public key is obtained by encrypting the second public key by using the contract key; the key proxy module decrypts the encrypted second public key by using the agreed key, and obtains the first A public key; wherein the appointment key is set to be used only when the key broker module is restarted.
需要说明的是,当密钥Agent重启时,在密钥Agent向密钥服务器发送第一公钥时,需使用约定密钥对第一公钥进行加密,并将使用约定密钥加密之后的第一公钥发送给密钥服务器,其中,密钥服务器在获取到第一公钥之后,就可以使用约定密钥进行解密。相同地,密钥服务器在向密钥Agent发送第二公钥时,也使用约定密钥对第二公钥进行加密,并将加密之后的第二公钥发送至密钥Agent,其中,密钥Agent在接收到加密之后的第二公钥之后,就可以使用约定密钥对第二公钥进行解密。 It should be noted that when the key agent is restarted, when the key agent sends the first public key to the key server, the first public key is encrypted by using the agreed key, and the first key is encrypted after using the agreed key. A public key is sent to the key server, and after the key server obtains the first public key, it can decrypt using the agreed key. Similarly, when the key server sends the second public key to the key agent, the second public key is also encrypted using the agreed key, and the encrypted second public key is sent to the key agent, where the key After receiving the second public key after encryption, the agent can decrypt the second public key using the agreed key.
需要说明的是,在本申请实施例中,只有在密钥Agent重启时才会使用“约定密钥”对第一公钥和第二公钥进行加密,并互相传输。也就是说,只有密钥Agent的维护者在变更密钥Agent时重启进程才是唯一合法使用约定密钥的时机,其它任何情形都是非法使用。例如,密钥Agent的维护者在密钥Agent重启时,使用了约定密钥获取密钥列表,在此之后,如果其他使用者再次使用约定密钥获取密钥列表时,表明该使用者为滥用者。因此,在本申请实施例中,仅在密钥Agent重启时才会使用一次“约定密钥”的设置,能够快速并有效地检测出滥用者。It should be noted that, in the embodiment of the present application, the first public key and the second public key are encrypted and transmitted to each other only when the key agent is restarted, using the “contract key”. That is to say, only the maintainer of the key agent restarts the process when changing the key agent is the only time to legally use the agreed key, and any other situation is illegal. For example, the maintainer of the key agent uses the contract key to obtain the key list when the key agent is restarted. After that, if other users use the agreed key again to obtain the key list, the user is abused. By. Therefore, in the embodiment of the present application, the setting of the "contract key" is used only when the key agent is restarted, and the abuser can be detected quickly and effectively.
由于从密钥服务器中获取到的密钥列表为加密的密钥列表,因此密钥Agent在拉取到密钥列表之后,需要对密钥列表进行解密。Since the key list obtained from the key server is an encrypted key list, the key agent needs to decrypt the key list after pulling the key list.
在本申请的一个可选实施方式中,在密钥代理模块接收业务模块发送的解密请求之前,还包括:密钥代理模块获取业务进程的进程PID,其中,业务进程为业务模块发送待解密的数据的进程;密钥代理模块对业务进程和进程PID进行合法性校验;密钥代理模块从密钥列表中获取目标密钥包括:在合法性校验通过的情况下,密钥代理模块从密钥列表中获取目标密钥。In an optional implementation manner of the present application, before the key proxy module receives the decryption request sent by the service module, the method further includes: the key proxy module acquiring the process PID of the service process, where the service process sends the service module to be decrypted. The process of the data; the key agent module checks the legality of the business process and the process PID; the key agent module obtains the target key from the key list, including: in the case that the legality check passes, the key agent module Get the target key in the key list.
在本申请实施例中,在对业务模块中待解密的数据所表示的业务进程进行解密之前,首先需要确定该业务进程的合法性。在对业务进程的合法性进行确定时,可以通过密钥Agent获取业务进程的进程PID,然后,通过密钥Agent对进程PID和业务进程的合法性进行校验。如果进程PID和业务进程的校验结果为合法时,即校验通过的情况下,密钥代理模块就可以从密钥列表中获取目标密钥,并通过该目标密钥对待解密的数据进行解密。In the embodiment of the present application, before decrypting the service process represented by the data to be decrypted in the service module, it is first necessary to determine the legality of the service process. When the legality of the service process is determined, the process PID of the service process can be obtained through the key agent, and then the legality of the process PID and the service process is verified by the key agent. If the verification result of the process PID and the service process is legal, that is, if the verification is passed, the key agent module may obtain the target key from the key list, and decrypt the data to be decrypted by the target key. .
需要说明的是,在本申请实施例中,密钥代理模块可以获取业务模块通过套接字SCM_RIGHTS传输的业务进程被内核所认证的进程PID,其中,套接字SCM_RIGHTS适用于unix domain socket。 It should be noted that, in the embodiment of the present application, the key proxy module may obtain the process PID that is authenticated by the kernel by the service module transmitted by the service module through the socket SCM_RIGHTS, wherein the socket SCM_RIGHTS is applicable to the unix domain socket.
在本申请的一个可选实施方式中,密钥代理模块对业务进程和进程PID进行合法性校验包括:密钥代理模块获取与进程PID对应的进程全路径;密钥代理模块判断进程全路径是否属于预先从密钥服务器获取到的合法路径中的路径;在判断出进程全路径属于合法路径中的路径的情况下,密钥代理模块对业务进程进行MD5校验操作,得到第一MD5校验结果;在判断出进程全路径不属于合法路径中的路径的情况下,判断出合法性校验不通过;密钥代理模块判断第一MD5校验结果是否与预先获取的与业务进程对应的第二MD5校验结果相同;若第一MD5校验结果与第二MD5校验结果相同,则判断出合法性校验通过;若第一MD5校验结果与第二MD5校验结果不同,则判断出合法性校验不通过。In an optional implementation manner of the present application, the key agent module performs legality verification on the service process and the process PID, including: the key agent module acquires a full path of the process corresponding to the process PID; and the key agent module determines the full path of the process. Whether it belongs to the path in the legal path obtained from the key server in advance; if it is determined that the path of the process belongs to the path in the legal path, the key agent module performs the MD5 check operation on the service process to obtain the first MD5 school. If the process full path does not belong to the path in the legal path, it is determined that the validity check fails; the key agent module determines whether the first MD5 check result is corresponding to the pre-acquired service process. The second MD5 check result is the same; if the first MD5 check result is the same as the second MD5 check result, it is determined that the validity check is passed; if the first MD5 check result is different from the second MD5 check result, then It is judged that the legality check fails.
具体校验过程为:密钥代理模块首先获取与进程PID对应的进程全路径,然后,将进程全路径与预先从密钥服务器中获取到的合法路径中的路径进行判断。如果判断出进程全路径属于合法路径中的路径,那么继续通过密钥代理模块对业务进程的MD5进行校验,得到第一MD5校验结果;如果判断出进程全路径不属于合法路径中的路径,那么业务进程和进程PID的合法性校验不通过。接下来,继续判断第一MD5校验结果与预先获取到的第二MD5校验结果是否相同,其中,如果相同,那么合法性校验通过,如果不相同,合法性校验不通过。The specific verification process is as follows: the key agent module first obtains the full path of the process corresponding to the process PID, and then determines the path of the process and the path in the legal path obtained from the key server in advance. If it is determined that the path of the process belongs to the path in the legal path, the MD5 of the service process is verified by the key agent module to obtain the first MD5 check result; if it is determined that the path of the process does not belong to the path in the legal path Then, the validity check of the business process and process PID does not pass. Next, it is determined whether the first MD5 check result is the same as the pre-acquired second MD5 check result, wherein if the same, the legality check passes, and if not, the legality check fails.
在本申请的一个可选实施方式中,在密钥代理模块对业务进程和进程PID进行合法性校验之后,并在密钥代理模块接收业务模块发送的解密请求之前,还包括:在合法性校验通过的情况下,密钥代理模块获取业务模块发送的第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据;密钥代理模块生成第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据;密钥代理模块将第二文件描述符传输给业务模块。In an optional implementation manner of the present application, after the key agent module performs the validity check on the service process and the process PID, and before the key agent module receives the decryption request sent by the service module, the method further includes: When the verification passes, the key agent module acquires the first file descriptor sent by the service module, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal data; the key agent module Generating a second file descriptor, wherein the second file descriptor is used by the service module to identify data sent by the key agent module as legitimate data; and the key agent module transmits the second file descriptor to the service module.
在校验业务进程合法性通过的情况下,需要密钥代理模块和业务模块 之间交换文件描述符。具体地,密钥代理模块可以首先获取业务模块的第一文件描述符,在获取到第一文件描述符之后,密钥代理模块就可以对业务模块发送的数据进行识别为合法数据。到此为止,业务模块已向密钥代理模块交换文件描述符,那么就需要密钥代理模块向业务模块交换文件描述符。此时,密钥代理模块可以将生成的第二文件描述符传输给业务模块,业务模块在接收到第二文件描述符之后,就可以对密钥代理模块发送的数据进行识别为合法数据。In the case of verifying the legality of the service process, the key agent module and the service module are required. Exchange file descriptors between. Specifically, the key agent module may first obtain the first file descriptor of the service module, and after obtaining the first file descriptor, the key agent module may identify the data sent by the service module as legal data. At this point, the business module has exchanged file descriptors with the key broker module, then the key broker module is required to exchange file descriptors with the business module. At this time, the key agent module may transmit the generated second file descriptor to the service module, and after receiving the second file descriptor, the service module may identify the data sent by the key agent module as legal data.
在本申请实施例中,第一文件描述符和第二文件描述符对应共享内存中存储数据的数据块,其中,共享内存用于存储解密请求的待解密的数据和解密之后的待检解密的数据,将在下述实施例中进行详细描述。例如,当业务模块在共享内存存储待解密的数据时,是在第一文件描述符在共享内存中所对应的区域内存储待解密的数据。存储待解密的数据之后,密钥代理模块就能够获知业务模块在共享内存存储了待解密的数据,然后,密钥代理模块就会去该区域内获取待解密的数据。In the embodiment of the present application, the first file descriptor and the second file descriptor correspond to a data block that stores data in the shared memory, where the shared memory is used to store the data to be decrypted of the decryption request and the to-be-decrypted after decryption. The data will be described in detail in the following examples. For example, when the service module stores the data to be decrypted in the shared memory, the data to be decrypted is stored in the area corresponding to the first file descriptor in the shared memory. After storing the data to be decrypted, the key agent module can learn that the service module stores the data to be decrypted in the shared memory, and then the key agent module goes to the area to obtain the data to be decrypted.
需要说明的是,在本申请实施例中,可以一次性交换多个文件描述符eventfd,不够用时再次通过校验交换更多eventfd,这样就能明显减少校验请求的数目,申请人通过测试发现linux系统下一次性能交换的最大fd数目是255。在密钥代理模块和业务模块完成文件描述符的交换之后,就可以接收业务模块发送的解密请求,以对解密请求中的待解密的数据进行解密。It should be noted that, in the embodiment of the present application, multiple file descriptors eventfd can be exchanged at one time, and more eventfd is exchanged by verification again when not enough, so that the number of verification requests can be significantly reduced, and the applicant finds through testing. The maximum number of fd for the next performance exchange of the Linux system is 255. After the key agent module and the service module complete the exchange of the file descriptor, the decryption request sent by the service module may be received to decrypt the data to be decrypted in the decryption request.
进一步地,在密钥代理模块对业务进程和进程PID进行合法性校验通过的情况下,密钥代理模块还可以为第一文件描述符设置目标权限,其中,目标权限包括以下至少之一:允许密钥代理模块对业务模块请求的待解密的数据进行解密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。Further, in a case where the key agent module passes the validity check of the service process and the process PID, the key agent module may further set a target authority for the first file descriptor, where the target authority includes at least one of the following: The key agent module is allowed to decrypt the data to be decrypted requested by the service module, and the key agent module is allowed to decrypt the data to be decrypted requested by the service module.
具体地,在密钥代理模块对业务进程和进程PID进行合法性校验通过 的情况下,密钥代理模块可以在交换文件描述符之后,为第一文件描述符设定目标权限,其中,设定的目标权限包括:允许密钥代理模块对业务模块请求的待解密的数据进行解密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。Specifically, the key agent module performs legality verification on the service process and the process PID. In the case that the key agent module can set the target authority for the first file descriptor after exchanging the file descriptor, the set target authority includes: the data to be decrypted requested by the key agent module to the service module. Decryption is performed to allow the key agent module to decrypt the data to be decrypted requested by the service module.
在密钥代理模块对第一文件描述符设置完成目标权限之后,密钥代理模块就可以根据接收到的解密请求对待解密的数据进行解密,然后,将解密之后的数据发送给业务模块。After the key agent module sets the target permission for the first file descriptor, the key agent module can decrypt the data to be decrypted according to the received decryption request, and then send the decrypted data to the service module.
其中,密钥代理模块接收业务模块发送的解密请求包括:密钥代理模块从共享内存中获取业务模块存入的待解密的数据;以及密钥代理模块将解密后的数据发送给业务模块包括:密钥代理模块将解密后的数据存入到共享内存中,以使得业务模块从共享内存中获取解密后的数据。The key agent module receives the decryption request sent by the service module, and the key agent module obtains the data to be decrypted stored by the service module from the shared memory, and the key agent module sends the decrypted data to the service module, including: The key agent module stores the decrypted data into the shared memory, so that the service module obtains the decrypted data from the shared memory.
业务模块在向密钥代理模块发送解密请求时,会将解密请求存入到共享内存中。在此之后,密钥代理模块就可以从共享内存中获取已存储的待解密的数据。相同地,当密钥代理模块使用目标密钥对待解密的数据的进行解密处理之后,还可以将解密处理之后的待解密的数据同样存入共享内存中。使得业务模块可以从共享内存中获取解密后的数据。When the business module sends a decryption request to the key broker module, the decryption request is stored in the shared memory. After that, the key agent module can retrieve the stored data to be decrypted from the shared memory. Similarly, after the key agent module decrypts the data to be decrypted using the target key, the data to be decrypted after the decryption process can also be stored in the shared memory. Enables the business module to retrieve the decrypted data from the shared memory.
通过上述描述可知,在本申请实施例中,密钥代理模块已预先为第一文件描述符设置目标权限,在此情况下,如果合法性校验通过,那么密钥代理模块从密钥列表中获取目标密钥,具体为:在目标权限包括允许密钥代理模块对业务模块请求的待解密的数据进行解密时,密钥代理模块从密钥列表中获取目标密钥包。As can be seen from the above description, in the embodiment of the present application, the key agent module has previously set a target authority for the first file descriptor. In this case, if the validity check is passed, the key agent module is from the key list. Obtaining the target key, specifically: when the target authority includes the key agent module to decrypt the data to be decrypted requested by the service module, the key agent module obtains the target key package from the key list.
需要说明的是,由于目标权限可以为仅允许密钥代理模块对业务模块请求的待解密的数据进行解密或者允许密钥代理模块对业务模块请求的待解密的数据进行解密。因此,密钥代理模块只有在确定出目标权限为允许密钥代理模块对业务模块请求的待解密的数据进行解密时,才可以从密钥列表中获取目标密钥,并使用获取到的目标密钥对待解密的数据进行解 密。It should be noted that, because the target authority may only allow the key agent module to decrypt the data to be decrypted requested by the service module or allow the key agent module to decrypt the data to be decrypted requested by the service module. Therefore, the key agent module can obtain the target key from the key list only when determining that the target authority is to allow the key agent module to decrypt the data to be decrypted requested by the service module, and use the obtained target secret. Key to solve the decrypted data dense.
在本申请的一个可选实施方式中,密钥代理模块获取业务进程的进程PID包括:密钥代理模块在非root运行模式下通过unix域套接字获取业务进程的进程PID;或者,密钥代理模块将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的进程PID。In an optional implementation manner of the present application, the process PID of the key agent module acquiring the service process includes: obtaining, by the key agent module, the process PID of the service process through the unix domain socket in the non-root operation mode; or, the key The proxy module configures the socket socket option as SO_PEERCRED and obtains the process PID of the business process through the socket socket.
在本申请实施例中,进程PID是通过unix域套接字中的套接字SCM_RIGHTS传输。由于unix域套接字传递准确进程PID的前提是非root模式运行的进程,因此,在传递进程PID之前,必须对本机root模式的需求进行审批。也即,需要在非root运行模式下通过unix域套接字获取业务进程的进程PID。进一步地,还可以通过密钥代理模块将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的进程PID。In the embodiment of the present application, the process PID is transmitted through the socket SCM_RIGHTS in the unix domain socket. Because the unix domain sockets pass the exact process PID is based on the non-root mode running process, the local root mode must be approved before the process PID is passed. That is, the process PID of the business process needs to be obtained through the unix domain socket in the non-root mode. Further, the option of the socket socket can be configured as SO_PEERCRED through the key proxy module, and the process PID of the business process can be obtained through the socket socket.
需要说明的是,在本申请实施例提供的业务解密方法中,与图7中的业务加密方法的过程相同。因此,在本申请实施例中,将不再对业务解密方法进行赘述。It should be noted that, in the service decryption method provided by the embodiment of the present application, the process is the same as the process of the service encryption method in FIG. 7. Therefore, in the embodiment of the present application, the service decryption method will not be described again.
下面将结合具体实施例对本申请提供的业务加密的方法进行说明。The method for encrypting the service provided by the present application will be described below in conjunction with specific embodiments.
图9是根据本申请实施例的一种可选的业务加密方法的流程图,如图9所示,密钥Agent和业务模块处于同一个物理单机中。FIG. 9 is a flowchart of an optional service encryption method according to an embodiment of the present application. As shown in FIG. 9, the key agent and the service module are in the same physical single machine.
在本申请实施例中,在密钥Agent重启时,密钥Agent使用约定密钥对第一公钥进行加密,并将加密之后的第一公钥发送至密钥服务器,密钥代理模块还可以接收密钥服务器发送的已加密的第二公钥,其中,第二公钥也采用约定密钥进行加密。密钥Agent在获取到第二公钥之后,使用约定密钥对第二公钥进行解密,密钥服务器在获取到第一公钥之后,也使用约定密钥对第一公钥进行解密。In the embodiment of the present application, when the key agent is restarted, the key agent encrypts the first public key by using the contract key, and sends the encrypted first public key to the key server, and the key agent module can also Receiving the encrypted second public key sent by the key server, wherein the second public key is also encrypted by using the agreed key. After obtaining the second public key, the key agent decrypts the second public key by using the agreed key. After obtaining the first public key, the key server also decrypts the first public key by using the agreed key.
接下来,密钥Agent就可以向密钥服务器发送密钥列表的拉取请求, 密钥服务器在接收到密钥拉取请求之后,将向密钥Agent传输加密后的密钥列表,其中,加密后的密钥列表是使用密钥服务器侧的第一通讯密钥对密钥列表进行加密得到的,第一通讯密钥是密钥服务器根据第一公钥和第二私钥生成得到的。密钥Agent在接收到加密之后的密钥列表之后,就可以使用与第一通讯密钥相同的第二通讯密钥进行解密,其中,第二通讯密钥是密钥代理模块根据第一私钥和第二公钥生成得到的。Next, the key agent can send a pull request of the key list to the key server. After receiving the key pull request, the key server transmits the encrypted key list to the key agent, where the encrypted key list is the first communication key pair key list using the key server side. The first communication key obtained by the encryption is generated by the key server according to the first public key and the second private key. After receiving the encrypted key list, the key agent may decrypt using the same second communication key as the first communication key, wherein the second communication key is the key agent module according to the first private key. And the second public key is generated.
需要说明的是,在本申请实施例中,只有在密钥Agent重启时才会使用“约定密钥”对第一公钥和第二公钥进行加密,并互相传输。It should be noted that, in the embodiment of the present application, the first public key and the second public key are encrypted and transmitted to each other only when the key agent is restarted, using the “contract key”.
也就是说,只有Agent的维护者在变更Agent时重启进程才是唯一合法使用约定密钥的时机,其它任何情形都是非法使用。例如,Agent的维护者在Agent重启时,使用了约定密钥获取密钥列表,在此之后,如果其他使用者再次使用约定密钥获取密钥列表时,表明该使用者为滥用者。因此,在本申请实施例中,仅在密钥Agent重启时才会使用一次“约定密钥”的设置,能够快速并有效地检测出滥用者。That is to say, only the maintainer of the Agent restarts the process when changing the Agent is the only time to legally use the agreed key, and any other situation is illegal. For example, when the agent maintains the Agent, the contract key is used to obtain the key list. After that, if the other user uses the agreed key to obtain the key list again, it indicates that the user is an abuser. Therefore, in the embodiment of the present application, the setting of the "contract key" is used only when the key agent is restarted, and the abuser can be detected quickly and effectively.
由于网络上传递的只有各自的公钥pubkey,然而,本申请实施例中提供的业务加密是使用第一私钥和第二公钥对加密后的密钥列表进行解密,因此,即使密钥列表被tcpdump也不会反推出密钥,这就避免了内网抓包导致的密钥泄漏的现象出现。Since only the respective public key pubkey is transmitted on the network, the service encryption provided in the embodiment of the present application decrypts the encrypted key list using the first private key and the second public key, so even the key list The key is not reversed by tcpdump, which avoids the key leakage caused by intranet capture.
需要说明的是,在本申请实施例中,还可以保护密钥Agent和密钥服务器的内存。具体地,可以直接把密钥Agent和密钥服务器的二进制strip掉(即,删除一切调试信息),然后再把密钥Agent和密钥服务器的代码安全隔离保存起来,这么一来gdb几乎成了瞎子,至少想简单修改变量是不可能了。It should be noted that, in the embodiment of the present application, the memory of the key agent and the key server may also be protected. Specifically, the binary of the key agent and the key server can be directly stripped off (ie, all debugging information is deleted), and then the code of the key agent and the key server is securely isolated, so that gdb is almost Dice, at least it is impossible to simply modify the variables.
在对密钥列表进行解密之后,密钥Agent需要对业务进程和业务进程的PID合法性进行校验。如图10所示,业务模块首先建立unix域套接字,并建立第一文件描述符,然后,使用unix域套接字中的套接字 SCM_RIGHTS将第一文件描述符传输至密钥Agent,以及利用套接字SCM_CREDENTIA向密钥Agent传输进程被内核所认证的进程PID。其中,SCM_RIGHTS和SCM_CREDENTIA均适用于unix domain socket,SCM_RIGHTS用于将一个进程中的描述符传输到另一个进程中,这种方法可以让一些只能在亲缘进程间通信的IPC扩展到非亲缘进程(如linux eventfd);SCM_CREDENTIA用于传输进程被内核所认证的进程PID。After decrypting the key list, the key agent needs to verify the PID legality of the business process and the business process. As shown in Figure 10, the service module first establishes a unix domain socket and establishes a first file descriptor, and then uses the socket in the unix domain socket. SCM_RIGHTS transfers the first file descriptor to the key agent, and uses the socket SCM_CREDENTIA to transfer the process PID that the process is authenticated by the kernel to the key agent. Among them, SCM_RIGHTS and SCM_CREDENTIA are applicable to unix domain socket, SCM_RIGHTS is used to transfer descriptors in one process to another process. This method can extend some IPCs that can only communicate between relative processes to non-affinity processes ( For example, linux eventfd); SCM_CREDENTIA is used to transfer the process PID whose process is authenticated by the kernel.
申请人通过相关实验发现,在尝试过的所有方法(例如,异步IO,本地网络socket,unix域套接字,管道,边缘触发,一次recv/send多个请求,eventfd)和看到的所有文档中,加密效率仅次于共享内存的IPC,并明显快过管道和通常的unix域套接字,更不用提网络socket,实用性最好。Applicants found through the relevant experiments that all the methods tried (for example, asynchronous IO, local network socket, unix domain socket, pipe, edge trigger, one recv/send multiple requests, eventfd) and all documents seen In addition, the encryption efficiency is second only to the shared memory IPC, and significantly faster than the pipeline and the usual unix domain sockets, not to mention the network socket, the most practical.
此时,在获取到进程PID之后,就可以对业务进程和进程PID的合法性进行校验,具体校验过程在上述步骤S1至步骤S5中进行详细描述,此处不再赘述。At this time, after the process PID is obtained, the legality of the service process and the process PID can be verified. The specific verification process is described in detail in the above steps S1 to S5, and details are not described herein.
进一步地,在合法性校验通过的情况下,密钥代理模块还可以向业务模块发送第一文件描述符eventfda,密钥代理模块在获取到第一文件描述符eventfda之后,将生成第二文件描述符eventfdb,并将第二文件描述符eventfdb发送至业务模块,以实现密钥代理模块和业务模块之间文件描述符的交换。Further, in the case that the validity check is passed, the key agent module may further send a first file descriptor eventfda to the service module, and the key agent module generates a second file after acquiring the first file descriptor eventfda. Descriptor eventfdb, and send the second file descriptor eventfdb to the business module to implement the exchange of file descriptors between the key agent module and the business module.
进一步地,在合法性校验通过的情况下,密钥代理模块还可以为第一文件描述符设置目标权限,其中,目标权限包括以下至少之一:允许密钥代理模块对业务模块请求的待加密的数据进行加密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。Further, in the case that the legality verification is passed, the key agent module may further set a target authority for the first file descriptor, where the target authority includes at least one of the following: allowing the key agent module to request the service module The encrypted data is encrypted, allowing the key agent module to decrypt the data to be decrypted requested by the service module.
接下来,业务模块就可以向第一文件描述符eventfda在共享内存中对应的空间中进行写数据的操作,即,将待加密的数据写入第一文件描述符eventfda在共享内存中对应的区域中(write eventfda)。在写入之后,密钥代理模块就能够获知业务模块写入了数据,此时,密钥代理模块将从共享 内存中读取待加密的数据(即,读第二文件描述符,read eventfdb),并读取之前为第一文件描述符eventfda配置的目标权限。Next, the service module can perform the operation of writing data to the first file descriptor eventfda in the corresponding space in the shared memory, that is, the data to be encrypted is written into the corresponding area of the first file descriptor eventfda in the shared memory. Medium (write eventfda). After writing, the key agent module can know that the business module has written data. At this time, the key agent module will be shared. The data to be encrypted is read in memory (ie, the second file descriptor is read, read eventfdb), and the target permissions previously configured for the first file descriptor eventfda are read.
最后,在目标权限包括允许密钥代理模块对所述业务模块请求的待加密的数据进行加密时,密钥代理模块就可以从密钥列表中获取目标密钥,进而,密钥代理模块就可以根据获取到的目标密钥对待加密的数据进行加密操作。Finally, when the target authority includes allowing the key agent module to encrypt the data to be encrypted requested by the service module, the key agent module can obtain the target key from the key list, and then the key agent module can Encrypt the data to be encrypted according to the obtained target key.
需要说明的是,在本申请实施例中,只能通过eventfd直接传递8Bytes的数据,所以请求包(即,请求对待加密的数据进行加密的数据包)/响应包(即,已完成加密的待加密的数据的数据包)的主体会保存在共享内存中。It should be noted that, in the embodiment of the present application, only 8 bytes of data can be directly transmitted through eventfd, so the request packet (that is, the data packet requesting encryption to be encrypted)/response packet (that is, the encrypted packet is to be completed) The body of the encrypted data packet is stored in shared memory.
进一步地需要说明的是,把密钥保存在共享内存中是不安全,但是,把明文和密文保存在共享内存确是安全的。因为eventfd的8Byte可用来传输关键部分,这样攻击者就不能获取完整的密钥信息。It should be further noted that it is not safe to store the key in the shared memory, but it is safe to store the plaintext and ciphertext in the shared memory. Because eventfd's 8Byte can be used to transfer key parts, the attacker can't get the complete key information.
进一步地,如果SCM_CREDENTIA传递的PID出现错误时,表明此时sendmsg会返回-1,errno会被设置为3(表示进程不存在)或1(表示伪造其它进程)。Further, if the PID passed by SCM_CREDENTIA has an error, it indicates that sendmsg will return -1 at this time, and errno will be set to 3 (indicating that the process does not exist) or 1 (indicating that other processes are forged).
即:#define ESRCH 3/*No such process*/Namely: #define ESRCH 3/*No such process*/
#define EPERM 1/*Operation not permitted*/#define EPERM 1/*Operation not permitted*/
进一步地,unix域套接字传递准确进程PID的前提是非root模式运行的进程,所以必须对密钥Agent的root模式的需求进行审批。Further, the premise of the unix domain socket passing the accurate process PID is the process running in the non-root mode, so the requirement of the root mode of the key agent must be approved.
密钥代理模块还可以将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的所述进程PID。The key broker module can also configure the socket socket option as SO_PEERCRED and obtain the process PID of the business process through the socket socket.
下面将就具体实施例对本申请实施例进行说明。The embodiments of the present application will be described below with reference to specific embodiments.
假设,测试环境为以下环境: Assume that the test environment is the following environment:
机器:空闲机器、48核@2.6GHZ;Machine: idle machine, 48 core @2.6GHZ;
业务进程:60进程,4800协程,仅和Agent打交道;Business process: 60 processes, 4800 coroutines, only dealing with Agent;
密钥Agent:10进程;其中,业务进程和密钥Agent均自由运行,没有设置CPU优先级。Key Agent: 10 processes; in which the business process and the key agent are free to run, and no CPU priority is set.
测试方式:test method:
空服务:没有任何逻辑,测试网络框架本身的基础效率;Empty service: without any logic, testing the basic efficiency of the network framework itself;
本地解密:直接解密微信票据;Local decryption: directly decrypt the WeChat bill;
票据=主票+从票;Bill = main ticket + slave ticket;
主票:AES+非对称加密,16Bytes;Main ticket: AES+ asymmetric encryption, 16Bytes;
从票:对称加密+非对称加密,12Bytes;From ticket: symmetric encryption + asymmetric encryption, 12Bytes;
密钥Agent解密:直接解密微信票据;Key Agent decryption: directly decrypt the WeChat ticket;
票据=主票+从票;Bill = main ticket + slave ticket;
主票:AES加密,16Bytes;Main ticket: AES encryption, 16Bytes;
从票:对称加密,12Bytes;From ticket: symmetric encryption, 12Bytes;
说明:由于密钥Agent大幅度强化了密钥安全,因此不再需要非对称加密。Note: Because key agents greatly enhance key security, asymmetric encryption is no longer needed.
压力测试结果:(整体CPU峰值)。Stress test results: (overall CPU peak).
通过测试可知,5台外部测试机对测试业务的请求均达到约30W/S,其中,空服务为17%、本地解密为31%-33%、Agent解密为33%-34%。According to the test, the requests of the five external test machines for the test business reached about 30W/S, of which 17% for the empty service, 31%-33% for the local decryption, and 33%-34% for the agent decryption.
8台外部测试机对测试业务的请求均达到约40W/S,其中,空服务为27-28%、本地解密为55%-56%、Agent解密为60%-61%。The requests of the 8 external test machines for the test business reached about 40W/S, of which 27-28% for the empty service, 55%-56% for the local decryption, and 60%-61% for the agent decryption.
由此可见,在极端情形下,密钥Agent方式相对于相关业务直接验证票据的方式增加的额外CPU负载很轻,极具实战价值。 It can be seen that in the extreme case, the additional CPU load added by the key agent method to directly verify the ticket relative to the related service is very light and extremely practical.
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于可选实施例,所涉及的动作和模块并不一定是本申请所必须的。It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should understand that the present application is not limited by the described action sequence. Because certain steps may be performed in other sequences or concurrently in accordance with the present application. In the following, those skilled in the art should also understand that the embodiments described in the specification are optional embodiments, and the actions and modules involved are not necessarily required by the present application.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对相关技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware, but in many cases, the former is A better implementation. Based on such understanding, the technical solution of the present application, which is essential or contributes to the related art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk, CD-ROM). The instructions include a number of instructions for causing a terminal device (which may be a cell phone, a computer, a server, or a network device, etc.) to perform the methods described in various embodiments of the present application.
实施例2Example 2
根据本申请实施例,还提供了一种用于实施上述业务处理方法的业务处理装置。图11是根据本申请实施例的一种可选的业务处理装置的示意图,如图11所示,该装置可以包括:According to an embodiment of the present application, a service processing apparatus for implementing the foregoing service processing method is further provided. FIG. 11 is a schematic diagram of an optional service processing apparatus according to an embodiment of the present application. As shown in FIG. 11, the apparatus may include:
第一获取单元1101,设置为获取第一信息,其中,第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;The first obtaining unit 1101 is configured to acquire first information, where the first information is used to indicate that the first type of the key agent module performs an execution result of the ciphertext processing request;
第一检测单元1103,设置为检测第一信息是否符合预定类型切换条件,其中,符合预定类型切换条件表示第一类型的密钥代理模块无法稳定执行密文处理请求的配置;The first detecting unit 1103 is configured to detect whether the first information meets a predetermined type switching condition, wherein the predetermined type switching condition indicates that the configuration of the first type of the key agent module cannot stably perform the ciphertext processing request;
第一执行单元1105,设置为在检测出第一信息符合预定类型切换条件的情况下,通过第二类型的密钥代理模块执行业务模块的密文处理请求。The first execution unit 1105 is configured to execute the ciphertext processing request of the service module by the second type of key proxy module in the case that the first information is detected to meet the predetermined type switching condition.
可选地,第一处理单元,设置为在获取第一信息之前,向第一类型的 密钥代理模块发送密文处理请求;获取第一类型的密钥代理模块执行密文处理请求的执行结果;第一获取单元包括:基于执行结果统计第一类型的密钥代理模块执行密文处理请求的成功率,其中,第一信息包括成功率。Optionally, the first processing unit is configured to be to the first type before acquiring the first information The key agent module sends a ciphertext processing request, and obtains an execution result of the first type of the key agent module to perform the ciphertext processing request; the first obtaining unit includes: performing, according to the execution result, the first type of the key agent module to perform ciphertext processing The success rate of the request, wherein the first information includes a success rate.
可选地,,预定类型切换条件包括成功率低于第一预定阈值,检测单元具体设置为:检测成功率是否低于第一预定阈值;若检测出成功率低于第一预定阈值,则确定第一信息符合预定类型切换条件;若检测出成功率不低于第一预定阈值,则确定第一信息不符合预定类型切换条件。Optionally, the predetermined type switching condition includes: the success rate is lower than the first predetermined threshold, and the detecting unit is specifically configured to: determine whether the success rate is lower than the first predetermined threshold; if the detected success rate is lower than the first predetermined threshold, determine The first information meets the predetermined type switching condition; if the detected success rate is not lower than the first predetermined threshold, it is determined that the first information does not meet the predetermined type switching condition.
可选地,第一类型的密钥代理模块为开发型密钥代理模块,第二类型的密钥代理模块为稳定型密钥代理模块,稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。Optionally, the first type of key agent module is a development type key agent module, the second type of key agent module is a stable key agent module, and the stable key agent module is executed within a predetermined time period. The ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
需要说明的是,上述开发型develop密钥代理模块可以但不限于为未经过验证的代理模块,通过验证处理,以得到上述稳定型stable密钥代理模块。It should be noted that the above-mentioned development type key agent module may be, but not limited to, an unauthenticated agent module, and the verification process is performed to obtain the stable stable key agent module.
可选地,第二处理单元,设置为在获取第一信息之前,在对系统中的密钥代理模块中的文件进行更新之后,将执行了更新操作的密钥代理模块记录为第一类型的密钥代理模块;若在预定时间段内均检测出第一类型的密钥代理模块执行密文处理请求的正确率高于预定正确率,则将第一类型的密钥代理模块记录为第二类型的密钥代理模块。Optionally, the second processing unit is configured to record the key agent module that performs the update operation as the first type after updating the file in the key agent module in the system before acquiring the first information. a key agent module; if it is detected that the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate within a predetermined time period, the first type of the key agent module is recorded as the second A type of key broker module.
可选地,第三处理单元,设置为在获取第一信息之前,在系统中的第一类型的密钥代理模块正在运行的过程中,若需对密钥代理模块中的文件进行更新,则对第一类型的密钥代理模块中的文件进行更新。Optionally, the third processing unit is configured to: before the first information of the first type of the key agent module in the system is running, if the file in the key agent module is updated, Update the files in the first type of key broker module.
可选地,第一执行单元包括:若系统中包括多个第二类型的密钥代理模块,则从多个第二类型的密钥代理模块中获取更新时间最晚的第二类型的密钥代理模块,通过更新时间最晚的第二类型的密钥代理模块执行密文处理请求。 Optionally, the first execution unit includes: if a plurality of second type of key agent modules are included in the system, obtaining a second type of key with the latest update time from the plurality of second type of key agent modules The proxy module performs the ciphertext processing request by the second type of key proxy module that updates the latest time.
可选地,第四处理单元,设置为在通过第二类型的密钥代理模块执行业务模块的密文处理请求之后,在接收到输入的切换指令之后,响应于切换指令,通过第一类型的密钥代理模块执行密文处理请求。Optionally, the fourth processing unit is configured to, after receiving the ciphertext processing request of the service module by the second type of key proxy module, after receiving the input switching instruction, respond to the switching instruction, by using the first type The key broker module performs a ciphertext processing request.
可选地,第五处理单元,设置为在通过第一类型的密钥代理模块或第二类型的密钥代理模块执行密文处理请求的过程中,通过业务线程获取密钥代理模块的密钥数据,其中,密钥代理模块设置为在检测出执行密文处理请求的成功率低于第二预定阈值的情况下,发送密钥数据;利用密钥数据解密共享内存中存储的密钥列表,得到解密后的密钥列表;利用解密后的密钥列表通过业务模块执行密文处理请求。Optionally, the fifth processing unit is configured to obtain the key of the key proxy module through the service thread in the process of performing the ciphertext processing request by the first type of key proxy module or the second type of key proxy module Data, wherein the key agent module is configured to transmit key data when detecting that the success rate of executing the ciphertext processing request is lower than a second predetermined threshold; decrypting the key list stored in the shared memory by using the key data, Obtaining a decrypted key list; performing a ciphertext processing request through the service module by using the decrypted key list.
可选地,第六处理单元,设置为在通过业务线程获取密钥代理模块的密钥数据之前,通过业务线程生成通信管道的第一端描述符和第二端描述符,其中,第一端描述符用于密钥代理模块将业务模块发送的数据识别为合法数据,第二端描述符用于业务模块将密钥代理模块发送的数据识别为合法数据;通过通信管道将第二端描述符传输给密钥代理模块。Optionally, the sixth processing unit is configured to generate, by the service thread, a first end descriptor and a second end descriptor of the communication pipeline before acquiring the key data of the key proxy module by the service thread, where the first end The descriptor is used by the key agent module to identify the data sent by the service module as legal data, and the second end descriptor is used by the service module to identify the data sent by the key agent module as legal data; the second end descriptor is sent through the communication pipeline. Transfer to the key broker module.
可选地,,通过业务线程获取密钥代理模块的密钥数据包括:通过业务线程周期性从通信管道的读端读取数据;若从通信管道的读端读取到数据,则确定获取到密钥数据。Optionally, obtaining, by the service thread, the key data of the key agent module includes: periodically reading data from the read end of the communication pipe through the service thread; if the data is read from the read end of the communication pipe, determining to obtain Key data.
可选地,通信管道还用于检测业务模块、以及密钥代理模块是否重启。Optionally, the communication pipeline is further configured to detect whether the service module and the key agent module are restarted.
可选地,第七处理单元,设置为在通过密钥代理模块执行密文处理请求的过程中,在密钥代理模块对业务进程进行合法性校验之后,在合法性校验通过的情况下,业务模块向密钥代理模块发送第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据;获取密钥代理模块生成的多个第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据。Optionally, the seventh processing unit is configured to, after performing the ciphertext processing request by the key proxy module, after the validity of the validity verification by the key proxy module, The service module sends a first file descriptor to the key proxy module, where the first file descriptor is used by the key proxy module to identify the data sent by the service module as legal data; and the second key generated by the key proxy module is obtained. A file descriptor, wherein the second file descriptor is used by the service module to identify data sent by the key agent module as legitimate data.
可选地,第七处理单元,设置为在获取密钥代理模块生成的多个第二 文件描述符之后,将获取到的多个第二文件描述符保存至队列中;依序利用队列中存储的第二文件描述符与密钥代理模块进行通信。Optionally, the seventh processing unit is configured to acquire multiple seconds generated by the key agent module After the file descriptor, the obtained second file descriptors are saved in the queue; the second file descriptor stored in the queue is used to communicate with the key agent module.
可选地,多个第二文件描述符的数目与密钥代理模块中用于执行密文处理请求的线程数目相对应。Optionally, the number of the plurality of second file descriptors corresponds to the number of threads in the key broker module for executing the ciphertext processing request.
可选地,密文处理请求包括:用于将待加密数据加密为密文数据的请求和/或用于将密文数据解密为解密数据的请求。Optionally, the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
在一个可选地的实施例中,该装置应用在密钥代理模块中,该装置包括:第一处理单元,设置在第一类型的密钥代理模块中,设置为接收并执行业务模块的密文处理请求,得到执行结果;第一处理单元,设置在第二类型的密钥代理模块中,设置为接收并执行业务模块的密文处理请求,其中,业务模块设置为在基于执行结果生成的第一信息符合预定类型切换条件的情况下,向第二类型的密钥代理模块发送密文处理请求。In an alternative embodiment, the apparatus is applied in a key broker module, the apparatus comprising: a first processing unit, disposed in the first type of key broker module, configured to receive and execute the secret of the service module Processing the request, obtaining an execution result; the first processing unit is disposed in the second type of key agent module, configured to receive and execute the ciphertext processing request of the service module, wherein the service module is set to be generated based on the execution result When the first information conforms to the predetermined type switching condition, the ciphertext processing request is sent to the second type of key agent module.
可选地,第一类型的密钥代理模块为开发型密钥代理模块,第二类型的密钥代理模块为稳定型密钥代理模块,稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。Optionally, the first type of key agent module is a development type key agent module, the second type of key agent module is a stable key agent module, and the stable key agent module is executed within a predetermined time period. The ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
可选地,第三处理单元,设置为在第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果之前,在对系统中的密钥代理模块中的文件进行更新之后,将执行了更新操作的密钥代理模块记录为第一类型的密钥代理模块;在第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果之后,若在预定时间段内均检测出第一类型的密钥代理模块执行密文处理请求的正确率高于预定正确率,则将第一类型的密钥代理模块记录为第二类型的密钥代理模块。Optionally, the third processing unit is configured to: in the first type of the key agent module, receive and execute the ciphertext processing request of the service module, and update the file in the key agent module in the system before obtaining the execution result. After that, the key agent module that performs the update operation is recorded as the first type of key agent module; after the first type of the key agent module receives and executes the ciphertext processing request of the service module, and after obtaining the execution result, if The first type of key agent module is recorded as the second type of key agent module by detecting that the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate within the predetermined time period.
可选地,更新单元,设置为在第一类型的密钥代理模块执行业务模块的密文处理请求的过程中,若需对密钥代理模块中的文件进行更新,则对第一类型的密钥代理模块中的文件进行更新。 Optionally, the updating unit is configured to: when the first type of the key agent module performs the ciphertext processing request of the service module, if the file in the key agent module needs to be updated, the first type of the secret is The files in the key broker module are updated.
可选地,检测单元,设置为在密钥代理模块执行密文处理请求的过程中,密钥代理模块检测执行密文处理请求的成功率是否低于第二预定阈值;若检测出执行密文处理请求的成功率是否低于第二预定阈值,则向业务模块发送密钥数据,其中,密钥数据用于解密共享内存中存储的密钥列表,得到解密后的密钥列表,业务模块还用于通过解密后的密钥列表执行密文处理请求。Optionally, the detecting unit is configured to: when the key agent module performs the ciphertext processing request, the key agent module detects whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold; if the execution ciphertext is detected If the success rate of the processing request is lower than the second predetermined threshold, the key data is sent to the service module, where the key data is used to decrypt the key list stored in the shared memory, and the decrypted key list is obtained, and the service module further Used to perform a ciphertext processing request through the decrypted key list.
可选地,第四处理单元,设置为在密钥代理模块检测执行密文处理请求的成功率是否低于第二预定阈值之前,密钥代理模块在执行完密文处理请求之后,基于密文处理请求中的请求时间与当前时间,判断执行当前的密文处理请求是否超时;若判断出执行当前的密文处理请求超时,则确定执行当前的密文处理请求失败;基于执行失败的密文处理请求的数量,统计密钥代理模块执行密文处理请求的成功率。Optionally, the fourth processing unit is configured to: after the key agent module detects whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, the key agent module is based on the ciphertext after executing the ciphertext processing request The processing time in the request is compared with the current time, and it is determined whether the current ciphertext processing request is timed out; if it is determined that the current ciphertext processing request is timed out, it is determined that the execution of the current ciphertext processing request fails; The number of requests processed, and the success rate of the statistics key agent module to perform ciphertext processing requests.
可选地,第六处理单元,设置为在密钥代理模块检测执行密文处理请求的成功率是否低于第二预定阈值之前,接收通过业务线程传输的通信管道的第二端描述符,其中,业务线程用于生成第一端描述符和第二端描述符,其中,第一端描述符用于密钥代理模块将业务模块发送的数据识别为合法数据,第二端描述符用于业务模块将密钥代理模块发送的数据识别为合法数据。Optionally, the sixth processing unit is configured to receive the second end descriptor of the communication pipeline transmitted by the service thread before the key proxy module detects whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, where The service thread is configured to generate a first end descriptor and a second end descriptor, wherein the first end descriptor is used by the key proxy module to identify the data sent by the service module as legal data, and the second end descriptor is used for the service. The module identifies the data sent by the key broker module as legitimate data.
可选地,向业务模块发送密钥数据包括:通过各个业务线程的通信管道的写端,发送密钥数据。Optionally, sending the key data to the service module includes: transmitting key data by using a write end of a communication pipeline of each service thread.
可选地,通信管道还用于检测业务模块、以及密钥代理模块是否重启。Optionally, the communication pipeline is further configured to detect whether the service module and the key agent module are restarted.
可选地,第六处理单元,设置为在通过密钥代理模块执行密文处理请求的过程中,在密钥代理模块对业务进程进行合法性校验之后,在合法性校验通过的情况下,密钥代理模块接收业务模块发送的第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据;密钥代理模块生成多个第二文件描述符,其中,第二文件描述符 用于业务模块将密钥代理模块发送的数据识别为合法数据;密钥代理模块向业务模块传输多个第二文件描述符。Optionally, the sixth processing unit is configured to, after performing the ciphertext processing request by the key proxy module, after the validity of the validity verification by the key proxy module, The key agent module receives the first file descriptor sent by the service module, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal data; the key agent module generates multiple second files. Descriptor, where the second file descriptor The service module identifies the data sent by the key agent module as legal data; the key agent module transmits a plurality of second file descriptors to the service module.
可选地,多个第二文件描述符的数目与密钥代理模块中用于执行密文处理请求的线程数目相对应。Optionally, the number of the plurality of second file descriptors corresponds to the number of threads in the key broker module for executing the ciphertext processing request.
可选地,密文处理请求包括:用于将待加密数据加密为密文数据的请求和/或用于将密文数据解密为解密数据的请求。Optionally, the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
在一个可选的实施例中,业务处理装置应用在密钥代理模块中,该装置包括:第一获取单元,设置为获取执行密文处理请求的执行结果;第一检测单元,设置为检测执行结果是否符合预定模式切换条件,其中,符合所述预定类型切换条件表示确定所述第一类型的密钥代理模块出现漏洞,也即,所述第一类型的密钥代理模块无法稳定执行密文处理请求;第一发送单元,设置为若检测出执行结果符合预定模式切换条件,则向业务模块发送指示信息,其中,指示信息用于指示业务模块切换到通过业务模块执行密文处理请求的模式。In an optional embodiment, the service processing device is applied in a key agent module, the device includes: a first obtaining unit configured to acquire an execution result of the execution of the ciphertext processing request; and a first detecting unit configured to detect execution Whether the result meets the predetermined mode switching condition, wherein the matching the predetermined type switching condition indicates that the first type of the key agent module is vulnerable, that is, the first type of the key agent module cannot stably execute the ciphertext Processing the request; the first sending unit is configured to: if the detection result is that the execution result meets the predetermined mode switching condition, send the indication information to the service module, where the indication information is used to indicate that the service module switches to the mode of performing the ciphertext processing request by the service module .
可选地,第一获取单元设置为:密钥代理模块在执行完密文处理请求之后,基于密文处理请求中的请求时间与当前时间,判断执行当前的密文处理请求是否超时;若判断出执行当前的密文处理请求超时,则密钥代理模块确定执行当前的密文处理请求失败;密钥代理模块基于执行失败的密文处理请求的数量,统计密钥代理模块执行密文处理请求的成功率,执行结果包括成功率。Optionally, the first obtaining unit is configured to: after the ciphertext processing request is executed, determine, according to the request time and the current time in the ciphertext processing request, whether the current ciphertext processing request is timed out; If the execution of the current ciphertext processing request timeout occurs, the key agent module determines that the execution of the current ciphertext processing request fails; the key agent module performs the ciphertext processing request based on the number of ciphertext processing requests that failed to execute. The success rate, the execution results include the success rate.
可选地,第一检测单元设置为:密钥代理模块检测成功率是否低于第二预定阈值;若检测出执行密文处理请求的成功率是否低于第二预定阈值,则确定执行结果符合预定模式切换条件。Optionally, the first detecting unit is configured to: the key agent module detects whether the success rate is lower than a second predetermined threshold; if it is detected whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, determining that the execution result is consistent Scheduled mode switching conditions.
可选地,第一发送单元设置为包括:密钥代理模块向业务模块发送密钥数据,其中,密钥数据用于解密共享内存中存储的密钥列表,得到解密 后的密钥列表,业务模块还设置为通过解密后的密钥列表执行密文处理请求。Optionally, the first sending unit is configured to: the key agent module sends the key data to the service module, where the key data is used to decrypt the key list stored in the shared memory, and obtain the decryption. After the key list, the service module is further configured to perform a ciphertext processing request through the decrypted key list.
可选地,密钥代理模块包括第一类型的密钥代理模块和第二类型的密钥代理模块,其中,第一类型的密钥代理模块为开发型密钥代理模块,第二类型的密钥代理模块为稳定型密钥代理模块,稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。Optionally, the key agent module includes a first type of key agent module and a second type of key agent module, wherein the first type of key agent module is a development type key agent module, and the second type of secret The key agent module is a stable key agent module, and the stable key agent module is a key agent module that performs a ciphertext processing request with a correct rate higher than a predetermined correct rate within a predetermined time period.
可选地,第一处理单元,设置为在密钥代理模块接收并执行业务模块的密文处理请求之前,在对密钥代理模块中的文件进行更新之后,将执行了更新操作的密钥代理模块记录为第一类型的密钥代理模块;在第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果之后,方法还包括:若在预定时间段内均检测出第一类型的密钥代理模块执行密文处理请求的正确率高于预定正确率,则将第一类型的密钥代理模块记录为第二类型的密钥代理模块。Optionally, the first processing unit is configured to: after the key agent module receives and executes the ciphertext processing request of the service module, after the file in the key agent module is updated, the key agent that performs the update operation is set The module records as a first type of key agent module; after the first type of key agent module receives and executes the ciphertext processing request of the service module, and obtains the execution result, the method further includes: if the predetermined time period is detected When the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate, the first type of key agent module is recorded as the second type of key agent module.
可选地,第二处理单元,设置为在第一类型的密钥代理模块执行业务模块的密文处理请求的过程中,若需对密钥代理模块中的文件进行更新,则对第一类型的密钥代理模块中的文件进行更新。Optionally, the second processing unit is configured to: when the first type of the key agent module performs the ciphertext processing request of the service module, if the file in the key agent module needs to be updated, the first type is The files in the key broker module are updated.
可选地,密文处理请求包括:用于将待加密数据加密为密文数据的请求和/或用于将密文数据解密为解密数据的请求。Optionally, the ciphertext processing request comprises: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into decrypted data.
根据本申请实施例,还提供了一种用于实施上述业务加密方法的业务加密装置。图12是根据本申请实施例的一种可选的业务加密装置的示意图,如图12所示,该装置可以包括:第一加密接收单元1201、第一加密获取单元1203、第一加密单元1205和第一加密发送单元1207,其中:According to an embodiment of the present application, a service encryption apparatus for implementing the foregoing service encryption method is further provided. FIG. 12 is a schematic diagram of an optional service encryption apparatus according to an embodiment of the present application. As shown in FIG. 12, the apparatus may include: a first encryption receiving unit 1201, a first encryption obtaining unit 1203, and a first encryption unit 1205. And a first encryption transmitting unit 1207, wherein:
第一加密接收单元1201,设置于密钥代理模块中,设置为接收业务模块发送的加密请求,其中,加密请求中携带有待加密的数据。 The first encryption receiving unit 1201 is disposed in the key agent module and configured to receive an encryption request sent by the service module, where the encryption request carries data to be encrypted.
第一加密获取单元1203,设置于密钥代理模块中,设置为从密钥列表中获取目标密钥,其中,密钥列表是预先从密钥服务器中拉取到的。The first encryption obtaining unit 1203 is disposed in the key agent module and configured to acquire the target key from the key list, wherein the key list is previously extracted from the key server.
第一加密单元1205,设置密钥代理模块中,设置为使用目标密钥对待加密的数据进行加密,得到加密后的数据。The first encryption unit 1205 sets the key agent module to encrypt the data to be encrypted using the target key to obtain the encrypted data.
第一加密发送单元1207,设置于密钥代理模块中,设置为将加密后的数据发送给业务模块。The first encryption sending unit 1207 is disposed in the key agent module and configured to send the encrypted data to the service module.
在本申请实施例中,通过密钥代理模块接收加密请求,然后,根据密钥请求获取目标密钥,接下来,通过目标密钥对待加密的数据进行加密,本申请实施例中提供的业务加密方式,达到了更加安全地为业务进行加密的目的,从而实现了提高了对业务进行加密时密钥安全性的技术效果,进而解决了相关技术中在对业务进行解密时密钥的安全性较低的技术问题。In the embodiment of the present application, the encryption request is received by the key agent module, and then the target key is obtained according to the key request, and then the data to be encrypted is encrypted by the target key, and the service encryption provided in the embodiment of the present application is encrypted. The method achieves the purpose of encrypting the service more securely, thereby achieving the technical effect of improving the key security when encrypting the service, thereby solving the security of the key when decrypting the service in the related art. Low technical issues.
可选地,第二加密发送单元,设置在密钥代理模块中,设置为在密钥代理模块接收业务模块发送的加密请求之前,将第一公钥发送给密钥服务器,并从密钥服务器接收第二公钥,其中,密钥代理模块上具有一对第一公钥和第一私钥,密钥服务器上具有一对第二公钥和第二私钥;第三加密发送单元,设置在密钥代理模块中,设置为向密钥服务器发送密钥列表拉取请求;第二加密接收单元,设置在密钥代理模块中,设置为接收密钥服务器发送的加密后的密钥列表,其中,加密后的密钥列表是使用密钥服务器侧的第一通讯密钥对密钥列表进行加密得到的,第一通讯密钥是密钥服务器根据第一公钥和第二私钥生成得到的;解密单元,设置在密钥代理模块中,设置为使用密钥代理模块侧的第二通讯密钥对加密后的密钥列表进行解密,得到密钥列表,其中,第二通讯密钥是密钥代理模块根据第一私钥和第二公钥生成得到的,第一通讯密钥与第二通讯密钥相同。Optionally, the second encryption sending unit is disposed in the key agent module, and is configured to send the first public key to the key server and receive the key server before receiving the encryption request sent by the service module by the key agent module. Receiving a second public key, wherein the key agent module has a pair of first public key and a first private key, the key server has a pair of second public key and a second private key; and the third encrypted sending unit sets In the key agent module, configured to send a key list pull request to the key server; the second encryption receiving unit is set in the key agent module, and is configured to receive the encrypted key list sent by the key server, The encrypted key list is obtained by encrypting the key list by using the first communication key on the key server side, and the first communication key is generated by the key server according to the first public key and the second private key. a decryption unit, configured in the key agent module, configured to decrypt the encrypted key list using the second communication key on the side of the key agent module to obtain a key list, wherein Communication module generates the proxy key is a key obtained by the first private key and a second public key, same as the first key and a second communication communication key.
可选地,第二加密发送单元包括:第一发送模块,设置为在密钥代理模块重启时,将加密后的第一公钥发送给密钥服务器,其中,加密后的第一公钥是使用约定密钥对第一公钥进行加密得到的;接收模块,设置为接 收加密后的第二公钥,其中,加密后的第二公钥是使用约定密钥对第二公钥进行加密得到的;解密模块,设置为使用约定密钥对加密后的第二公钥进行解密,得到第二公钥;其中,约定密钥被设置为仅在密钥代理模块重启时使用。Optionally, the second encryption sending unit includes: a first sending module, configured to send the encrypted first public key to the key server when the key agent module is restarted, where the encrypted first public key is The first public key is encrypted by using a contract key; the receiving module is set to be connected Receiving the encrypted second public key, wherein the encrypted second public key is obtained by encrypting the second public key using the agreed key; and the decrypting module is set to use the agreed key pair to encrypt the second public key Decrypting is performed to obtain a second public key; wherein the appointment key is set to be used only when the key broker module is restarted.
可选地,装置该包括:第二加密获取单元,设置于密钥代理模块中,设置为在密钥代理模块接收业务模块发送的加密请求之前,获取业务进程的进程PID,其中,业务进程为业务模块发送待加密的数据的进程;校验单元,设置于密钥代理模块中,设置为对业务进程和进程PID进行合法性校验;以及第一加密获取单元包括:第一获取模块,设置于密钥代理模块中,设置为在合法性校验通过的情况下,密钥代理模块从密钥列表中获取目标密钥。Optionally, the device includes: a second encryption acquiring unit, configured in the key agent module, configured to acquire a process PID of the service process, where the service process is a process, before the key agent module receives the encryption request sent by the service module a process of sending the data to be encrypted by the service module; the verification unit is set in the key agent module, and is set to perform legality verification on the service process and the process PID; and the first encryption acquisition unit includes: a first acquisition module, and a setting In the key proxy module, the key proxy module obtains the target key from the key list if the validity check is passed.
可选地,校验单元包括:第二获取模块,设置为获取与进程PID对应的进程全路径;第一判断模块,设置为判断进程全路径是否属于预先从密钥服务器获取到的合法路径中的路径;校验模块,设置为在判断出进程全路径属于合法路径中的路径的情况下,对业务进程进行MD5校验操作,得到第一MD5校验结果;第一确定模块,设置为在判断出进程全路径不属于合法路径中的路径的情况下,判断出合法性校验不通过;第二判断模块,设置为判断第一MD5校验结果是否与预先获取的与业务进程对应的第二MD5校验结果相同;第二确定模块,设置为在判断出第一MD5校验结果与第二MD5校验结果相同的情况下,判断出合法性校验通过;第三确定模块,设置为在判断出第一MD5校验结果与第二MD5校验结果不同的情况下,判断出合法性校验不通过。Optionally, the verification unit includes: a second obtaining module, configured to acquire a full path of the process corresponding to the process PID; and a first determining module, configured to determine whether the full path of the process belongs to a legal path obtained from the key server in advance The path of the verification module is set to perform the MD5 verification operation on the service process to obtain the first MD5 verification result when the path of the process is determined to belong to the path in the legal path; the first determining module is set to If it is determined that the path of the process does not belong to the path in the legal path, it is determined that the validity check fails; the second determining module is configured to determine whether the first MD5 check result is corresponding to the pre-acquired service process. The second MD5 check result is the same; the second determining module is configured to determine that the validity check is passed when it is determined that the first MD5 check result is the same as the second MD5 check result; and the third determining module is set to When it is determined that the first MD5 check result is different from the second MD5 check result, it is determined that the validity check fails.
可选地,装置还包括,第三加密获取单元,设置于密钥代理模块中,设置为在密钥代理模块对业务进程和进程PID进行合法性校验之后,并在密钥代理模块接收业务模块发送的加密请求之前,在合法性校验通过的情况下,获取业务模块发送的第一文件描述符,其中,第一文件描述符用于 密钥代理模块将业务模块发送的数据识别为合法数据;生成单元,设置于密钥代理模块中,设置为生成第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据;传输单元,设置于密钥代理模块中,设置为将第二文件描述符传输给业务模块。Optionally, the device further includes: a third encryption acquiring unit, configured in the key agent module, configured to perform the validity check on the service process and the process PID after the key agent module, and receive the service in the key agent module Before the encryption request sent by the module, in the case that the validity check is passed, the first file descriptor sent by the service module is obtained, where the first file descriptor is used for The key agent module identifies the data sent by the service module as legal data; the generating unit is disposed in the key agent module and configured to generate a second file descriptor, wherein the second file descriptor is used by the service module to use the key agent The data sent by the module is identified as legal data; the transmission unit is disposed in the key agent module and configured to transmit the second file descriptor to the service module.
可选地,第一加密接收单元包括:第三获取模块,设置于密钥代理模块中,设置为接收业务模块发送的加密请求包括:密钥代理模块从共享内存中获取业务模块存入的待加密的数据;第一加密发送单元包括:第二发送模块,设置于密钥代理模块中,设置为将加密后的数据存入到共享内存中,以使得业务模块从共享内存中获取加密后的数据。Optionally, the first encryption receiving unit includes: a third acquiring module, configured in the key proxy module, and configured to receive the encryption request sent by the service module, where the key proxy module obtains the service module from the shared memory The encrypted data includes: a second sending module, configured in the key proxy module, configured to store the encrypted data in the shared memory, so that the service module obtains the encrypted content from the shared memory. data.
可选地,装置还包括,设置单元,设置于密钥代理模块中,设置为在密钥代理模块对业务进程和进程PID进行合法性校验之后,并在密钥代理模块接收业务模块发送的加密请求之前,在合法性校验通过的情况下,密钥代理模块为第一文件描述符设置目标权限,其中,目标权限包括以下至少之一:允许密钥代理模块对业务模块请求的待加密的数据进行加密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。Optionally, the device further includes: a setting unit, configured in the key agent module, configured to perform a validity check on the service process and the process PID of the key agent module, and receive the service module sent by the key agent module Before the encryption request, in the case that the legality verification is passed, the key agent module sets the target authority for the first file descriptor, wherein the target authority includes at least one of the following: the key agent module is requested to encrypt the service module. The data is encrypted, allowing the key agent module to decrypt the data to be decrypted requested by the service module.
可选地,第一获取模块包括:获取子模块,设置为允许密钥代理模块对业务模块请求的待加密的数据进行加密时,密钥代理模块从密钥列表中获取目标密钥。Optionally, the first obtaining module includes: an obtaining submodule, configured to allow the key proxy module to encrypt the data to be encrypted requested by the service module, and the key proxy module obtains the target key from the key list.
可选地,第二加密获取单元包括:第四获取模块,设置为在非root运行模式下通过unix域套接字获取业务进程的进程PID;或者,第五获取模块,设置为将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的进程PID。Optionally, the second encryption obtaining unit includes: a fourth obtaining module, configured to acquire a process PID of the service process through the unix domain socket in the non-root running mode; or, the fifth obtaining module is configured to socket the socket The word option is configured as SO_PEERCRED, and the process PID of the business process is obtained through the socket socket.
需要说明的是,该实施例中的第一加密接收单元1201可以设置为执行本申请实施例1中的步骤S702,该实施例中的第一加密获取单元1203可以设置为执行本申请实施例1中的步骤S704,该实施例中的第一加密单元1205可以设置为执行本申请实施例1中的步骤S706,该实施例中的 第一加密发送单元1207可以设置为执行本申请实施例1中的步骤S708。It should be noted that the first encryption receiving unit 1201 in this embodiment may be configured to perform step S702 in the first embodiment of the present application. The first encryption obtaining unit 1203 in this embodiment may be configured to perform the first embodiment of the present application. In step S704, the first encryption unit 1205 in this embodiment may be configured to perform step S706 in Embodiment 1 of the present application, in this embodiment The first encryption transmitting unit 1207 may be configured to perform step S708 in Embodiment 1 of the present application.
根据本申请实施例,还提供了一种用于实施上述业务解密方法的业务解密装置。图13是根据本申请实施例的一种可选的业务解密装置的示意图,如图13所示,该装置可以包括:第一解密接收单元1301、第一解密获取单元1303、第一解密单元1305和第一解密发送单元1307,其中:According to an embodiment of the present application, a service decryption apparatus for implementing the above service decryption method is further provided. FIG. 13 is a schematic diagram of an optional service decryption apparatus according to an embodiment of the present application. As shown in FIG. 13, the apparatus may include: a first decryption receiving unit 1301, a first decryption acquisition unit 1303, and a first decryption unit 1305. And a first decryption transmitting unit 1307, wherein:
第一解密接收单元,设置于密钥代理模块中,设置为接收业务模块发送的解密请求,其中,解密请求中携带有待解密的数据。The first decryption receiving unit is disposed in the key proxy module and configured to receive the decryption request sent by the service module, where the decryption request carries data to be decrypted.
第一解密获取单元,设置于密钥代理模块中,设置为从密钥列表中获取目标密钥,其中,密钥列表是预先从密钥服务器中拉取到的。The first decryption obtaining unit is disposed in the key agent module and configured to obtain the target key from the key list, wherein the key list is previously extracted from the key server.
第一解密单元,设置密钥代理模块中,设置为使用目标密钥对待解密的数据进行解密,得到解密后的数据。The first decryption unit sets the key agent module to decrypt the data to be decrypted using the target key to obtain the decrypted data.
第一解密发送单元,设置于密钥代理模块中,设置为将解密后的数据发送给业务模块。The first decryption sending unit is disposed in the key agent module and configured to send the decrypted data to the service module.
在本申请实施例中,通过密钥代理模块接收解密请求,然后,根据密钥请求获取目标密钥,接下来,通过目标密钥对待解密的数据进行解密,本申请实施例中提供的业务解密方式,达到了更加安全地为业务进行解密的目的,从而实现了提高了对业务进行解密时密钥安全性的技术效果,进而解决了相关技术中在对业务进行解密时密钥的安全性较低的技术问题。In the embodiment of the present application, the decryption request is received by the key agent module, and then the target key is obtained according to the key request, and then the data to be decrypted is decrypted by the target key, and the service decryption provided in the embodiment of the present application is decrypted. The method achieves the purpose of decrypting the service more securely, thereby realizing the technical effect of improving the security of the key when decrypting the service, thereby solving the security of the key when decrypting the service in the related art. Low technical issues.
可选地,第二解密发送单元,设置在密钥代理模块中,设置为在密钥代理模块接收业务模块发送的解密请求之前,将第一公钥发送给密钥服务器,并从密钥服务器接收第二公钥,其中,密钥代理模块上具有一对第一公钥和第一私钥,密钥服务器上具有一对第二公钥和第二私钥;第三解密发送单元,设置在密钥代理模块中,设置为向密钥服务器发送密钥列表拉取请求;第二解密接收单元,设置在密钥代理模块中,设置为接收密钥服务器发送的加密后的密钥列表,其中,加密后的密钥列表是使用密钥服务 器侧的第一通讯密钥对密钥列表进行加密得到的,第一通讯密钥是密钥服务器根据第一公钥和第二私钥生成得到的;第二解密单元,设置在密钥代理模块中,设置为使用密钥代理模块侧的第二通讯密钥对加密后的密钥列表进行解密,得到密钥列表,其中,第二通讯密钥是密钥代理模块根据第一私钥和第二公钥生成得到的,第一通讯密钥与第二通讯密钥相同。Optionally, the second decryption sending unit is disposed in the key agent module, and configured to send the first public key to the key server and receive the key server before the key agent module receives the decryption request sent by the service module Receiving a second public key, wherein the key agent module has a pair of first public key and a first private key, the key server has a pair of second public key and a second private key; and the third decryption sending unit sets In the key agent module, configured to send a key list pull request to the key server; the second decryption receiving unit is set in the key agent module, and is configured to receive the encrypted key list sent by the key server, Where the encrypted key list is a key service The first communication key of the device side is obtained by encrypting the key list, and the first communication key is generated by the key server according to the first public key and the second private key; and the second decryption unit is set in the key agent. In the module, the second key of the key agent module is used to decrypt the encrypted key list to obtain a key list, wherein the second communication key is a key agent module according to the first private key and The second public key is generated, and the first communication key is the same as the second communication key.
可选地,第二解密发送单元包括:第一发送模块,设置为在密钥代理模块重启时,将加密后的第一公钥发送给密钥服务器,其中,加密后的第一公钥是使用约定密钥对第一公钥进行加密得到的;接收模块,设置为从密钥服务器接收加密后的第二公钥,其中,加密后的第二公钥是使用约定密钥对第二公钥进行加密得到的;解密模块,设置为密钥代理模块使用约定密钥对加密后的第二公钥进行解密,得到第二公钥;其中,约定密钥被设置为仅在密钥代理模块重启时使用。Optionally, the second decryption sending unit includes: a first sending module, configured to send the encrypted first public key to the key server when the key agent module is restarted, where the encrypted first public key is The first public key is obtained by encrypting the first public key; the receiving module is configured to receive the encrypted second public key from the key server, wherein the encrypted second public key is the second key using the agreed key The key is encrypted; the decryption module is configured to decrypt the encrypted second public key by using the contract key to obtain a second public key; wherein the appointment key is set to be only in the key agent module Used when restarting.
可选地,装置该包括:第二解密获取单元,设置于密钥代理模块中,设置为在密钥代理模块接收业务模块发送的解密请求之前,获取业务进程的进程PID,其中,业务进程为业务模块发送待解密的数据的进程;校验单元,设置于密钥代理模块中,设置为对业务进程和进程PID进行合法性校验;第一解密获取单元包括:第一获取模块,设置于密钥代理模块中,设置为在合法性校验通过的情况下,密钥代理模块从密钥列表中获取目标密钥。Optionally, the device includes: a second decryption acquiring unit, configured to be configured in the key agent module, configured to acquire a process PID of the service process, where the key process module receives the decryption request sent by the service module, where the service process is The process of sending the data to be decrypted by the service module; the verification unit is set in the key agent module, and is set to perform legality verification on the service process and the process PID; the first decryption acquisition unit includes: a first acquisition module, which is set in In the key agent module, it is set that the key agent module obtains the target key from the key list if the validity check is passed.
可选地,校验单元包括:第二获取模块,设置为获取与进程PID对应的进程全路径;第一判断模块,设置为判断进程全路径是否属于预先从密钥服务器获取到的合法路径中的路径;校验模块,设置为在判断出进程全路径属于合法路径中的路径的情况下,对业务进程进行MD5校验操作,得到第一MD5校验结果;第一确定模块,设置为在判断出进程全路径不属于合法路径中的路径的情况下,判断出合法性校验不通过;第二判断模块,设置为判断第一MD5校验结果是否与预先获取的与业务进程对应的 第二MD5校验结果相同;第二确定模块,设置为在判断出第一MD5校验结果与第二MD5校验结果相同的情况下,判断出合法性校验通过;第三确定模块,设置为在判断出第一MD5校验结果与第二MD5校验结果不同的情况下,判断出合法性校验不通过。Optionally, the verification unit includes: a second obtaining module, configured to acquire a full path of the process corresponding to the process PID; and a first determining module, configured to determine whether the full path of the process belongs to a legal path obtained from the key server in advance The path of the verification module is set to perform the MD5 verification operation on the service process to obtain the first MD5 verification result when the path of the process is determined to belong to the path in the legal path; the first determining module is set to If it is determined that the path of the process does not belong to the path in the legal path, it is determined that the validity check fails; the second determining module is configured to determine whether the first MD5 check result is corresponding to the pre-acquired service process. The second MD5 check result is the same; the second determining module is configured to determine that the validity check is passed when it is determined that the first MD5 check result is the same as the second MD5 check result; the third determining module sets In order to determine that the first MD5 check result is different from the second MD5 check result, it is determined that the validity check fails.
可选地,装置还包括,第三解密获取单元,设置于密钥代理模块中,设置为在密钥代理模块对业务进程和进程PID进行合法性校验之后,并在密钥代理模块接收业务模块发送的解密请求之前,在合法性校验通过的情况下,获取业务模块发送的第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据;生成单元,设置于密钥代理模块中,设置为生成第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据;传输单元,设置于密钥代理模块中,设置为将第二文件描述符传输给业务模块。Optionally, the device further includes: a third decryption acquiring unit, configured in the key agent module, configured to receive the service after the key agent module performs the validity check on the service process and the process PID, and in the key agent module Before the decryption request sent by the module, if the validity check is passed, the first file descriptor sent by the service module is obtained, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal. a data generating unit, configured to generate a second file descriptor, wherein the second file descriptor is used by the service module to identify the data sent by the key proxy module as legal data; the transmission unit, setting In the key broker module, it is set to transmit the second file descriptor to the service module.
可选地,第一解密接收单元包括:第三获取模块,设置于密钥代理模块中,设置为接收业务模块发送的解密请求包括:密钥代理模块从共享内存中获取业务模块存入的待解密的数据;第一解密发送单元包括:第二发送模块,设置于密钥代理模块中,设置为将解密后的数据存入到共享内存中,以使得业务模块从共享内存中获取解密后的数据。Optionally, the first decryption receiving unit includes: a third obtaining module, configured in the key proxy module, configured to receive the decryption request sent by the service module, where the key proxy module obtains the service module from the shared memory Decrypted data; the first decryption sending unit comprises: a second sending module, disposed in the key proxy module, configured to store the decrypted data in the shared memory, so that the service module obtains the decrypted data from the shared memory data.
可选地,装置还包括,设置单元,设置于密钥代理模块中,设置为在密钥代理模块对业务进程和进程PID进行合法性校验之后,并在密钥代理模块接收业务模块发送的解密请求之前,在合法性校验通过的情况下,密钥代理模块为第一文件描述符设置目标权限,其中,目标权限包括以下至少之一:允许密钥代理模块对业务模块请求的待加密的数据进行加密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。Optionally, the device further includes: a setting unit, configured in the key agent module, configured to perform a validity check on the service process and the process PID of the key agent module, and receive the service module sent by the key agent module Before the decryption request, in the case that the legality verification is passed, the key agent module sets the target authority for the first file descriptor, wherein the target authority includes at least one of the following: the key agent module is allowed to encrypt the service module request The data is encrypted, allowing the key agent module to decrypt the data to be decrypted requested by the service module.
可选地,第一获取模块包括:获取子模块,设置为允许密钥代理模块对业务模块请求的待解密的数据进行解密时,密钥代理模块从密钥列表中获取目标密钥。 Optionally, the first obtaining module includes: an obtaining submodule, configured to allow the key proxy module to decrypt the data to be decrypted requested by the service module, and the key proxy module obtains the target key from the key list.
可选地,第二解密获取单元包括:第四获取模块,设置为在非root运行模式下通过unix域套接字获取业务进程的进程PID;或者,第五获取模块,设置为将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的进程PID。Optionally, the second decryption acquiring unit includes: a fourth acquiring module, configured to acquire a process PID of the service process through the unix domain socket in the non-root running mode; or, the fifth acquiring module is configured to socket the socket The word option is configured as SO_PEERCRED, and the process PID of the business process is obtained through the socket socket.
需要说明的是,该实施例中的第一解密接收单元701可以设置为执行本申请实施例1中的步骤S302,该实施例中的第一解密获取单元703可以设置为执行本申请实施例1中的步骤S304,该实施例中的第一解密单元705可以设置为执行本申请实施例1中的步骤S306,该实施例中的第一解密发送单元707可以设置为执行本申请实施例1中的步骤S308。It should be noted that the first decryption receiving unit 701 in this embodiment may be configured to perform step S302 in the first embodiment of the present application. The first decryption obtaining unit 703 in this embodiment may be configured to perform the first embodiment of the present application. In step S304, the first decryption unit 705 in this embodiment may be configured to perform step S306 in the first embodiment of the present application, and the first decryption sending unit 707 in this embodiment may be configured to perform the first embodiment in the present application. Step S308.
通过上述模块,可以解决了相关技术中在对业务进行解密时密钥的安全性较低的技术问题,从而实现了提高了对业务进行加密时密钥安全性的技术效果。Through the above module, the technical problem that the security of the key is low when the service is decrypted in the related art can be solved, thereby realizing the technical effect of improving the key security when encrypting the service.
此处需要说明的是,上述模块与对应的步骤所实现的示例和应用场景相同,但不限于上述实施例1所公开的内容。需要说明的是,上述模块作为装置的一部分可以运行在如图1所示的硬件环境中,可以通过软件实现,也可以通过硬件实现,其中,硬件环境包括网络环境。It should be noted here that the above modules are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the contents disclosed in the above embodiment 1. It should be noted that the foregoing module may be implemented in a hardware environment as shown in FIG. 1 as part of the device, and may be implemented by software or by hardware, where the hardware environment includes a network environment.
实施例3Example 3
根据本申请实施例,还提供了一种用于实施上述业务处理方法的电子装置。According to an embodiment of the present application, an electronic device for implementing the foregoing service processing method is also provided.
图14是根据本申请实施例的一种电子装置的结构框图,如图14所示,该电子装置可以包括:一个或多个(图中仅示出一个)处理器1401(如上述实施例中的密钥代理模块)、存储器1403、以及传输装置1405(如上述实施例中的发送装置),如图14所示,该电子装置还可以包括输入输出设备1407。FIG. 14 is a structural block diagram of an electronic device according to an embodiment of the present application. As shown in FIG. 14, the electronic device may include: one or more (only one is shown) processor 1401 (as in the above embodiment) The key agent module), the memory 1403, and the transmission device 1405 (such as the transmitting device in the above embodiment), as shown in FIG. 14, the electronic device may further include an input/output device 1407.
其中,存储器1403可设置为存储软件程序以及模块,如本申请实施 例中的业务处理方法和装置对应的程序指令/模块,处理器1401通过运行存储在存储器1403内的软件程序以及模块,从而执行各种功能应用以及数据处理,即实现上述的业务处理方法。存储器1403可包括高速随机存储器,还可以包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器1403可进一步包括相对于处理器1401远程设置的存储器,这些远程存储器可以通过网络连接至终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory 1403 can be configured to store software programs and modules, as implemented in the present application. In the example, the business processing method and the program instruction/module corresponding to the device, the processor 1401 executes various functional applications and data processing by executing the software program and the module stored in the memory 1403, that is, implementing the above-described business processing method. Memory 1403 can include high speed random access memory, and can also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory. In some examples, memory 1403 can further include memory remotely located relative to processor 1401, which can be connected to the terminal over a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
上述的传输装置1405设置为经由一个网络接收或者发送数据,还可以设置为处理器与存储器之间的数据传输。上述的网络具体实例可包括有线网络及无线网络。在一个实例中,传输装置1405包括一个网络适配器(Network Interface Controller,NIC),其可通过网线与其他网络设备与路由器相连从而可与互联网或局域网进行通讯。在一个实例中,传输装置1405为射频(Radio Frequency,RF)模块,其设置为通过无线方式与互联网进行通讯。The above-described transmission device 1405 is configured to receive or transmit data via a network, and may also be configured as data transmission between the processor and the memory. Specific examples of the above network may include a wired network and a wireless network. In one example, the transmission device 1405 includes a Network Interface Controller (NIC) that can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network. In one example, the transmission device 1405 is a Radio Frequency (RF) module configured to communicate with the Internet wirelessly.
其中,具体地,存储器1403用于存储应用程序。Specifically, the memory 1403 is configured to store an application.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤:获取第一信息,其中,第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;检测第一信息是否符合预定类型切换条件,其中,符合预定类型切换条件表示确定第一类型的密钥代理模块出现漏洞;在检测出第一信息符合预定类型切换条件的情况下,通过第二类型的密钥代理模块执行业务模块的密文处理请求。The processor 1401 may invoke the application stored in the memory 1403 via the transmission device 1405 to perform the step of: acquiring first information, wherein the first information is used to indicate that the first type of key agent module performs execution of the ciphertext processing request a result of detecting whether the first information meets a predetermined type switching condition, wherein the matching the predetermined type switching condition indicates that a vulnerability occurs in the first type of key agent module; and when detecting that the first information meets the predetermined type switching condition, The second type of key agent module executes the ciphertext processing request of the service module.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤在获取第一信息之前,向第一类型的密钥代理模块发送密文处理请求;获取第一类型的密钥代理模块执行密文处理请求的执行结果;获取第一信息包括:基于执行结果统计第一类型的密钥代理模块执 行密文处理请求的成功率,其中,第一信息包括成功率。The processor 1401 may invoke the application stored in the memory 1403 by the transmission device 1405 to perform the following steps: before acquiring the first information, sending a ciphertext processing request to the first type of key proxy module; acquiring the first type of key The proxy module executes the execution result of the ciphertext processing request; obtaining the first information includes: counting the first type of the key proxy module based on the execution result The success rate of the ciphertext processing request, wherein the first information includes a success rate.
可选地,预定类型切换条件包括成功率低于第一预定阈值,处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤:检测成功率是否低于第一预定阈值;若检测出成功率低于第一预定阈值,则确定第一信息符合预定类型切换条件;若检测出成功率不低于第一预定阈值,则确定第一信息不符合预定类型切换条件。Optionally, the predetermined type switching condition includes the success rate being lower than the first predetermined threshold, and the processor 1401 may invoke the application stored in the memory 1403 by the transmitting device 1405 to perform the step of: detecting whether the success rate is lower than the first predetermined threshold. And if the detected success rate is lower than the first predetermined threshold, determining that the first information meets the predetermined type switching condition; and if the detected success rate is not lower than the first predetermined threshold, determining that the first information does not meet the predetermined type switching condition.
可选地,第一类型的密钥代理模块为开发型密钥代理模块,第二类型的密钥代理模块为稳定型密钥代理模块,稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。Optionally, the first type of key agent module is a development type key agent module, the second type of key agent module is a stable key agent module, and the stable key agent module is executed within a predetermined time period. The ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,在获取第一信息之前,在对系统中的密钥代理模块中的文件进行更新之后,将执行了更新操作的密钥代理模块记录为第一类型的密钥代理模块;若在预定时间段内均检测出第一类型的密钥代理模块执行密文处理请求的正确率高于预定正确率,则将第一类型的密钥代理模块记录为第二类型的密钥代理模块。The processor 1401 may call the application stored in the memory 1403 through the transmission device 1405 to perform the following steps, and after updating the file in the key agent module in the system before the first information is acquired, the update operation will be performed. The key agent module is recorded as a first type of key agent module; if it is detected within a predetermined time period that the correct rate of the first type of key agent module performing the ciphertext processing request is higher than the predetermined correct rate, then A type of key broker module is recorded as a second type of key broker module.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,在获取第一信息之前,在系统中的第一类型的密钥代理模块正在运行的过程中,若需对密钥代理模块中的文件进行更新,则对第一类型的密钥代理模块中的文件进行更新。The processor 1401 may invoke the application stored in the memory 1403 through the transmission device 1405 to perform the following steps. Before the first information is acquired, in the process that the first type of the key agent module in the system is running, The files in the key broker module are updated to update the files in the first type of key broker module.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,若系统中包括多个第二类型的密钥代理模块,则从多个第二类型的密钥代理模块中获取更新时间最晚的第二类型的密钥代理模块,通过更新时间最晚的第二类型的密钥代理模块执行密文处理请求。The processor 1401 may invoke the application stored in the memory 1403 through the transmission device 1405 to perform the following steps. If the system includes multiple second type of key agent modules, from the plurality of second type of key agent modules Obtaining the second type of key agent module with the latest update time, and executing the ciphertext processing request by the second type of key agent module with the latest update time.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,在通过第二类型的密钥代理模块执行业务模块的密 文处理请求之后,在接收到输入的切换指令之后,响应于切换指令,通过第一类型的密钥代理模块执行密文处理请求。The processor 1401 may call the application stored in the memory 1403 through the transmission device 1405 to perform the following steps: performing the confidentiality of the service module by using the second type of key agent module After processing the request, after receiving the input switching instruction, the ciphertext processing request is executed by the first type of key agent module in response to the switching instruction.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,在通过第一类型的密钥代理模块或第二类型的密钥代理模块执行密文处理请求的过程中,通过业务线程获取密钥代理模块的密钥数据,其中,密钥代理模块设置为在检测出执行密文处理请求的成功率低于第二预定阈值的情况下,发送密钥数据;利用密钥数据解密共享内存中存储的密钥列表,得到解密后的密钥列表;利用解密后的密钥列表通过业务模块执行密文处理请求。The processor 1401 may call the application stored in the memory 1403 through the transmission device 1405 to perform the following steps, in the process of executing the ciphertext processing request by the first type of key agent module or the second type of key agent module, Obtaining key data of the key agent module by the service thread, wherein the key agent module is configured to send the key data when detecting that the success rate of executing the ciphertext processing request is lower than a second predetermined threshold; using the key The data decrypts the key list stored in the shared memory to obtain a decrypted key list; and uses the decrypted key list to execute the ciphertext processing request through the service module.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,在通过业务线程获取密钥代理模块的密钥数据之前,通过业务线程生成通信管道的第一端描述符和第二端描述符,其中,第一端描述符用于密钥代理模块将业务模块发送的数据识别为合法数据,第二端描述符用于业务模块将密钥代理模块发送的数据识别为合法数据;通过通信管道将第二端描述符传输给密钥代理模块。The processor 1401 may invoke the application stored in the memory 1403 by the transmission device 1405 to perform the following steps: before acquiring the key data of the key agent module by the service thread, generating the first end descriptor of the communication pipe through the service thread and a second end descriptor, wherein the first end descriptor is used by the key proxy module to identify the data sent by the service module as legal data, and the second end descriptor is used by the service module to identify the data sent by the key proxy module as legal Data; the second end descriptor is transmitted to the key broker module through the communication pipe.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,通过业务线程周期性从通信管道的读端读取数据;若从通信管道的读端读取到数据,则确定获取到密钥数据。The processor 1401 can call the application stored in the memory 1403 through the transmission device 1405 to perform the steps of periodically reading data from the read end of the communication pipe through the service thread; if the data is read from the read end of the communication pipe, Make sure to get the key data.
可选地,通信管道还用于检测业务模块、以及密钥代理模块是否重启。Optionally, the communication pipeline is further configured to detect whether the service module and the key agent module are restarted.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,在通过密钥代理模块执行密文处理请求的过程中,在密钥代理模块对业务进程进行合法性校验之后,在合法性校验通过的情况下,业务模块向密钥代理模块发送第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据;获取密钥代理模块生成的多个第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据。 The processor 1401 may call the application stored in the memory 1403 by the transmission device 1405 to perform the following steps: during the execution of the ciphertext processing request by the key agent module, the validity of the business process is verified by the key agent module. Then, in the case that the validity check is passed, the service module sends a first file descriptor to the key proxy module, where the first file descriptor is used by the key proxy module to identify the data sent by the service module as legal data; Obtaining a plurality of second file descriptors generated by the key agent module, wherein the second file descriptor is used by the service module to identify the data sent by the key agent module as legal data.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,在获取密钥代理模块生成的多个第二文件描述符之后,将获取到的多个第二文件描述符保存至队列中;依序利用队列中存储的第二文件描述符与密钥代理模块进行通信。The processor 1401 may call the application stored by the memory 1403 through the transmission device 1405 to perform the following steps, after acquiring the plurality of second file descriptors generated by the key agent module, the acquired second file descriptors Save to the queue; sequentially communicate with the key broker module using the second file descriptor stored in the queue.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,多个第二文件描述符的数目与密钥代理模块中用于执行密文处理请求的线程数目相对应。The processor 1401 may call the application stored in the memory 1403 via the transmission device 1405 to perform the following steps, the number of the plurality of second file descriptors corresponding to the number of threads in the key agent module for executing the ciphertext processing request.
可选的,密文处理请求包括:用于将待加密数据加密为密文数据的请求和/或用于将密文数据解密为解密数据的请求。Optionally, the ciphertext processing request includes: a request for encrypting the data to be encrypted into ciphertext data and/or a request for decrypting the ciphertext data into the decrypted data.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果;第二类型的密钥代理模块接收并执行业务模块的密文处理请求,其中,业务模块设置为在基于执行结果生成的第一信息符合预定类型切换条件的情况下,向第二类型的密钥代理模块发送密文处理请求,其中,符合预定类型切换条件表示确定第一类型的密钥代理模块出现漏洞。The processor 1401 may invoke the application stored in the memory 1403 by the transmission device 1405 to perform the following steps. The first type of key agent module receives and executes the ciphertext processing request of the service module to obtain an execution result; the second type of secret The key agent module receives and executes the ciphertext processing request of the service module, wherein the service module is configured to send the ciphertext to the second type of key agent module if the first information generated based on the execution result meets the predetermined type switching condition Processing the request, wherein conforming to the predetermined type of switching condition indicates determining that the first type of key agent module is vulnerable.
可选的,第一类型的密钥代理模块为开发型密钥代理模块,第二类型的密钥代理模块为稳定型密钥代理模块,稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。Optionally, the first type of key agent module is a development type key agent module, the second type of key agent module is a stable key agent module, and the stable key agent module is executed within a predetermined time period. The ciphertext processing request is more accurate than the key agent module of the predetermined correct rate.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,密钥代理模块获取执行密文处理请求的执行结果;密钥代理模块检测执行结果是否符合预定模式切换条件,其中,符合预定模式切换条件表示确定密钥代理模块出现漏洞;The processor 1401 may call the application stored in the memory 1403 through the transmission device 1405 to perform the following steps, the key agent module acquires an execution result of executing the ciphertext processing request; and the key agent module detects whether the execution result meets the predetermined mode switching condition, Wherein, meeting the predetermined mode switching condition indicates that the key agent module is vulnerable;
若检测出执行结果符合预定模式切换条件,则密钥代理模块向业务模块发送指示信息,其中,指示信息用于指示业务模块切换到通过业务模块 执行密文处理请求的模式。If it is detected that the execution result meets the predetermined mode switching condition, the key agent module sends the indication information to the service module, where the indication information is used to indicate that the service module switches to the service module. The mode in which the ciphertext processing request is executed.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,密钥代理模块获取执行密文处理请求的执行结果包括:密钥代理模块在执行完密文处理请求之后,基于密文处理请求中的请求时间与当前时间,判断执行当前的密文处理请求是否超时;若判断出执行当前的密文处理请求超时,则密钥代理模块确定执行当前的密文处理请求失败;密钥代理模块基于执行失败的密文处理请求的数量,统计密钥代理模块执行密文处理请求的成功率,执行结果包括成功率。The processor 1401 may invoke the application stored in the memory 1403 by the transmission device 1405 to perform the following steps. The key agent module obtains the execution result of the execution of the ciphertext processing request, including: after the cryptographic processing request is executed by the key agent module, Determining whether to execute the current ciphertext processing request timeout based on the request time and the current time in the ciphertext processing request; if it is determined that the current ciphertext processing request is timed out, the key agent module determines that the execution of the current ciphertext processing request fails. The key agent module calculates the success rate of the ciphertext processing request based on the number of ciphertext processing requests that fail to execute, and the execution result includes the success rate.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,密钥代理模块检测执行结果是否符合预定模式切换条件包括:密钥代理模块检测成功率是否低于第二预定阈值;若检测出执行密文处理请求的成功率是否低于第二预定阈值,则确定执行结果符合预定模式切换条件。The processor 1401 may invoke the application stored in the memory 1403 by the transmission device 1405 to perform the following steps. The key agent module detects whether the execution result meets the predetermined mode switching condition, including: the key agent module detects whether the success rate is lower than the second predetermined a threshold; if it is detected whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, determining that the execution result conforms to the predetermined mode switching condition.
处理器1401可以通过传输装置1405调用存储器1403存储的应用程序,以执行下述步骤,密钥代理模块向业务模块发送密钥数据,其中,密钥数据用于解密共享内存中存储的密钥列表,得到解密后的密钥列表,业务模块还设置为通过解密后的密钥列表执行密文处理请求。The processor 1401 may invoke an application stored in the memory 1403 via the transmission device 1405 to perform the following steps. The key agent module transmits key data to the service module, wherein the key data is used to decrypt the key list stored in the shared memory. The decrypted key list is obtained, and the service module is further configured to execute the ciphertext processing request through the decrypted key list.
根据本申请实施例,还提供了一种用于实施上述业务加密(或业务解密)方法的电子装置。According to an embodiment of the present application, an electronic device for implementing the above-described service encryption (or service decryption) method is also provided.
图15是根据本申请实施例的一种电子装置的结构框图,如图15所示,该电子装置可以包括:一个或多个(图中仅示出一个)处理器1501(如上述实施例中的密钥代理模块)、存储器1503、以及传输装置1505(如上述实施例中的发送装置),如图15所示,该电子装置还可以包括输入输出设备1507。FIG. 15 is a structural block diagram of an electronic device according to an embodiment of the present application. As shown in FIG. 15, the electronic device may include: one or more (only one is shown) processor 1501 (as in the above embodiment) The key agent module), the memory 1503, and the transmission device 1505 (such as the transmitting device in the above embodiment), as shown in FIG. 15, the electronic device may further include an input/output device 1507.
其中,存储器1503可存储软件程序以及模块,如本申请实施例中的 业务加密(或业务解密)方法和装置对应的程序指令/模块,处理器1501通过运行存储在存储器1503内的软件程序以及模块,从而执行各种功能应用以及数据处理,即实现上述的业务加密(或业务解密)方法。存储器1503可包括高速随机存储器,还可以包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器1503可进一步包括相对于处理器1501远程设置的存储器,这些远程存储器可以通过网络连接至终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory 1503 can store software programs and modules, as in the embodiment of the present application. The service encryption (or service decryption) method and the program instruction/module corresponding to the device, the processor 1501 performs various function applications and data processing by executing the software program and the module stored in the memory 1503, that is, implementing the above-mentioned service encryption ( Or business decryption) method. The memory 1503 may include a high speed random access memory, and may also include non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory. In some examples, memory 1503 can further include memory remotely located relative to processor 1501, which can be connected to the terminal over a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
上述的传输装置1505经由一个网络接收或者发送数据,还可以处理器与存储器之间的数据传输。上述的网络具体实例可包括有线网络及无线网络。在一个实例中,传输装置1505包括一个网络适配器(Network Interface Controller,NIC),其可通过网线与其他网络设备与路由器相连从而可与互联网或局域网进行通讯。在一个实例中,传输装置1505为射频(Radio Frequency,RF)模块,其用于通过无线方式与互联网进行通讯。The above-mentioned transmission device 1505 receives or transmits data via a network, and can also transfer data between the processor and the memory. Specific examples of the above network may include a wired network and a wireless network. In one example, the transmission device 1505 includes a Network Interface Controller (NIC) that can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network. In one example, the transmission device 1505 is a Radio Frequency (RF) module for communicating with the Internet wirelessly.
其中,具体地,存储器1503用于存储应用程序。Specifically, the memory 1503 is used to store an application.
处理器1501可以通过传输装置1505调用存储器1503存储的应用程序,以执行下述步骤:The processor 1501 can call the application stored in the memory 1503 through the transmission device 1505 to perform the following steps:
处理器1501还用于执行本申请提供的业务加密方法中的下述步骤:The processor 1501 is further configured to perform the following steps in the service encryption method provided by the application:
接收业务模块发送的加密请求,其中,加密请求中携带有待加密的数据;从密钥列表中获取目标密钥,其中,密钥列表是预先从密钥服务器中拉取到的;使用目标密钥对待加密的数据进行加密,得到加密后的数据;密钥代理模块将加密后的数据发送给业务模块。Receiving an encryption request sent by the service module, where the encryption request carries data to be encrypted; obtaining a target key from the key list, wherein the key list is previously extracted from the key server; using the target key The encrypted data is encrypted to obtain the encrypted data; the key agent module sends the encrypted data to the service module.
处理器1501还用于执行下述步骤:将第一公钥发送给所述密钥服务器,并从所述密钥服务器接收第二公钥,其中,所述密钥代理模块上具有一对所述第一公钥和第一私钥,所述密钥服务器上具有一对所述第二公钥 和第二私钥;向所述密钥服务器发送密钥列表拉取请求;所述密钥代理模块接收所述密钥服务器发送的加密后的密钥列表,其中,所述加密后的密钥列表是使用所述密钥服务器侧的第一通讯密钥对所述密钥列表进行加密得到的,所述第一通讯密钥是所述密钥服务器根据所述第一公钥和所述第二私钥生成得到的;使用所述密钥代理模块侧的第二通讯密钥对所述加密后的密钥列表进行解密,得到所述密钥列表,其中,所述第二通讯密钥是所述密钥代理模块根据所述第一私钥和所述第二公钥生成得到的,所述第一通讯密钥与所述第二通讯密钥相同。The processor 1501 is further configured to: send a first public key to the key server, and receive a second public key from the key server, where the key agent module has a pair of a first public key and a first private key, the key server having a pair of the second public key And a second private key; transmitting a key list pull request to the key server; the key proxy module receiving the encrypted key list sent by the key server, wherein the encrypted key The list is obtained by encrypting the key list using a first communication key on the key server side, the first communication key being the key server according to the first public key and the first Generating the second private key; decrypting the encrypted key list using the second communication key on the key proxy module side to obtain the key list, wherein the second communication key is The key agent module generates the first communication key and the second public key according to the first private key and the second public key.
处理器1501还用于执行下述步骤:在所述密钥代理模块重启时,将加密后的所述第一公钥发送给所述密钥服务器,其中,所述加密后的所述第一公钥是使用约定密钥对所述第一公钥进行加密得到的;从所述密钥服务器接收加密后的所述第二公钥,其中,所述加密后的所述第二公钥是使用所述约定密钥对所述第二公钥进行加密得到的;使用所述约定密钥对所述加密后的第二公钥进行解密,得到所述第二公钥;其中,所述约定密钥被设置为仅在所述密钥代理模块重启时使用。The processor 1501 is further configured to: when the key agent module is restarted, send the encrypted first public key to the key server, where the encrypted first The public key is obtained by encrypting the first public key using a contract key; receiving the encrypted second public key from the key server, wherein the encrypted second public key is Obtaining the second public key by using the agreement key; decrypting the encrypted second public key by using the agreement key to obtain the second public key; wherein the agreement The key is set to be used only when the key broker module is restarted.
处理器1501还用于执行下述步骤:在密钥代理模块接收业务模块发送的加密请求之前,获取业务进程的进程PID,其中,业务进程为业务模块发送待加密的数据的进程;对业务进程和进程PID进行合法性校验;从密钥列表中获取目标密钥包括:在合法性校验通过的情况下,密钥代理模块从密钥列表中获取目标密钥。The processor 1501 is further configured to: before the key proxy module receives the encryption request sent by the service module, acquire a process PID of the service process, where the service process sends a process of the data to be encrypted to the service module; The legality check is performed with the process PID; obtaining the target key from the key list includes: when the validity check is passed, the key agent module obtains the target key from the key list.
处理器1501还用于执行下述步骤:获取与进程PID对应的进程全路径;判断进程全路径是否属于预先从密钥服务器获取到的合法路径中的路径;在判断出进程全路径属于合法路径中的路径的情况下,对业务进程进行MD5校验操作,得到第一MD5校验结果;在判断出进程全路径不属于合法路径中的路径的情况下,判断出合法性校验不通过;判断第一MD5校验结果是否与预先获取的与业务进程对应的第二MD5校验结果相同; 若第一MD5校验结果与第二MD5校验结果相同,则判断出合法性校验通过;若第一MD5校验结果与第二MD5校验结果不同,则判断出合法性校验不通过。The processor 1501 is further configured to: obtain a process full path corresponding to the process PID; determine whether the process full path belongs to a path in a legal path obtained from the key server in advance; and determine that the process full path belongs to the legal path. In the case of the path, the MD5 check operation is performed on the service process to obtain the first MD5 check result; if it is determined that the process full path does not belong to the path in the legal path, it is determined that the validity check fails; Determining whether the first MD5 check result is the same as the second MD5 check result corresponding to the pre-acquired service process; If the first MD5 check result is the same as the second MD5 check result, it is determined that the validity check is passed; if the first MD5 check result is different from the second MD5 check result, it is determined that the validity check fails. .
处理器1501还执行下述步骤:在密钥代理模块对业务进程和进程PID进行合法性校验之后,并在密钥代理模块接收业务模块发送的加密请求之前,且在合法性校验通过的情况下,获取业务模块发送的第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据;生成第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据;将第二文件描述符传输给业务模块。The processor 1501 further performs the following steps: after the key agent module performs the validity check on the service process and the process PID, and before the key agent module receives the encryption request sent by the service module, and passes the validity check. In the case that the first file descriptor sent by the service module is obtained, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal data; and the second file descriptor is generated, where the second file is generated. The descriptor is used by the service module to identify the data sent by the key proxy module as legal data; the second file descriptor is transmitted to the service module.
处理器1501还用于执行下述步骤:接收业务模块发送的加密请求包括:从共享内存中获取业务模块存入的待加密的数据;将加密后的数据发送给业务模块包括:将加密后的数据存入到共享内存中,以使得业务模块从共享内存中获取加密后的数据。The processor 1501 is further configured to: perform the following steps: receiving the encryption request sent by the service module includes: acquiring data to be encrypted stored by the service module from the shared memory; and transmitting the encrypted data to the service module, including: encrypting The data is stored in the shared memory so that the business module obtains the encrypted data from the shared memory.
处理器1501还用于执行下述步骤:在密钥代理模块对业务进程和进程PID进行合法性校验之后,并在密钥代理模块接收业务模块发送的加密请求之前,且在合法性校验通过的情况下,为第一文件描述符设置目标权限,其中,目标权限包括以下至少之一:允许密钥代理模块对业务模块请求的待加密的数据进行加密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。The processor 1501 is further configured to perform the following steps: after the key agent module performs the validity check on the service process and the process PID, and before the key agent module receives the encryption request sent by the service module, and the validity check In the case of the first file descriptor, the target permission is set, wherein the target authority includes at least one of the following: the key agent module is allowed to encrypt the data to be encrypted requested by the service module, and the key agent module is allowed to the service module. The requested data to be decrypted is decrypted.
处理器1501还用于执行下述步骤:在合法性校验通过的情况下,在目标权限包括允许密钥代理模块对业务模块请求的待加密的数据进行加密时,密钥代理模块从密钥列表中获取目标密钥。The processor 1501 is further configured to perform the following steps: in the case that the legality verification is passed, when the target authority includes allowing the key proxy module to encrypt the data to be encrypted requested by the service module, the key proxy module is from the key Get the target key in the list.
处理器1501还用于执行下述步骤:密钥代理模块在非root运行模式下通过unix域套接字获取业务进程的进程PID;或者,密钥代理模块将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业 务进程的进程PID。The processor 1501 is further configured to: the key proxy module acquires the process PID of the service process through the unix domain socket in the non-root operation mode; or the key proxy module configures the option of the socket socket as the SO_PEERCRED And through the socket socket acquisition industry Process PID of the process.
处理器1501还用于执行本申请提供的业务解密方法中的下述步骤:The processor 1501 is further configured to perform the following steps in the service decryption method provided by the application:
接收业务模块发送的解密请求,其中,解密请求中携带有待解密的数据;从密钥列表中获取目标密钥,其中,密钥列表是预先从密钥服务器中拉取到的;使用目标密钥对待解密的数据进行解密,得到解密后的数据;密钥代理模块将解密后的数据发送给业务模块。Receiving a decryption request sent by the service module, where the decryption request carries data to be decrypted; obtaining a target key from the key list, wherein the key list is previously extracted from the key server; using the target key The decrypted data is decrypted to obtain the decrypted data; the key agent module sends the decrypted data to the service module.
处理器1501还用于执行下述步骤:将第一公钥发送给所述密钥服务器,并从所述密钥服务器接收第二公钥,其中,所述密钥代理模块上具有一对所述第一公钥和第一私钥,所述密钥服务器上具有一对所述第二公钥和第二私钥;向所述密钥服务器发送密钥列表拉取请求;所述密钥代理模块接收所述密钥服务器发送的加密后的密钥列表,其中,所述加密后的密钥列表是使用所述密钥服务器侧的第一通讯密钥对所述密钥列表进行加密得到的,所述第一通讯密钥是所述密钥服务器根据所述第一公钥和所述第二私钥生成得到的;使用所述密钥代理模块侧的第二通讯密钥对所述加密后的密钥列表进行解密,得到所述密钥列表,其中,所述第二通讯密钥是所述密钥代理模块根据所述第一私钥和所述第二公钥生成得到的,所述第一通讯密钥与所述第二通讯密钥相同。The processor 1501 is further configured to: send a first public key to the key server, and receive a second public key from the key server, where the key agent module has a pair of a first public key having a pair of the second public key and a second private key; and a key list pull request sent to the key server; the key The proxy module receives the encrypted key list sent by the key server, wherein the encrypted key list is obtained by encrypting the key list by using the first communication key on the key server side. The first communication key is generated by the key server according to the first public key and the second private key; using the second communication key on the key proxy module side Decrypting the encrypted key list to obtain the key list, wherein the second communication key is generated by the key agent module according to the first private key and the second public key, The first communication key is the same as the second communication key.
处理器1501还用于执行下述步骤:在所述密钥代理模块重启时,将加密后的所述第一公钥发送给所述密钥服务器,其中,所述加密后的所述第一公钥是使用约定密钥对所述第一公钥进行加密得到的;从所述密钥服务器接收加密后的所述第二公钥,其中,所述加密后的所述第二公钥是使用所述约定密钥对所述第二公钥进行加密得到的;使用所述约定密钥对所述加密后的第二公钥进行解密,得到所述第二公钥;其中,所述约定密钥被设置为仅在所述密钥代理模块重启时使用。The processor 1501 is further configured to: when the key agent module is restarted, send the encrypted first public key to the key server, where the encrypted first The public key is obtained by encrypting the first public key using a contract key; receiving the encrypted second public key from the key server, wherein the encrypted second public key is Obtaining the second public key by using the agreement key; decrypting the encrypted second public key by using the agreement key to obtain the second public key; wherein the agreement The key is set to be used only when the key broker module is restarted.
处理器1501还用于执行下述步骤:在密钥代理模块接收业务模块发送的解密请求之前,获取业务进程的进程PID,其中,业务进程为业务模 块发送待解密的数据的进程;对业务进程和进程PID进行合法性校验;从密钥列表中获取目标密钥包括:在合法性校验通过的情况下,密钥代理模块从密钥列表中获取目标密钥。The processor 1501 is further configured to: obtain the process PID of the service process, where the service process is a service mode, before the key agent module receives the decryption request sent by the service module. The process of sending the data to be decrypted by the block; verifying the legality of the business process and the process PID; and obtaining the target key from the key list includes: in the case that the legality verification is passed, the key agent module is from the key list Get the target key.
处理器1501还用于执行下述步骤:获取与进程PID对应的进程全路径;判断进程全路径是否属于预先从密钥服务器获取到的合法路径中的路径;在判断出进程全路径属于合法路径中的路径的情况下,对业务进程进行MD5校验操作,得到第一MD5校验结果;在判断出进程全路径不属于合法路径中的路径的情况下,判断出合法性校验不通过;判断第一MD5校验结果是否与预先获取的与业务进程对应的第二MD5校验结果相同;若第一MD5校验结果与第二MD5校验结果相同,则判断出合法性校验通过;若第一MD5校验结果与第二MD5校验结果不同,则判断出合法性校验不通过。The processor 1501 is further configured to: obtain a process full path corresponding to the process PID; determine whether the process full path belongs to a path in a legal path obtained from the key server in advance; and determine that the process full path belongs to the legal path. In the case of the path, the MD5 check operation is performed on the service process to obtain the first MD5 check result; if it is determined that the process full path does not belong to the path in the legal path, it is determined that the validity check fails; Determining whether the first MD5 check result is the same as the second MD5 check result corresponding to the service process obtained in advance; if the first MD5 check result is the same as the second MD5 check result, determining that the validity check is passed; If the first MD5 check result is different from the second MD5 check result, it is determined that the validity check fails.
处理器1501还用于执行下述步骤:在密钥代理模块对业务进程和进程PID进行合法性校验之后,并在密钥代理模块接收业务模块发送的解密请求之前,且在合法性校验通过的情况下,获取业务模块发送的第一文件描述符,其中,第一文件描述符用于密钥代理模块将业务模块发送的数据识别为合法数据;生成第二文件描述符,其中,第二文件描述符用于业务模块将密钥代理模块发送的数据识别为合法数据;将第二文件描述符传输给业务模块。The processor 1501 is further configured to perform the following steps: after the key agent module performs the validity check on the service process and the process PID, and before the key agent module receives the decryption request sent by the service module, and the validity check And obtaining, by the first file descriptor sent by the service module, where the first file descriptor is used by the key agent module to identify the data sent by the service module as legal data; and the second file descriptor is generated, where The second file descriptor is used by the service module to identify the data sent by the key agent module as legal data; and the second file descriptor is transmitted to the service module.
处理器1501还用于执行下述步骤:接收业务模块发送的解密请求包括:从共享内存中获取业务模块存入的待解密的数据;将解密后的数据发送给业务模块包括:将解密后的数据存入到共享内存中,以使得业务模块从共享内存中获取解密后的数据。The processor 1501 is further configured to: perform the following steps: the receiving the decryption request sent by the service module comprises: acquiring data to be decrypted stored by the service module from the shared memory; and sending the decrypted data to the service module comprises: decrypting the decrypted The data is stored in the shared memory so that the business module obtains the decrypted data from the shared memory.
处理器1501还用于执行下述步骤:在密钥代理模块对业务进程和进程PID进行合法性校验之后,并在密钥代理模块接收业务模块发送的解密请求之前,且在合法性校验通过的情况下,为第一文件描述符设置目标权 限,其中,目标权限包括以下至少之一:允许密钥代理模块对业务模块请求的待解密的数据进行解密,允许密钥代理模块对业务模块请求的待解密的数据进行解密。The processor 1501 is further configured to perform the following steps: after the key agent module performs the validity check on the service process and the process PID, and before the key agent module receives the decryption request sent by the service module, and the validity check In the case of passing, set the target right for the first file descriptor The target authority includes at least one of the following: the key proxy module is allowed to decrypt the data to be decrypted requested by the service module, and the key proxy module is allowed to decrypt the data to be decrypted requested by the service module.
处理器1501还用于执行下述步骤:在合法性校验通过的情况下,在目标权限包括允许密钥代理模块对业务模块请求的待解密的数据进行解密时,密钥代理模块从密钥列表中获取目标密钥。The processor 1501 is further configured to perform the following steps: in the case that the legality verification is passed, when the target authority includes the key agent module to decrypt the data to be decrypted requested by the service module, the key agent module slave key Get the target key in the list.
处理器1501还用于执行下述步骤:密钥代理模块在非root运行模式下通过unix域套接字获取业务进程的进程PID;或者,密钥代理模块将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取业务进程的进程PID。The processor 1501 is further configured to: the key proxy module acquires the process PID of the service process through the unix domain socket in the non-root operation mode; or the key proxy module configures the option of the socket socket as the SO_PEERCRED And get the process PID of the business process through the socket socket.
采用本申请实施例,提供了一种业务加密(或业务解密)的方案。通过密钥代理模块接收加密(或解密)请求,然后,根据密钥请求获取目标密钥,接下来,通过目标密钥对待加密(或待解密)的数据进行加密,本申请实施例中提供的业务加密(或解密)方式,达到了更加安全地为业务进行加密(或解密)的目的,从而实现了提高了对业务进行加密(或解密)时密钥安全性的技术效果,进而解决了现有技术中在对业务进行解密时密钥的安全性较低的技术问题。With the embodiment of the present application, a scheme of service encryption (or service decryption) is provided. Receiving an encryption (or decryption) request by the key agent module, and then acquiring the target key according to the key request, and then encrypting the data to be encrypted (or to be decrypted) by the target key, which is provided in the embodiment of the present application. The service encryption (or decryption) method achieves the purpose of encrypting (or decrypting) the service more securely, thereby realizing the technical effect of improving the key security when encrypting (or decrypting) the service, thereby solving the present problem. There is a technical problem in the technology that the security of the key is low when the service is decrypted.
可选地,本实施例中的具体示例可以参考上述实施例中所描述的示例,本实施例在此不再赘述。For example, the specific examples in this embodiment may refer to the examples described in the foregoing embodiments, and details are not described herein again.
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令终端设备相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:闪存盘、只读存储器(Read-Only Memory,ROM)、随机存取器(Random Access Memory,RAM)、磁盘或光盘等。 A person of ordinary skill in the art may understand that all or part of the steps of the foregoing embodiments may be completed by a program to instruct terminal device related hardware, and the program may be stored in a computer readable storage medium, and the storage medium may be Including: flash disk, read-only memory (ROM), random access memory (RAM), disk or optical disk.
实施例4Example 4
本申请的实施例还提供了一种存储介质。可选地,在本实施例中,上述存储介质可以用于执行业务处理方法的程序代码。可选地,在本实施例中,上述存储介质可以位于上述实施例所示的网络中的多个网络设备中的至少一个网络设备上。Embodiments of the present application also provide a storage medium. Optionally, in this embodiment, the foregoing storage medium may be used to execute program code of a service processing method. Optionally, in this embodiment, the foregoing storage medium may be located on at least one of the plurality of network devices in the network shown in the foregoing embodiment.
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:Optionally, in the present embodiment, the storage medium is arranged to store program code for performing the following steps:
获取第一信息,其中,第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;检测第一信息是否符合预定类型切换条件,其中,符合预定类型切换条件表示确定第一类型的密钥代理模块出现漏洞;在检测出第一信息符合预定类型切换条件的情况下,通过第二类型的密钥代理模块执行业务模块的密文处理请求。Obtaining first information, wherein the first information is used to indicate that the first type of key agent module performs an execution result of the ciphertext processing request; and detecting whether the first information meets a predetermined type switching condition, wherein the predetermined type switching condition is determined to be determined A vulnerability occurs in the first type of key agent module; in the case where it is detected that the first information conforms to the predetermined type of switching condition, the ciphertext processing request of the service module is executed by the second type of key agent module.
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:Optionally, in the present embodiment, the storage medium is arranged to store program code for performing the following steps:
S11,密钥代理模块接收业务模块发送的加密请求,其中,加密请求中携带有待加密的数据;S11. The key agent module receives an encryption request sent by the service module, where the encryption request carries data to be encrypted.
S12,密钥代理模块从密钥列表中获取目标密钥,其中,密钥列表是预先从密钥服务器中拉取到的;S12. The key agent module obtains a target key from a key list, where the key list is previously extracted from the key server;
S13,密钥代理模块使用目标密钥对待加密的数据进行加密,得到加密后的数据;S13. The key agent module encrypts the data to be encrypted by using the target key, and obtains the encrypted data.
S14,密钥代理模块将加密后的数据发送给业务模块。S14. The key agent module sends the encrypted data to the service module.
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:Optionally, in the present embodiment, the storage medium is arranged to store program code for performing the following steps:
S21,密钥代理模块接收业务模块发送的解密请求,其中,解密请求 中携带有待解密的数据;S21. The key agent module receives a decryption request sent by the service module, where the decryption request Carrying data to be decrypted;
S22,密钥代理模块从密钥列表中获取目标密钥,其中,密钥列表是预先从密钥服务器中拉取到的;S22. The key agent module obtains a target key from a key list, where the key list is previously extracted from the key server.
S23,密钥代理模块使用目标密钥对待解密的数据进行解密,得到解密后的数据;S23. The key agent module decrypts the data to be decrypted by using the target key to obtain the decrypted data.
S24,密钥代理模块将解密后的数据发送给业务模块。S24. The key agent module sends the decrypted data to the service module.
可选地,本实施例中的具体示例可以参考上述实施例中所描述的示例,本实施例在此不再赘述。For example, the specific examples in this embodiment may refer to the examples described in the foregoing embodiments, and details are not described herein again.
可选地,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。Optionally, in this embodiment, the foregoing storage medium may include, but not limited to, a USB flash drive, a Read-Only Memory (ROM), a Random Access Memory (RAM), a mobile hard disk, and a magnetic memory. A variety of media that can store program code, such as a disc or a disc.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the embodiments of the present application are merely for the description, and do not represent the advantages and disadvantages of the embodiments.
上述实施例中的集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在上述计算机可读取的存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在存储介质中,包括若干指令用以使得一台或多台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。The integrated unit in the above embodiment, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in the above-described computer readable storage medium. Based on such understanding, the technical solution of the present application, in essence or the contribution to the prior art, or all or part of the technical solution may be embodied in the form of a software product, which is stored in a storage medium. A number of instructions are included to cause one or more computer devices (which may be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application.
在本申请的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above-mentioned embodiments of the present application, the descriptions of the various embodiments are different, and the parts that are not detailed in a certain embodiment can be referred to the related descriptions of other embodiments.
在本申请所提供的几个实施例中,应该理解到,所揭露的客户端,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外 的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided by the present application, it should be understood that the disclosed client may be implemented in other manners. Wherein, the device embodiments described above are only schematic, for example, the division of the unit is only a logical function division, and the actual implementation may have another The manner of division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, unit or module, and may be electrical or otherwise.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
以上所述仅是本申请的可选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。The above description is only an alternative embodiment of the present application, and it should be noted that those skilled in the art can make several improvements and retouchings without departing from the principles of the present application. It should also be considered as the scope of protection of this application.
工业实用性Industrial applicability
在本申请实施例中,获取第一信息,其中,第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;检测第一信息是否符合预定类型切换条件;在检测出第一信息符合预定类型切换条件的情况下,通过第二类型的密钥代理模块执行业务模块的密文处理请求,在上述实施例中,可以根据第一类型的密钥代理处理模块执行密文处理请求的结果来确定是否符合预定类型切换条件,在符合切换条件的情况下,不再通过第一类型的密钥代理处理模块执行密文处理请求,而是通过第二类型的密钥代理处理模块执行密文处理请求,在该方案中,可以在第一类型的密钥代理处理模块无法继续稳定的执行密文处理请求,则将切换第二类型的密钥代理模块,以稳定处理密文处理请求,解决了现有技术中,在对业务进行 加解密时密钥的稳定性较低的问题。 In the embodiment of the present application, the first information is obtained, where the first information is used to indicate that the first type of the key agent module performs the execution result of the ciphertext processing request; whether the first information meets the predetermined type switching condition; If the first information meets the predetermined type switching condition, the ciphertext processing request of the service module is executed by the second type of key proxy module. In the above embodiment, the secret may be executed according to the first type of key proxy processing module. The result of the file processing request determines whether the predetermined type switching condition is met, and if the switching condition is met, the ciphertext processing request is no longer performed by the first type of key agent processing module, but the second type of key agent is used. The processing module executes the ciphertext processing request. In the solution, the first type of the key proxy processing module cannot continue to perform the ciphertext processing request stably, and the second type of the key proxy module is switched to stabilize the processing. The text processing request solves the prior art and is in the business The problem of low key stability during encryption and decryption.

Claims (64)

  1. 一种业务处理方法,包括:A business processing method comprising:
    获取第一信息,其中,所述第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;Obtaining first information, where the first information is used to indicate that an execution result of the first type of key proxy module performs a ciphertext processing request;
    检测所述第一信息是否符合预定类型切换条件,其中,符合所述预定类型切换条件表示确定所述第一类型的密钥代理模块出现漏洞;Detecting whether the first information meets a predetermined type switching condition, wherein the matching the predetermined type switching condition indicates that a vulnerability occurs in the first type of key agent module;
    在检测出所述第一信息符合所述预定类型切换条件的情况下,通过第二类型的密钥代理模块执行业务模块的密文处理请求。In a case where it is detected that the first information conforms to the predetermined type switching condition, the ciphertext processing request of the service module is executed by the second type of key agent module.
  2. 根据权利要求1所述的方法,其中,The method of claim 1 wherein
    在获取第一信息之前,所述方法还包括:向所述第一类型的密钥代理模块发送密文处理请求;获取所述第一类型的密钥代理模块执行密文处理请求的执行结果;Before the obtaining the first information, the method further includes: sending a ciphertext processing request to the first type of key proxy module; and acquiring an execution result of the ciphertext processing request by the first type of the key proxy module;
    获取第一信息包括:基于所述执行结果统计所述第一类型的密钥代理模块执行密文处理请求的成功率,其中,所述第一信息包括所述成功率。Acquiring the first information includes: counting, according to the execution result, a success rate of the first type of key agent module performing a ciphertext processing request, wherein the first information includes the success rate.
  3. 根据权利要求2所述的方法,其中,所述预定类型切换条件包括成功率低于第一预定阈值,检测所述第一信息是否符合预定类型切换条件包括:The method of claim 2, wherein the predetermined type of switching condition comprises a success rate lower than a first predetermined threshold, and detecting whether the first information meets a predetermined type of switching condition comprises:
    检测所述成功率是否低于所述第一预定阈值;Detecting whether the success rate is lower than the first predetermined threshold;
    若检测出所述成功率低于所述第一预定阈值,则确定所述第一信息符合所述预定类型切换条件;If it is detected that the success rate is lower than the first predetermined threshold, determining that the first information meets the predetermined type switching condition;
    若检测出所述成功率不低于所述第一预定阈值,则确定所述第一信息不符合所述预定类型切换条件。And if it is detected that the success rate is not lower than the first predetermined threshold, determining that the first information does not meet the predetermined type switching condition.
  4. 根据权利要求1所述的方法,其中,所述第一类型的密钥代理模块为开发型密钥代理模块,所述第二类型的密钥代理模块为稳定型密钥代理模块,所述稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。 The method according to claim 1, wherein said first type of key agent module is a development type key agent module, said second type of key agent module is a stable type key agent module, said stabilizing The type key agent module is a key agent module that performs a ciphertext processing request with a correct rate higher than a predetermined correct rate within a predetermined time period.
  5. 根据权利要求4所述的方法,其中,在获取第一信息之前,所述方法还包括:The method of claim 4, wherein before the obtaining the first information, the method further comprises:
    在对系统中的密钥代理模块中的文件进行更新之后,将执行了更新操作的密钥代理模块记录为所述第一类型的密钥代理模块;After updating the file in the key agent module in the system, the key agent module that performs the update operation is recorded as the first type of key agent module;
    若在预定时间段内均检测出所述第一类型的密钥代理模块执行所述密文处理请求的正确率高于预定正确率,则将所述第一类型的密钥代理模块记录为第二类型的密钥代理模块。If it is detected that the correct rate of the first type of key agent module executing the ciphertext processing request is higher than a predetermined correct rate within a predetermined time period, the first type of key agent module is recorded as the first Two types of key broker modules.
  6. 根据权利要求1所述的方法,其中,在获取第一信息之前,所述方法还包括:The method of claim 1, wherein before the obtaining the first information, the method further comprises:
    在系统中的第一类型的密钥代理模块正在运行的过程中,若需对密钥代理模块中的文件进行更新,则对所述第一类型的密钥代理模块中的文件进行更新。During the running of the first type of key agent module in the system, if the file in the key agent module needs to be updated, the file in the first type of key agent module is updated.
  7. 根据权利要求1所述的方法,其中,通过第二类型的密钥代理模块执行所述业务模块请求的密文处理请求包括:The method of claim 1, wherein the ciphertext processing request requested by the service module by the second type of key broker module comprises:
    若系统中包括多个第二类型的密钥代理模块,则从多个第二类型的密钥代理模块中获取更新时间最晚的第二类型的密钥代理模块,通过所述更新时间最晚的第二类型的密钥代理模块执行所述密文处理请求。If a plurality of second type of key agent modules are included in the system, the second type of key agent module with the latest update time is obtained from the plurality of second type of key agent modules, and the update time is the latest. The second type of key broker module executes the ciphertext processing request.
  8. 根据权利要求1所述的方法,其中,在通过第二类型的密钥代理模块执行所述业务模块的密文处理请求之后,所述方法还包括:The method of claim 1, wherein after performing the ciphertext processing request of the service module by the second type of key broker module, the method further comprises:
    在接收到输入的切换指令之后,响应于所述切换指令,通过所述第一类型的密钥代理模块执行密文处理请求。After receiving the input switching instruction, the ciphertext processing request is performed by the first type of key broker module in response to the switching instruction.
  9. 根据权利要求1所述的方法,其中,在通过第一类型的密钥代理模块或第二类型的密钥代理模块执行所述密文处理请求的过程中,所述方法还包括: The method of claim 1, wherein in the performing the ciphertext processing request by the first type of key broker module or the second type of key broker module, the method further comprises:
    通过业务线程获取所述密钥代理模块的密钥数据,其中,所述密钥代理模块设置为在检测出执行所述密文处理请求的成功率低于第二预定阈值的情况下,发送所述密钥数据;Obtaining, by the service thread, the key data of the key agent module, wherein the key agent module is configured to send the station if it is detected that the success rate of executing the ciphertext processing request is lower than a second predetermined threshold Key data
    利用所述密钥数据解密共享内存中存储的密钥列表,得到解密后的密钥列表;Decrypting the key list stored in the shared memory by using the key data to obtain a decrypted key list;
    利用所述解密后的密钥列表通过业务模块执行所述密文处理请求。The ciphertext processing request is executed by the service module by using the decrypted key list.
  10. 根据权利要求9所述的方法,其中,在通过业务线程获取所述密钥代理模块的密钥数据之前,所述方法还包括:The method of claim 9, wherein before the obtaining the key data of the key broker module by the service thread, the method further comprises:
    通过所述业务线程生成通信管道的第一端描述符和第二端描述符,其中,所述第一端描述符用于所述密钥代理模块将所述业务模块发送的数据识别为合法数据,所述第二端描述符用于所述业务模块将所述密钥代理模块发送的数据识别为合法数据;Generating, by the service thread, a first end descriptor and a second end descriptor of a communication pipeline, wherein the first end descriptor is used by the key proxy module to identify data sent by the service module as legal data The second end descriptor is used by the service module to identify data sent by the key proxy module as legal data;
    通过所述通信管道将所述第二端描述符传输给所述密钥代理模块。Transmitting the second end descriptor to the key broker module via the communication conduit.
  11. 根据权利要求10所述的方法,其中,通过业务线程获取所述密钥代理模块的密钥数据包括:The method of claim 10, wherein the obtaining the key data of the key agent module by the service thread comprises:
    通过所述业务线程周期性从所述通信管道的读端读取数据;Reading data from the read end of the communication pipe periodically through the service thread;
    若从所述通信管道的读端读取到数据,则确定获取到所述密钥数据。If data is read from the read end of the communication pipe, it is determined that the key data is acquired.
  12. 根据权利要求10所述的方法,其中,所述通信管道还用于检测所述业务模块、以及所述密钥代理模块是否重启。The method of claim 10 wherein said communication conduit is further for detecting said service module and whether said key agent module is restarted.
  13. 根据权利要求1所述的方法,其中,在通过密钥代理模块执行所述密文处理请求的过程中,所述方法还包括:The method of claim 1, wherein in the performing the ciphertext processing request by the key broker module, the method further comprises:
    在所述密钥代理模块对业务进程进行合法性校验之后,在所述合法性校验通过的情况下,所述业务模块向所述密钥代理模块发送第一 文件描述符,其中,所述第一文件描述符用于所述密钥代理模块将所述业务模块发送的数据识别为合法数据;After the validity of the validity of the service process by the key agent module, the service module sends the first to the key agent module if the validity check is passed. a file descriptor, wherein the first file descriptor is used by the key agent module to identify data sent by the service module as legal data;
    获取所述密钥代理模块生成的多个第二文件描述符,其中,所述第二文件描述符用于所述业务模块将所述密钥代理模块发送的数据识别为合法数据。Obtaining a plurality of second file descriptors generated by the key agent module, wherein the second file descriptor is used by the service module to identify data sent by the key agent module as legal data.
  14. 根据权利要求13所述的方法,其中,在获取所述密钥代理模块生成的多个第二文件描述符之后,所述方法还包括:The method of claim 13, wherein after acquiring the plurality of second file descriptors generated by the key broker module, the method further comprises:
    将获取到的所述多个第二文件描述符保存至队列中;Saving the obtained plurality of second file descriptors into a queue;
    依序利用所述队列中存储的第二文件描述符与所述密钥代理模块进行通信。The second file descriptor stored in the queue is used to communicate with the key broker module in sequence.
  15. 根据权利要求13所述的方法,其中,所述多个第二文件描述符的数目与所述密钥代理模块中用于执行所述密文处理请求的线程数目相对应。The method of claim 13, wherein the number of the plurality of second file descriptors corresponds to a number of threads in the key broker module for executing the ciphertext processing request.
  16. 根据权利要求1至15中任意一项所述的方法,其中,所述密文处理请求包括:用于将待加密数据加密为密文数据的请求和/或用于将密文数据解密为解密数据的请求。The method according to any one of claims 1 to 15, wherein the ciphertext processing request comprises: a request for encrypting data to be encrypted into ciphertext data and/or for decrypting ciphertext data into decryption Request for data.
  17. 一种业务处理方法,包括:A business processing method comprising:
    第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果;The first type of key agent module receives and executes the ciphertext processing request of the service module, and obtains an execution result;
    第二类型的密钥代理模块接收并执行所述业务模块的密文处理请求,其中,所述业务模块设置为在基于所述执行结果生成的第一信息符合预定类型切换条件的情况下,向所述第二类型的密钥代理模块发送密文处理请求,其中,符合所述预定类型切换条件表示确定所述第一类型的密钥代理模块出现漏洞。a second type of key agent module receives and executes a ciphertext processing request of the service module, wherein the service module is configured to: if the first information generated based on the execution result meets a predetermined type switching condition, The second type of key broker module sends a ciphertext processing request, wherein conforming to the predetermined type of handover condition indicates that a vulnerability occurs in the first type of key broker module.
  18. 根据权利要求17所述的方法,其中,所述第一类型的密钥代理模块为开发型密钥代理模块,所述第二类型的密钥代理模块为稳定型密钥 代理模块,所述稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。The method of claim 17, wherein the first type of key agent module is a development type key agent module and the second type of key agent module is a stable type key The proxy module, the stable key proxy module is a key broker module that performs a ciphertext processing request with a correct rate higher than a predetermined correct rate within a predetermined time period.
  19. 根据权利要求17所述的方法,其中,The method of claim 17, wherein
    在第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果之前,所述方法还包括:在对系统中的密钥代理模块中的文件进行更新之后,将执行了更新操作的密钥代理模块记录为所述第一类型的密钥代理模块;Before the first type of key agent module receives and executes the ciphertext processing request of the service module, and obtains the execution result, the method further includes: after updating the file in the key agent module in the system, the method is executed. The key agent module of the update operation is recorded as the first type of key agent module;
    在第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果之后,所述方法还包括:若在预定时间段内均检测出所述第一类型的密钥代理模块执行所述密文处理请求的正确率高于预定正确率,则将所述第一类型的密钥代理模块记录为第二类型的密钥代理模块。After the first type of key agent module receives and executes the ciphertext processing request of the service module, and obtains the execution result, the method further includes: if the first type of the key agent module is detected within a predetermined time period The correctness rate of the execution of the ciphertext processing request is higher than the predetermined correct rate, and the first type of key broker module is recorded as the second type of key broker module.
  20. 根据权利要求17所述的方法,其中,在所述第一类型的密钥代理模块执行所述业务模块的密文处理请求的过程中,所述方法还包括:The method according to claim 17, wherein in the process of the ciphertext processing request of the service module of the first type of the key agent module, the method further comprises:
    若需对密钥代理模块中的文件进行更新,则对所述第一类型的密钥代理模块中的文件进行更新。If the file in the key agent module needs to be updated, the file in the first type of key agent module is updated.
  21. 根据权利要求17所述的方法,其中,在密钥代理模块执行所述密文处理请求的过程中,所述方法还包括:The method of claim 17, wherein in the process of the key broker module performing the ciphertext processing request, the method further comprises:
    所述密钥代理模块检测执行所述密文处理请求的成功率是否低于第二预定阈值;The key agent module detects whether a success rate of executing the ciphertext processing request is lower than a second predetermined threshold;
    若检测出执行所述密文处理请求的成功率是否低于第二预定阈值,则向所述业务模块发送密钥数据,And if it is detected whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, sending key data to the service module,
    其中,所述密钥数据用于解密共享内存中存储的密钥列表,得到解密后的密钥列表,所述业务模块还设置为通过所述解密后的密钥列表执行所述密文处理请求。The key data is used to decrypt a key list stored in the shared memory to obtain a decrypted key list, and the service module is further configured to execute the ciphertext processing request by using the decrypted key list. .
  22. 根据权利要求21所述的方法,其中,在所述密钥代理模块检测执行 所述密文处理请求的成功率是否低于第二预定阈值之前,所述方法还包括:The method of claim 21 wherein said key agent module detects execution The method further includes: before the success rate of the ciphertext processing request is lower than a second predetermined threshold, the method further includes:
    所述密钥代理模块在执行完所述密文处理请求之后,基于所述密文处理请求中的请求时间与当前时间,判断执行当前的所述密文处理请求是否超时;After performing the ciphertext processing request, the key proxy module determines whether to execute the current ciphertext processing request timeout based on the request time and the current time in the ciphertext processing request;
    若判断出执行当前的所述密文处理请求超时,则确定执行当前的所述密文处理请求失败;If it is determined that the current ciphertext processing request is timed out, it is determined that the execution of the current ciphertext processing request fails;
    基于执行失败的密文处理请求的数量,统计所述密钥代理模块执行所述密文处理请求的成功率。The success rate of the ciphertext processing request by the key agent module is counted based on the number of ciphertext processing requests that fail to execute.
  23. 根据权利要求21所述的方法,其中,在所述密钥代理模块检测执行所述密文处理请求的成功率是否低于第二预定阈值之前,所述方法还包括:The method of claim 21, wherein before the key agent module detects whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, the method further comprises:
    接收通过业务线程传输的通信管道的第二端描述符,其中,所述业务线程用于生成第一端描述符和第二端描述符,其中,所述第一端描述符用于所述密钥代理模块将所述业务模块发送的数据识别为合法数据,所述第二端描述符用于所述业务模块将所述密钥代理模块发送的数据识别为合法数据。Receiving a second end descriptor of a communication pipeline transmitted by the service thread, wherein the service thread is configured to generate a first end descriptor and a second end descriptor, wherein the first end descriptor is used for the secret The key agent module identifies the data sent by the service module as legal data, and the second end descriptor is used by the service module to identify the data sent by the key agent module as legal data.
  24. 根据权利要求23所述的方法,其中,向所述业务模块发送密钥数据包括:The method of claim 23, wherein transmitting the key data to the service module comprises:
    通过各个所述业务线程的通信管道的写端,发送所述密钥数据。The key data is transmitted through a write end of a communication pipe of each of the service threads.
  25. 根据权利要求23所述的方法,其中,所述通信管道还用于检测所述业务模块、以及所述密钥代理模块是否重启。The method of claim 23 wherein said communication conduit is further for detecting said service module and whether said key agent module is restarted.
  26. 根据权利要求17所述的方法,其中,在通过密钥代理模块执行所述密文处理请求的过程中,所述方法还包括:The method of claim 17, wherein in the performing the ciphertext processing request by the key broker module, the method further comprises:
    在所述密钥代理模块对业务进程进行合法性校验之后,在所述合法性校验通过的情况下,所述密钥代理模块接收所述业务模块发送的 第一文件描述符,其中,所述第一文件描述符用于所述密钥代理模块将所述业务模块发送的数据识别为合法数据;After the validity of the validity of the service process by the key agent module, if the validity check is passed, the key agent module receives the message sent by the service module. a first file descriptor, wherein the first file descriptor is used by the key agent module to identify data sent by the service module as legal data;
    所述密钥代理模块生成多个第二文件描述符,其中,所述第二文件描述符用于所述业务模块将所述密钥代理模块发送的数据识别为合法数据;The key agent module generates a plurality of second file descriptors, wherein the second file descriptor is used by the service module to identify data sent by the key agent module as legal data;
    所述密钥代理模块向所述业务模块传输多个所述第二文件描述符。The key broker module transmits a plurality of the second file descriptors to the service module.
  27. 根据权利要求26所述的方法,其中,所述多个第二文件描述符的数目与所述密钥代理模块中用于执行所述密文处理请求的线程数目相对应。The method of claim 26, wherein the number of the plurality of second file descriptors corresponds to a number of threads in the key broker module for executing the ciphertext processing request.
  28. 根据权利要求17至27中任意一项所述的方法,其中,所述密文处理请求包括:用于将待加密数据加密为密文数据的请求和/或用于将密文数据解密为解密数据的请求。The method according to any one of claims 17 to 27, wherein the ciphertext processing request comprises: a request for encrypting data to be encrypted into ciphertext data and/or for decrypting ciphertext data into decryption Request for data.
  29. 一种业务处理方法,包括:A business processing method comprising:
    密钥代理模块获取执行密文处理请求的执行结果;The key agent module obtains an execution result of the execution of the ciphertext processing request;
    所述密钥代理模块检测所述执行结果是否符合预定模式切换条件,其中,符合所述预定模式切换条件表示确定所述密钥代理模块出现漏洞;The key agent module detects whether the execution result meets a predetermined mode switching condition, wherein the meeting the predetermined mode switching condition indicates that the key agent module is vulnerable;
    若检测出所述执行结果符合预定模式切换条件,则所述密钥代理模块向业务模块发送指示信息,其中,所述指示信息用于指示所述业务模块切换到通过所述业务模块执行所述密文处理请求的模式。And if the execution result is that the execution result meets the predetermined mode switching condition, the key agent module sends the indication information to the service module, where the indication information is used to indicate that the service module switches to perform the The mode in which the ciphertext handles the request.
  30. 根据权利要求29所述的方法,其中,密钥代理模块获取执行密文处理请求的执行结果包括:The method of claim 29, wherein the obtaining, by the key agent module, the execution result of the execution of the ciphertext processing request comprises:
    所述密钥代理模块在执行完所述密文处理请求之后,基于所述密文处理请求中的请求时间与当前时间,判断执行当前的所述密文处理 请求是否超时;After performing the ciphertext processing request, the key proxy module determines to perform the current ciphertext processing based on the request time and the current time in the ciphertext processing request. Whether the request times out;
    若判断出执行当前的所述密文处理请求超时,则所述密钥代理模块确定执行当前的所述密文处理请求失败;If it is determined that the current ciphertext processing request timeout is performed, the key agent module determines that the execution of the current ciphertext processing request fails;
    所述密钥代理模块基于执行失败的密文处理请求的数量,统计所述密钥代理模块执行所述密文处理请求的成功率,所述执行结果包括所述成功率。The key agent module counts a success rate of the ciphertext processing request by the key agent module based on the number of ciphertext processing requests that fail to execute, and the execution result includes the success rate.
  31. 根据权利要求30所述的方法,其中,所述密钥代理模块检测所述执行结果是否符合预定模式切换条件包括:The method according to claim 30, wherein the key agent module detecting whether the execution result meets a predetermined mode switching condition comprises:
    所述密钥代理模块检测所述成功率是否低于第二预定阈值;The key agent module detects whether the success rate is lower than a second predetermined threshold;
    若检测出执行所述密文处理请求的成功率是否低于第二预定阈值,则确定所述执行结果符合所述预定模式切换条件。If it is detected whether the success rate of executing the ciphertext processing request is lower than a second predetermined threshold, it is determined that the execution result conforms to the predetermined mode switching condition.
  32. 根据权利要求29所述的方法,其中,所述密钥代理模块向业务模块发送指示信息包括:The method of claim 29, wherein the transmitting the indication information to the service module by the key agent module comprises:
    所述密钥代理模块向所述业务模块发送密钥数据,其中,所述密钥数据用于解密共享内存中存储的密钥列表,得到解密后的密钥列表,所述业务模块还用于通过所述解密后的密钥列表执行所述密文处理请求。The key agent module sends key data to the service module, where the key data is used to decrypt a key list stored in the shared memory to obtain a decrypted key list, and the service module is further used to The ciphertext processing request is executed by the decrypted key list.
  33. 根据权利要求29所述的方法,其中,所述密钥代理模块包括第一类型的密钥代理模块和第二类型的密钥代理模块,其中,所述第一类型的密钥代理模块为开发型密钥代理模块,所述第二类型的密钥代理模块为稳定型密钥代理模块,所述稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。The method of claim 29, wherein said key broker module comprises a first type of key broker module and a second type of key broker module, wherein said first type of key broker module is developed a type key proxy module, the second type of key proxy module is a stable key proxy module, and the stable key proxy module is configured to perform a ciphertext processing request with a higher correct rate than a predetermined period of time The correct rate key agent module.
  34. 根据权利要求33所述的方法,其中,The method of claim 33, wherein
    在密钥代理模块接收并执行业务模块的密文处理请求之前,所述方法还包括:在对密钥代理模块中的文件进行更新之后,将执行了更新操作的密钥代理模块记录为所述第一类型的密钥代理模块; Before the key agent module receives and executes the ciphertext processing request of the service module, the method further includes: after updating the file in the key agent module, recording the key agent module that performs the update operation as the a first type of key agent module;
    在第一类型的密钥代理模块接收并执行业务模块的密文处理请求,得到执行结果之后,所述方法还包括:若在预定时间段内均检测出所述第一类型的密钥代理模块执行所述密文处理请求的正确率高于预定正确率,则将所述第一类型的密钥代理模块记录为第二类型的密钥代理模块。After the first type of key agent module receives and executes the ciphertext processing request of the service module, and obtains the execution result, the method further includes: if the first type of the key agent module is detected within a predetermined time period The correctness rate of the execution of the ciphertext processing request is higher than the predetermined correct rate, and the first type of key broker module is recorded as the second type of key broker module.
  35. 根据权利要求33所述的方法,其中,在所述第一类型的密钥代理模块执行所述业务模块的密文处理请求的过程中,所述方法还包括:The method according to claim 33, wherein in the process of the ciphertext processing request of the service module of the first type, the method further comprises:
    若需对密钥代理模块中的文件进行更新,则对所述第一类型的密钥代理模块中的文件进行更新。If the file in the key agent module needs to be updated, the file in the first type of key agent module is updated.
  36. 根据权利要求29至35中任意一项所述的方法,其中,所述密文处理请求包括:用于将待加密数据加密为密文数据的请求和/或用于将密文数据解密为解密数据的请求。The method according to any one of claims 29 to 35, wherein the ciphertext processing request comprises: a request for encrypting data to be encrypted into ciphertext data and/or for decrypting ciphertext data into decryption Request for data.
  37. 根据权利要求36所述的方法,其中,在所述密文处理请求为用于将待加密数据加密为密文数据的请求的情况下,还包括:The method according to claim 36, wherein, in the case that the ciphertext processing request is a request for encrypting data to be encrypted into ciphertext data, the method further includes:
    所述密钥代理模块接收所述业务模块发送的加密请求,其中,所述加密请求中携带有待加密的数据;The key agent module receives an encryption request sent by the service module, where the encryption request carries data to be encrypted;
    所述密钥代理模块从密钥列表中获取目标密钥,其中,所述密钥列表是预先从密钥服务器中拉取到的;The key agent module acquires a target key from a key list, wherein the key list is previously extracted from the key server;
    所述密钥代理模块使用所述目标密钥对所述待加密的数据进行加密,得到加密后的数据;The key agent module encrypts the data to be encrypted by using the target key to obtain encrypted data;
    所述密钥代理模块将所述加密后的数据发送给所述业务模块。The key broker module sends the encrypted data to the service module.
  38. 根据权利要求37所述的方法,其中,在密钥代理模块接收业务模块发送的加密请求之前,还包括:The method of claim 37, wherein before the key proxy module receives the encryption request sent by the service module, the method further comprises:
    所述密钥代理模块将第一公钥发送给所述密钥服务器,并从所述密钥服务器接收第二公钥,其中,所述密钥代理模块上具有一对所述第一公钥和第一私钥,所述密钥服务器上具有一对所述第二公钥和第 二私钥;The key agent module sends a first public key to the key server and receives a second public key from the key server, wherein the key agent module has a pair of the first public key And a first private key having a pair of said second public key and said Second private key;
    所述密钥代理模块向所述密钥服务器发送密钥列表拉取请求;The key agent module sends a key list pull request to the key server;
    所述密钥代理模块接收所述密钥服务器发送的加密后的密钥列表,其中,所述加密后的密钥列表是使用所述密钥服务器侧的第一通讯密钥对所述密钥列表进行加密得到的,所述第一通讯密钥是所述密钥服务器根据所述第一公钥和所述第二私钥生成得到的;The key agent module receives the encrypted key list sent by the key server, wherein the encrypted key list is the first communication key on the key server side to the key The first communication key is generated by the key server according to the first public key and the second private key.
    所述密钥代理模块使用所述密钥代理模块侧的第二通讯密钥对所述加密后的密钥列表进行解密,得到所述密钥列表,其中,所述第二通讯密钥是所述密钥代理模块根据所述第一私钥和所述第二公钥生成得到的,所述第一通讯密钥与所述第二通讯密钥相同。The key agent module decrypts the encrypted key list by using a second communication key on the key agent module side to obtain the key list, where the second communication key is The key agent module generates the first communication key and the second public key according to the first private key and the second public key.
  39. 根据权利要求38所述的方法,其中,所述密钥代理模块将第一公钥发送给所述密钥服务器,并从所述密钥服务器接收第二公钥包括:The method of claim 38, wherein the key agent module transmits the first public key to the key server, and receiving the second public key from the key server comprises:
    在所述密钥代理模块重启时,所述密钥代理模块将加密后的所述第一公钥发送给所述密钥服务器,其中,所述加密后的所述第一公钥是使用约定密钥对所述第一公钥进行加密得到的;The key agent module sends the encrypted first public key to the key server when the key agent module is restarted, wherein the encrypted first public key is a usage agreement Encrypting the first public key by a key;
    所述密钥代理模块从所述密钥服务器接收加密后的所述第二公钥,其中,所述加密后的所述第二公钥是使用所述约定密钥对所述第二公钥进行加密得到的;The key agent module receives the encrypted second public key from the key server, wherein the encrypted second public key is to use the promise key to the second public key Obtained by encryption;
    所述密钥代理模块使用所述约定密钥对所述加密后的第二公钥进行解密,得到所述第二公钥;The key proxy module decrypts the encrypted second public key by using the contract key to obtain the second public key;
    其中,所述约定密钥被设置为仅在所述密钥代理模块重启时使用。Wherein, the appointment key is set to be used only when the key agent module is restarted.
  40. 根据权利要求37所述的方法,其中,The method of claim 37, wherein
    在所述密钥代理模块接收业务模块发送的加密请求之前,还包括:所述密钥代理模块获取业务进程的进程PID,其中,所述业务进程为所述业务模块发送所述待加密的数据的进程;所述密钥代理模块对所 述业务进程和所述进程PID进行合法性校验;Before the key agent module receives the encryption request sent by the service module, the method further includes: the key agent module acquiring a process PID of the service process, where the service process sends the data to be encrypted for the service module Process; the key agent module is opposite The service process and the process PID are checked for legality;
    所述密钥代理模块从密钥列表中获取目标密钥包括:在所述合法性校验通过的情况下,所述密钥代理模块从所述密钥列表中获取所述目标密钥。The obtaining, by the key agent module, the target key from the key list includes: obtaining, by the key agent module, the target key from the key list if the validity check is passed.
  41. 根据权利要求40所述的方法,其中,所述密钥代理模块对所述业务进程和所述进程PID进行所述合法性校验包括:The method of claim 40, wherein the performing a validity check on the service process and the process PID by the key agent module comprises:
    所述密钥代理模块获取与所述进程PID对应的进程全路径;The key agent module acquires a process full path corresponding to the process PID;
    所述密钥代理模块判断所述进程全路径是否属于预先从所述密钥服务器获取到的合法路径中的路径;Determining, by the key agent module, whether the path of the process belongs to a path in a legal path acquired in advance from the key server;
    在判断出所述进程全路径属于所述合法路径中的路径的情况下,所述密钥代理模块对所述业务进程进行MD5校验操作,得到第一MD5校验结果;在判断出所述进程全路径不属于所述合法路径中的路径的情况下,判断出所述合法性校验不通过;When it is determined that the path of the process belongs to the path in the legal path, the key agent module performs an MD5 check operation on the service process to obtain a first MD5 check result; If the process full path does not belong to the path in the legal path, it is determined that the validity check fails.
    所述密钥代理模块判断所述第一MD5校验结果是否与预先获取的与所述业务进程对应的第二MD5校验结果相同;The key agent module determines whether the first MD5 check result is the same as the second MD5 check result corresponding to the service process acquired in advance;
    若所述第一MD5校验结果与所述第二MD5校验结果相同,则判断出所述合法性校验通过;若所述第一MD5校验结果与所述第二MD5校验结果不同,则判断出所述合法性校验不通过。If the first MD5 check result is the same as the second MD5 check result, it is determined that the validity check is passed; if the first MD5 check result is different from the second MD5 check result Then, it is determined that the legality check fails.
  42. 根据权利要求40所述的方法,其中,在所述密钥代理模块对所述业务进程和所述进程PID进行合法性校验之后,并在所述密钥代理模块接收所述业务模块发送的加密请求之前,还包括:The method according to claim 40, wherein after the key agent module performs legality verification on the service process and the process PID, and receives, by the key agent module, the service module sends Before encrypting the request, it also includes:
    在所述合法性校验通过的情况下,所述密钥代理模块获取所述业务模块发送的第一文件描述符,其中,所述第一文件描述符用于所述密钥代理模块将所述业务模块发送的数据识别为合法数据;And in the case that the validity check is passed, the key proxy module acquires a first file descriptor sent by the service module, where the first file descriptor is used by the key proxy module The data sent by the service module is identified as legal data;
    所述密钥代理模块生成第二文件描述符,其中,所述第二文件描述符用于所述业务模块将所述密钥代理模块发送的数据识别为合法 数据;The key agent module generates a second file descriptor, wherein the second file descriptor is used by the service module to identify data sent by the key agent module as legal data;
    所述密钥代理模块将所述第二文件描述符传输给所述业务模块。The key broker module transmits the second file descriptor to the service module.
  43. 根据权利要求42所述的方法,其中,The method of claim 42, wherein
    所述密钥代理模块接收所述业务模块发送的加密请求包括:所述密钥代理模块从共享内存中获取所述业务模块存入的所述待加密的数据;The receiving, by the key agent module, the encryption request sent by the service module includes: acquiring, by the key agent module, the data to be encrypted stored by the service module from the shared memory;
    所述密钥代理模块将所述加密后的数据发送给所述业务模块包括:所述密钥代理模块将所述加密后的数据存入到所述共享内存中,以使得所述业务模块从所述共享内存中获取所述加密后的数据。The key agent module sending the encrypted data to the service module includes: the key agent module storing the encrypted data into the shared memory, so that the service module is The encrypted data is obtained in the shared memory.
  44. 根据权利要求42所述的方法,其中,在所述密钥代理模块对所述业务进程和所述进程PID进行合法性校验之后,并在所述密钥代理模块接收所述业务模块发送的加密请求之前,还包括:The method according to claim 42, wherein after the key agent module performs a validity check on the service process and the process PID, and receives, by the key agent module, the service module sends Before encrypting the request, it also includes:
    在所述合法性校验通过的情况下,所述密钥代理模块为所述第一文件描述符设置目标权限,其中,所述目标权限包括以下至少之一:允许所述密钥代理模块对所述业务模块请求的待加密的数据进行加密,允许所述密钥代理模块对所述业务模块请求的待解密的数据进行解密。And in the case that the legality verification is passed, the key agent module sets a target authority for the first file descriptor, where the target authority includes at least one of: allowing the key agent module to The data to be encrypted requested by the service module is encrypted, and the key proxy module is allowed to decrypt the data to be decrypted requested by the service module.
  45. 根据权利要求44所述的方法,其中,在所述合法性校验通过的情况下,所述密钥代理模块从所述密钥列表中获取所述目标密钥包括:The method according to claim 44, wherein, in the case that the validity check is passed, the key agent module acquiring the target key from the key list comprises:
    在所述目标权限包括允许所述密钥代理模块对所述业务模块请求的待加密的数据进行加密时,所述密钥代理模块从所述密钥列表中获取所述目标密钥。The key agent module acquires the target key from the key list when the target authority includes allowing the key agent module to encrypt data to be encrypted requested by the service module.
  46. 根据权利要求40所述的方法,其中,所述密钥代理模块获取业务进程的进程PID包括:The method according to claim 40, wherein the process of acquiring the process PID of the business process by the key agent module comprises:
    所述密钥代理模块在非root运行模式下通过unix域套接字获取 所述业务进程的所述进程PID;或者The key agent module acquires through a unix domain socket in a non-root mode of operation. The process PID of the business process; or
    所述密钥代理模块将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取所述业务进程的所述进程PID。The key proxy module configures the option of the socket socket as SO_PEERCRED, and acquires the process PID of the service process through the socket socket.
  47. 根据权利要求36所述的方法,其中,在所述密文处理请求为用于将密文数据解密为解密数据的请求的情况下,包括:The method of claim 36, wherein, in the case where the ciphertext processing request is a request for decrypting ciphertext data into decrypted data, the method comprises:
    所述密钥代理模块接收所述业务模块发送的解密请求,其中,所述解密请求中携带有待解密的数据;The key agent module receives a decryption request sent by the service module, where the decryption request carries data to be decrypted;
    所述密钥代理模块从密钥列表中获取目标密钥,其中,所述密钥列表是预先从密钥服务器中拉取到的;The key agent module acquires a target key from a key list, wherein the key list is previously extracted from the key server;
    所述密钥代理模块使用所述目标密钥对所述待解密的数据进行解密,得到解密后的数据;The key agent module decrypts the data to be decrypted by using the target key to obtain decrypted data;
    所述密钥代理模块将所述解密后的数据发送给所述业务模块。The key agent module sends the decrypted data to the service module.
  48. 根据权利要求47所述的方法,其中,在密钥代理模块接收业务模块发送的解密请求之前,还包括:The method of claim 47, wherein before the key agent module receives the decryption request sent by the service module, the method further comprises:
    所述密钥代理模块将第一公钥发送给所述密钥服务器,并从所述密钥服务器接收第二公钥,其中,所述密钥代理模块上具有一对所述第一公钥和第一私钥,所述密钥服务器上具有一对所述第二公钥和第二私钥;The key agent module sends a first public key to the key server and receives a second public key from the key server, wherein the key agent module has a pair of the first public key And a first private key, the key server having a pair of the second public key and a second private key;
    所述密钥代理模块向所述密钥服务器发送密钥列表拉取请求;The key agent module sends a key list pull request to the key server;
    所述密钥代理模块接收所述密钥服务器发送的加密后的密钥列表,其中,所述加密后的密钥列表是使用所述密钥服务器侧的第一通讯密钥对所述密钥列表进行加密得到的,所述第一通讯密钥是所述密钥服务器根据所述第一公钥和所述第二私钥生成得到的;The key agent module receives the encrypted key list sent by the key server, wherein the encrypted key list is the first communication key on the key server side to the key The first communication key is generated by the key server according to the first public key and the second private key.
    所述密钥代理模块使用所述密钥代理模块侧的第二通讯密钥对所述加密后的密钥列表进行解密,得到所述密钥列表,其中,所述第 二通讯密钥是所述密钥代理模块根据所述第一私钥和所述第二公钥生成得到的,所述第一通讯密钥与所述第二通讯密钥相同。The key agent module decrypts the encrypted key list by using a second communication key on the key agent module side to obtain the key list, where the The second communication key is generated by the key agent module according to the first private key and the second public key, and the first communication key is the same as the second communication key.
  49. 根据权利要求48所述的方法,其中,所述密钥代理模块将第一公钥发送给所述密钥服务器,并从所述密钥服务器接收第二公钥包括:The method of claim 48, wherein the key agent module transmits the first public key to the key server, and receiving the second public key from the key server comprises:
    在所述密钥代理模块重启时,所述密钥代理模块将加密后的所述第一公钥发送给所述密钥服务器,其中,所述加密后的所述第一公钥是使用约定密钥对所述第一公钥进行加密得到的;The key agent module sends the encrypted first public key to the key server when the key agent module is restarted, wherein the encrypted first public key is a usage agreement Encrypting the first public key by a key;
    所述密钥代理模块从所述密钥服务器接收加密后的所述第二公钥,其中,所述加密后的所述第二公钥是使用所述约定密钥对所述第二公钥进行加密得到的;The key agent module receives the encrypted second public key from the key server, wherein the encrypted second public key is to use the promise key to the second public key Obtained by encryption;
    所述密钥代理模块使用所述约定密钥对所述加密后的第二公钥进行解密,得到所述第二公钥;The key proxy module decrypts the encrypted second public key by using the contract key to obtain the second public key;
    其中,所述约定密钥被设置为仅在所述密钥代理模块重启时使用。Wherein, the appointment key is set to be used only when the key agent module is restarted.
  50. 根据权利要求47所述的方法,其中,The method according to claim 47, wherein
    在所述密钥代理模块接收业务模块发送的解密请求之前,还包括:所述密钥代理模块获取业务进程的进程PID,其中,所述业务进程为所述业务模块发送所述待解密的数据的进程;所述密钥代理模块对所述业务进程和所述进程PID进行合法性校验;Before the key agent module receives the decryption request sent by the service module, the method further includes: the key agent module acquiring a process PID of the service process, where the service process sends the data to be decrypted for the service module The process of verifying the validity of the service process and the process PID by the key agent module;
    所述密钥代理模块从密钥列表中获取目标密钥包括:在所述合法性校验通过的情况下,所述密钥代理模块从所述密钥列表中获取所述目标密钥。The obtaining, by the key agent module, the target key from the key list includes: obtaining, by the key agent module, the target key from the key list if the validity check is passed.
  51. 根据权利要求50所述的方法,其中,所述密钥代理模块对所述业务进程和所述进程PID进行所述合法性校验包括:The method of claim 50, wherein the key agent module performs the legality check on the service process and the process PID comprises:
    所述密钥代理模块获取与所述进程PID对应的进程全路径;The key agent module acquires a process full path corresponding to the process PID;
    所述密钥代理模块判断所述进程全路径是否属于预先从所述密 钥服务器获取到的合法路径中的路径;Determining, by the key agent module, whether the full path of the process belongs to the prior from the secret The path in the legal path obtained by the key server;
    在判断出所述进程全路径属于所述合法路径中的路径的情况下,所述密钥代理模块对所述业务进程进行MD5校验操作,得到第一MD5校验结果;在判断出所述进程全路径不属于所述合法路径中的路径的情况下,判断出所述合法性校验不通过;When it is determined that the path of the process belongs to the path in the legal path, the key agent module performs an MD5 check operation on the service process to obtain a first MD5 check result; If the process full path does not belong to the path in the legal path, it is determined that the validity check fails.
    所述密钥代理模块判断所述第一MD5校验结果是否与预先获取的与所述业务进程对应的第二MD5校验结果相同;The key agent module determines whether the first MD5 check result is the same as the second MD5 check result corresponding to the service process acquired in advance;
    若所述第一MD5校验结果与所述第二MD5校验结果相同,则判断出所述合法性校验通过;若所述第一MD5校验结果与所述第二MD5校验结果不同,则判断出所述合法性校验不通过。If the first MD5 check result is the same as the second MD5 check result, it is determined that the validity check is passed; if the first MD5 check result is different from the second MD5 check result Then, it is determined that the legality check fails.
  52. 根据权利要求50所述的方法,其中,在所述密钥代理模块对所述业务进程和所述进程PID进行合法性校验之后,并在所述密钥代理模块接收所述业务模块发送的解密请求之前,还包括:The method of claim 50, wherein after the key agent module performs a legality check on the service process and the process PID, and receives, at the key agent module, the service module sends Before decrypting the request, it also includes:
    在所述合法性校验通过的情况下,所述密钥代理模块获取所述业务模块发送的第一文件描述符,其中,所述第一文件描述符用于所述密钥代理模块将所述业务模块发送的数据识别为合法数据;And in the case that the validity check is passed, the key proxy module acquires a first file descriptor sent by the service module, where the first file descriptor is used by the key proxy module The data sent by the service module is identified as legal data;
    所述密钥代理模块生成第二文件描述符,其中,所述第二文件描述符用于所述业务模块将所述密钥代理模块发送的数据识别为合法数据;The key agent module generates a second file descriptor, wherein the second file descriptor is used by the service module to identify data sent by the key agent module as legal data;
    所述密钥代理模块将所述第二文件描述符传输给所述业务模块。The key broker module transmits the second file descriptor to the service module.
  53. 根据权利要求52所述的方法,其中,The method of claim 52, wherein
    所述密钥代理模块接收所述业务模块发送的解密请求包括:所述密钥代理模块从共享内存中获取所述业务模块存入的所述待解密的数据;The receiving, by the key agent module, the decryption request sent by the service module includes: the key agent module acquiring, from the shared memory, the data to be decrypted stored by the service module;
    所述密钥代理模块将所述解密后的数据发送给所述业务模块包括:所述密钥代理模块将所述解密后的数据存入到所述共享内存中, 以使得所述业务模块从所述共享内存中获取所述解密后的数据。The key agent module sending the decrypted data to the service module includes: the key agent module storing the decrypted data into the shared memory, So that the service module obtains the decrypted data from the shared memory.
  54. 根据权利要求52所述的方法,其中,在所述密钥代理模块对所述业务进程和所述进程PID进行合法性校验之后,并在所述密钥代理模块接收所述业务模块发送的解密请求之前,还包括:The method according to claim 52, wherein after the key agent module performs legality verification on the service process and the process PID, and receives, by the key agent module, the service module sends Before decrypting the request, it also includes:
    在所述合法性校验通过的情况下,所述密钥代理模块为所述第一文件描述符设置目标权限,其中,所述目标权限包括以下至少之一:允许所述密钥代理模块对所述业务模块请求的待加密的数据进行加密,允许所述密钥代理模块对所述业务模块请求的待解密的数据进行解密。And in the case that the legality verification is passed, the key agent module sets a target authority for the first file descriptor, where the target authority includes at least one of: allowing the key agent module to The data to be encrypted requested by the service module is encrypted, and the key proxy module is allowed to decrypt the data to be decrypted requested by the service module.
  55. 根据权利要求54所述的方法,其中,在所述合法性校验通过的情况下,所述密钥代理模块从所述密钥列表中获取所述目标密钥包括:The method according to claim 54, wherein, in the case that the validity check is passed, the obtaining, by the key agent module, the target key from the key list comprises:
    在所述目标权限包括允许所述密钥代理模块对所述业务模块请求的待解密的数据进行解密时,所述密钥代理模块从所述密钥列表中获取所述目标密钥。The key agent module obtains the target key from the key list when the target authority includes allowing the key agent module to decrypt data to be decrypted requested by the service module.
  56. 根据权利要求50所述的方法,其中,所述密钥代理模块获取业务进程的进程PID包括:The method according to claim 50, wherein the process of acquiring the process PID of the business process by the key agent module comprises:
    所述密钥代理模块在非root运行模式下通过unix域套接字获取所述业务进程的所述进程PID;或者The key agent module acquires the process PID of the service process through a unix domain socket in a non-root operation mode; or
    所述密钥代理模块将socket套接字的选项配置为SO_PEERCRED,并通过socket套接字获取所述业务进程的所述进程PID。The key proxy module configures the option of the socket socket as SO_PEERCRED, and acquires the process PID of the service process through the socket socket.
  57. 一种业务处理装置,包括:A service processing device comprising:
    第一获取单元,设置为获取第一信息,其中,所述第一信息用于表示第一类型的密钥代理模块执行密文处理请求的执行结果;a first acquiring unit, configured to acquire first information, where the first information is used to indicate that an execution result of the ciphertext processing request by the first type of key proxy module is performed;
    第一检测单元,设置为检测所述第一信息是否符合预定类型切换条件,其中,符合所述预定类型切换条件表示确定所述第一类型的密 钥代理模块中出现了漏洞;a first detecting unit, configured to detect whether the first information meets a predetermined type switching condition, wherein the matching the predetermined type switching condition indicates determining the first type of confidentiality A vulnerability has occurred in the key broker module;
    第一执行单元,设置为在检测出所述第一信息符合所述预定类型切换条件的情况下,通过第二类型的密钥代理模块执行业务模块的密文处理请求。The first execution unit is configured to execute the ciphertext processing request of the service module by using the second type of key proxy module in a case that the first information is detected to meet the predetermined type of switching condition.
  58. 一种业务处理装置,其中,包括:A service processing device, comprising:
    第一处理单元,设置在第一类型的密钥代理模块中,设置为接收并执行业务模块的密文处理请求,得到执行结果;a first processing unit, configured in the key broker module of the first type, configured to receive and execute a ciphertext processing request of the service module, to obtain an execution result;
    第一处理单元,设置在第二类型的密钥代理模块中,设置为接收并执行所述业务模块的密文处理请求,其中,所述业务模块设置为在基于所述执行结果生成的第一信息符合预定类型切换条件的情况下,向所述第二类型的密钥代理模块发送密文处理请求,其中,符合所述预定类型切换条件表示确定所述第一类型的密钥代理模块中出现了漏洞。a first processing unit, configured to be in a second type of key broker module, configured to receive and execute a ciphertext processing request of the service module, wherein the service module is configured to be first generated based on the execution result Sending a ciphertext processing request to the second type of key broker module if the information conforms to a predetermined type of switching condition, wherein the matching of the predetermined type of switching condition indicates that the first type of key broker module is present The loophole.
  59. 根据权利要求58所述的装置,其中,所述第一类型的密钥代理模块为开发型密钥代理模块,所述第二类型的密钥代理模块为稳定型密钥代理模块,所述稳定型密钥代理模块为在预定时间段内、执行密文处理请求的正确率高于预定正确率的密钥代理模块。The apparatus according to claim 58, wherein said first type of key agent module is a development type key agent module, said second type of key agent module is a stable type key agent module, said stabilizing The type key agent module is a key agent module that performs a ciphertext processing request with a correct rate higher than a predetermined correct rate within a predetermined time period.
  60. 一种业务处理装置,其中,包括:A service processing device, comprising:
    第一获取单元,设置为获取执行密文处理请求的执行结果;a first obtaining unit, configured to obtain an execution result of performing a ciphertext processing request;
    第一检测单元,设置为检测所述执行结果是否符合预定模式切换条件,其中,符合所述预定模式切换条件表示确定密钥代理模块出现漏洞;a first detecting unit, configured to detect whether the execution result meets a predetermined mode switching condition, wherein the meeting the predetermined mode switching condition indicates that the key agent module is vulnerable;
    第一发送单元,设置为若检测出所述执行结果符合预定模式切换条件,则向业务模块发送指示信息,其中,所述指示信息用于指示所述业务模块切换到通过所述业务模块执行所述密文处理请求的模式。The first sending unit is configured to: if the detection result is that the execution result meets the predetermined mode switching condition, send the indication information to the service module, where the indication information is used to indicate that the service module switches to execute by using the service module The mode in which the ciphertext handles the request.
  61. 根据权利要求60所述的装置,其中,在所述密文处理请求为用于将 待加密数据加密为密文数据的请求的情况下,包括:The apparatus of claim 60, wherein the ciphertext processing request is for In the case where the data to be encrypted is encrypted as a request for ciphertext data, it includes:
    第一加密接收单元,设置于所述密钥代理模块中,设置为接收所述业务模块发送的加密请求,其中,所述加密请求中携带有待加密的数据;a first encryption receiving unit, configured to receive an encryption request sent by the service module, where the encryption request carries data to be encrypted;
    第一加密获取单元,设置于所述密钥代理模块中,设置为从密钥列表中获取目标密钥,其中,所述密钥列表是预先从密钥服务器中拉取到的;a first encryption obtaining unit, configured in the key agent module, configured to obtain a target key from a key list, wherein the key list is previously extracted from the key server;
    第一加密单元,设置所述密钥代理模块中,设置为使用所述目标密钥对所述待加密的数据进行加密,得到加密后的数据;a first encryption unit, configured to encrypt the data to be encrypted using the target key, to obtain encrypted data;
    第一加密发送单元,设置于所述密钥代理模块中,设置为将所述加密后的数据发送给所述业务模块。The first encryption sending unit is disposed in the key agent module and configured to send the encrypted data to the service module.
  62. 根据权利要求60所述的装置,其中,在所述密文处理请求为用于将密文数据解密为解密数据的请求的情况下,包括:The apparatus according to claim 60, wherein, in the case where the ciphertext processing request is a request for decrypting ciphertext data into decrypted data, the method comprises:
    第一解密接收单元,设置于所述密钥代理模块中,设置为接收所述业务模块发送的解密请求,其中,所述解密请求中携带有待解密的数据;a first decryption receiving unit, configured to receive the decryption request sent by the service module, where the decryption request carries data to be decrypted;
    第一解密获取单元,设置于所述密钥代理模块中,设置为从密钥列表中获取目标密钥,其中,所述密钥列表是预先从密钥服务器中拉取到的;a first decryption acquisition unit, configured to be located in the key agent module, configured to obtain a target key from a key list, wherein the key list is previously extracted from the key server;
    第一解密单元,设置于所述密钥代理模块中,设置为使用所述目标密钥对所述待解密的数据进行解密,得到解密后的数据;a first decryption unit, configured to be in the key agent module, configured to decrypt the data to be decrypted by using the target key to obtain decrypted data;
    第一解密发送单元,设置于所述密钥代理模块中,设置为将所述解密后的数据发送给所述业务模块。The first decryption sending unit is disposed in the key agent module and configured to send the decrypted data to the service module.
  63. 一种存储介质,所述存储介质包括存储的程序,其中,所述程序运行时执行上述权利要求1至16或17至28或29至56任一项中所述的方法。 A storage medium comprising a stored program, wherein the program is executed to perform the method of any of the preceding claims 1 to 16 or 17 to 28 or 29 to 56.
  64. 一种电子装置,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器通过所述计算机程序执行所述权利要求1至16或17至28或29至56任一项中所述的方法。 An electronic device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein the processor executes the claim 1 through the computer program The method of any of 16 or 17 to 28 or 29 to 56.
PCT/CN2017/091903 2016-08-08 2017-07-05 Service processing method and device, and storage medium and electronic device WO2018028359A1 (en)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201610643327.XA CN106302422B (en) 2016-08-08 2016-08-08 Business encryption and decryption method and device
CN201610643327.X 2016-08-08
CN201611018871.1 2016-11-18
CN201611018871.1A CN108076021B (en) 2016-11-18 2016-11-18 Service processing method and device

Publications (1)

Publication Number Publication Date
WO2018028359A1 true WO2018028359A1 (en) 2018-02-15

Family

ID=61162768

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/091903 WO2018028359A1 (en) 2016-08-08 2017-07-05 Service processing method and device, and storage medium and electronic device

Country Status (1)

Country Link
WO (1) WO2018028359A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111626865A (en) * 2020-05-22 2020-09-04 泰康保险集团股份有限公司 Data processing method and device, electronic equipment and storage medium
CN112464212A (en) * 2020-03-30 2021-03-09 上海汇招信息技术有限公司 Data authority control reconstruction method based on mature complex service system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1671099A (en) * 2004-03-16 2005-09-21 株式会社东芝 Encryption key sharing scheme for automatically updating shared key
CN103024716A (en) * 2012-11-27 2013-04-03 中兴通讯股份有限公司 Method, device and system for wireless fidelity (WiFi) traffic statistics
CN103516702A (en) * 2012-06-29 2014-01-15 北京新媒传信科技有限公司 Symmetrical encryption method and system and central server
CN104268488A (en) * 2006-02-28 2015-01-07 塞尔蒂卡姆公司 System And Method For Product Registration
WO2016003491A1 (en) * 2014-06-30 2016-01-07 Nicira, Inc. Encryption architecture

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1671099A (en) * 2004-03-16 2005-09-21 株式会社东芝 Encryption key sharing scheme for automatically updating shared key
CN104268488A (en) * 2006-02-28 2015-01-07 塞尔蒂卡姆公司 System And Method For Product Registration
CN103516702A (en) * 2012-06-29 2014-01-15 北京新媒传信科技有限公司 Symmetrical encryption method and system and central server
CN103024716A (en) * 2012-11-27 2013-04-03 中兴通讯股份有限公司 Method, device and system for wireless fidelity (WiFi) traffic statistics
WO2016003491A1 (en) * 2014-06-30 2016-01-07 Nicira, Inc. Encryption architecture

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112464212A (en) * 2020-03-30 2021-03-09 上海汇招信息技术有限公司 Data authority control reconstruction method based on mature complex service system
CN111626865A (en) * 2020-05-22 2020-09-04 泰康保险集团股份有限公司 Data processing method and device, electronic equipment and storage medium
CN111626865B (en) * 2020-05-22 2023-10-03 泰康保险集团股份有限公司 Data processing method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
EP3937424B1 (en) Blockchain data processing methods and apparatuses based on cloud computing
CN109347835B (en) Information transmission method, client, server, and computer-readable storage medium
US10462114B2 (en) System and associated software for providing advanced data protections in a defense-in-depth system by integrating multi-factor authentication with cryptographic offloading
CN110492990B (en) Private key management method, device and system under block chain scene
EP3937045B1 (en) Hash updating methods and apparatuses of blockchain integrated station
Kim et al. Predictability of Android OpenSSL's pseudo random number generator
WO2016107203A1 (en) Identity authentication method and device
WO2019019887A1 (en) Server authentication method, apparatus and system for terminal access, server and computer readable storage medium
US20220109667A1 (en) Cryptographic trust enabled devices of cybersecurity systems
JP2009087035A (en) Encryption client device, encryption package distribution system, encryption container distribution system, encryption management server device, solftware module management device and software module management program
US8745389B2 (en) Avoiding padding oracle attacks
US11755499B2 (en) Locally-stored remote block data integrity
Nguyen et al. LogSafe: Secure and scalable data logger for IoT devices
CN110781140B (en) Method, device, computer equipment and storage medium for signing data in blockchain
JP2010514000A (en) Method for securely storing program state data in an electronic device
US11570213B2 (en) Collaborative security for application layer encryption
CN113014444A (en) Internet of things equipment production test system and safety protection method
US11606193B2 (en) Distributed session resumption
WO2023051337A1 (en) Data processing method and apparatus, and device and storage medium
CN107959569B (en) Key supplementing method, key supplementing device and key supplementing system based on symmetric key pool
CN113347143A (en) Identity authentication method, device, equipment and storage medium
WO2018028359A1 (en) Service processing method and device, and storage medium and electronic device
US11792003B2 (en) Distributed storage system and method of reusing symmetric keys for encrypted message transmissions
CN108154037B (en) Inter-process data transmission method and device
CN115174188A (en) Message transmission method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17838489

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17838489

Country of ref document: EP

Kind code of ref document: A1