Code signature method and device, equipment and storage medium

Through the hybrid dual signature method, combining pre-quantum and post-quantum code signatures, the problems of insufficient security and poor compatibility of existing technologies under the threat of quantum computing are solved, and high security and smooth migration transition of the code are achieved.

CN118748593APending Publication Date: 2024-10-08CETC CYBERSPACE SECURITY TECH CO LTD
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202411118000.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-15
Publication Date
2024-10-08

AI Technical Summary

Technical Problem

Existing code signing methods have insufficient security in the face of quantum computing threats. Traditional public key cryptography algorithms are easily cracked. Emerging technologies require changes to the hardware architecture and have poor compatibility, making it difficult to migrate from pre-quantum to post-quantum cryptography.

Method used

Adopting a hybrid dual signature method, the code is signed and verified separately through pre-quantum and post-quantum code signing components, and a hybrid dual-signed post-code package is generated, utilizing pre-integrated code signing components and verification components, containing multiple sub-code signing components and certificates Authentication infrastructure that enables the combination of pre-quantum and post-quantum cryptography.

Benefits of technology

It improves the security of code under the threat of quantum computing, avoids major modifications to the existing equipment software and hardware architecture, achieves smooth migration from pre-quantum to post-quantum cryptography, enhances anti-quantum security and is compatible with the original code signing mechanism. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118748593A_ABST
    Figure CN118748593A_ABST
Patent Text Reader

Abstract

The invention discloses a code signature method and device, equipment and a storage medium, and relates to the technical field of information security, and the method comprises the steps: carrying out the pre-code signature of a to-be-signed code through a first sub-code signature component and a first signature certificate, and obtaining a first code signature value, packaging the to-be-signed code, the first code signature value and the first signature certificate to obtain a pre-quantum signature post-code packet; performing post-quantum code signature on the to-be-signed code through a second sub-code signature component in the code signature component by using a second signature certificate to obtain a second code signature value, and packaging the second code signature value and the second signature certificate into a pre-quantum signature post-code packet, and obtaining the code package after mixing the double signatures, and sending the code package to a verification component so as to verify the code to be signed. According to the method, the security of code starting, running and updating under the threat of quantum computing can be improved, high feasibility is achieved, and smooth transition from front quantum to back quantum migration is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information security technology, and in particular to a code signing method, device, equipment and storage medium. Background Art

[0002] Currently, in order to prevent forgery and tampering, codes (such as firmware, operating systems, mobile applications, and application container images) are usually required to be digitally signed before they are distributed and updated to ensure the integrity of the code. In addition, the code recipient can verify the signature to prove that the code has not been modified during transmission, and can also provide source authentication to identify who controls the code when it is signed.

[0003] Currently, traditional code signing methods include code signing schemes based on pre-quantum cryptographic signature algorithms, code signing schemes based on post-quantum public key algorithms based on emerging technologies such as lattices, and code signing schemes built using pure post-quantum signature algorithms. However, all three methods have disadvantages. Among them, although the code signing scheme built based on the pre-quantum cryptographic signature algorithm can be safely applied to traditional computer systems, it is difficult to resist quantum computing attacks. For example, quantum algorithms such as Shor can crack public key cryptographic algorithms based on large number factorization and discrete logarithm difficulty in a short period of time, thereby completely destroying existing public key cryptographic algorithms, such as RSA (an asymmetric encryption algorithm), ECC (Elliptic Curve Cryptography), SM2 (an elliptic curve public key cryptographic algorithm), etc., causing subversive damage to the security of traditional code signing and update mechanisms; and the code signing scheme based on the post-quantum public key algorithm of emerging technologies such as lattice requires the deployment of new basic cryptographic software and hardware components, thereby changing the software and hardware architecture of existing computers, so the feasibility of enhancing the anti-quantum security of existing devices and signature devices with more urgent needs is weak; in addition, although the code signing scheme constructed with a pure post-quantum signature algorithm can resist quantum attacks, it is not compatible enough, and it is difficult to achieve a smooth transition from pre-quantum to post-quantum cryptography. Summary of the invention

[0004] In view of this, the purpose of this application is to provide a code signing method, device, equipment and storage medium, which can improve the security of code startup, operation and update under the threat of quantum computing, and does not require major modifications to the software and hardware architecture of existing equipment, thereby improving feasibility and achieving a smooth transition from pre-quantum to post-quantum cryptography. The specific scheme is as follows:

[0005] In a first aspect, the present application discloses a code signing method applied to a code signing system, wherein the code signing system is pre-integrated with a code signing component and a verification component, wherein the code signing component includes a plurality of sub-code signing components, and each of the sub-code signing components includes a code signing module and a certificate authentication infrastructure, and the verification component includes a plurality of verification modules, including:

[0006] Get the code to be signed;

[0007] Performing a pre-quantum code signature on the code to be signed by using a first sub-code signature component in the code signature component and a first signature certificate to obtain a first code signature value, and packaging the code to be signed, the first code signature value and the first signature certificate to obtain a pre-quantum signature post-code package; the first signature certificate is a certificate generated by using the certificate authentication infrastructure in the first sub-code signature component;

[0008] The code to be signed is post-quantum code signed by the second sub-code signing component in the code signing component and using the second signing certificate to obtain a second code signature value, and the second code signature value and the second signing certificate are packaged into the pre-quantum signed post-code package to obtain a hybrid dual-signed post-code package; the second signing certificate is a certificate generated by using the certificate authentication infrastructure in the second sub-code signing component;

[0009] The hybrid dual-signed code package is sent to the verification component to verify the code to be signed based on the first signing certificate and / or the second signing certificate in the hybrid dual-signed code package.

[0010] Optionally, the certificate authentication infrastructure includes a certificate authentication system, a cryptographic device and a key management system;

[0011] Accordingly, before obtaining the code to be signed, the following steps are also included:

[0012] Generate a pre-quantum private key and a certificate request file using the certificate authentication system and the key management system located in the certificate authentication infrastructure of the first sub-code signing component;

[0013] Sending the certificate request file to a certificate issuing authority so that the certificate issuing authority confirms the certificate request file and issues the first signature certificate containing the pre-quantum private key after confirmation;

[0014] The certificate authentication system and the key management system located in the certificate authentication infrastructure of the second sub-code signing component are used to generate post-quantum public and private keys and the second signature certificate.

[0015] Optionally, the performing a pre-quantum code signing on the code to be signed by using a first sub-code signing component in the code signing component and a first signing certificate to obtain a first code signature value, and packaging the code to be signed, the first code signature value and the first signing certificate to obtain a pre-quantum signed code package, including:

[0016] By using the cryptographic device in the certificate authentication infrastructure of the first sub-code signing component and using a preset first message digest algorithm to perform digest calculation on the code to be signed, a first code digest value is obtained;

[0017] Performing a signature operation on the first code digest value by using a code signing module in a first sub-code signing component of the code signing component and a hash algorithm corresponding to the pre-quantum private key and the first signing certificate to obtain a first code signature value;

[0018] The signer information corresponding to the first sub-code signature component is obtained to obtain the first signer information, and the first signer information, the code to be signed, the first code signature value and the first signature certificate are packaged to obtain a pre-quantum signature post-code package; the first signer information includes an identifier of a hash algorithm corresponding to the first signature certificate, an identifier of the first message digest algorithm, an issuer identifier corresponding to the first signature certificate, and a certificate serial number.

[0019] Optionally, the post-quantum code signing of the code to be signed is performed by using a second sub-code signing component in the code signing component and a second signing certificate to obtain a second code signature value, and the second code signature value and the second signing certificate are packaged into the pre-quantum signed post-code package to obtain a hybrid dual-signed post-code package, including:

[0020] The code to be signed is digested by the cryptographic device in the certificate authentication infrastructure of the second sub-code signing component and a preset second message digest algorithm is used to obtain a second code digest value;

[0021] Performing a signature operation on the second code digest value by using a code signing module in a second sub-code signing component of the code signing component and a hash algorithm corresponding to the post-quantum public and private keys and the second signing certificate to obtain a second code signature value;

[0022] The signer information corresponding to the second sub-code signature component is obtained to obtain the second signer information, and the second signer information, the second code signature value and the second signature certificate are packaged into the pre-quantum signature post-code package to obtain a hybrid dual-signature post-code package; the second signer information includes an identifier of a hash algorithm corresponding to the second signature certificate, an identifier of the second message digest algorithm, an issuer identifier corresponding to the second signature certificate, and a certificate serial number.

[0023] Optionally, the verifying the code to be signed based on the first signing certificate and / or the second signing certificate in the hybrid dual-signed code package includes:

[0024] Parsing the hybrid dual-signed code package to obtain the first signer information and the second signer information;

[0025] Acquire the first signing certificate according to the issuer identifier and certificate serial number corresponding to the first signing certificate contained in the first signer information;

[0026] Verifying the first signature certificate, and if the verification passes, obtaining the issuer public key from the verification module, and signing the code to be signed using the issuer public key and a hash algorithm corresponding to the first signature certificate to obtain a third code signature value;

[0027] Determine whether the first code signature value is consistent with the third code signature value, and if they are consistent, obtain the second signature certificate according to the issuer identifier and certificate serial number corresponding to the second signature certificate contained in the second signer information;

[0028] Verifying the second signature certificate, and if the verification passes, signing the code to be signed using the issuer public key and a hash algorithm corresponding to the second signature certificate to obtain a fourth code signature value;

[0029] It is determined whether the second code signature value is consistent with the fourth code signature value, and if they are consistent, it is determined that the verification of the code to be signed is passed.

[0030] Optionally, the generating of the pre-quantum private key and the certificate request file by using the certificate authentication system and the key management system in the certificate authentication infrastructure of the first sub-code signing component includes:

[0031] The certificate authentication system and the key management system located in the certificate authentication infrastructure of the first sub-code signing component are used to generate a pre-quantum private key and a certificate request file in csr format.

[0032] Optionally, sending the certificate request file to a certificate issuing authority so that the certificate request file is confirmed by the certificate issuing authority, and issuing the first signature certificate containing the pre-quantum private key after confirmation, includes:

[0033] The certificate request file is sent to a certificate issuing authority so that the certificate request file is confirmed by the certificate issuing authority, and after confirmation, the first signature certificate containing the pre-quantum private key is issued in a .pfx file format.

[0034] In a second aspect, the present application discloses a code signing device applied to a code signing system, wherein the code signing system is pre-integrated with a code signing component and a verification component, wherein the code signing component includes a plurality of sub-code signing components, and each of the sub-code signing components includes a code signing module and a certificate authentication infrastructure, and the verification component includes a plurality of verification modules, including:

[0035] Code acquisition module, used to obtain the code to be signed;

[0036] A first code signing module, configured to perform a pre-quantum code signing on the code to be signed by using a first sub-code signing component in the code signing component and a first signing certificate to obtain a first code signature value; the first signing certificate is a certificate generated by using a certificate authentication infrastructure in the first sub-code signing component;

[0037] A first packaging module is used to package the code to be signed, the first code signature value and the first signature certificate to obtain a pre-quantum signature code package;

[0038] A second code signing module, configured to perform post-quantum code signing on the code to be signed by using a second sub-code signing component in the code signing component and a second signing certificate to obtain a second code signature value; the second signing certificate is a certificate generated by using a certificate authentication infrastructure in the second sub-code signing component;

[0039] A second packaging module is used to package the second code signature value and the second signature certificate into the pre-quantum signed code package to obtain a hybrid dual-signed code package;

[0040] A code package sending module is used to send the hybrid dual-signed code package to the verification component to verify the code to be signed based on the first signature certificate and / or the second signature certificate in the hybrid dual-signed code package.

[0041] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein the processor implements the aforementioned code signing method when executing a computer program stored in the memory.

[0042] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned code signing method is implemented.

[0043] It can be seen that the present application is applied to a code signing system, wherein the code signing system is pre-integrated with a code signing component and a verification component, wherein the code signing component includes a plurality of sub-code signing components, and each of the sub-code signing components includes a code signing module and a certificate authentication infrastructure, and the verification component includes a plurality of verification modules, firstly obtaining the code to be signed, and then using the first sub-code signing component in the code signing component and the first signing certificate to perform a pre-quantum code signing on the code to be signed to obtain a first code signature value, and then packaging the code to be signed, the first code signature value, and the first signing certificate to obtain a pre-quantum signature post-code package; the first signing certificate is a certificate for obtaining a pre-quantum signature post-code package using the first sub-code signing component. The certificate is generated by the certificate authentication infrastructure in the signature component; then, the code to be signed is post-quantum code signed by the second sub-code signature component in the code signature component and using the second signature certificate to obtain a second code signature value, and the second code signature value and the second signature certificate are packaged into the pre-quantum signed post-code package to obtain a hybrid dual-signed post-code package; the second signature certificate is a certificate generated by the certificate authentication infrastructure in the second sub-code signature component; finally, the hybrid dual-signed post-code package is sent to the verification component to verify the code to be signed based on the first signature certificate and / or the second signature certificate in the hybrid dual-signed post-code package. This application uses a code signing system that pre-integrates a code signing component and a verification component to perform pre-quantum code signing and post-quantum code signing on the code to be signed. Compared with the existing code signing scheme, this application introduces post-quantum cryptographic code signing and implements hybrid dual signatures, thereby improving the security of code startup, operation and update under the threat of quantum computing. This application does not require major modifications to the software and hardware architecture of existing devices, so it is highly feasible. In addition, by adopting a hybrid mechanism of pre-quantum and post-quantum, while providing anti-quantum security, it can also be effectively compatible with the original code signing mechanism, thereby achieving a smooth transition from pre-quantum to post-quantum cryptographic migration. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0045] Figure 1 A flow chart of a code signing method disclosed in this application;

[0046] Figure 2 A specific code signing system structure diagram disclosed in this application;

[0047] Figure 3 A schematic diagram of a specific code package structure disclosed in this application;

[0048] Figure 4 A schematic diagram of a specific signature data structure disclosed in this application;

[0049] Figure 5 This is a schematic diagram of the structure of a code signing device disclosed in this application;

[0050] Figure 6 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0051] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0052] The embodiment of the present application discloses a code signing method, which is applied to a code signing system. The code signing system is pre-integrated with a code signing component and a verification component. The code signing component includes multiple sub-code signing components, and each of the sub-code signing components includes a code signing module and a certificate authentication infrastructure. The verification component includes multiple verification modules, see Figure 1 As shown, the method includes:

[0053] Step S11: Obtain the code to be signed.

[0054] It should be noted that the code signing scheme proposed in this application is applied to a pre-created code signing system, in which two components are pre-integrated, namely, a code signing component and a verification component, wherein the code signing component contains multiple independent sub-code signing components, and each sub-code signing component contains two parts: a code signing module and a certificate authentication infrastructure. For details, see Figure 2 As shown, a sub-code signing component 1 and a sub-code signing component 2 are created in the code signing component, and each sub-code signing component includes two parts: a code signing module and a certificate authentication infrastructure, and three verification modules are created in the verification component, namely, verification module 1, verification module 2 and verification module 3. Among them, the code signing module is used to receive the code to be signed submitted by the user, and to verify and authorize the identity of the user, and to generate a digital signature after the verification and authorization are passed; the certificate authentication infrastructure is used to provide the code signing module with a signer identity authentication service, and the signer can specifically be a code developer. In addition, each sub-code signing component can be deployed on different computer devices respectively, so as to implement the code signing operation proposed in this application. Each verification module can provide verification services for different verifiers respectively. For example, verification module 1 is used to perform a single signature verification on sub-code signing component 1, verification module 2 is used to perform a single signature verification on sub-code signing component 2, and verification module 3 is used to perform mixed dual signature verification on sub-code signing component 1 and sub-code signing component 2.

[0055] In this embodiment, when the code needs to be signed, the code to be signed in the code package, such as firmware, operating system, mobile application, and application container image code, can be read according to a preset reading method. The preset reading method can be pre-set by a third-party manufacturer.

[0056] Step S12: Perform a pre-quantum code signature on the code to be signed by using the first sub-code signature component in the code signature component and the first signature certificate to obtain a first code signature value, and package the code to be signed, the first code signature value and the first signature certificate to obtain a pre-quantum signature code package; the first signature certificate is a certificate generated by using the certificate authentication infrastructure in the first sub-code signature component.

[0057] In this embodiment, after the code to be signed is obtained, the code to be signed is further pre-quantum code signed by the first sub-code signing component (such as sub-code signing component 1) contained in the code signing component and the first signing certificate (such as signing certificate 1) generated by the certificate authentication infrastructure in the sub-code signing component 1 to obtain a first code signature value (such as code signature value 1), and then the code to be signed, the code signature value 1 and the first signing certificate are packaged to obtain a pre-quantum signed code package; the first sub-code signing component is a component capable of pre-quantum cryptographic signature, and the pre-quantum signature algorithm used includes but is not limited to RSA, ECC, SM2 and other algorithms.

[0058] In a specific implementation, the certificate authentication infrastructure specifically includes a certificate authentication system (i.e., Certificate Authority), a cryptographic device, and a key management system; accordingly, before obtaining the code to be signed, it specifically includes: using the certificate authentication system and the key management system in the certificate authentication infrastructure of the first sub-code signing component to generate a pre-quantum private key and a certificate request file; sending the certificate request file to the certificate issuing authority to confirm the certificate request file through the certificate issuing authority, and issuing the first signature certificate containing the pre-quantum private key after confirmation; using the certificate authentication system and the key management system in the certificate authentication infrastructure of the second sub-code signing component to generate a post-quantum public and private key and the second signature certificate. In this embodiment, the certificate authentication infrastructure specifically includes three parts: a certificate authentication system, a cryptographic device, and a key management system, which are used to provide signer identity authentication services for the code signing module. Specifically, before code signing, a pre-quantum private key and certificate request file can be generated by the certificate authentication system (i.e., CA system) and key management system in the certificate authentication infrastructure of the first sub-code signing component located on the signer (such as the code developer) side, and then the certificate request file is sent to a certificate issuing authority recognized by a third-party manufacturer, so that the certificate issuing authority can confirm the certificate request file and issue a signature certificate 1 containing the pre-quantum private key in the form of a file after confirmation; similarly, the certificate authentication system (i.e., CA system) and key management system in the certificate authentication infrastructure of the second sub-code signing component (such as the sub-code signing component 2) can be used to generate post-quantum public and private keys and a second signature certificate (such as signature certificate 2), wherein the sub-code signing component 2 is a component capable of post-quantum cryptographic signing, and the post-quantum signature algorithm used includes but is not limited to LMS (Least Mean Squares), HSS (a hash algorithm) and other algorithms.It should be pointed out that the generation of post-quantum public and private keys is related to the post-quantum signature algorithm corresponding to the signature certificate 2, and the selection of the post-quantum signature algorithm can be selected according to factors such as security strength requirements, business quantity, resource allocation, etc. For example, when the post-quantum signature algorithm corresponding to the signature certificate 2 is LMS, considering that the key parameters of the LMS algorithm include the hash algorithm H used, the length of each node value of the LMS number in bytes n, the tree height h, and the type identification value of the LMS algorithm lmstype, when generating the post-quantum public and private keys and the signature certificate 2, the application command for generating the initial public and private keys can be sent to the cryptographic device in the sub-code signature component 2, and the above-mentioned key parameter information can be sent; then, when the cryptographic device After receiving the above application command and key parameter information, the device uses a random number generator to randomly generate a 16-byte string I and an n-byte secret seed SEED, and sets the private key counter q=0. The LMS algorithm is used to calculate the root node T[1]. Then, based on the above information, a cryptographic device key index number index and a key pair are generated, which are the public key value (lmstype, type, I, T[1]) and the private key value (lmstype, type, I, q, SEED). Finally, a signature certificate 2 can be issued through the certificate authentication infrastructure based on the public key value and other information, and a corresponding relationship between the issuer and the cryptographic device key index number index is established.

[0059] Specifically, the use of the certificate authentication system and the key management system in the certificate authentication infrastructure of the first sub-code signing component to generate the pre-quantum private key and the certificate request file may include: using the certificate authentication system and the key management system in the certificate authentication infrastructure of the first sub-code signing component to generate the pre-quantum private key and the certificate request file in csr format. In this embodiment, when the CA system and the key management system in the certificate authentication infrastructure of the sub-code signing component 1 are used to generate the pre-quantum private key and the certificate request file, the file format of the certificate request file is csr (Certificate Signing Request).

[0060] Specifically, the sending of the certificate request file to the certificate issuing authority so that the certificate request file is confirmed by the certificate issuing authority, and the issuing of the first signature certificate containing the pre-quantum private key after confirmation may include: sending the certificate request file to the certificate issuing authority so that the certificate request file is confirmed by the certificate issuing authority, and the issuing of the first signature certificate containing the pre-quantum private key in the .pfx (a binary format file) file format after confirmation. That is, after confirmation by the certificate issuing authority approved by the third-party manufacturer, the signature certificate 1 is issued in the .pfx file format, and the signature certificate 1 contains the pre-quantum private key.

[0061] In a specific implementation manner, the method of performing a pre-quantum code signing on the code to be signed by using the first sub-code signing component in the code signing component and the first signing certificate to obtain a first code signature value, and packaging the code to be signed, the first code signature value and the first signing certificate to obtain a pre-quantum signature code package may specifically include: performing a digest calculation on the code to be signed by using the cryptographic device in the certificate authentication infrastructure of the first sub-code signing component and a preset first message digest algorithm to obtain a first code digest value; performing a signature operation on the first code digest value by using the pre-quantum private key and the hash algorithm corresponding to the first signing certificate through the code signing module in the first sub-code signing component of the code signing component to obtain the first code signature value; obtaining the signer information corresponding to the first sub-code signing component to obtain the first signer information, and packaging the first signer information, the code to be signed, the first code signature value and the first signing certificate to obtain a pre-quantum signature code package; the first signer information includes an identifier of the hash algorithm corresponding to the first signing certificate, an identifier of the first message digest algorithm, an issuer identifier corresponding to the first signing certificate and a certificate serial number. For example, the code to be signed is first calculated by using the cryptographic device in the certificate authentication infrastructure of the sub-code signing component 1 and the sha256 algorithm (a cryptographic hash function) to obtain the first code digest value (hash_data1). Then, a signer information signer_info1 related to the pre-quantum cryptography can be obtained, and the signer information signer_info1 and hash_data1 are stored together in the pre-created file to be signed (content_data1). Then, the pre-quantum private key and the hash algorithm corresponding to the first signature certificate (such as ECC, Elliptic CurvesCryptography, elliptic curve encryption) performs a signature operation on the file to be signed (content_data) to obtain the first code signature value sign_data1; further, obtain the digest algorithm identifier (id-sha256), the signature algorithm identifier (id-ecc) and the code signature value sign_data1, the issuer identifier and certificate serial number corresponding to the signature certificate 1 and save them to the signer information signer_info1, and finally save the signer information signer_info1, signature certificate 1, the code to be signed, the code signature value sign_data1 and other information to the pre-created signature data file, and package the signature data file to obtain the pre-quantum signature post-code package, wherein the format of the data file can adopt the PKCS#7 (syntax standard for encrypted messages) format.

[0062] Step S13: Perform post-quantum code signing on the code to be signed by using the second sub-code signing component in the code signing component and the second signing certificate to obtain a second code signature value, and package the second code signature value and the second signing certificate into the pre-quantum signed post-code package to obtain a hybrid dual-signed post-code package; the second signing certificate is a certificate generated by using the certificate authentication infrastructure in the second sub-code signing component.

[0063] In this embodiment, after the code to be signed, the first code signature value and the first signature certificate are packaged to obtain a pre-quantum signed code package, the code to be signed can be further post-quantum code signed by the second sub-code signature component (such as sub-code signature component 2) in the code signature component and the second signature (such as signature certificate 2) certificate to obtain the second code signature value (sign_data2), and the sign_data2 and signature certificate 2 are packaged together into the pre-quantum signed code package, thereby obtaining a hybrid dual-signed code package containing pre-quantum signature information and post-quantum signature information; wherein sign_data2 is a certificate generated by the certificate authentication infrastructure in the second sub-code signature component.

[0064] Specifically, the method of performing post-quantum code signing on the code to be signed by using the second sub-code signing component in the code signing component and the second signing certificate to obtain a second code signature value, and packaging the second code signature value and the second signing certificate into the pre-quantum signed post-code package to obtain a hybrid dual-signed post-code package may include: performing digest calculation on the code to be signed by using the cryptographic device in the certificate authentication infrastructure of the second sub-code signing component and a preset second message digest algorithm to obtain a second code digest value; performing a signature operation on the second code digest value by using the post-quantum public and private keys and the hash algorithm corresponding to the second signing certificate through the code signing module in the second sub-code signing component of the code signing component to obtain the second code signature value; obtaining the signer information corresponding to the second sub-code signing component to obtain the second signer information, and packaging the second signer information, the second code signature value and the second signing certificate into the pre-quantum signed post-code package to obtain a hybrid dual-signed post-code package; the second signer information includes an identifier of the hash algorithm corresponding to the second signing certificate, an identifier of the second message digest algorithm, an issuer identifier corresponding to the second signing certificate and a certificate serial number. For example, the code signing module in the sub-code signing component 2 is used to calculate the digest of the code to be signed in the original code package or the code package after the pre-quantum signature by using the message digest algorithm SM3 (a cryptographic hash function standard), and the second code digest value hash_data2 is obtained; then, a signer information signer_info2 related to the post-quantum cryptography is obtained, and the second code digest value hash_data2 and the signer information signer_info2 are saved together in a pre-created file to be signed (content_data); then, the cryptographic device in the sub-code signing component 2 is used, and the private key value (lmstype, type, I, q, SEED) securely stored inside the cryptographic device is used. ) performs a post-quantum signature operation on the code to be signed, obtains a second code signature value sign_data2, and returns the signature value sign_data2 to the code signing module; finally, the code signing module obtains the signer information corresponding to the sub-code signature component 2, obtains the second signer information signer_info2, and packages the second signer information signer_info2, the second code signature value sign_data2 and the signature certificate 2 into the above-mentioned pre-quantum signature post-code package, thereby obtaining a hybrid dual-signature post-code package; specifically, as shown in 3, the structure of the hybrid dual-signature post-code package can specifically be composed of a system header, a file header, bytes, section data and signature data, wherein the content of the signature data can be referred to Figure 4As shown, it may specifically include information such as version number, signature certificate set (including signature certificate 1 and signature certificate 2), signer information (including signer information 1 and signer information 2), message digest algorithm identifier set, and original content of the signature (i.e., content_data), and the information in signature certificate 1, signature certificate 2, signer information 1, and signer information 2 may be collected and stored according to actual application requirements. By adopting the traditional hash algorithm, the software and hardware architecture of the existing device does not need to be significantly modified, so this solution is feasible.

[0065] In a specific embodiment, taking the LMS algorithm as an example, the cryptographic device can first obtain the corresponding public-private key pair in the internal storage according to the key index number index, specifically including the public key value (lmstype, type, I, T[1]) and the private key value (lmstype, type, I, q, SEED), and then obtain the hash algorithm type as SM3 according to lmstype, and then calculate the secret original image array x_q=(x_q[0], ..., x_q[p-1]) of the private key according to the I, q, and SEED values; wherein, x_q[i] = SM3(I|| u32str(q) || u16str(i) || u8str(0xFF) || SEED), and uNstr(q) represents the N bits of the integer q. Next, a random number generator is used to generate an n-byte string C. According to the type and x_q values, the LM-OTS algorithm is used to calculate the lmots_sig and LM-OTS public key (type, I, q, K_q) corresponding to the qth node. Further, according to the leaf node q, the public key values ​​of each node in the authentication path are calculated from bottom to top (path[0], ..., path[h-1]), and a signature value lms_sig=(u32str(q), lmots_sig, lms_type, (path[0], path[1], ..., path[h-1])) is generated. The signature value lms_sig is then returned to the code signing module. At the same time, the leaf node counter q is set to q+1, and it is determined whether q exceeds the usage range 2^h. If not, the private key value corresponding to the current key index value index is updated synchronously. The value of h is obtained based on the corresponding relationship with the lmstype value. Furthermore, the issuer ID and certificate serial number corresponding to the signature certificate 2, the message digest algorithm ID (id-sm3), the signature algorithm ID (id-alg-hss-lms-sm3-hashsig), and the code signature value lms_sig information can be saved to the signer information signer_info2, and the signer information signer_info2, signature certificate 2 and other information can be saved to Figure 4 The signature data in .

[0066] Step S14: Send the hybrid dual-signed code package to the verification component to verify the code to be signed based on the first signing certificate and / or the second signing certificate in the hybrid dual-signed code package.

[0067] In this embodiment, after the second code signature value and the second signature certificate are packaged into the pre-quantum signed code package to obtain a hybrid dual-signed code package, the hybrid dual-signed code package can be sent to a corresponding verification module (such as Figure 2 The verification module 1, verification module 2 or verification module 3 in the hybrid dual-signed code package is used to verify the code to be signed based on the first signature certificate and / or the second signature certificate in the hybrid dual-signed code package. It should be pointed out that different verification modules can verify a single sub-code signature component or multiple sub-code signature components. For example, the verification module 1 parses the information corresponding to the sub-code signature component 1 from the hybrid dual-signed code package, such as the signer information 1, the signature value 1, the code to be signed, etc., and then obtains the signature certificate 1 according to the signer information 1, and uses the signature certificate 1 to verify the code to be signed, wherein the sub-code signature component 1 can be located on the third-party manufacturer side. Similarly, the code verification can be performed on a single sub-code signature component 2 through the verification module 2. The specific verification process is the same as above, and the sub-code signature component 2 can be specifically located on the code developer side. In another specific implementation, the sub-code signature component 1 and the sub-code signature component 2 can also be verified simultaneously through the verification module 3.

[0068] Specifically, the verifying the code to be signed based on the first signature certificate and / or the second signature certificate in the hybrid dual-signed code package may include: parsing the hybrid dual-signed code package to obtain the first signer information and the second signer information; obtaining the first signature certificate according to the issuer identifier and certificate serial number corresponding to the first signature certificate contained in the first signer information; verifying the first signature certificate, if the verification is successful, obtaining the issuer public key from the verification module, and signing the code to be signed by using the issuer public key and the hash algorithm corresponding to the first signature certificate to obtain a third code signature value; judging whether the first code signature value is consistent with the third code signature value, if they are consistent, obtaining the second signature certificate according to the issuer identifier and certificate serial number corresponding to the second signature certificate contained in the second signer information; verifying the second signature certificate, if the verification is successful, signing the code to be signed by using the issuer public key and the hash algorithm corresponding to the second signature certificate to obtain a fourth code signature value; judging whether the second code signature value is consistent with the fourth code signature value, if they are consistent, determining that the verification of the code to be signed is successful. In this embodiment, verification module 3 is used as an example to perform code verification on sub-code signature component 1 and sub-code signature component 2 at the same time. Specifically, verification module 3 can first Figure 4 Extract the signer information signer_info1 and signer information signer_info2 in the signer information set from the signature data of the hybrid double-signed code package, and obtain the corresponding signature certificates, i.e., signature certificate 1 and signature certificate 2, through the issuer identifier and certificate serial number in the signer information. Then obtain the signature algorithm identifier, certificate signature value, certificate data to be signed and other information according to the signature certificate, so as to verify the certificate signature value, validity period and issuer information, i.e., verify the signature certificate. If the signature certificate verification is successful, further verify the code to be signed. First, extract the signature algorithm identifier and public key in the code to be signed, the signature algorithm identifier and the signer information signer_info1, and then sign the code to be signed according to the hash algorithm and public key corresponding to the signature algorithm identifier to obtain the code signature value 3, and compare it with the code signature value 1. If they are consistent, it indicates that the sub-code signature component 1 has passed the verification.

[0069] Similarly, the sub-code signature component 2 can be further verified by the verification module 3. For example, after the signature certificate is verified, the public key value (lmstype, type, I, T[1]) of the code signature is extracted from the signature certificate 2, and the hash algorithm identifier corresponding to the signature certificate 2 is obtained from the signer information signer_info2, and then the algorithm key parameters of the corresponding hash algorithm are obtained according to the identifier, such as the hash algorithm H used, the length of each node value of the LMS number in bytes n, the tree height h, and the LMS algorithm type identifier value lmstype. Then, the code signature value lms_sig, lmots_sig, the leaf node value q of the signature, the LMS algorithm type lms_type, the authentication path (path[0], path[1], ..., path[h-1]) and other parameter information are obtained from signer_info2. Finally, the root node T'[1] is calculated according to the LMS algorithm, the LM-OTS verification algorithm and the above parameter information, and it is determined whether T' is equal to T. If they are the same, it indicates that the sub-code signature component 2 has been verified, that is, the signature code has been double-verified. From the above, it can be seen that the present application adopts a framework that separates pre-quantum code signatures from post-quantum code signatures, which may specifically include multiple sub-code signature components and verification modules. Therefore, while keeping the original system components unchanged, that is, on the basis of the traditional code signature mechanism, an independent post-quantum code signature component can be smoothly added. Therefore, it can be compatible with traditional code signature schemes in terms of cryptographic system, code signature mechanism and data format; and, the post-quantum code signature component is introduced, so it can resist quantum computing threats and improve system security; in addition, due to the use of a hybrid dual code signature method, including a signature code package structure, a code signing method, and a code signing verification method based on a hybrid dual code signing mechanism, and by embedding multiple signer information in a single signature data of the code signature package, the post-quantum code signature information can be smoothly added. Therefore, while increasing security, it can be compatible with the original code signing mechanism, and does not require major modifications to the software and hardware architecture of existing devices, so it is more feasible.

[0070] It can be seen that the embodiment of the present application is applied to a code signing system, and the code signing system is pre-integrated with a code signing component and a verification component, the code signing component includes multiple sub-code signing components, and each of the sub-code signing components includes a code signing module and a certificate authentication infrastructure, the verification component includes multiple verification modules, firstly obtains the code to be signed, and then uses the first sub-code signing component in the code signing component and the first signing certificate to perform a pre-quantum code signing on the code to be signed to obtain a first code signature value, and packages the code to be signed, the first code signature value and the first signing certificate to obtain a pre-quantum signature post-code package; the first signing certificate is a certificate that is signed using the first sub-code signing component. Then, the code to be signed is post-quantum code signed by a second sub-code signing component in the code signing component and using a second signature certificate to obtain a second code signature value, and the second code signature value and the second signature certificate are packaged into the pre-quantum signed post-code package to obtain a hybrid dual-signed post-code package; the second signature certificate is a certificate generated by using the certificate authentication infrastructure in the second sub-code signing component; finally, the hybrid dual-signed post-code package is sent to the verification component to verify the code to be signed based on the first signature certificate and / or the second signature certificate in the hybrid dual-signed post-code package. The embodiment of the present application performs pre-quantum code signing and post-quantum code signing on the code to be signed respectively through a code signing system that pre-integrates a code signing component and a verification component. Compared with the existing code signing scheme, a post-quantum cryptographic code signature is introduced, and a hybrid double signature is implemented, thereby improving the security of code startup, operation and update under the threat of quantum computing. In addition, the present application does not require major modifications to the software and hardware architecture of existing devices, so it is highly feasible. In addition, by adopting a hybrid mechanism of pre-quantum and post-quantum, while providing anti-quantum security, it can also be effectively compatible with the original code signing mechanism, thereby achieving a smooth transition from pre-quantum to post-quantum cryptographic migration.

[0071] Correspondingly, the embodiment of the present application also discloses a code signing device, which is applied to a code signing system. The code signing system is pre-integrated with a code signing component and a verification component. The code signing component includes multiple sub-code signing components, and each of the sub-code signing components includes a code signing module and a certificate authentication infrastructure. The verification component includes multiple verification modules, see Figure 5 As shown, the device comprises:

[0072] The code acquisition module 11 is used to acquire the code to be signed;

[0073] A first code signing module 12 is used to perform a pre-quantum code signing on the code to be signed by using a first sub-code signing component in the code signing component and a first signing certificate to obtain a first code signature value; the first signing certificate is a certificate generated by using a certificate authentication infrastructure in the first sub-code signing component;

[0074] A first packaging module 13 is used to package the code to be signed, the first code signature value and the first signature certificate to obtain a pre-quantum signature code package;

[0075] A second code signing module 14 is used to perform post-quantum code signing on the code to be signed by using a second sub-code signing component in the code signing component and a second signing certificate to obtain a second code signature value; the second signing certificate is a certificate generated by using the certificate authentication infrastructure in the second sub-code signing component;

[0076] A second packaging module 15 is used to package the second code signature value and the second signature certificate into the pre-quantum signed code package to obtain a hybrid dual-signed code package;

[0077] The code package sending module 16 is used to send the hybrid dual-signed code package to the verification component to verify the code to be signed based on the first signature certificate and / or the second signature certificate in the hybrid dual-signed code package.

[0078] Among them, the specific working processes of the above-mentioned modules can refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0079] It can be seen that the embodiment of the present application is applied to a code signing system, and the code signing system is pre-integrated with a code signing component and a verification component, the code signing component includes multiple sub-code signing components, and each of the sub-code signing components includes a code signing module and a certificate authentication infrastructure, the verification component includes multiple verification modules, firstly obtains the code to be signed, and then uses the first sub-code signing component in the code signing component and the first signing certificate to perform a pre-quantum code signing on the code to be signed to obtain a first code signature value, and packages the code to be signed, the first code signature value and the first signing certificate to obtain a pre-quantum signature post-code package; the first signing certificate is a certificate that is signed using the first sub-code signing component. Then, the code to be signed is post-quantum code signed by a second sub-code signing component in the code signing component and using a second signature certificate to obtain a second code signature value, and the second code signature value and the second signature certificate are packaged into the pre-quantum signed post-code package to obtain a hybrid dual-signed post-code package; the second signature certificate is a certificate generated by using the certificate authentication infrastructure in the second sub-code signing component; finally, the hybrid dual-signed post-code package is sent to the verification component to verify the code to be signed based on the first signature certificate and / or the second signature certificate in the hybrid dual-signed post-code package. This application implements pre-quantum code signing and post-quantum code signing for signed codes respectively through a code signing system that pre-integrates a code signing component and a verification component. Compared with the existing code signing scheme, this application introduces post-quantum cryptographic code signing and implements hybrid dual signature, thereby improving the security of code startup, operation and update under the threat of quantum computing. This application does not require major modifications to the software and hardware architecture of existing devices, so it is highly feasible. In addition, by adopting a hybrid mechanism of pre-quantum and post-quantum, while providing anti-quantum security, it can also be effectively compatible with the original code signing mechanism, thereby achieving a smooth transition from pre-quantum to post-quantum cryptographic migration.

[0080] In some specific embodiments, the certificate authentication infrastructure includes a certificate authentication system, a cryptographic device, and a key management system;

[0081] Correspondingly, before the code acquisition module 11, the following may also be included:

[0082] A first information generation unit is used to generate a pre-quantum private key and a certificate request file using the certificate authentication system and the key management system located in the certificate authentication infrastructure of the first sub-code signing component;

[0083] A first request file sending unit, configured to send the certificate request file to a certificate issuing authority, so that the certificate issuing authority confirms the certificate request file and issues the first signature certificate containing the pre-quantum private key after confirmation;

[0084] The second information generation unit is used to generate post-quantum public and private keys and the second signature certificate by using the certificate authentication system and the key management system located in the certificate authentication infrastructure of the second sub-code signing component.

[0085] In some specific embodiments, the first code signing module 12 may specifically include:

[0086] A first digest calculation unit is used to perform digest calculation on the code to be signed by using the cryptographic device located in the certificate authentication infrastructure of the first sub-code signing component and a preset first message digest algorithm to obtain a first code digest value;

[0087] A first signature operation unit is configured to perform a signature operation on the first code digest value by using a code signature module in a first sub-code signature component of the code signature component and a hash algorithm corresponding to the pre-quantum private key and the first signature certificate to obtain a first code signature value;

[0088] A first signer information acquisition unit, configured to acquire the signer information corresponding to the first sub-code signature component, to obtain first signer information;

[0089] Accordingly, the first packaging module 13 may specifically include:

[0090] a first information packaging unit, configured to package the first signer information, the code to be signed, the first code signature value, and the first signature certificate to obtain a pre-quantum signature post-code package; the first signer information includes an identifier of a hash algorithm corresponding to the first signature certificate, an identifier of the first message digest algorithm, an issuer identifier corresponding to the first signature certificate, and a certificate serial number.

[0091] In some specific embodiments, the second code signing module 14 may specifically include:

[0092] A second digest calculation unit is used to calculate the digest of the code to be signed by using the cryptographic device in the certificate authentication infrastructure of the second sub-code signing component and a preset second message digest algorithm to obtain a second code digest value;

[0093] A second signature operation unit is used to perform a signature operation on the second code digest value by using a code signature module in a second sub-code signature component of the code signature component and a hash algorithm corresponding to the post-quantum public and private keys and the second signature certificate to obtain a second code signature value;

[0094] A second signer information acquisition unit is used to acquire the signer information corresponding to the second sub-code signature component to obtain the second signer information;

[0095] Accordingly, the second packaging module 15 may specifically include:

[0096] a second information packaging unit, configured to package the second signer information, the second code signature value, and the second signature certificate into the pre-quantum signature post-code package to obtain a hybrid dual-signature post-code package; the second signer information includes an identifier of a hash algorithm corresponding to the second signature certificate, an identifier of the second message digest algorithm, an issuer identifier corresponding to the second signature certificate, and a certificate serial number.

[0097] In some specific embodiments, the code packet sending module 16 may specifically include:

[0098] a code package parsing unit, configured to parse the hybrid dual-signed code package to obtain the first signer information and the second signer information;

[0099] A first signature certificate obtaining unit, configured to obtain the first signature certificate according to the issuer identifier and certificate serial number corresponding to the first signature certificate contained in the first signer information;

[0100] A first signature certificate verification unit, used to verify the first signature certificate;

[0101] A public key acquisition unit, used to acquire the issuer's public key from the verification module if the verification is successful;

[0102] A first code signing unit is used to sign the code to be signed by using the issuer public key and the hash algorithm corresponding to the first signature certificate to obtain a third code signature value;

[0103] A first judging unit, configured to judge whether the first code signature value is consistent with the third code signature value;

[0104] A second signature certificate obtaining unit, configured to obtain the second signature certificate according to the issuer identifier and certificate serial number corresponding to the second signature certificate contained in the second signer information if they are consistent;

[0105] A second signature certificate verification unit, used to verify the second signature certificate;

[0106] A second code signing unit is configured to sign the code to be signed by using the issuer public key and a hash algorithm corresponding to the second signature certificate to obtain a fourth code signature value if the verification is successful;

[0107] A second judging unit, configured to judge whether the second code signature value is consistent with the fourth code signature value;

[0108] The determination unit is used to determine that the verification of the code to be signed is passed if they are consistent.

[0109] In some specific embodiments, the first information generating unit may specifically include:

[0110] The third information generation unit is used to generate a pre-quantum private key and a certificate request file in CSR format by using the certificate authentication system and the key management system located in the certificate authentication infrastructure of the first sub-code signing component.

[0111] In some specific embodiments, the first request file sending unit may specifically include:

[0112] The second request file sending unit is used to send the certificate request file to a certificate issuing authority so that the certificate request file can be confirmed by the certificate issuing authority, and after confirmation, the first signature certificate containing the pre-quantum private key is issued in a .pfx file format.

[0113] Furthermore, the present application also discloses an electronic device. Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.

[0114] Figure 6 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the code signing method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0115] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0116] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0117] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the code signing method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.

[0118] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed code signing method. The specific steps of the method can refer to the corresponding contents disclosed in the aforementioned embodiments, and will not be repeated here.

[0119] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0120] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0121] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0122] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0123] The above is a detailed introduction to a code signing method, device, equipment and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A code signing method, characterized in that: Applied to a code signing system, the code signing system is pre-integrated with a code signing component and a verification component, the code signing component includes multiple sub-code signing components, and each of the sub-code signing components includes a code signing module and a certificate authentication infrastructure, the verification component includes multiple verification modules, and the method includes: Get the code to be signed; Performing a pre-quantum code signature on the code to be signed by using a first sub-code signature component in the code signature component and a first signature certificate to obtain a first code signature value, and packaging the code to be signed, the first code signature value and the first signature certificate to obtain a pre-quantum signature post-code package; the first signature certificate is a certificate generated by using the certificate authentication infrastructure in the first sub-code signature component; The code to be signed is post-quantum code signed by the second sub-code signing component in the code signing component and using the second signing certificate to obtain a second code signature value, and the second code signature value and the second signing certificate are packaged into the pre-quantum signed post-code package to obtain a hybrid dual-signed post-code package; the second signing certificate is a certificate generated by using the certificate authentication infrastructure in the second sub-code signing component; The hybrid dual-signed code package is sent to the verification component to verify the code to be signed based on the first signing certificate and / or the second signing certificate in the hybrid dual-signed code package.

2. The code signing method according to claim 1, characterized in that: The certificate authentication infrastructure includes a certificate authentication system, a cryptographic device and a key management system; Accordingly, before obtaining the code to be signed, the following steps are also included: Generate a pre-quantum private key and a certificate request file using the certificate authentication system and the key management system located in the certificate authentication infrastructure of the first sub-code signing component; Sending the certificate request file to a certificate issuing authority so that the certificate issuing authority confirms the certificate request file and issues the first signature certificate containing the pre-quantum private key after confirmation; The certificate authentication system and the key management system located in the certificate authentication infrastructure of the second sub-code signing component are used to generate post-quantum public and private keys and the second signature certificate.

3. The code signing method according to claim 2, characterized in that: The method uses the first sub-code signing component in the code signing component and the first signing certificate to perform a pre-quantum code signing on the code to be signed to obtain a first code signature value, and packages the code to be signed, the first code signature value and the first signing certificate to obtain a pre-quantum signed code package, including: By using the cryptographic device in the certificate authentication infrastructure of the first sub-code signing component and using a preset first message digest algorithm to perform digest calculation on the code to be signed, a first code digest value is obtained; Performing a signature operation on the first code digest value by using a code signing module in a first sub-code signing component of the code signing component and a hash algorithm corresponding to the pre-quantum private key and the first signing certificate to obtain a first code signature value; The signer information corresponding to the first sub-code signature component is obtained to obtain the first signer information, and the first signer information, the code to be signed, the first code signature value and the first signature certificate are packaged to obtain a pre-quantum signature post-code package; the first signer information includes an identifier of a hash algorithm corresponding to the first signature certificate, an identifier of the first message digest algorithm, an issuer identifier corresponding to the first signature certificate, and a certificate serial number.

4. The code signing method according to claim 3, characterized in that: The method of performing post-quantum code signing on the code to be signed by using the second sub-code signing component in the code signing component and the second signing certificate to obtain a second code signature value, and packaging the second code signature value and the second signing certificate into the pre-quantum signed post-code package to obtain a hybrid dual-signed post-code package includes: The code to be signed is digested by the cryptographic device in the certificate authentication infrastructure of the second sub-code signing component and a preset second message digest algorithm is used to obtain a second code digest value; Performing a signature operation on the second code digest value by using a code signing module in a second sub-code signing component of the code signing component and a hash algorithm corresponding to the post-quantum public and private keys and the second signing certificate to obtain a second code signature value; The signer information corresponding to the second sub-code signature component is obtained to obtain the second signer information, and the second signer information, the second code signature value and the second signature certificate are packaged into the pre-quantum signature post-code package to obtain a hybrid dual-signature post-code package; the second signer information includes an identifier of a hash algorithm corresponding to the second signature certificate, an identifier of the second message digest algorithm, an issuer identifier corresponding to the second signature certificate, and a certificate serial number.

5. The code signing method according to claim 4, characterized in that: The verifying the code to be signed based on the first signature certificate and / or the second signature certificate in the hybrid dual-signed code package includes: Parsing the hybrid dual-signed code package to obtain the first signer information and the second signer information; Acquire the first signing certificate according to the issuer identifier and certificate serial number corresponding to the first signing certificate contained in the first signer information; Verifying the first signature certificate, and if the verification passes, obtaining the issuer public key from the verification module, and signing the code to be signed using the issuer public key and a hash algorithm corresponding to the first signature certificate to obtain a third code signature value; Determine whether the first code signature value is consistent with the third code signature value, and if they are consistent, obtain the second signature certificate according to the issuer identifier and certificate serial number corresponding to the second signature certificate contained in the second signer information; Verifying the second signature certificate, and if the verification passes, signing the code to be signed using the issuer public key and a hash algorithm corresponding to the second signature certificate to obtain a fourth code signature value; It is determined whether the second code signature value is consistent with the fourth code signature value, and if they are consistent, it is determined that the verification of the code to be signed is passed.

6. The code signing method according to any one of claims 2 to 5, characterized in that: The method of using the certificate authentication system and the key management system in the certificate authentication infrastructure of the first sub-code signing component to generate a pre-quantum private key and a certificate request file includes: The certificate authentication system and the key management system located in the certificate authentication infrastructure of the first sub-code signing component are used to generate a pre-quantum private key and a certificate request file in csr format.

7. The code signing method according to any one of claims 2 to 5, characterized in that: The sending of the certificate request file to a certificate issuing authority so that the certificate issuing authority confirms the certificate request file and issues the first signature certificate containing the pre-quantum private key after confirmation, including: The certificate request file is sent to a certificate issuing authority so that the certificate request file is confirmed by the certificate issuing authority, and after confirmation, the first signature certificate containing the pre-quantum private key is issued in a .pfx file format.

8. A code signing device, characterized in that: Applied to a code signing system, the code signing system is pre-integrated with a code signing component and a verification component, the code signing component includes multiple sub-code signing components, and each of the sub-code signing components includes a code signing module and a certificate authentication infrastructure, and the verification component includes multiple verification modules, including: Code acquisition module, used to obtain the code to be signed; A first code signing module, configured to perform a pre-quantum code signing on the code to be signed by using a first sub-code signing component in the code signing component and a first signing certificate to obtain a first code signature value; the first signing certificate is a certificate generated by using a certificate authentication infrastructure in the first sub-code signing component; A first packaging module is used to package the code to be signed, the first code signature value and the first signature certificate to obtain a pre-quantum signature code package; A second code signing module, configured to perform post-quantum code signing on the code to be signed by using a second sub-code signing component in the code signing component and a second signing certificate to obtain a second code signature value; the second signing certificate is a certificate generated by using a certificate authentication infrastructure in the second sub-code signing component; A second packaging module is used to package the second code signature value and the second signature certificate into the pre-quantum signed code package to obtain a hybrid dual-signed code package; A code package sending module is used to send the hybrid dual-signed code package to the verification component to verify the code to be signed based on the first signature certificate and / or the second signature certificate in the hybrid dual-signed code package.

9. An electronic device, characterized in that: The method comprises a processor and a memory; wherein the processor implements the code signing method according to any one of claims 1 to 7 when executing the computer program stored in the memory.

10. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein, when the computer program is executed by a processor, the code signing method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Communication data transmission method and device, equipment and storage medium

    CN119011287A

  • Identity authentication method and system

    CN119519980A

  • Secure key storage method, application and system of HSS post-quantum digital signature algorithm

    CN121396492A

  • Communication method and communication apparatus

    WO2026086626A1

  • Communication method and communication apparatus

    WO2026086628A1