Lightweight key management method and system based on national secret algorithm
By adopting a lightweight key management method based on the national secret algorithm in IoT devices, using a white box to save the root key and load user key information through a hash bucket, the performance caused by key management in the prior art is solved. Bottlenecks and security threat issues achieve efficient and secure key management.
Patent Information
- Application Number
- CN202411629608.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-11-15
AI Technical Summary
The existing key management methods in IoT devices have limited computing resources, resulting in performance bottlenecks, increasing network latency, and being susceptible to root key theft in white box attack environments, threatening system security.
The lightweight key management method based on the national secret algorithm is adopted, and the root key is saved using a white box and the user key information is loaded through the hash bucket, reducing network overhead and supporting secure communication between heterogeneous terminals.
It realizes lightweight key management with high security and good performance, reduces network overhead, supports secure communication between heterogeneous terminals, and improves the security and performance of the system.
Smart Images

Figure CN119135456B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of key management, and in particular to a lightweight key management method and system based on a national secret algorithm. Background Art
[0002] The statements in this section merely mention background technology related to the present invention and do not necessarily constitute prior art.
[0003] With the development of information technology, the importance of information security has become increasingly prominent. Keys are the key factor in ensuring information security. Once the keys of a system are leaked, the information security of the system will be threatened. When designing a cryptographic system, the core issue that needs to be solved is the key management issue. Therefore, the role of key management is particularly important.
[0004] Key management refers to a set of technologies and procedures for establishing and maintaining key relationships between authorized parties, involving the entire process from key generation to final destruction, including key generation, storage, distribution and negotiation, use, backup and recovery, update, revocation and destruction. Most existing key management methods or systems are based on public key infrastructure, which requires complex certificate management and key escrow mechanisms. However, due to the limited computing resources of IoT devices, that is, the limited ability to process data, this approach may lead to performance bottlenecks in IoT terminals, which will greatly increase network latency and cause network transmission jams, thereby affecting the communication quality between IoT terminals and other terminals. In addition, in the environment of white box attacks, the root key of the server or terminal can be easily stolen, thereby threatening the security of the entire system. Summary of the invention
[0005] To address the deficiencies of the above-mentioned prior art, the present invention provides a lightweight key management method and system based on the national secret algorithm, which supports secure communication with general users, servers, and Internet of Things terminals. The key management server generates and stores the key file of each user, and encrypts the key file using a white box. Each user has a separate white box that is physically distributed. On this basis, the key management server loads and verifies user information in the form of a hash bucket. The user uses the white box to decrypt the private key file to obtain the key, thereby establishing a secure connection with the key management server. The above method can reduce network overhead, support secure communication between heterogeneous terminals, and achieve lightweight key management with high security and good performance.
[0006] In a first aspect, the present invention provides a lightweight key management method based on a national secret algorithm.
[0007] A lightweight key management method based on a national secret algorithm is implemented based on an end-to-end encryption key system. The system includes a key management server and a user. The key management server is used to perform a user creation process, an information loading process, a secure connection process, and a key distribution process.
[0008] The user creation process includes: creating SM4 white boxes for users in the domain and physically distributing them, and creating users and generating user information based on user names and user passwords;
[0009] The information loading process includes: loading user information and storing it in a hash bucket, obtaining the user's SM2 public key, decrypting the shared key using the SM4 white box; and loading local information and decrypting it;
[0010] The secure connection process includes: creating a thread to communicate with the user, searching for user information in a hash bucket and verifying it after receiving a data packet sent by the user, decrypting the key information using a shared key, and negotiating to obtain a session key, thereby establishing a secure connection;
[0011] The key distribution process includes: after receiving the key distribution request sent by the user, searching the user information in the hash bucket and verifying it, decrypting the data packet using the session key, generating a key distribution data packet and replying to the user.
[0012] In a second aspect, the present invention provides a lightweight key management system based on the national secret algorithm.
[0013] A lightweight key management system based on the national secret algorithm, including:
[0014] User creation module, used to create SM4 white boxes for users in the domain and physically distribute them, and to create users and generate user information based on user names and user passwords;
[0015] Information loading module, used to load user information and store it in the hash bucket, obtain the user's SM2 public key, use the SM4 white box to decrypt the shared key; and load local information and decrypt it;
[0016] The secure connection module is used to create a thread to communicate with the user. After receiving the data packet sent by the user, it searches the hash bucket for user information and verifies it, decrypts the key information using the shared key, and negotiates to obtain the session key to establish a secure connection.
[0017] The key distribution module is used to search and verify the user information in the hash bucket after receiving the key distribution request sent by the user, decrypt the data packet using the session key, generate a key distribution data packet and reply to the user.
[0018] In a third aspect, the present invention further provides an electronic device comprising a memory and a processor, and computer instructions stored in the memory and executed on the processor, wherein when the computer instructions are executed by the processor, the steps of the method described in the first aspect are completed.
[0019] In a fourth aspect, the present invention further provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, complete the steps of the method described in the first aspect.
[0020] One or more of the above technical solutions have the following beneficial effects:
[0021] 1. The present invention provides a lightweight key management method and system based on the national secret algorithm, which uses a white box to store the root key and protects the security of the user key information through white box encryption. On this basis, the user key information is loaded using a hash bucket to improve the user key information retrieval speed, and can allocate keys to users, supporting secure communication between general users, servers, and IoT terminals. Compared with the prior art, the method proposed by the present invention can effectively reduce network overhead, support secure communication between heterogeneous terminals, and achieve lightweight key management with high security and good performance.
[0022] 2. The present invention adopts the existing national secret algorithms SM2, SM3, and SM4 to form a three-layer key management method. The three layers of keys are, from top to bottom, the root key (i.e., stored in a white box), the shared key and the SM2 public and private key, and the session key. The root key is used to protect the shared key and the SM2 private key, and the shared key and the SM2 public and private key are used to protect the negotiated session key. When the user and the key management server negotiate the session key, it means that a secure connection has been established to achieve secure communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0024] Figure 1 This is an overall flow chart of the lightweight key management method based on the national encryption algorithm described in an embodiment of the present invention. DETAILED DESCRIPTION
[0025] It should be noted that the following detailed descriptions are exemplary only, are intended to describe specific embodiments, are intended to provide further explanation of the present invention, and are not intended to limit exemplary embodiments according to the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those of ordinary skill in the art to which the present invention belongs. In addition, it should also be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0026] Embodiment 1
[0027] This embodiment provides a lightweight key management method based on a national secret algorithm, which is implemented based on an end-to-end encryption key system. The system includes a key management server and a user. The key management server is used to perform a user creation process, an information loading process, a secure connection process, and a key distribution process.
[0028] The user creation process includes: creating SM4 white boxes for users in the domain and physically distributing them, and creating users and generating user information based on user names and user passwords;
[0029] The information loading process includes: loading user information and storing it in a hash bucket, obtaining the user's SM2 public key, decrypting the shared key using the SM4 white box; and loading local information and decrypting it;
[0030] The secure connection process includes: creating a thread to communicate with the user, searching for user information in a hash bucket and verifying it after receiving a data packet sent by the user, decrypting the key information using a shared key, and negotiating to obtain a session key, thereby establishing a secure connection;
[0031] The key distribution process includes: after receiving the key distribution request sent by the user, searching the user information in the hash bucket and verifying it, decrypting the data packet using the session key, generating a key distribution data packet and replying to the user.
[0032] like Figure 1 As shown, the following content introduces the lightweight key management method based on the national secret algorithm proposed in this embodiment in more detail.
[0033] The lightweight key management method based on the national secret algorithm proposed in this embodiment is implemented based on an end-to-end encryption key system, which includes a key management server and a user, wherein the key management server is used to manage user keys; further, the server is a type of user, and the management scope of the key management server is a domain, and the servers in the domain are also managed by the key management server. The method proposed in this embodiment is implemented through the interaction between the key management server and the user, and specifically includes the following steps:
[0034] Step S101, user creation process, namely: the key management server creates an SM4 white box for the user and distributes it physically; creates a user based on the user name and user password, and generates user information. In this embodiment, the generated user information includes the user's prv, pub, kpu, and sek files. Among them, the above-mentioned generated files are all binary files, prv, pub, kpu, and sek are all file name suffixes used to distinguish the type of file. The prv file can be called a private key file, the pub file can be called a public key file, the kpu file can be called a server public key file, and the sek file can be called a password file.
[0035] Furthermore, the process of generating the prv, pub, and kpu files in the above step S101 includes:
[0036] First, before creating a user, a random number array nonce is generated; and before each user is created, the user password and software identification are processed by the SM3 algorithm to obtain HashA. The software identification is a string array, which is already available in the user / server.
[0037] Secondly, generate prv, pub, and kpu files, including:
[0038] S101-a1: Generate private key structure, public key structure, and server public key structure;
[0039] S101-a2: Fill the user name into the above structure;
[0040] S101-a3: Generate a 128-bit shared key, use white box encryption, and fill it into the public key structure and private key structure; among them, white box encryption technology is an existing technology, which is a technology that integrates keys and symmetric encryption algorithms (SM4 algorithm is used in this embodiment) and can store keys.
[0041] S101-a4: Encrypt the nonce array using the SM4 algorithm;
[0042] S101-a5: Generate SM2 public key, private key and parameter ZA; encrypt SM2 private key using white box encryption, fill SM2 public key, SM2 private key and parameter ZA into private key structure, fill SM2 public key and ZA into public key structure and server public key structure; wherein parameter ZA is one of the parameters of SM2 algorithm itself;
[0043] S101-a6: Calculate uid (i.e. user ID) based on the user name using CRC32 algorithm and fill it into each structure;
[0044] S101-a7: Calculate the hash value for the data in the above structure using the SM3hmac algorithm. For the private key structure, the key is the 32 bytes starting from the 16th element of the nonce array; for the public key structure, the key is the 32 bytes starting from the 20th element of the nonce array; for the server public key structure, the key is the 32 bytes starting from the 12th element of the nonce array;
[0045] S101-a8: Output the public key structure as a pub file and the server public key structure as a kpu file; encrypt the private key structure using the SM4 algorithm, with the encryption mode being CTR, the key being the first 16 bytes of HashA, and the IV being the last 16 bytes of HashA, and then output as a prv file.
[0046] It should be made clear here that IV refers to the initial vector. In the CTR mode of the SM4 algorithm, there is an IV that encrypts the plaintext together with the encryption key.
[0047] In addition, generate sek files, including:
[0048] S101-b1: Generate a 256-byte random array p;
[0049] S101-b2: Take offset = p[0]%32, and take p+offset+i bytes as the SM2 private key, i∈[0, 1, 2, …, 31]; where % represents the modulo operation;
[0050] S101-b3: Generate SM2 public key sm2iPubk according to SM2 private key, and the public key sm2iPubk is in array form;
[0051] S101-b4: Take offset=sm2iPubk[0]%16, use SM2 algorithm to encrypt the user name and password, and store them in p+64+offset+i, i∈[0, 1, 2, …, 63];
[0052] S101-b5: Encrypt array p using white box and output array p as a sek file.
[0053] It can be seen from the above generation steps that the file names of the files generated in the above step S101 are all 32-bit hash values generated by the user name through the CRC32 algorithm. The above files specifically include:
[0054] (1) The prv file includes: uid (user ID), shared key, user name, SM2 public key, SM2 private key, SM2 algorithm ZA, nonce array, and hash value;
[0055] Among them, the shared key and SM2 private key are encrypted using a white box; the nonce array is encrypted using the SM4 algorithm, the encryption mode is CTR, and the encryption key and IV are obtained from the array CV (the value of the array CV is fixed), the shared key and the user name; the hash value is calculated using the SM3hmac algorithm, and the key is the 32 bytes starting from the 16th element of the nonce array; the file is encrypted using the SM4 algorithm, the encryption mode is CTR, the key is the last 16 bytes of HashA, and the IV is the first 16 bytes of HashA; the uid is obtained from the user name through the CRC32 algorithm.
[0056] (2) The pub file includes: uid, shared key, user name, SM2 public key, ZA of SM2 algorithm, and hash value;
[0057] Among them, the shared key is encrypted using a white box; the hash value is calculated using the SM3hmac algorithm, and the key is 32 bytes starting from the 20th element of the nonce array.
[0058] (3) The kpu file includes: uid, user name, SM2 public key, ZA of SM2 algorithm, and hash value;
[0059] The hash value is calculated using the SM3hmac algorithm, and the key is the 32 bytes starting from the 12th element of the nonce array.
[0060] (4)sek file includes: user name, user password, SM2 private key, etc.
[0061] Among them, the sek file is used to save the user name and password, and the user name and password are encrypted using the SM2 algorithm. The SM2 private key, user name and password are inserted into a 256-byte random array and encrypted using white box encryption.
[0062] Step S102, information transmission process, that is: the key management server transmits the user's prv file to the user through a secure channel (only used for transmitting files), and transmits the key management server's kpu file to the user.
[0063] As another implementation method, if the user is a server in the domain, a sek file needs to be transmitted.
[0064] The following steps S103-S104 are the information loading process, which specifically include:
[0065] Step S103: The key management server loads the pub files of all users, stores them in the hash bucket, obtains the user SM2 public key to communicate with the user / server; and uses the white box to decrypt the shared key.
[0066] In the above step S103, the key management server reads the user's pub file and stores it in the hash bucket to extract the key information. The process includes:
[0067] S103-a1: Initialize the hash bucket and apply for a memory segment to store the hash bucket nodes;
[0068] S103-a2: Load the user's pub file and store it in the hash node. If there is a file with the same hash value, it will be stored in the form of a linked list;
[0069] S103-a3: Decrypt the shared key using the white box.
[0070] Step S104, the key management server reads the local prv file, uses the white box to decrypt the sek file to extract the user password, and then decrypts the prv file content; uses the white box to decrypt the shared key and SM2 private key, and uses the shared key, user name, and CV to decrypt the nonce array.
[0071] In the above step S104, the key management server loads / reads and decrypts the local information, and the process includes:
[0072] S104-a1: Load the prv file and sek file of the key management server;
[0073] S104-a2: Use white box to decrypt sek file into array buffer;
[0074] S104-a3: take offset=buffer[0]%32, extract buffer+offset+i bytes as SM2 private key, i∈[0, 1, 2, …, 31];
[0075] S104-a4: Generate SM2 public key sm2iPubk according to SM2 private key; take offset=sm2iPubk[0]%16, use SM2 algorithm to decrypt buffer+64+offset+i, i∈[0,1,2,…,63], and extract user password;
[0076] S104-a5: Use SM3 algorithm to process the user password and software identifier to obtain HashA;
[0077] S104-a6: Decrypt the prv file using the SM4 algorithm. The decryption mode is CTR. The key is the last 16 bytes of HashA. The IV is the first 16 bytes of HashA.
[0078] S104-a7: Use SM3hamc algorithm to check whether the file has been tampered with;
[0079] S104-a8; Use the white box to decrypt the shared key and SM2 private key in the prv file; Use the SM4 algorithm to decrypt the nonce array, the decryption mode is CTR, the key is the first 16 bytes of the hash value generated by the CV, shared key, and user name using the SM3 algorithm, and the IV is the last 16 bytes of the above hash value.
[0080] The following steps S105 to S108 are a secure connection process, including:
[0081] Step S105: The key management server creates a thread and waits for receiving a UDP data packet.
[0082] Step S106: The user reads the local prv file, and uses the user password and software identifier to decrypt the prv file content; uses the white box to decrypt the shared key and SM2 private key, and uses the shared key, user name, and CV to decrypt the nonce array. When the user reads and decrypts the local file, if the user is a server, it is necessary to first use the white box to decrypt the sek file to extract the user password, and then decrypt the prv file content.
[0083] In the above step S106, the user reads and decrypts the local information, and the process includes:
[0084] S106-a1: Load the prv file of the key management server;
[0085] S106-a2: Use the SM3 algorithm to process the user password and the software identifier to obtain HashA; as an implementation method, if the user is a server, first use the white box to decrypt the sek file to extract the user password, and then use the SM3 algorithm to process the user password and the software identifier to obtain HashA;
[0086] S106-a3: Decrypt the prv file using the SM4 algorithm. The decryption mode is CTR. The key is the last 16 bytes of HashA. The IV is the first 16 bytes of HashA.
[0087] S106-a4: Use SM3hamc algorithm to check whether the file has been tampered with;
[0088] S106-a5; Use the white box to decrypt the shared key and SM2 private key in the prv file; Use the SM4 algorithm to decrypt the nonce array, the decryption mode is CTR, the key is the first 16 bytes of the hash value generated by the CV, shared key, and user name using the SM3 algorithm, and the IV is the last 16 bytes of the above hash value.
[0089] Step S107: The user reads the kpu file of the key management server and obtains the public key information of the key management server SM2.
[0090] Step S108, the user creates a thread to communicate with the key management server, the user generates a session key or session key parameters, encrypts it with a shared key and sends a data packet to the key management server. After receiving the data packet, the key management server searches the hash bucket for user information and verifies it, decrypts the key information with the shared key, and negotiates to obtain the session key, thereby establishing a secure connection.
[0091] In the above steps, if the session key is received, the key management server replies to the user with a confirmation data packet encrypted with the session key, and a secure connection is successfully established;
[0092] If session key parameters are received, the key management server generates session key parameters and calculates the session key based on the user's session key parameters. It then sends a data packet containing the generated session key parameters encrypted with the shared key to the user. After the user receives the data packet, he uses the shared key to decrypt the session key parameters, calculates the session key, and successfully establishes a secure connection.
[0093] Based on the above steps, the key management server needs to negotiate the session key with the user to establish a secure connection, and negotiate the session key for communication between the user and the key management server. The session key must be renegotiated each time a secure connection is established. That is, when the user goes offline and logs in again, the session key needs to be negotiated with the key management server to establish a secure connection.
[0094] Preferably, the negotiation method of the above-mentioned session key can select control key, SM2 public key encryption, digital envelope, digital signature envelope, SM2-ECDH and SM2 key negotiation, etc. Among them, the control key method refers to the user generating a 128-bit session key, filling it into the data packet, and sending it to the key management server after encryption with the shared key; the SM2 public key encryption method refers to the user generating a 128-bit session key, encrypting the session key using the SM2 algorithm, filling it into the data packet, and sending it to the key management server after encryption with the shared key; the digital envelope method refers to the user generating a 128-bit session key, encrypting the session key using a digital envelope, filling it into the data packet, and sending it to the key management server after encryption with the shared key; the digital signature envelope method refers to the user generating a 128-bit session key, encrypting the session key using a digital envelope, filling it into the data packet, and sending it to the key management server after encryption with the shared key; the SM2-ECDH method refers to the user and the key management server generating SM2-ECDH parameters, exchanging them after encryption with the shared key, and each calculating the session key; the SM2-key negotiation method refers to the user and the key management server generating SM2 key negotiation parameters, exchanging them after encryption with the shared key, and each calculating the session key.
[0095] The following steps S109 to S110 are a key distribution process, including:
[0096] Step S109: The user initiates a key distribution request to the key management server for communication with another user, which is encrypted using the session key.
[0097] Step S110, the key management server receives the key distribution request, searches for the user information in the hash bucket and verifies it, decrypts the data packet using the session key, obtains IDA (the user who initiated the request) and IDB (the user who will establish a connection with the user who initiated the request), searches for the IDB user information in the hash bucket, generates a key distribution data packet and replies to the user.
[0098] In the above scheme of this embodiment, the existing national secret algorithms SM2, SM3, and SM4 are adopted to form a three-layer key management method. The three layers of keys are, from top to bottom, the root key (i.e., stored using white boxes), the shared key and the SM2 public and private keys, and the session key. The root key is used to protect the shared key and the SM2 private key, and the shared key and the SM2 public and private keys are used to protect the negotiated session key. When the user and the key management server negotiate the session key, it means that a secure connection has been established, and secure communication can be achieved at this time.
[0099] Embodiment 2
[0100] This embodiment provides a lightweight key management system based on the national secret algorithm, including:
[0101] User creation module, used to create SM4 white boxes for users in the domain and physically distribute them, and to create users and generate user information based on user names and user passwords;
[0102] Information loading module, used to load user information and store it in the hash bucket, obtain the user's SM2 public key, use the SM4 white box to decrypt the shared key; and load local information and decrypt it;
[0103] The secure connection module is used to create a thread to communicate with the user. After receiving the data packet sent by the user, it searches the hash bucket for user information and verifies it, decrypts the key information using the shared key, and negotiates to obtain the session key to establish a secure connection.
[0104] The key distribution module is used to search and verify the user information in the hash bucket after receiving the key distribution request sent by the user, decrypt the data packet using the session key, generate a key distribution data packet and reply to the user.
[0105] Embodiment 3
[0106] This embodiment provides an electronic device, including a memory and a processor, and computer instructions stored in the memory and executed on the processor. When the computer instructions are executed by the processor, the steps in the lightweight key management method based on the national secret algorithm as described above are completed.
[0107] Embodiment 4
[0108] This embodiment also provides a computer-readable storage medium for storing computer instructions. When the computer instructions are executed by a processor, the steps in the lightweight key management method based on the national encryption algorithm as described above are completed.
[0109] The steps involved in the above embodiments 2 to 4 correspond to the method embodiment 1, and the specific implementation methods can refer to the relevant description part of embodiment 1. The term "computer-readable storage medium" should be understood as a single medium or multiple media including one or more instruction sets; it should also be understood to include any medium that can store, encode or carry an instruction set for execution by a processor and enable the processor to execute any method in the present invention.
[0110] Those skilled in the art should understand that the modules or steps of the present invention described above can be implemented by a general-purpose computer device, or alternatively, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. The present invention is not limited to any specific combination of hardware and software.
[0111] The above description is only a preferred embodiment of the present invention. Although the specific implementation mode of the present invention is described in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Technical personnel in the relevant field should understand that on the basis of the technical solution of the present invention, various modifications or deformations that can be made by technical personnel in this field without creative work are still within the scope of protection of the present invention.
Claims
1. A lightweight key management method based on a national secret algorithm, characterized in that: Based on the end-to-end encryption key system, the system includes a key management server and a user, and the key management server is used to perform the user creation process, information loading process, secure connection process and key distribution process; The user creation process includes: creating SM4 white boxes for users in the domain and physically distributing them, and creating users and generating user information based on user names and user passwords; The user information includes the user's prv, pub, kpu, and sek files; wherein the above-mentioned files generated are all binary files, prv, pub, kpu, and sek are all file name suffixes used to distinguish the types of files, the prv file is a private key file, the pub file is a public key file, the kpu file is a server public key file, and the sek file is a password file; The prv file includes: uid, shared key, user name, SM2 public key, SM2 private key, ZA of SM2 algorithm, nonce array, hash value; wherein, the shared key and SM2 private key are encrypted by white box; the nonce array is encrypted by SM4 algorithm, the encryption mode is CTR, and the encryption key and IV are obtained by array CV, shared key and user name; the hash value is calculated by SM3hmac algorithm, and the key is 32 bytes starting from the 16th element of the nonce array; the file is encrypted by SM4 algorithm, the encryption mode is CTR, the key is the last 16 bytes of HashA, and IV is the first 16 bytes of HashA; uid is obtained by the user name through CRC32 algorithm; The pub file includes: uid, shared key, user name, SM2 public key, ZA of SM2 algorithm, hash value; wherein, the shared key is encrypted by white box; the hash value is calculated by SM3hmac algorithm, and the key is 32 bytes starting from the 20th element of nonce array; The kpu file includes: uid, user name, SM2 public key, ZA of SM2 algorithm, and hash value; wherein the hash value is calculated using SM3hmac algorithm, and the key is 32 bytes starting from the 12th element of the nonce array; The sek file includes: a user name, a user password, and an SM2 private key; wherein the sek file is used to store the user name and the user password, encrypt the user name and the user password using the SM2 algorithm, and insert the SM2 private key, the user name and the user password into a 256-byte random array p, using white box encryption; The information loading process includes: loading user information and storing it in a hash bucket, obtaining the user's SM2 public key, and using the SM4 white box to decrypt the shared key; and loading local information and decrypting it; specifically: the key management server loads all users' pub files, stores them in a hash bucket, obtains the user's SM2 public key, and uses the white box to decrypt the shared key; The key management server reads the local prv file, uses the white box to decrypt the sek file to extract the user password, and decrypts the content of the prv file; uses the white box to decrypt the shared key and SM2 private key, and uses the shared key, user name, and array CV to decrypt the nonce array; The secure connection process includes: creating a thread to communicate with the user, searching for user information in a hash bucket and verifying it after receiving a data packet sent by the user, decrypting the key information using a shared key, and negotiating to obtain a session key, thereby establishing a secure connection; The key distribution process includes: after receiving the key distribution request sent by the user, searching the user information in the hash bucket and verifying it, decrypting the data packet using the session key, generating a key distribution data packet and replying to the user.
2. A lightweight key management method based on a national secret algorithm as claimed in claim 1, characterized in that: It also includes the information transmission process; After the key management server creates the user, it transmits the user's prv file to the user through a secure channel, and transmits the key management server's kpu file to the user.
3. A lightweight key management method based on a national secret algorithm as claimed in claim 1, characterized in that: The secure connection process includes: The key management server creates a thread and waits for receiving data packets; The user loads the local prv file and uses the user password and software identifier to decrypt the prv file content; uses the white box to decrypt the shared key and SM2 private key, and uses the shared key, user name, and array CV to decrypt the nonce array; and the user loads the kpu file of the key management server to obtain the SM2 public key information of the key management server; The user creates a thread to communicate with the key management server, generates a session key or session key parameters, and sends a data packet to the key management server after encrypting it with a shared key; After receiving the data packet, the key management server searches for the user information in the hash bucket and verifies it, decrypts the key information using the shared key, and negotiates the session key to establish a secure connection.
4. A lightweight key management method based on a national secret algorithm as claimed in claim 3, characterized in that: When the session key is received, the key management server replies to the user with a confirmation data packet encrypted with the session key, successfully establishing a secure connection; When the session key parameters are received, the key management server generates session key parameters and calculates the session key based on the user's session key parameters. It then sends a data packet containing the generated session key parameters encrypted with the shared key to the user. After the user receives the data packet, he uses the shared key to decrypt the session key parameters, calculates the session key, and successfully establishes a secure connection.
5. A lightweight key management method based on a national secret algorithm as claimed in claim 3, characterized in that: The negotiation of the session key selects any one of control key, SM2 public key encryption, digital envelope, digital signature envelope, SM2-ECDH and SM2 key negotiation.
6. A lightweight key management system based on the national secret algorithm, characterized in that: include: User creation module, used to create SM4 white boxes for users in the domain and physically distribute them, and to create users and generate user information based on user names and user passwords; The user information includes the user's prv, pub, kpu, and sek files; wherein the above-mentioned files generated are all binary files, prv, pub, kpu, and sek are all file name suffixes used to distinguish the types of files, the prv file is a private key file, the pub file is a public key file, the kpu file is a server public key file, and the sek file is a password file; The prv file includes: uid, shared key, user name, SM2 public key, SM2 private key, ZA of SM2 algorithm, nonce array, hash value; wherein, the shared key and SM2 private key are encrypted by white box; the nonce array is encrypted by SM4 algorithm, the encryption mode is CTR, and the encryption key and IV are obtained by array CV, shared key and user name; the hash value is calculated by SM3hmac algorithm, and the key is 32 bytes starting from the 16th element of the nonce array; the file is encrypted by SM4 algorithm, the encryption mode is CTR, the key is the last 16 bytes of HashA, and IV is the first 16 bytes of HashA; uid is obtained by the user name through CRC32 algorithm; The pub file includes: uid, shared key, user name, SM2 public key, ZA of SM2 algorithm, hash value; wherein, the shared key is encrypted by white box; the hash value is calculated by SM3hmac algorithm, and the key is 32 bytes starting from the 20th element of nonce array; The kpu file includes: uid, user name, SM2 public key, ZA of SM2 algorithm, and hash value; wherein the hash value is calculated using SM3hmac algorithm, and the key is 32 bytes starting from the 12th element of the nonce array; The sek file includes: user name, user password, SM2 private key; wherein, the sek file is used to save the user name and user password, encrypt the user name and user password using the SM2 algorithm, and insert the SM2 private key, user name and user password into a 256-byte random array p, and use white box encryption; the information loading module is used to load user information and store it in a hash bucket, obtain the user's SM2 public key, and use the SM4 white box to decrypt the shared key; and load local information and decrypt it; specifically: the key management server loads all users' pub files, stores them in a hash bucket, obtains the user's SM2 public key, and uses the white box to decrypt the shared key; The key management server reads the local prv file, uses the white box to decrypt the sek file to extract the user password, and decrypts the content of the prv file; uses the white box to decrypt the shared key and SM2 private key, and uses the shared key, user name, and array CV to decrypt the nonce array; The secure connection module is used to create a thread to communicate with the user. After receiving the data packet sent by the user, it searches the hash bucket for user information and verifies it, decrypts the key information using the shared key, and negotiates to obtain the session key to establish a secure connection. The key distribution module is used to search and verify the user information in the hash bucket after receiving the key distribution request sent by the user, decrypt the data packet using the session key, generate a key distribution data packet and reply to the user.
7. An electronic device, characterized in that: It comprises a memory and a processor, and computer instructions stored in the memory and executed on the processor. When the computer instructions are executed by the processor, the steps of a lightweight key management method based on a national secret algorithm as described in any one of claims 1 to 5 are completed.
8. A computer-readable storage medium, characterized in that: Used to store computer instructions, which, when executed by a processor, complete the steps of a lightweight key management method based on a national secret algorithm as described in any one of claims 1-5.
Citation Information
Patent Citations
Key management method and system
CN111464301A
Security enhancement method for bastion host based on national cryptographic encryption machine
CN115001703A