A security two-dimensional code method based on domestic chips and national encryption algorithm

By using domestically produced chips and national cryptographic algorithms in the QR code generation and parsing process, the security issues of QR code data transmission and scanning are solved, achieving data privacy, tamper-proofing, and efficient encryption and decryption.

CN117714067BActive Publication Date: 2026-11-24UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311711217.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2023-09-28
Filing Date
2023-12-13
Publication Date
2026-11-24
Estimated Expiration
2043-12-13

AI Technical Summary

Technical Problem

Existing QR codes pose security risks during data transmission and scanning, making them vulnerable to malicious cracking and attacks, which can lead to information leaks.

Method used

It adopts domestically produced chips and national cryptographic algorithms, and encrypts QR code data through SM2 digital signature algorithm, SM4 encryption algorithm and SM3 hash algorithm. In the generation and parsing process, the national cryptographic core is used to assist in the calculation to ensure the confidentiality, integrity and availability of the data.

Benefits of technology

The generated QR code can only be decoded on a specific platform, preventing data leakage and tampering, improving the security of information transmission and the security of the QR code, and enhancing encryption and decryption efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117714067B_ABST
    Figure CN117714067B_ABST
Patent Text Reader

Abstract

This invention provides a secure QR code method based on domestically produced chips and national cryptographic algorithms. Both encryption and decryption steps are completed within the domestically produced chip. The use of national cryptographic algorithms and core technologies accelerates the process, ensuring security while improving encryption and decryption efficiency. QR code security technology based on domestically produced chips and national cryptographic algorithms refers to using domestically produced chips and national cryptographic algorithms to ensure the security of QR codes during generation, transmission, and parsing. The generated QR codes can only be scanned and decoded on specific platforms, preventing data leakage and tampering, improving the security of information transmission and the security of the QR code itself, and meeting the security requirements for anti-tampering, anti-leakage, and anti-attack during QR code transmission and scanning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to data encryption technology, and particularly to QR code encryption and decryption technology. Background Technology

[0002] The rapid development of mobile internet has driven the application and widespread use of QR codes in daily life. QR codes are widely used, serving both as a carrier of information and as a method and means of information dissemination. However, scanning QR codes through unknown external interfaces makes them vulnerable to malicious attacks, necessitating the concealment of the original QR code data. Online decoding may expose databases, leading to attacks and information leaks. Therefore, the security issues of QR codes deserve our attention.

[0003] Security encryption algorithms used in data storage, transmission, and identity authentication play a crucial role in ensuring information security, especially in big data, communications, social networking, cloud computing, and the Internet of Things. In key industries across various sectors in my country, the adoption of domestically produced products to replace industrial control systems and components, forming an integrated system of independently controllable chips, products, and industrial control systems, further guarantees the security of the hardware environment.

[0004] Domestic cryptographic algorithms are a series of commercially available cryptographic algorithms publicly released in my country. Among them, the most widely used include the SM2 elliptic curve public-key cryptography algorithm, the SM3 cryptographic hash algorithm, and the SM4 block cipher algorithm. The SM2 elliptic curve public-key cryptography algorithm mainly corresponds to the internationally used ECC and RSA algorithms, and includes three parts: public-key encryption algorithm, key exchange protocol, and digital signature algorithm. Compared to the ECDSA algorithm, the SM2 digital signature algorithm has higher security. The SM3 cryptographic hash algorithm is a hash algorithm that compresses messages of arbitrary length into a 256-bit digest using a one-way hash function, with a message block length of 512 bits. Its security is higher than the MD5 and SHA-1 algorithms. Furthermore, compared to the internationally used SHA-256 algorithm, the SM3 algorithm has a more complex structure and can more effectively resist differential analysis with strong collisions, linear analysis with weak collisions, and bit-tracking methods. Its security is relatively high, and its implementation efficiency is slightly higher than or equal to that of the SHA-256 algorithm. The SM4 block cipher is a symmetric encryption algorithm that uses a symmetric key to encrypt and decrypt messages. The SM4 algorithm consists of an encryption / decryption algorithm and a key expansion algorithm, both of which employ a 32-round nonlinear iterative structure. Compared to the Advanced Encryption Standard (AES), the SM4 algorithm can effectively resist various cryptanalysis methods such as differential attacks, linear attacks, and integral attacks, and has strong security redundancy. Summary of the Invention

[0005] The technical problem to be solved by this invention is to provide an encryption and decryption method based on domestically produced chips and domestically produced cryptographic algorithms in order to ensure the security of QR code original data transmission and scanning process.

[0006] The technical solution adopted by this invention to solve the above-mentioned technical problems is a secure QR code method based on domestically produced chips and national cryptographic algorithms, comprising the following steps:

[0007] 1) Registration steps: After the client completes registration and login on the key management sub-server through the designated platform APP, the key management sub-server assigns a unique identity ID to the client and records it on the key management sub-server.

[0008] 2) Encryption steps:

[0009] 2-1) The encryption server obtains the Uniform Resource Locator (URL) of the plaintext to be encrypted, generates the public and private key pair of the SM2 digital signature algorithm and the SM4 encryption key and distributes them to the key management sub-server, defines the elliptic curve and curve base points to be used by the ECDHE key negotiation algorithm, and saves them to the key management sub-server and the client.

[0010] 2-1) The server uses the SM3 hash algorithm to generate a digest of the plaintext URL, and uses the SM2 private key to encrypt the digest using the SM2 digital signature algorithm to generate a digital signature, ensuring the reliability of the data source and guaranteeing the non-repudiation and immutability of the data;

[0011] 2-2) The SM4 encryption algorithm is used to generate an SM4 round key using the SM4 encryption key, and then the plaintext URL is encrypted using the SM4 round key to generate the first ciphertext, thus ensuring the privacy of the data.

[0012] 2-3) After concatenating the first ciphertext with the digital signature to form valid data, the data is encoded, and then a CRC32 checksum is generated based on the encoded data to enable the data to detect and correct errors.

[0013] 2-4) Concatenate the valid data with the CRC32 checksum to form the data to be encoded, encode the data to be encoded into a QR code, generate a QR code, and publish it;

[0014] 3) Decryption steps:

[0015] 3-1) After the client scans and recognizes the QR code using the specified platform interface, the CRC32 checksum in the QR code is extracted for error detection. After the error is detected, the QR code is decoded to obtain and extract the first ciphertext and digital signature, and the client's ID and key negotiation request are sent to the key management sub-server.

[0016] 3-2) After receiving the client's ID and key negotiation request, the key management sub-server verifies the validity of the client's ID, generates a random number locally as the server's encrypted private key, and multiplies the server's encrypted private key by the elliptic curve basis point to obtain the server's encrypted public key; the client generates a random number locally as the client's encrypted private key, and multiplies the client's encrypted private key by the elliptic curve basis point to obtain the client's encrypted public key; the key management sub-server and the client exchange their encrypted public keys, and both parties calculate the multiplication of the other party's encrypted public key with their local encrypted private key, and use the data at the specified position in the multiplication result as the shared symmetric key;

[0017] 3-3) The key management sub-server concatenates the SM2 public key and the SM4 encryption key to generate the data to be encrypted; it uses the SM4 encryption algorithm to generate a negotiation round key using the shared symmetric key, and then uses the negotiation round key to encrypt the data to be encrypted to obtain the second ciphertext and transmit it to the client.

[0018] 3-3) After receiving the second ciphertext, the client uses the SM4 decryption algorithm to generate a negotiation round key using the shared symmetric key, and then uses the negotiation round key to decrypt the second ciphertext to obtain the SM2 public key and the SM4 encryption key;

[0019] 3-4) The client uses the SM4 encryption algorithm to generate an SM4 round key using the SM4 encryption key, and then uses the SM4 round key to decrypt the first ciphertext in the QR code to obtain the URL of the plaintext;

[0020] 3-5) The client uses the national cryptographic core to decrypt the SM2 signature verification algorithm to obtain the SM2 public key and verify the digital signature in the QR code. If the verification is successful, the data can be obtained using the URL.

[0021] Both the encryption and decryption steps described above are completed within the domestically produced chip.

[0022] Furthermore, domestically produced chips utilize national cryptographic cores for computational assistance when performing SM4 encryption / decryption algorithms and SM2 digital signature / verification algorithms. Using national cryptographic algorithms and cores for acceleration ensures security while also improving encryption / decryption efficiency.

[0023] QR code security technology based on domestically produced chips and national cryptographic algorithms refers to the use of domestically produced chips and national cryptographic algorithms to ensure the security of QR codes during generation, transmission, and parsing. National cryptographic algorithms are cryptographic algorithms independently developed by my country and have become one of the international standards. The application of national cryptographic algorithms can guarantee the confidentiality, integrity, and availability of information.

[0024] The beneficial effects of this invention are that by encrypting the data through the set encryption and signature algorithms, the generated QR code can only be scanned and decoded on a specific platform, preventing the data itself from being leaked or tampered with, improving the security of information transmission and the security of the QR code itself, and meeting the security requirements of QR code in terms of anti-tampering, anti-leakage, and anti-attack during transmission and scanning. Attached Figure Description

[0025] Figure 1 This is a data flow framework diagram of the encryption and decryption scheme of the present invention;

[0026] Figure 2 This is a flowchart of the SM4 encryption / decryption algorithm of the present invention;

[0027] Figure 3 This is a flowchart of the SM2 digital signature algorithm of the present invention;

[0028] Figure 4 This is a diagram of the QR code data structure of the present invention; Detailed Implementation Plan

[0029] The overall encryption / decryption scheme of this invention, including the data flow and processing framework, is as follows: Figure 1 As shown, the key encryption and decryption algorithms involved are listed below. Figure 2 and Figure 3 The original data structure in the QR code is as follows: Figure 4 As shown, the encryption server, three key management servers, and decryption client involved all contain domestically produced chips and Chinese cryptographic cores. The specific implementation steps of this invention are as follows:

[0030] Registration steps:

[0031] After a client completes registration and login on the key management sub-server through the designated platform APP, the key management sub-server assigns a unique identity ID to the client and records it on the key management sub-server.

[0032] Encryption steps:

[0033] All encryption and decryption algorithms in this invention use the national cryptographic core for computation and acceleration, improving encryption and decryption efficiency while ensuring security. The technical solution adopted is shown below, and the parameters involved in the solution are explained in Table 1:

[0034] Table 1. Description of Encryption / Decryption Scheme Parameters

[0035] symbol Symbol definition FK SM4 contains four 8-byte system parameters CK 32 fixed parameters of 8 bytes in SM4 MK SM4 encryption key <![CDATA[C p ]]> Ciphertext after SM4 encrypted URL <![CDATA[C p ’]]> Ciphertext after SM4 encryption key DMK SM4 key negotiated by DH rk SM4 round key Drk SM4 round key negotiated with DH SM4_Enc SM4 encryption algorithm SM4_Dec SM4 decryption algorithm sk SM2 signing private key pk SM2 Verification Public Key ABS Summary information generated by SM3 DSS Digital signatures generated by SM2 SM2_Sign SM2 signature algorithm SM2_Verify SM2 verification algorithm URL Transaction plaintext

[0036] Step 1: The encryption server obtains the plaintext data to be encrypted. The data to be encrypted is itself a URL address. A public-private key pair (pk, sk) for the SM2 digital signature algorithm is generated locally, with a length of 32 bytes. An SM4 encryption key MK = (MK0, MK1, MK2, MK3) ∈ (Z2) is randomly generated. 32 ) 4 MK is 16 bytes long; it defines the elliptic curve and its base point G required for the ECDHE key negotiation algorithm. The local encryption server stores sk locally and distributes pk and MK to three key management sub-servers. The client and the key management sub-server store the elliptic curve and its base point G defined by the encryption server.

[0037] Step 2: The encryption server processes the plaintext using the SM3 cryptographic hash algorithm and assists in the calculation using the national cryptographic core. First, the input data is divided into several groups of 512 bits each. If the last group is less than 512 bits, it is padded to 512 bits according to the rules. After multiple rounds of iterative compression, a digest value of 256 bits is output, generating a 32-byte digest information ABS.

[0038] Step 3: The encryption server signs the ABS using the SM2 elliptic curve digital signature algorithm and uses the national cryptographic core for assisted calculation. Using sk as the algorithm parameter, a series of calculations are performed on the ABS to finally generate a 64-byte digital signature DSS, i.e., SM2_Sign(ABS,sk)->DSS;

[0039] Step 4: The encryption server uses the SM4 encryption algorithm to encrypt the plaintext URL and uses the national cryptographic core for assisted computation. Based on the SM4 encryption key, a round key Gen_rk(MK,FK,CK)->rk is generated. The URL is then encrypted using rk, generating a 16-byte ciphertext C. p That is, SM4_Enc(URL,rk)->C p FK and CK are parameters in the SM4 algorithm.

[0040] Step 5: Place C p The +DSS characters are concatenated together to form valid data, and the data is processed using Base64 encoding rules to obtain a visible string;

[0041] Step 6: Calculate the 32-bit cyclic redundancy check code of the visible string using CRC32, which is 4 bytes in total;

[0042] Step 7: Calculate the length of the visible string and store it as a 2-byte segment. Concatenate the 2-byte segment, the 4-byte CRC32 checksum segment, and the visible string together to form the data to be encoded.

[0043] Step 8: Perform QR encoding on the data to be encoded to generate a QR code and publish it;

[0044] QR code recognition and decryption steps:

[0045] Step 1: The client uses the platform interface to scan and recognize the QR code;

[0046] Step 2: After the client scans the code, it obtains a 2-byte length segment + a 4-byte CRC32 checksum segment + a visible string, and extracts the 4-byte CRC32 checksum for error detection;

[0047] Step 3: The client extracts the visible string based on the length segment, decodes the visible string using Base64, and obtains the C string. p +DSS; The client sends its ID and key negotiation request to the key management sub-server;

[0048] Step 4: The key management sub-server and the client begin key negotiation. The client generates its own random number as the private key Rc, and multiplies it with the elliptic curve base point G to obtain the public key Qc = Rc × G; the server generates its own random number as the private key Rs, and multiplies it with the elliptic curve base point G to obtain the public key Qs = Rs × G.

[0049] Step 5: The client and server exchange their public keys Qc and Qs. The client calculates the point (x1, y1) = Rc × Qs, and the server calculates the point (x2, y2) = Rs × Qc. The coordinates x1 = x2 calculated by both parties are used as the shared symmetric key DMK.

[0050] Step Six: The key management sub-server concatenates pk and MK together to form 48 bytes of data to be encrypted. This data is then encrypted using the SM4 encryption algorithm, with the national cryptographic core used for auxiliary computation. First, a round key Gen_rk(DMK,FK,CK)->Drk is generated based on DMK. Then, Drk is used to encrypt the data to be encrypted, generating a 16-byte ciphertext C. p ',SM4_Enc(pk+MK,Drk)->C p ', then C p Transmitted to the client platform;

[0051] Step 7: Decrypt the ciphertext C received by the client from the server. p Afterwards, the national cryptographic core is used to assist in the calculation of the SM4 decryption algorithm. The algorithm uses DMK to generate the round key Gen_rk(DMK,FK,CK)->Drk, and reverses the round key Drk to generate Drk'. Drk' is then used to decrypt the received C. p Decryption is performed, i.e., SM4_Dec(C p',Drk')->pk+MK, get pk and MK;

[0052] Step 8: The client platform uses the SM4 decryption algorithm to decrypt the received ciphertext, with the assistance of the national cryptographic core. Based on the obtained MK, a round key Gen_rk(MK,FK,CK)->rk is generated, and this round key rk is reversed to generate rk'. rk' is then used to decrypt the C in the QR code. p Decryption is performed, SM4_Dec(C p ,rk')->URL, get the URL;

[0053] Step 9: The decryption client platform uses the national cryptographic core to assist in the calculation of the SM2 signature verification algorithm. It verifies the DSS in the QR code using pk as a parameter, i.e., SM2_Verify(pk,DSS). Once verification is successful, the data can be retrieved using the plaintext URL.

[0054] The above scheme uses SM4 symmetric encryption during the QR code generation and transmission process to ensure the security of privacy data and keys. The SM2 digital signature algorithm is used to sign the data information to ensure the immutability, security and integrity of the data.

[0055] This invention encrypts data using pre-defined encryption and digital signature algorithms, generating QR codes that can only be scanned and decoded on specific platforms. This ensures data privacy and tamper-proofness, and improves the security of information transmission and the security of the QR codes themselves.

[0056] The integrity of data during transmission is ensured by using a CRC32 checksum.

[0057] Using national cryptographic algorithms and core technologies for acceleration ensures security while also improving encryption and decryption efficiency.

Claims

1. A secure QR code method based on domestically produced chips and national cryptographic algorithms, characterized in that, Information verification and encryption / decryption both use the national cryptographic algorithm, including the following steps: 1) Registration steps: After the client completes registration and login on the key management sub-server through the designated platform APP, the key management sub-server assigns a unique identity ID to the client and records it on the key management sub-server. 2) Encryption steps: 2-1) The encryption server obtains the Uniform Resource Locator (URL) of the plaintext to be encrypted, generates the public and private key pair of the SM2 digital signature algorithm and the SM4 encryption key and distributes them to the key management sub-server, defines the elliptic curve and elliptic curve base points to be used by the ECDHE key negotiation algorithm, and saves them to the key management sub-server and the client. 2-1) The encryption server uses the SM3 hash algorithm to generate a digest of the plaintext URL, and uses the SM2 private key to encrypt the digest using the SM2 digital signature algorithm to generate a digital signature; 2-2) The encryption server uses the SM4 encryption algorithm to generate an SM4 round key using the SM4 encryption key, and then uses the SM4 round key to encrypt the plaintext URL to generate the first ciphertext; 2-3) The encryption server concatenates the first ciphertext with the digital signature to form valid data, encodes it, and then generates a CRC32 checksum based on the encoded data; 2-4) The encryption server concatenates the valid data with the CRC32 checksum to form the data to be encoded, performs two-dimensional encoding on the data to be encoded to generate a QR code, and publishes it; 3) Decryption steps: 3-1) After the client scans and recognizes the QR code using the specified platform interface, the CRC32 checksum in the QR code is extracted for error detection. After the error is detected, the QR code is decoded to obtain and extract the first ciphertext and digital signature, and the client's ID and key negotiation request are sent to the key management sub-server. 3-2) After receiving the ID and key negotiation request from the client, the key management sub-server verifies the validity of the client's ID. If the ID is valid, the key management sub-server and the client negotiate a shared symmetric key using the ECDHE key negotiation algorithm: The key management sub-server generates a random number locally as the server's private key and multiplies it by the elliptic curve basis point to obtain the server's public key; the client generates a random number locally as the client's private key and multiplies it by the elliptic curve basis point to obtain the client's public key; the key management sub-server and the client exchange their public keys, and both parties calculate the multiplication of the other party's public key with their local private key, using the data at a specified position in the multiplication result as the shared symmetric key; 3-3) The key management sub-server concatenates the SM2 public key and the SM4 encryption key to generate the data to be encrypted; it uses the SM4 encryption algorithm to generate a negotiation round key using the shared symmetric key, and then uses the negotiation round key to encrypt the data to be encrypted to obtain the second ciphertext and transmit it to the client. 3-3) After receiving the second ciphertext, the client uses the SM4 decryption algorithm to generate a negotiation round key using the shared symmetric key, and then uses the negotiation round key to decrypt the second ciphertext to obtain the SM2 public key and the SM4 encryption key; 3-4) The client uses the SM4 encryption algorithm to generate an SM4 round key using the SM4 encryption key, and then uses the SM4 round key to decrypt the first ciphertext to obtain the URL of the plaintext; 3-5) The client uses the national cryptographic core to decrypt the SM2 signature verification algorithm to obtain the SM2 public key and verify the digital signature. If the verification is successful, the data can be obtained using the URL. Both the encryption and decryption steps described above are completed within the domestically produced chip.

2. The method as described in claim 1, characterized in that, Domestically produced chips use the national cryptographic core for assistance in calculations when performing SM4 encryption or decryption algorithms and SM2 digital signature and verification algorithms.

3. The method as described in claim 1, characterized in that, In 3-2), the first half of the multiplication result is used as the shared symmetric key.

Citation Information

Patent Citations

  • Ticket checking system based on HMAC-SM3 message authentication code

    CN110738740A

  • Two-dimensional code generation method and device, computer equipment and storage medium

    CN116070665A