A digital certificate implementation method based on hardware-accelerated national encryption algorithm

Through hardware acceleration of national secret algorithms SM2, SM3, and SM4, the problem of low signature verification performance of digital certificates is solved, achieving performance and high security close to international standards, and supporting URIs extension fields to enhance certificate description capabilities.

CN115314213BActive Publication Date: 2024-10-15GCSOFT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210693027.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-17
Publication Date
2024-10-15
Estimated Expiration
2042-06-17

AI Technical Summary

Technical Problem

In the existing technology, digital certificates based on the national secret algorithm suite implemented in pure software have poor performance in signature verification scenarios and cannot be compared with international standard algorithms.

Method used

Adopt the national secret algorithms SM2, SM3, and SM4 that support hardware acceleration to improve computing efficiency through hardware acceleration, and apply it to the generation and verification process of digital certificates, combined with the X.509 standard protocol to ensure the security and operation of the certificate efficiency.

Benefits of technology

Significantly improves the signature verification performance of digital certificates, close to the performance of international standard algorithms, improves the security and security strength of certificates, and supports extended field URIs to enhance certificate description capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115314213B_ABST
    Figure CN115314213B_ABST
Patent Text Reader

Abstract

The present invention discloses a digital certificate implementation method based on a national secret algorithm supporting hardware acceleration, comprising the following steps: step 1, determining a certificate template; step 2, setting a national secret algorithm SM2 supporting hardware acceleration; step 3, obtaining a byte array of public key information of the certificate owner; step 4, obtaining a byte array of relevant information of the certificate owner; step 5, obtaining a byte array of relevant information of the certificate signer; step 6, combining the serial number of the certificate and each byte array to obtain a certificate body; step 7, adding extended information to the certificate body; step 8, using the national secret algorithm SM2 to hash the certificate body to obtain signature information, and signing the signature information; step 9, combining the national secret algorithm SM2, the certificate body, and the signature to obtain a complete certificate. The present invention can both ensure the security of the certificate and improve the operating efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of digital certificate implementation methods, and in particular to a digital certificate implementation method based on a national cryptographic algorithm that supports hardware acceleration. Background Art

[0002] The national cryptographic algorithm, i.e. the national commercial cryptographic algorithm, is a cryptographic algorithm standard and its application specifications recognized and announced by the National Cryptography Administration, including the SM series. A digital certificate is a file digitally signed by a CA that includes information about the owner of a public key and a public key. X.509 is a standard that defines the format of digital certificates and is applicable to network protocols such as TLS. Currently, the mainstream open source implementations of X.509 digital certificates that support the national cryptographic algorithm suite basically use the national cryptographic algorithm SM2 / SM3 implemented in pure software. Compared with the implementation of the international standard algorithm ECDSA / SHA256 with the same security level, its signature verification performance in a wide range of usage scenarios is much inferior. Summary of the invention

[0003] The purpose of the present invention is to provide a method for implementing a digital certificate based on a hardware-accelerated national cryptographic algorithm to solve the problem that the digital certificate implemented based on a pure software national cryptographic algorithm suite in the prior art has poor performance in signature verification scenarios.

[0004] In order to achieve the above object, the technical solution adopted by the present invention is:

[0005] A method for implementing a digital certificate based on a hardware-accelerated national encryption algorithm includes the following steps:

[0006] Step 1: Determine a certificate template, wherein the content of the certificate template includes the serial number of the certificate, relevant information and key information of the certificate owner, and relevant information and key information of the certificate signer;

[0007] Step 2: Set the signature algorithm of the certificate template to the national secret algorithm SM2 that supports hardware acceleration. The national secret algorithm SM2 includes a public key algorithm, a signature algorithm SM2-with-SM3, and a hash algorithm SM3;

[0008] Step 3: Obtain the public key information of the certificate owner from the certificate template, and serialize the public key information of the certificate owner into a byte array;

[0009] Step 4: Obtain the certificate owner's related information from the certificate template, and serialize the certificate owner's related information into a byte array;

[0010] Step 5: Get the certificate signer related information from the certificate template, and serialize the certificate signer related information into a byte array;

[0011] Step 6: Combine the serial number of the certificate in step 1, the byte array corresponding to the public key information of the certificate owner obtained in step 3, the byte array corresponding to the relevant information of the certificate owner obtained in step 4, and the byte array corresponding to the relevant information of the certificate signer obtained in step 5, so as to construct the certificate body;

[0012] Step 7: Add extended information to the certificate body;

[0013] Step 8: Use the hash algorithm SM3 in the national secret algorithm SM2 set in step 2 to hash the certificate body expanded in step 7 to obtain signature information, and use the signature algorithm SM2-with-SM3 in the national secret algorithm SM2 set in step 2 to sign the obtained signature information;

[0014] Step 9: Combine the national secret algorithm SM2 of step 2, the certificate body after expansion in step 7, and the signature obtained in step 8 to construct a complete certificate, and serialize the complete certificate to obtain a digital certificate.

[0015] Furthermore, the public key information of the certificate owner in step 3 includes the public key coordinates obtained from the certificate owner's secret key information in step 1 and the algorithm identification information obtained from the public key algorithm in step 2.

[0016] Furthermore, the certificate owner-related information in step 4 includes country, organization, unit department, common name, province, city, region and their corresponding identification information.

[0017] Furthermore, the certificate signer-related information in step 5 includes country, organization, unit department, common name, province, city, region and their corresponding identification information.

[0018] Furthermore, in step 7, the extended information added to the certificate body includes SAN information, the key ID of the certificate signer, the key ID of the certificate owner, and the purpose of the certificate.

[0019] Furthermore, the SAN information includes a URIs field.

[0020] The present invention provides a digital certificate implementation method based on the national secret algorithm that supports hardware acceleration, which greatly improves the signature verification performance and surpasses the performance of the international standard algorithm. The present invention implements the national secret algorithms SM2, SM3, and SM4 that support hardware acceleration to improve the computing efficiency; then the aforementioned national secret algorithms are applied to the implementation of the digital certificate standard protocol, which can not only ensure the security of the certificate, but also improve the operating efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 It is a flowchart of a method for generating an X.509 digital certificate according to an embodiment of the present invention.

[0022] Figure 2 It is a processing flow chart of signing using the national encryption algorithm SM2 that supports hardware acceleration in an embodiment of the present invention.

[0023] Figure 3 It is a processing flow chart of signature verification using the national encryption algorithm SM2 that supports hardware acceleration in an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0025] This embodiment is described by taking the generation of an X.509 digital certificate as an example. In order to compare the generation process of an X.509 digital certificate when using the national cryptographic algorithm SM2 that supports hardware acceleration and when not using the national cryptographic algorithm that supports hardware acceleration, this embodiment combines the two for description.

[0026] like Figure 1 As shown, this embodiment includes the following steps:

[0027] (1) Determine the certificate template and check whether the relevant attributes of the certificate template are set correctly.

[0028] The content of the certificate template includes the certificate serial number, relevant information and key information of the certificate owner, relevant information and key information of the certificate signer, maximum path MaxPathLen, etc. Necessary checks are performed on the input parameters to determine whether the signer's private key type is correct, whether the certificate template contains the serial number SerialNumber, and if it is a CA certificate template, it is also necessary to check whether the maximum path MaxPathLen is set correctly.

[0029] (2) If a national encryption algorithm that supports hardware acceleration is used, the signature algorithm used in this certificate template generation is set to the national encryption algorithm SM2 that supports hardware acceleration. The national encryption algorithm SM2 includes: public key algorithm: SM2, and its elliptic curve uses SM2-P-256; signature algorithm is SM2-with-SM3, and the signature algorithm identification code (OID) is 1.2.156.10197.1.501; hash algorithm SM3.

[0030] (3) If the national encryption algorithm that supports hardware acceleration is not used, the international standard signature algorithm used for this certificate generation is derived based on the signature algorithm configuration in the certificate template. A typical international standard algorithm configuration is as follows: the public key algorithm is ECDSA, and its elliptic curve uses elliptic.P256; the signature algorithm is ECDSAWithSHA256, and the signature algorithm OID is 1.2.840.10045.4.3.2; the hash algorithm is SHA256.

[0031] (4) Serialized certificate public key information.

[0032] Get the public key information of the certificate owner from the certificate template and serialize the public key information of the certificate owner into a byte array.

[0033] Specifically, obtain the public key from the key information of the certificate owner, obtain the public key algorithm elliptic curve OID from the public key algorithm, serialize the public key coordinates of the certificate owner into a byte array, and serialize the elliptic curve OID into a byte array, so as to obtain the byte array of the certificate owner's public key information.

[0034] (5) Generate relevant information about the certificate owner.

[0035] Get the certificate owner's related information from the certificate template and serialize it into a byte array. The certificate owner's related information includes country, organization, unit department, common name, province, city, region and their corresponding OIDs. Generally, the following fields are supported: C: country, OID: 2.5.4.6; O: organization, OID: 2.5.4.10; OU: unit department, OID: 2.5.4.11; CN: common name, OID: 2.5.4.3; ST: province, OID: 2.5.4.8; L: region, OID: 2.5.4.7.

[0036] (6) Generate certificate signer information

[0037] Get the certificate signer related information from the certificate template and serialize it into a byte array. The certificate signer related information includes country, organization, unit department, common name, province, city, region and their corresponding OIDs. Generally support the following fields: C: country, OID: 2.5.4.6; O: organization, OID: 2.5.4.10; OU: unit department, OID: 2.5.4.11; CN: common name, OID: 2.5.4.3; ST: province, OID: 2.5.4.8; L: region, OID: 2.5.4.7.

[0038] (7) Construct the certificate body content

[0039] The certificate body is constructed by combining the serial number SerialNumber obtained in the previous step, the byte array corresponding to the certificate public key information, the byte array corresponding to the certificate signer related information, and the byte array corresponding to the certificate owner related information.

[0040] (8) Add extended information to the certificate body.

[0041] The extended information includes: certificate signer key ID; certificate owner key ID; certificate (public key) purpose; SAN (Subject Alternate Name) information, which is used to replace the CN common name field of the certificate owner, thereby achieving a more flexible and secure description of the certificate owner.

[0042] The SAN fields supported by this embodiment include: DNSNames, EmailAddresses, IPAddresses, URIs. Currently, there is no X.509 implementation that supports both URIs and the national encryption algorithm with hardware acceleration function. This embodiment can achieve higher security strength by supporting both at the same time.

[0043] (9) If the national encryption algorithm SM2 that supports hardware acceleration is used, the hash algorithm SM3 is used to pre-hash the certificate body in order to obtain the signature information and reduce the length of the signature message. Compared with the international standard hash algorithm, the hash algorithm SM3 has higher security autonomy and roughly the same security strength and performance.

[0044] (10) If the national encryption algorithm that supports hardware acceleration is not used, the hash algorithm SHA256 in step (3) is used to pre-hash the certificate body in order to obtain the signature information and reduce the length of the signature message.

[0045] (11) If the national encryption algorithm SM2 that supports hardware acceleration is used, the signature algorithm SM2 therein is used to sign the signature message (the pre-hashed result of the entire certificate) obtained in step (9).

[0046] (12) If the national encryption algorithm that supports hardware acceleration is not used, the signature algorithm ECDSAWithSHA256 in step 3 is used to sign the signature message (the pre-hashed result of the entire certificate) obtained in step (10).

[0047] (13) The certificate body, signature algorithm and signature combination are packaged to obtain a complete certificate, and the complete certificate is serialized into a byte array to obtain an X.509 certificate.

[0048] like Figure 2 As shown, the signing process of step (11) of this embodiment is as follows:

[0049] 1. Use hash algorithm SM3 to perform ZA mixed hashing on the signed message

[0050] 2. Generate a random number k in the range [1, n-1], where n is the parameter of the elliptic curve SM2-P-256: subgroup order;

[0051] 3. Calculate P = k*G, that is, (x, y) = k*G, the x coordinate is assigned to r (part of the signature), G is the base point of the elliptic curve SM2-P-256; P is another point on the elliptic curve, calculated by G and k, and its coordinates are (x, y); 4. Calculate r = (e+P(x)) mod n, e is the large integer converted from the ZA mixed hash result; P(x) is the x coordinate value of the coordinate P calculated in step 3;

[0052] 5. If the platform is AMD64 or ARM64 architecture, use the CPU-related instruction set to implement a fast (1+d)^-1 reciprocal operation, where d is the signer's SM2 private key;

[0053] 6. If the platform is not AMD64 or ARM64 architecture, implement the (1+d)^-1 reciprocal operation through pure software programming, where d is the signer's SM2 private key;

[0054] 7. Calculate s = (((1+d)^-1)(k-rd)) mod n, where s is the other part of the signature;

[0055] 8. Serialize the signature result (r, s) into an asn1 format byte array.

[0056] like Figure 3 As shown, this embodiment also provides a signature verification process for the signature obtained in step (11), and the signature verification process is the reverse process of the signature process in step (11), which is as follows:

[0057] 1. Deserialize the asn1 format signature into a (r, s) signature;

[0058] 2. Use hash algorithm SM3 to perform ZA mixed hashing on the signature verification message; 3. Calculate t = (r + s) mod n;

[0059] 4. If the platform is AMD64 or ARM64 architecture, use the CPU-related instruction set to quickly calculate the new coordinates using s*G+t*pub, where G is the base point of the curve SM2-P-256 and pub is the signer's SM2 public key;

[0060] 5. If the platform is not AMD64 or ARM64 architecture, use pure software programming to implement s*G+t*pub to calculate the new coordinates, where G is the base point of the curve SM2-P-256 and pub is the signer's SM2 public key;

[0061] 6. Calculate R = (e + x') mod n, where x' is the x-axis value of the new coordinate and e is the large integer converted from the ZA mixed hash result;

[0062] 7. Compare the R value calculated in step 6 to see if it is equal to the r value of the signature.

[0063] It can be seen from the above embodiments that the present invention supports the hardware-accelerated national encryption algorithm. Compared with the X.509 certificate implementation of SM2 implemented by pure software, the present invention improves the signature verification performance of the X.509 certificate by two orders of magnitude, which is basically the same as the international standard X.509 signature verification performance;

[0064] The present invention supports the national encryption algorithm, so that the X.509 certificate has sufficient security autonomy and controllability, as well as higher security strength.

[0065] The present invention supports certificate extension field URIs, which is used to supplement the SAN field to replace the CommonName field of the certificate owner, thereby obtaining a more flexible certificate owner description capability and a higher security strength.

[0066] The embodiments described in the present invention are merely descriptions of the preferred implementation modes of the present invention, and are not intended to limit the concept and scope of the present invention. Without departing from the design concept of the present invention, various modifications and improvements made to the technical solutions of the present invention by engineers and technicians in this field should fall within the protection scope of the present invention. The technical contents for which protection is sought in the present invention have all been recorded in the claims.

Claims

1. A digital certificate implementation method based on hardware-accelerated national encryption algorithm, characterized in that: The following steps are involved: Step 1: Determine a certificate template, wherein the content of the certificate template includes the serial number of the certificate, relevant information and key information of the certificate owner, and relevant information and key information of the certificate signer; Step 2: Set the signature algorithm of the certificate template to the national secret algorithm SM2 that supports hardware acceleration. The national secret algorithm SM2 includes a public key algorithm, a signature algorithm SM2-with-SM3, and a hash algorithm SM3; Step 3: Obtain the public key information of the certificate owner from the certificate template, and serialize the public key information of the certificate owner into a byte array; Step 4: Obtain the certificate owner's related information from the certificate template, and serialize the certificate owner's related information into a byte array; Step 5: Get the certificate signer related information from the certificate template, and serialize the certificate signer related information into a byte array; Step 6: Combine the serial number of the certificate in step 1, the byte array corresponding to the public key information of the certificate owner obtained in step 3, the byte array corresponding to the relevant information of the certificate owner obtained in step 4, and the byte array corresponding to the relevant information of the certificate signer obtained in step 5, so as to construct the certificate body; Step 7: Add extended information to the certificate body; Step 8: Use the hash algorithm SM3 in the national secret algorithm SM2 set in step 2 to hash the certificate body expanded in step 7 to obtain signature information, and use the signature algorithm SM2-with-SM3 in the national secret algorithm SM2 set in step 2 to sign the obtained signature information; Step 9: Combine the national secret algorithm SM2 of step 2, the certificate body after expansion in step 7, and the signature obtained in step 8 to construct a complete certificate, and serialize the complete certificate to obtain a digital certificate.

2. According to claim 1, a method for implementing a digital certificate based on a hardware-accelerated national encryption algorithm is characterized in that: The public key information of the certificate owner in step 3 includes the public key coordinates obtained from the certificate owner's key information in step 1 and the algorithm identification information obtained from the public key algorithm in step 2.

3. According to claim 1, a method for implementing a digital certificate based on a hardware-accelerated national encryption algorithm is characterized in that: The certificate owner-related information in step 4 includes country, organization, unit department, common name, province, city, region and their corresponding identification information.

4. According to claim 1, a method for implementing a digital certificate based on a hardware-accelerated national encryption algorithm is characterized in that: The certificate signer-related information in step 5 includes country, organization, unit department, common name, province, city, region and their corresponding identification information.

5. According to claim 1, a method for implementing a digital certificate based on a hardware-accelerated national encryption algorithm is characterized in that: In step 7, the extended information added to the certificate body includes SAN information, the key ID of the certificate signer, the key ID of the certificate owner, and the purpose of the certificate.

6. A digital certificate implementation method based on supporting hardware accelerated national encryption algorithm according to claim 5, characterized in that: The SAN information includes a URIs field.