Key distribution methods, systems, devices, storage media, and program products
By combining the WebSocket protocol and the SM series algorithms, a secure and efficient remote distribution of POS device keys is achieved, solving the problems of cumbersome operation and low security in existing technologies. It supports the transmission of information from various devices and meets financial security requirements.
Patent Information
- Application Number
- CN202411294170.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2044-09-14
AI Technical Summary
Existing POS device key distribution methods are cumbersome, require physical connections, and have low security, failing to meet financial security requirements. Furthermore, remote distribution schemes using the RSA algorithm have low security and cannot achieve secure risk control based on the merchant's geographical location.
Data exchange is performed using the WebSocket protocol, and encryption, decryption, and signature verification are performed using the SM series of domestic cryptographic algorithms to achieve two-way authentication and ensure the security and scalability of the key distribution process.
Data exchange is achieved through a single secure connection, supporting the uploading of information from multiple devices to meet various risk control needs. It improves the security and convenience of key distribution and is suitable for the rapid deployment and secure management of smart POS devices.
Smart Images

Figure CN119449316B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information security technology, and in particular to key distribution methods, systems, devices, storage media, and program products. Background Technology
[0002] With the rapid development of banking services, smart POS terminals have gradually become the mainstream offline payment processing terminals. During device deployment, the security and convenience requirements for device activation and master key issuance are increasing. Currently, there are two main methods for key issuance:
[0003] (1) Wireless key distribution based on serial cable: This method requires connecting the POS machine to a dedicated secure room and secure equipment inside the bank via a serial cable, and using the matching key distribution software to verify the device and distribute the key. However, this method is cumbersome to operate and requires a physical connection. It cannot achieve secure risk control based on the merchant's geographical location, and is not secure or convenient enough.
[0004] (2) Remote distribution based on RSA international algorithm: This method uses a trusted certificate built into the smart POS device when it leaves the factory. When the device is activated, it remotely connects to the TCP interface provided by the bank on the Internet or dedicated line via TCP protocol, and uses the RSA international algorithm to verify the device and distribute the RSA key. However, the RSA algorithm used in this method has low security and cannot meet the national requirements for network security and financial security. Summary of the Invention
[0005] The main purpose of this application is to provide a key distribution method, system, device, storage medium, and program product, aiming to solve the technical problem of how to improve the security and scalability of key distribution.
[0006] To achieve the above objectives, this application proposes a key distribution method, which is applied to a client, the method comprising:
[0007] The verification public key certificate and signature are sent to the server via the WebSocket protocol, so that the server can perform signature verification based on the verification public key certificate and the signature to obtain the first signature verification result;
[0008] Receive the first signature verification result returned by the server, and use the verification public key certificate to perform signature verification on the first signature verification result to obtain the second signature verification result;
[0009] The random number in the second signature result is signed to obtain a second signature value. The second signature value is then sent to the server so that the server can use the verification public key certificate and the signing private key to verify and sign the second signature value to obtain a third signature value.
[0010] The system receives the third signature value returned by the server and verifies the consistency of the third signature value using the verification public key certificate. If the verification is successful, the system uses the encryption certificate to encrypt the device information and sends the encrypted device information to the server, so that the server generates a master key and a verification value based on the encrypted device information and encrypts the master key using the encryption public key.
[0011] Receive the encrypted master key and verification value sent by the server, and decrypt and store the encrypted master key based on the verification value.
[0012] In one embodiment, the step of receiving the encrypted master key and verification value sent by the server, and decrypting and storing the encrypted master key based on the verification value includes:
[0013] Receive the encrypted master key and verification value sent by the server;
[0014] The encrypted master key is decrypted using the decryption private key to obtain the decrypted master key;
[0015] Calculate and compare the verification value of the decrypted master key with the verification value returned by the server to see if they are consistent.
[0016] If they match, the decrypted master key is stored in the device's secure area.
[0017] In one embodiment, after the step of storing the decrypted master key in the device's secure area, the method further includes:
[0018] Generate a key distribution result and send the key distribution result to the server so that the server can update the data based on the key distribution result.
[0019] Furthermore, to achieve the above objectives, this application also proposes a key distribution method, which is applied to a server and includes:
[0020] Receive the verification public key certificate and signature sent by the client, and verify the signature according to the verification public key certificate to obtain the first signature verification result;
[0021] The first verification result is sent to the client so that the client can use the verification public key certificate to verify and sign the first verification result to obtain the second verification result.
[0022] The system receives the second signature value sent by the client, verifies and signs the second signature value using a verification public key certificate and a signing private key to obtain a third signature value, and returns the third signature value to the client so that the client can use the verification public key certificate to verify the consistency of the third signature value. After the verification is successful, the system uses an encryption certificate to encrypt the device information and sends the encrypted device information to the server.
[0023] Receive encrypted device information sent by the client, and generate a master key and a verification value based on the encrypted device information;
[0024] After encrypting the master key using the public key, the encrypted master key and the verification value are sent to the client, so that the client can decrypt and store the encrypted master key based on the verification value.
[0025] In one embodiment, after the step of encrypting the master key using the public key and sending the encrypted master key and verification value to the client, the method further includes:
[0026] Receive the key distribution result sent by the client, and update the data based on the key distribution result.
[0027] In one embodiment, the step of generating a master key and a verification value based on the encrypted device information includes:
[0028] The encrypted device information is decrypted using the decryption private key to obtain the decrypted device information;
[0029] The decrypted device information is verified;
[0030] If the decrypted device information passes verification, a master key and a verification value are generated.
[0031] Furthermore, to achieve the above objectives, this application also proposes a key distribution system, which includes a client and a server; the client includes:
[0032] The first sending module is used to send a verification public key certificate and a first signature to the server via the WebSocket protocol, so that the server can perform signature verification based on the verification public key certificate and the first signature to obtain a first signature verification result.
[0033] The first receiving module is used to receive the first signature verification result returned by the server, and use the verification public key certificate to perform signature verification on the first signature verification result to obtain the second signature verification result.
[0034] The signature module is used to sign the random number in the second signature result to obtain a second signature value, and send the second signature value to the server so that the server can use the verification public key certificate and the signature private key to verify and sign the second signature value to obtain a third signature value.
[0035] The verification module is used to receive the third signature value returned by the server, and use the verification public key certificate to verify the consistency of the third signature value. If the verification is successful, the device information is encrypted using the encryption certificate and the encrypted device information is sent to the server.
[0036] The storage module is used to receive the encrypted master key and verification value sent by the server, and to decrypt and store the encrypted master key based on the verification value.
[0037] The server includes:
[0038] The second receiving module is used to receive the verification public key certificate and the first signature sent by the client, and to verify the signature according to the verification public key certificate to obtain the first signature verification result.
[0039] The second sending module is used to send the first verification result to the client, so that the client can use the verification public key certificate to verify and sign the first verification result to obtain the second verification result.
[0040] The signature verification module is used to receive the second signature value sent by the client, and use the verification public key certificate and the signature private key to verify and sign the second signature value to obtain a third signature value, and return the third signature value to the client.
[0041] The generation module is used to receive encrypted device information sent by the client and generate a master key and a verification value based on the encrypted device information.
[0042] The distribution module is used to encrypt the master key using the public key and distribute the encrypted master key and the verification value to the client, so that the client can decrypt and store the encrypted master key based on the verification value.
[0043] In addition, to achieve the above objectives, this application also proposes a key distribution device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the key distribution method as described above.
[0044] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the key distribution method as described above.
[0045] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the key distribution method described above.
[0046] This application proposes a key distribution method, system, device, storage medium, and program product. Specifically, the client sends a verification public key certificate and signature to the server via the WebSocket protocol; receives and verifies a first verification result returned by the server to obtain a second verification result; signs the random number in the second verification result to obtain a first signature value; and sends the first signature value and the random number to the server. After receiving the first signature value and the random number, the server generates a master key and a verification value, and distributes the encrypted master key and verification value to the client; the client decrypts and stores the master key. This scheme achieves two-way authentication through a public key certificate authentication mechanism, ensuring the trustworthiness of both parties. By verifying and signing the random number, replay attacks are effectively prevented. During the key distribution process, an encryption certificate is used to encrypt device information, ensuring the security of the master key and providing good scalability. Attached Figure Description
[0047] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0048] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0049] Figure 1 This is a flowchart illustrating the first embodiment of the key distribution method for this application.
[0050] Figure 2 This is a flowchart illustrating Embodiment 2 of the key distribution method for this application.
[0051] Figure 3 This is a flowchart illustrating Embodiment 3 of the key distribution method for this application;
[0052] Figure 4 This is a flowchart illustrating Embodiment 4 of the key distribution method for this application;
[0053] Figure 5 This is a schematic diagram of the overall scheme for the key distribution method in this application;
[0054] Figure 6 This is a flowchart illustrating the two-way authentication process for the key distribution method in this application.
[0055] Figure 7 This is a flowchart illustrating the challenge and response process for the key distribution method in this application.
[0056] Figure 8 This is a flowchart illustrating the key distribution method of this application.
[0057] Figure 9 This is a schematic diagram of the module structure of the key distribution system according to an embodiment of this application.
[0058] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0059] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0060] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0061] The main solution of this application embodiment is as follows: The client sends a verification public key certificate and signature to the server via the WebSocket protocol, so that the server can perform signature verification based on the verification public key certificate and signature to obtain a first verification result; the client receives the first verification result returned by the server and uses the verification public key certificate to perform signature verification on the first verification result to obtain a second verification result; the client signs the random number in the second verification result to obtain a second signature value, and sends the second signature value to the server, so that the server can use the verification public key certificate and signature private key to verify and sign the second signature value to obtain a third signature value; the client receives the third signature value returned by the server and uses the verification public key certificate to verify the consistency of the third signature value. If the verification is successful, the client uses an encryption certificate to encrypt the device information and sends the encrypted device information to the server, so that the server generates a master key and a verification value based on the encrypted device information and encrypts the master key using the encryption public key; the client receives the encrypted master key and verification value sent by the server, and decrypts and stores the encrypted master key based on the verification value. The server receives a verification public key certificate and signature from the client, verifies the signature based on the verification public key certificate, and obtains a first verification result. It then sends the first verification result to the client so that the client can use the verification public key certificate to verify and sign the first verification result, obtaining a second verification result. The server receives a second signature value from the client, verifies and signs the second signature value using the verification public key certificate and a signing private key, obtaining a third signature value. The third signature value is returned to the client so that the client can use the verification public key certificate to verify the consistency of the third signature value. After successful verification, the server encrypts the device information using an encryption certificate and sends the encrypted device information to the server. The server receives the encrypted device information from the client and generates a master key and a verification value based on the encrypted device information. After encrypting the master key using the encryption public key, the server sends the encrypted master key and verification value to the client so that the client can decrypt and store the encrypted master key based on the verification value.
[0062] Existing technologies suffer from drawbacks such as the need for physical connections, poor security, and complex communication protocols, hindering the rapid deployment and secure management of POS devices. Furthermore, current remote key distribution schemes cannot achieve secure risk control based on merchant geolocation, failing to meet national financial security requirements. Additionally, existing key distribution schemes utilize TCP protocols or RSA algorithms, resulting in complex communication protocols and low security.
[0063] This application provides a solution that enables data exchange in a single secure connection based on the WebSocket protocol, and uses the SM series of domestic cryptographic algorithms for encryption, decryption, signature verification, and ensures the security of the remote distribution of the device master key; it supports the transmission of various device information such as GPS, can meet various risk control needs, and has good scalability.
[0064] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device capable of performing the above functions. The following description uses a personal computer as an example to illustrate this embodiment and the subsequent embodiments.
[0065] Based on this, this application provides a key distribution method applied to a client. (Refer to...) Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the key distribution method of this application.
[0066] In this embodiment, the key distribution method includes steps S10 to S50:
[0067] Step S10: Send the verification public key certificate and signature to the server via the WebSocket protocol, so that the server can perform signature verification based on the verification public key certificate and the signature to obtain the first signature verification result;
[0068] It should be noted that in this embodiment, the smart POS device acts as a client and accesses the server through a front-end application interface.
[0069] Additionally, it should be noted that smart POS devices come pre-installed with a POS signature certificate and a POS encryption certificate issued by the POS manufacturer's national cryptographic CA (Certificate Authority). Furthermore, the client uses the POS signature private key to sign data such as the device serial number, manufacturer code, POS encryption public key certificate, and POS verification public key certificate.
[0070] Optionally, to ensure data security during transmission, the client and server establish a WebSocket communication connection. Data can be exchanged based on the HTTPS protocol during the handshake phase. After the connection is established, full-duplex communication is performed on a single connection. Both the client and the server can directly send data to each other, completing data transmission in a secure and reliable connection process, avoiding the impact of multiple connection establishments on communication efficiency and security.
[0071] Then, the client sends the signature, vendor code, and POS encryption public key certificate and POS verification public key certificate to the front-end application via the WebSocket protocol. The front-end application then forwards these to the server. The server uses the POS verification public key certificate to perform signature verification. After the verification process is complete, the server returns a response to the client via the WebSocket connection, indicating the first verification result and whether the authentication was successful.
[0072] Step S20: Receive the first verification result returned by the server, and use the verification public key certificate to perform signature verification on the first verification result to obtain the second verification result;
[0073] It should be noted that the first verification result includes, but is not limited to, the organization's random number, the organization's encryption public key certificate, the organization's verification public key certificate, and the first signature value.
[0074] Optionally, after the server returns the first signature result to the client via the WebSocket protocol, the client uses a pre-built-in root certificate of a national cryptographic CA verification authority to verify the authenticity of the authority's public key certificate in the first signature result received from the server, ensuring the validity of the authority's identity. If the signature verification passes, it proves that the first signature result sent by the server has not been tampered with, and a second signature result is generated and saved for subsequent processing.
[0075] Step S30: Sign the random number in the second signature result to obtain a second signature value, and send the second signature value to the server so that the server can use the verification public key certificate and the signing private key to verify and sign the second signature value to obtain a third signature value;
[0076] It is worth noting that since the random number needs to be regenerated with each interaction, attackers cannot obtain the private key in the device's security module, thus failing to generate the correct signature value and causing the signature verification to fail. Therefore, executing step S30 can avoid the problem of message replay attacks.
[0077] Optionally, the client uses the POS signing private key to concatenate and sign the organization random number, the POS random number, and the POS encryption public key certificate to obtain a second signature value. The client then sends the second signature value and the POS random number to the server, which verifies and signs the second signature value and the POS random number based on the POS verification public key certificate to obtain a third signature value.
[0078] Step S40: Receive the third signature value returned by the server, and verify the consistency of the third signature value using the verification public key certificate. If the verification is successful, encrypt the device information using the encryption certificate, and send the encrypted device information to the server so that the server can generate a master key and a verification value based on the encrypted device information, and encrypt the master key using the encryption public key.
[0079] Optionally, the client receives information returned by the server, including a third signature value generated by the server and other data such as an institutional random number, a POS random number, and an institutional cryptographic public key certificate. The client then uses the institutional verification public key certificate to verify the third signature value. The verification process involves decrypting the third signature value returned by the server and comparing it with the client's recalculated data to be signed, namely the institutional random number, the POS random number, and the hash value of the institutional cryptographic public key certificate.
[0080] Specifically, the system recalculates the institution's random number, POS random number, and the hash value of the institution's encrypted public key certificate. It then decrypts the third signature value using the institution's signing private key and compares the decrypted result with the hash value calculated by the client. If these two hash values match, the third signature is valid, further indicating that the data has not been tampered with during transmission.
[0081] Once the consistency verification of the third signature value is successful, the client uses the institution's public key certificate to encrypt business elements such as device information. The device information includes the merchant number, SMS activation code, and encrypted device information, which in turn includes GPS information.
[0082] The encrypted device information is then sent to the server so that the server can decrypt and verify the encrypted device information, and generate the corresponding master key and verification value based on the verified device information.
[0083] Step S50: Receive the encrypted master key and verification value returned by the server, and decrypt and store the encrypted master key based on the verification value.
[0084] Optionally, firstly, after receiving the encrypted and signed master key returned by the server, the client uses the institution's verification public key to verify the encrypted and signed master key, and then uses the POS decryption private key to decrypt the verified master key to obtain the decrypted master key.
[0085] Then, calculate and compare whether the decrypted master key verification value is consistent with the master key verification value returned by the server. This can be done by calculating the hash value of the master key verification value and the hash value of the master key verification value returned by the server respectively, and comparing whether the two hash values are consistent. If they are consistent, it means that the verification is successful.
[0086] If the verification value passes, the decrypted master key is stored in the device's secure area. Once the POS device has the master key, it can be activated and used for subsequent operations such as check-in and card swiping.
[0087] Specifically, the method described in the above embodiments involves the client sending a verification public key certificate and signature to the server via the WebSocket protocol, so that the server can perform signature verification based on the verification public key certificate and signature to obtain a first verification result; receiving the first verification result returned by the server, and using the verification public key certificate to perform signature verification on the first verification result to obtain a second verification result; signing the random number in the second verification result to obtain a second signature value, and sending the second signature value to the server, so that the server can use the verification public key certificate and signature private key to verify and sign the second signature value to obtain a third signature value; receiving the third signature value returned by the server, and using the verification public key certificate to verify the consistency of the third signature value. If the verification passes, the client uses an encryption certificate to encrypt the device information and sends the encrypted device information to the server, so that the server can generate a master key and a verification value based on the encrypted device information, encrypt the master key using the encryption public key, and send the encrypted master key and verification value to the client; receiving the encrypted master key and verification value sent by the server, and decrypting and storing the encrypted master key based on the verification value. This solution uses the WebSocket protocol to achieve data exchange in a single secure connection and employs the SM series of domestic cryptographic algorithms to perform encryption, decryption, signature verification, and other operations, ensuring the security of the remote distribution of device master keys. It also supports the uploading of various device information such as GPS, which can meet various risk control needs and has good scalability.
[0088] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 After step S50, the key distribution method further includes step S51:
[0089] Step S51: Generate a key distribution result and send the key distribution result to the server so that the server can update the data based on the key distribution result.
[0090] Optionally, after completing the key distribution and processing, the client needs to confirm whether the distributed key has been correctly applied or stored. If there are any errors or exceptions during the key distribution process, these distribution results are also recorded, and the key distribution results are encapsulated into a message or request, and the encapsulated key distribution results are sent back to the server via the WebSocket protocol.
[0091] This allows the server to update the key status information in the database or enable new encrypted communication based on the key distribution result after receiving the result.
[0092] Through the methods described above, the client sends the key distribution result to the server in real time, which helps the server maintain a real-time understanding of the client's key status and make decisions based on the actual situation, thereby ensuring the security, consistency and availability of the system.
[0093] Based on this, this application provides a key distribution method applied to a server. (Refer to...) Figure 3 , Figure 3 This is a flowchart illustrating the third embodiment of the key distribution method of this application.
[0094] In this embodiment, the key distribution method includes steps S60 to S100:
[0095] Step S60: Receive the verification public key certificate and signature sent by the client, and verify the signature according to the verification public key certificate to obtain the first verification result;
[0096] Optionally, after receiving the signature, vendor code, POS encryption public key certificate, and POS verification public key certificate sent by the client via the WebSocket protocol, the server uses the POS verification public key certificate to perform signature verification. If the signature verification passes, it indicates that the data sent by the client has not been tampered with during transmission, and a first verification result is generated. Simultaneously, the server uses its built-in POS vendor CA certificate to verify the issuer of the POS verification public key certificate, ensuring that the POS verification public key certificate was issued by the vendor CA.
[0097] Step S70: Send the first verification result to the client so that the client can use the verification public key certificate to verify and sign the first verification result to obtain the second verification result;
[0098] It should be noted that the first verification result includes, but is not limited to, the organization's random number, the organization's encryption public key certificate, the organization's verification public key certificate, and the first signature value.
[0099] Optionally, after the server-side verification is successful, the first signature verification result is returned to the front-end application. Based on the first signature verification result, the POS encryption / signature verification public key is stored in memory, a 17-byte institutional random number is generated, and the institutional encryption / signature verification public key certificate is obtained. The front-end application then returns the institutional encryption public key certificate, the institutional signature verification public key certificate, the 17-byte institutional random number, and the first signature value to the client via the WebSocket protocol. This allows the client to use the built-in institutional CA to verify the institutional public key certificate based on the returned data, ensuring the validity of the institutional identity.
[0100] Step S80: Receive the second signature value sent by the client, and verify and sign the second signature value using the verification public key certificate and the signing private key to obtain the third signature value. Return the third signature value to the client so that the client can use the verification public key certificate to verify the consistency of the third signature value. After the verification is successful, use the encryption certificate to encrypt the device information and send the encrypted device information to the server.
[0101] Optionally, after receiving the second signature value and POS random number sent by the client, the server uses the built-in POS verification public key certificate to verify the second signature value and POS random number. The second signature value is obtained by the client signing the organization random number, POS random number and POS encryption public key certificate by concatenating them using the POS signing private key.
[0102] After the signature verification is successful, the organization's random number, POS random number, and organization's encryption public key are signed using the organization's signing private key to obtain a third signature value. This third signature value is then returned to the client so that the client can verify its consistency and encrypt the device information based on the verification result.
[0103] Step S90: Receive encrypted device information sent by the client, and generate a master key and a verification value based on the encrypted device information;
[0104] It should be noted that the master key is a crucial cryptographic element used for encryption and decryption operations in subsequent communications. The checksum is used to ensure the integrity of subsequent communication data.
[0105] Optionally, after receiving the encrypted device information returned by the client, the server uses the organization's decryption private key to decrypt the encrypted device information to obtain the decrypted device information. The encrypted device information is obtained by the client using the organization's encryption public key certificate to encrypt the device information.
[0106] Next, the decrypted device information and other business elements are verified. This verification process includes checking whether the device information conforms to the expected format, logic, or business rules. For example, it verifies whether the device information is valid, exists, or matches previously stored or expected information. Once all business elements have passed verification, a master key and master key verification value are generated.
[0107] Step S100: Encrypt the master key using the public key, and send the encrypted master key and the verification value to the client so that the client can decrypt and store the encrypted master key based on the verification value.
[0108] Optionally, after obtaining the master key and the verification value, the master key is encrypted using the POS encryption public key. Then, the encrypted master key ciphertext and the master key verification value are returned to the front-end application. Based on the encrypted master key ciphertext and the master key verification value, the front-end application sends the corresponding signature content to the server. The signature content includes the organization random number, the POS random number, the master key, and the master key verification value. The front-end application signs the organization random number, the POS random number, the master key, and the master key verification value to obtain the fourth signature value.
[0109] The server then sends the signed master key, master key verification value, and fourth signature value to the client so that the client can verify the signature of the master key, master key verification value, and fourth signature value, and then use the private key to decrypt and compare it with the master key verification value, thus realizing the storage of the master key.
[0110] The method described in the above embodiments specifically involves the server receiving a verification public key certificate and signature sent by the client, verifying the signature based on the verification public key certificate to obtain a first verification result; sending the first verification result to the client so that the client can use the verification public key certificate to verify and sign the first verification result to obtain a second verification result; receiving a second signature value sent by the client, and verifying and signing the second signature value using the verification public key certificate and the signing private key to obtain a third signature value, which is then returned to the client; receiving encrypted device information sent by the client, and generating a master key and a verification value based on the encrypted device information; encrypting the master key using the encryption public key, and sending the encrypted master key and verification value to the client so that the client can decrypt and store the encrypted master key based on the verification value. This scheme uses the SM series procedural cryptography algorithm to sign and encrypt transmitted data, ensuring security and controllability during two-way authentication and key transmission between the device and the server. The entire process can be completed via the Internet without the need for dedicated equipment and network environment, improving the security and convenience of smart POS key distribution.
[0111] Based on the third embodiment of this application, in the fourth embodiment of this application, the content that is the same as or similar to that in the third embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 4 After step S100, the key distribution method further includes step S101:
[0112] Step S101: Receive the key distribution result sent by the client, and update the data based on the key distribution result.
[0113] Optionally, after receiving the key distribution result from the client via the WebSocket protocol, the server performs corresponding processing based on the key distribution result. If the key distribution is successful, the server updates the information about the key status in the database, such as updating the key management database, marking the key status, or adjusting the key lifecycle management strategy.
[0114] Through the methods described in the above embodiments, the server can maintain a real-time understanding of the client's key status based on the mirror data update of the key distribution result, thereby ensuring the security, consistency and availability of the system.
[0115] For example, to help understand the implementation flow of the key distribution method obtained by combining Embodiment 1 and Embodiment 3 above, please refer to Figure 5 , Figure 5 A general scheme diagram of a key distribution method is provided, specifically:
[0116] This embodiment of the scheme consists of four steps: two-way authentication, challenge response, key issuance, and result notification. The smart POS device must complete the interaction with the front-end application in this order. The front-end application controls the execution order of the four steps to prevent attackers from bypassing security authentication.
[0117] In this embodiment, the smart POS device interacts with the front-end application via WebSocket communication, and the client accesses the server through the front-end application interface. First, a connection is established through domain name TLS authentication. Then, the validity of the smart POS device is authenticated through two steps: mutual authentication and challenge response. After successful authentication, key distribution and result notification are performed, and finally, the client disconnects the connection.
[0118] Please refer to Figure 6 , Figure 6 This is a flowchart of the two-way authentication process for the key distribution method in this embodiment, specifically:
[0119] It should be noted that two-way authentication means that the client uses the root certificate to authenticate the server's certificate, while the server uses the vendor's CA to authenticate the client's certificate, ensuring the trustworthiness of both parties in the communication.
[0120] Optionally, the smart POS device, acting as a client, comes pre-installed with a POS signature certificate and a POS encryption certificate issued by the POS manufacturer's national cryptographic CA. The client uses the POS signature private key to sign data such as the device number, manufacturer code, POS encryption public key certificate, and POS verification public key certificate to obtain a signature value. The client then sends the signature value, manufacturer code, POS encryption public key certificate, and POS verification public key certificate together to the server.
[0121] The server uses the POS signature verification public key certificate for signature verification to ensure that the message has not been tampered with. At the same time, it uses the POS vendor CA verification certificate chain built into the server to ensure that the POS signature verification public key certificate is issued by the vendor CA.
[0122] Once the server-side verification is successful, it returns the initial verification result to the client, including the organization's random number, the organization's encrypted public key certificate, the organization's verification public key certificate, and the signature value. The client then uses its built-in national cryptographic CA (Certificate Authority) to verify this result, ensuring the validity of the organization's identity.
[0123] Please refer to Figure 7 , Figure 7 This is a flowchart of the challenge-response process for the key distribution method in this embodiment, specifically:
[0124] It should be noted that since a new random number is generated with each interaction, attackers cannot obtain the private key in the device's security module, and therefore cannot generate a valid signature value. This will cause the signature verification to fail. The challenge-response mechanism can prevent message replay problems that occur during the attack.
[0125] Optionally, the client uses the POS signing private key to sign the organization random number, the POS random number, and the POS encryption public key certificate to obtain a signature value C, and sends the signature value C and the POS random number to the server. The server uses the built-in POS verification public key certificate to verify the corresponding signature value and the POS random number. After successful verification, the server uses the organization signing private key to sign the second verification result, including the organization random number, the POS random number, and the organization encryption public key certificate, to obtain a signature value D, and returns the signature value D to the client. The client uses the organization verification public key certificate to verify the consistency of the signature value D.
[0126] Please refer to Figure 8 , Figure 8 This is a flowchart of the key distribution method in this embodiment, specifically:
[0127] It should be noted that the key distribution process uses a national cryptographic certificate to encrypt transmitted data such as device information and keys.
[0128] Optionally, the client uses an organization's public key certificate to encrypt business elements such as device information and sends it to the server. The server uses the organization's private key to decrypt the decrypted device information and then verifies the decrypted device information and other business elements. The device information includes the device's GPS information. During the key distribution process, the device's GPS information can be recorded when the smart POS device is activated.
[0129] Once the verification is successful, a master key and a verification value are generated. The master key is then encrypted using the POS encryption public key. Simultaneously, the organization's random number, the POS random number, the ciphertext of the master key, and the verification value are signed to obtain a signature value E. The ciphertext of the master key, the verification value, and the signature value E are then sent to the client. After verifying the signature using the organization's signature verification public key, the client decrypts the master key using the POS decryption private key, calculates and compares the verification value with the one returned by the server, and finally stores the master key in the device's secure area.
[0130] Finally, the client sends the key distribution result to the server, and the server performs data updates and other related processing based on the key distribution result.
[0131] This embodiment employs a process design involving two-way authentication, challenge and response, key distribution, and result updating. It utilizes the WebSocket protocol to achieve data exchange within a single secure connection and employs the SM series of domestic cryptographic algorithms for encryption, decryption, and signature verification, ensuring the security of the remote distribution of the device master key. It supports the uploading of various device information, such as GPS data, and can meet diverse risk control needs, exhibiting excellent scalability.
[0132] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the key distribution method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0133] This application also provides a key distribution system; please refer to [link / reference]. Figure 9 The key distribution system includes:
[0134] The sending module 10 is used to send a verification public key certificate and a first signature to the server via the WebSocket protocol, so that the server can perform signature verification based on the verification public key certificate and the first signature to obtain a first signature verification result;
[0135] The receiving module 20 is used to receive the first signature verification result returned by the server, and use the verification public key certificate to perform signature verification on the first signature verification result to obtain the second signature verification result;
[0136] The signature module 30 signs the random number in the second signature verification result to obtain a second signature value, and sends the second signature value to the server so that the server can use the verification public key certificate and the signature private key to verify and sign the second signature value to obtain a third signature value.
[0137] The verification module 40 is used to receive the third signature value returned by the server and verify the consistency of the third signature value using the verification public key certificate. If the verification is successful, the device information is encrypted using the encryption certificate and the encrypted device information is sent to the server so that the server generates a master key and a verification value based on the encrypted device information and encrypts the master key using the encryption public key.
[0138] The storage module 50 is used to receive the encrypted master key and verification value sent by the server, and to decrypt and store the encrypted master key based on the verification value.
[0139] The server includes:
[0140] The receiving module 20 is used to receive the verification public key certificate and the first signature sent by the client, and to verify the signature according to the verification public key certificate to obtain the first signature verification result;
[0141] Sending module 10 is used to send the first verification result to the client, so that the client can use the verification public key certificate to verify and sign the first verification result to obtain the second verification result;
[0142] The signature verification module 60 is used to receive the second signature value sent by the client, and use the verification public key certificate and the signature private key to verify and sign the second signature value to obtain a third signature value. The third signature value is returned to the client so that the client can use the verification public key certificate to verify the consistency of the third signature value. After the verification is successful, the device information is encrypted using the encryption certificate and the encrypted device information is sent to the server.
[0143] The generation module 70 is used to receive encrypted device information sent by the client and generate a master key and a verification value based on the encrypted device information.
[0144] The distribution module 80 is used to encrypt the master key using the encryption public key, and to distribute the encrypted master key and the verification value to the client, so that the client can decrypt and store the encrypted master key based on the verification value.
[0145] The key distribution system provided in this application, employing the key distribution method described in the above embodiments, can solve the technical problem of how to improve the security and scalability of key distribution. Compared with the prior art, the beneficial effects of the key distribution system provided in this application are the same as those of the key distribution method provided in the above embodiments, and other technical features of the key distribution system are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0146] This application provides a key distribution device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the key distribution method in Embodiment 1 above.
[0147] The key distribution device in this application embodiment may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Android Devices), PMPs (Portable Media Players), etc., as well as fixed terminals such as digital TVs, desktop computers, etc.
[0148] The key distribution device may include a processing system (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 1002 or programs loaded from the storage system into random access memory (RAM). The RAM also stores various programs and data required for the operation of the key distribution device. The processing system, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus. Typically, the following systems can be connected to the I / O interface: input systems including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output systems including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage systems including, for example, magnetic tape, hard disks, etc.; and communication systems. The communication system allows the key distribution device to communicate wirelessly or wiredly with other devices to exchange data.
[0149] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication system, or installed from a storage system, or installed from a ROM. When the computer program is executed by a processing system, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0150] The key distribution device provided in this application, employing the key distribution method described in the above embodiments, can solve the technical problem of how to improve the security and scalability of key distribution. Compared with the prior art, the beneficial effects of the key distribution device provided in this application are the same as those of the key distribution method provided in the above embodiments, and other technical features in this key distribution device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0151] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0152] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0153] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the key distribution method in the above embodiments.
[0154] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0155] The aforementioned computer-readable storage medium may be included in the key distribution device; or it may exist independently and not assembled into the key distribution device.
[0156] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by the key distribution device, the key distribution device: sends a verification public key certificate and signature to the server via the WebSocket protocol on the client side, so that the server can perform signature verification based on the verification public key certificate and signature to obtain a first verification result; receives the first verification result returned by the server, and uses the verification public key certificate to perform signature verification on the first verification result to obtain a second verification result; signs the random number in the second verification result to obtain a second signature value, and applies the second signature value... The system sends the third signature value to the server, which uses the verification public key certificate and signing private key to verify and sign the second signature value. It then receives the third signature value returned by the server and verifies its consistency using the verification public key certificate. If the verification passes, it encrypts the device information using the encryption certificate and sends the encrypted device information to the server, enabling the server to generate a master key and a verification value based on the encrypted device information. The server then encrypts the master key using the encryption public key. Finally, it receives the encrypted master key and verification value returned by the server, decrypts the encrypted master key based on the verification value, and stores it. The server receives a verification public key certificate and signature from the client, verifies the signature based on the verification public key certificate, and obtains a first verification result. It then sends the first verification result to the client so that the client can use the verification public key certificate to verify and sign the first verification result, obtaining a second verification result. The server receives a second signature value from the client, verifies and signs the second signature value using the verification public key certificate and a signing private key, obtaining a third signature value. The third signature value is returned to the client so that the client can use the verification public key certificate to verify the consistency of the third signature value. After successful verification, the server encrypts the device information using an encryption certificate and sends the encrypted device information to the server. The server receives the encrypted device information from the client and generates a master key and a verification value based on the encrypted device information. After encrypting the master key using the encryption public key, the server sends the encrypted master key and verification value back to the client so that the client can decrypt and store the encrypted master key based on the verification value.
[0157] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0158] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0159] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0160] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described key distribution method, thereby solving the technical problem of how to improve the security and scalability of key distribution. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the key distribution method provided in the above embodiments, and will not be repeated here.
[0161] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the key distribution method described above.
[0162] The computer program product provided in this application can solve the technical problem of how to improve the security and scalability of key distribution. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the key distribution method provided in the above embodiments, and will not be repeated here.
[0163] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A key distribution method, characterized in that, The method is applied to a client, which is a smart POS device. The client interacts with the front-end application via the WebSocket protocol and accesses the server through the front-end application interface. The method includes: The verification public key certificate and signature are sent to the server via the WebSocket protocol, so that the server can perform signature verification based on the verification public key certificate and the signature to obtain the first signature verification result; Receive the first signature verification result returned by the server, and use the verification public key certificate to perform signature verification on the first signature verification result to obtain the second signature verification result; The random number in the second signature result is signed to obtain a second signature value. The second signature value is then sent to the server so that the server can use the verification public key certificate and the signing private key to verify and sign the second signature value to obtain a third signature value. The system receives the third signature value returned by the server and verifies the consistency of the third signature value using the verification public key certificate. If the verification is successful, the system uses the encryption certificate to encrypt the device information and sends the encrypted device information to the server, so that the server generates a master key and a verification value based on the encrypted device information and encrypts the master key using the encryption public key. Receive the encrypted master key and verification value sent by the server, and decrypt and store the encrypted master key based on the verification value.
2. The method as described in claim 1, characterized in that, The steps of receiving the encrypted master key and verification value from the server, and decrypting and storing the encrypted master key based on the verification value include: Receive the encrypted master key and verification value sent by the server; The encrypted master key is decrypted using the decryption private key to obtain the decrypted master key; Calculate and compare the verification value of the decrypted master key with the verification value returned by the server to see if they are consistent. If they match, the decrypted master key is stored in the device's secure area.
3. The method as described in claim 2, characterized in that, After the step of storing the decrypted master key in the device's secure area, the method further includes: Generate a key distribution result and send the key distribution result to the server so that the server can update the data based on the key distribution result.
4. A key distribution method, characterized in that, The method is applied to the server side, wherein the smart POS device acts as a client, interacting with the front-end application via the WebSocket protocol and accessing the server through the front-end application interface. The method includes: The system receives a verification public key certificate and a signature sent by the client via the WebSocket protocol, and verifies the signature based on the verification public key certificate to obtain a first verification result. The first verification result is sent to the client so that the client can use the verification public key certificate to verify and sign the first verification result to obtain a second verification result, and sign the random value in the second verification result to obtain a second signature value; The system receives the second signature value sent by the client, verifies and signs the second signature value using a verification public key certificate and a signing private key to obtain a third signature value, and returns the third signature value to the client so that the client can use the verification public key certificate to verify the consistency of the third signature value. After the verification is successful, the system uses an encryption certificate to encrypt the device information and sends the encrypted device information to the server. Receive encrypted device information sent by the client, and generate a master key and a verification value based on the encrypted device information; After encrypting the master key using the public key, the encrypted master key and the verification value are sent to the client, so that the client can decrypt and store the encrypted master key based on the verification value.
5. The method as described in claim 4, characterized in that, After the step of encrypting the master key using the public key and sending the encrypted master key and verification value to the client, the method further includes: Receive the key distribution result sent by the client, and update the data based on the key distribution result.
6. The method as described in claim 4, characterized in that, The step of generating the master key and verification value based on the encrypted device information includes: The encrypted device information is decrypted using the decryption private key to obtain the decrypted device information; The decrypted device information is verified; If the decrypted device information passes verification, a master key and a verification value are generated.
7. A key distribution system, characterized in that, The system includes a client and a server; the client is a smart POS device, which interacts with the front-end application via the WebSocket protocol and accesses the server through the front-end application interface. The client includes: The sending module is used to send a verification public key certificate and a first signature to the server via the WebSocket protocol, so that the server can perform signature verification based on the verification public key certificate and the first signature to obtain a first signature verification result; The receiving module is used to receive the first signature verification result returned by the server, and use the verification public key certificate to perform signature verification on the first signature verification result to obtain the second signature verification result. The signature module signs the random number in the second verification result to obtain a second signature value, and sends the second signature value to the server so that the server can use the verification public key certificate and the signing private key to verify and sign the second signature value to obtain a third signature value. The verification module is used to receive the third signature value returned by the server and verify the consistency of the third signature value using the verification public key certificate. If the verification is successful, the device information is encrypted using the encryption certificate and the encrypted device information is sent to the server so that the server generates a master key and a verification value based on the encrypted device information and encrypts the master key using the encryption public key. The storage module is used to receive the encrypted master key and verification value returned by the server, and to decrypt and store the encrypted master key based on the verification value. The server includes: The receiving module is used to receive the verification public key certificate and the first signature sent by the client, and to verify the signature according to the verification public key certificate to obtain the first signature verification result; The sending module is used to send the first verification result to the client, so that the client can use the verification public key certificate to verify and sign the first verification result to obtain a second verification result, and sign the random value in the second verification result to obtain a second signature value; The signature verification module is used to receive the second signature value sent by the client, and use the verification public key certificate and the signature private key to verify and sign the second signature value to obtain a third signature value. The third signature value is returned to the client so that the client can use the verification public key certificate to verify the consistency of the third signature value. After the verification is successful, the device information is encrypted using the encryption certificate and the encrypted device information is sent to the server. The generation module is used to receive encrypted device information sent by the client and generate a master key and a verification value based on the encrypted device information. The distribution module is used to encrypt the master key using the public key and distribute the encrypted master key and the verification value to the client, so that the client can decrypt and store the encrypted master key based on the verification value.
8. A key distribution device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the key distribution method as described in any one of claims 1 to 6.
9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the key distribution method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the key distribution method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Master key management method and device
CN111431708A
Bidirectional authentication method, terminal and server
CN111931158A