SM2 algorithm key segmentation signature system and method
Technical Field
The invention relates to the technical field of information security, in particular to the technical field of a key signature method, and particularly relates to a SM2 algorithm key segmentation signature system and method.
Background
In recent years, network security events are frequent, and network attacks are raised from personal events such as information leakage, fund stealing, telecommunication fraud, phishing websites and the like to security events of the whole society, which affect our lives, government services, social stability and even social security. The cryptographic technology is a core technology of network information security, has an important position on the national security strategy under the global environment of the internet, is the basis for realizing the autonomous and controllable national network information, and can be widely applied to industry systems relating to civil and basic information resources, such as e-government affairs, energy, traffic, health, education and the like.
The SM2 algorithm is an elliptic curve public key cryptographic algorithm issued by the national crypto authority in 12 months and 17 days in 2010, and compared with the RSA algorithm, the SM2 algorithm has the advantages of high safety, high computing speed and small storage space under the same key strength, and meanwhile, compared with the international standard ECC algorithm, the SM2 algorithm is better in initial state coding and encryption computing efficiency.
With the development of the mobile internet, the mobile device becomes a fundamental trend for changing the traditional computing, and the popularity of the mobile intelligent terminal is higher and higher as the mobile device has stepped into the intelligent era. People use fragmented time to surf the internet, and mobile office, mobile electronic commerce and mobile electronic government have great development, and the safety problem is followed, and identity authentication and digital signature of a mobile terminal need to be solved. Under the circumstance, how to realize digital signature by efficiently utilizing the mobile equipment and combining a domestic cryptographic algorithm becomes a problem which needs to be solved urgently.
Disclosure of Invention
In order to solve the problems of the prior art, the invention provides an SM2 algorithm key segmentation signature system and a method thereof, which are characterized in that a mobile terminal is combined, an SM2 key is generated by utilizing mobile equipment and cloud cryptographic service together, the key is segmented into two parts and is respectively stored by the mobile equipment terminal and a cloud cryptographic server, the method realizes a signature algorithm based on SM2 key segmentation, digital signature is completed by the mobile equipment and the cloud terminal together, the key is ensured not to be leaked in the signature process, and the key security of the mobile equipment terminal can be effectively protected.
The technical scheme adopted by the invention is as follows:
an SM2 algorithm key segmentation signature system comprises a mobile device, a cloud password service and a third-party CA center, wherein the mobile device and the cloud password service respectively generate random numbers, the validity verification of an SM2 key is completed at one end of the mobile device, and the SM2 key is confirmed and generated; the mobile equipment and the cloud password service respectively complete part of the SM2 algorithm digital signature, and finally generate a digital signature at one end of the mobile equipment;
the mobile device is responsible for generating random numbers, completing validity verification of SM2 keys and partial calculation of generating SM2 digital signatures, and in addition, the mobile device can generate temporary keys for communication with cloud encryption services;
the cloud password service is responsible for generating random numbers, transmitting the random numbers with encryption authentication data of a mobile equipment end and realizing partial calculation of an SM2 signature algorithm;
the third party CA center is responsible for issuing the digital certificate, on one hand, issues the certificate for the cloud password service to ensure the legal identity of the cloud password service, and on the other hand, issues the digital certificate for the mobile device to provide legal identity authentication for the password application of the mobile device.
The mobile equipment adopts external hardware to encrypt the terminal equipment.
The cloud password service adopts a hardware password machine or uses a cloud password machine to complete encryption and signature operation.
An SM2 algorithm key splitting signature method comprises a method for splitting key generation and a method for completing digital signature, wherein the method for splitting key generation comprises the following steps:
step 101, a third party CA center issues a digital certificate for a cloud password service;
102, generating a temporary key pair by the mobile equipment, and providing a split key generation request to the cloud password service;
103, the cloud password service generates a random number dc, encrypts the random number dc by using a public key of the mobile device, signs the random number dc by using a self secret key, and sends the random number dc to the mobile device;
104, the mobile equipment decrypts by using a temporary private key, verifies the certificate validity and the signature validity, and obtains a random number dc of the cloud password service;
step 105, the mobile device generates a random number dm, and calculates d ═ dc × dm-1, d ∈ [ 1; n-2], wherein n is the order of one base point of the SM2 elliptic curve;
step 106, the mobile device calculates a point P ═ P, (xP, yP) ═ d ] G, where G is a base point and (xP, yP) is a coordinate; if P meets the requirement of the SM2 elliptic curve, go to step 107, otherwise go to step 108;
step 107, the mobile device sends a key generation success message to the cloud cryptographic service, wherein the SM2 key pair is (dm x dc-1; P), dm is used as a private key of the mobile device, dc is used as a private key of the cloud cryptographic service, and P is a public key;
step 108, the mobile device sends a key generation failure message to the cloud password service, and goes to step 102 to re-apply for a random number;
step 109, the SM2 divides the key pair to generate successfully, and the third party CA center issues a digital certificate for the key;
the method for completing the digital signature comprises the following steps:
step 201, the mobile device calculates a hash value Z of the user, then splices a plaintext M, calculates a digest value thereof, converts the digest value into an integer, and records the integer as e;
step 202, the mobile device generates a temporary key pair, and provides a split key generation request to the cloud cryptographic service;
step 203, the cloud cryptographic service generates a random number k ∈ [1, n-1], calculates SM2 elliptic curve points (x1, y1) ═ k ] G, calculates r ═ e + x1) mod n, and regenerates the random number if r ═ 0 or r + k ═ n;
step 204, the cloud cryptographic service calculates t ═ k + r × dc-1; encrypting the (r, t) by using a public key of the mobile equipment, signing by using a self secret key, and sending to the mobile equipment;
step 205, the mobile device decrypts by using the temporary private key, and then verifies the certificate validity and the signature validity to obtain (r, t);
step 206, the mobile device calculates s ═ (t-r × dm) × dm-1, if s ═ 0, go to step 207, otherwise go to step 208;
step 207, the mobile device sends a key generation failure message to the cloud cryptographic service, and goes to step 202 to sign again;
step 208, the mobile device sends a signature success message to the cloud cryptographic service, and the signature value of SM2 is (r, s).
In step 102, the mobile device sends a request for generating a split key to the cloud cryptographic service, where the request includes a mobile device identifier, a public key of a temporary key pair, and an application time.
In step 202, the request for generating the split key to the cloud cryptographic service by the mobile device includes a mobile device identifier, a public key of the temporary key pair, and a digest value integer e.
The method of split key generation further comprises:
and step 209, the mobile device verifies the signature value by using the public key certificate thereof.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
the invention provides an SM2 algorithm key segmentation signature system and method, which are characterized in that a mobile terminal is combined, an SM2 key is generated by utilizing mobile equipment and cloud password service together, and the key is segmented into two parts which are respectively stored by the mobile equipment terminal and a cloud password server. The process of generating the key adopts the encrypted signature to realize the data interaction between the equipment end and the cloud end, thereby ensuring the transmission safety. The SM signature algorithm based on key segmentation is used for respectively completing calculation by a mobile device end and a cloud end, and random numbers are generated by using a cloud end hardware device in the signature process, so that the generation intensity of the random numbers is also ensured; the key and signature generation is finished at the mobile equipment end, the cloud end cannot obtain the key part of the mobile equipment end, and even the calculated key content cannot be obtained, so that the key safety of the mobile equipment end is ensured. On the other hand, the key is divided, even if part of the key is leaked, a malicious attacker cannot forge the digital signature, and the security of the key is effectively protected. In addition, the mobile device end can also access an external password encryption hardware device to enhance the strength of generating the SM2 key.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a system configuration diagram of an SM2 algorithm key division signature system according to the present invention;
FIG. 2 is a flowchart of a key generation method of the SM2 algorithm key partitioning signature method of the present invention;
fig. 3 is a flow chart of a digital signature method of the SM2 algorithm key partitioning signature method of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Example one
As shown in fig. 1, the SM2 algorithm key splitting signature system of the embodiment includes a mobile device, a cloud cryptographic service, and a third party CA center. The mobile equipment and the cloud password service respectively generate random numbers, the validity verification of an SM2 key is completed at the mobile equipment end, and the SM2 key is confirmed to be generated; the mobile equipment and the cloud password service respectively complete a part of SM2 algorithm digital signature, and finally generate a digital signature at the mobile equipment end; the SM2 digital signature verification operation based on the method is the same as the standard SM2 algorithm. The mobile device is responsible for generating random numbers, verifying the validity of an SM2 key and partially calculating the generation of an SM2 digital signature, and in addition, the mobile device can generate a temporary key for communication with a cloud encryption service, and the security of the mobile device can be improved by adopting external hardware to encrypt a terminal device. The cloud password service is responsible for generating random numbers, transmitting encryption authentication data of the mobile equipment end and realizing partial calculation of an SM2 signature algorithm, and the cloud password service can adopt a hardware password machine and can also use a cloud password machine to finish operations such as encryption signature and the like. The third-party CA center is mainly responsible for issuing the digital certificate, on one hand, issues the certificate for the cloud password service to ensure the legal identity of the cloud password service, and on the other hand, issues the digital certificate for the mobile device to provide legal identity authentication for the password application of the mobile device.
For clarity of description, it is assumed in this embodiment that the cloud and the device side both use the SM2 algorithm, the encryption key algorithm is the SM2 SM, the SM3SM serves as the digest algorithm, the SM3SM2 SM serves as the signature algorithm, and the digital certificate uses the X509 format. The data format of the mobile device side key generation request is as follows:
ID: mobile device identification
PubKey: public key of temporary key pair
T1: application time
The nonces: disposable digital mark
SigAlg: signature algorithm
Signature: signature value
The data format of the digital signature request of the mobile device side is as follows:
ID: mobile device identification
e: processed plaintext digest value
PubKey: public key of temporary key pair
T1: application time
The nonces: disposable digital mark
SigAlg: signature algorithm
Signature: signature value
It will be appreciated by those skilled in the art that the configurations according to embodiments of the present invention can be applied on other data formats than those using the above data formats.
Example 2:
the SM2 algorithm key splitting signature method of the present embodiment includes a method for splitting key generation and a method for completing digital signature, where the key generation method refers to fig. 2, and includes the following steps:
step 101, the third party CA center issues a digital certificate for the cloud password service;
102, the mobile device generates a temporary key pair, and provides a split key generation request (including a mobile device identifier, a public key of the temporary key pair, application time, and the like) to the cloud cryptographic service;
103, the cloud password service generates a random number dc, encrypts the random number dc by using a public key of the mobile device, signs the random number dc by using a self secret key, and sends the random number dc to the mobile device;
and 104, the mobile equipment firstly decrypts by using the temporary private key, then verifies the certificate validity and the signature validity of the mobile equipment, and obtains the random number dc of the cloud password service.
Step 105, the mobile device generates a random number dm, and calculates d ═ dc × dm-1, d ∈ [ 1; n-2], where n is the order of one base point of the SM2 elliptic curve.
Step 106, the mobile device calculates a point P ═ P, (xP, yP) ═ d ] G, where G is a base point and (xP, yP) is a coordinate; if P meets the requirement of the SM2 elliptic curve, go to step 107, otherwise go to step 108;
step 107, the mobile device sends a key generation success message to the cloud cryptographic service, wherein the SM2 key pair is (dm x dc-1; P), dm is used as a private key of the mobile device, dc is used as a private key of the cloud cryptographic service, and P is a public key;
and step 108, the mobile equipment sends a key generation failure message to the cloud password service, and the step 102 is carried out to apply for the random number again.
Step 109, the SM2 splits the key pair successfully, and the third party CA center issues a digital certificate for the key.
Method of completing digital signature referring to fig. 3, comprising the steps of:
step 201, the mobile device calculates a hash value Z of the user, then splices a plaintext M, calculates a digest value thereof, converts the digest value into an integer, and records the integer as e;
step 202, the mobile device generates a temporary key pair, and provides a split key generation request (including a mobile device identifier, a public key of the temporary key pair, a digest value integer e, etc.) to the cloud cryptographic service;
step 203, the cloud cryptographic service generates a random number k ∈ [1, n-1], calculates SM2 elliptic curve points (x1, y1) ═ k ] G, calculates r ═ e + x1) mod n, and regenerates the random number if r ═ 0 or r + k ═ n;
step 204, the cloud cryptographic service calculates t ═ k + r × dc-1; encrypting the (r, t) by using a public key of the mobile equipment, signing by using a self secret key, and sending to the mobile equipment;
step 205, the mobile device decrypts by using the temporary private key, and then verifies the certificate validity and the signature validity to obtain (r, t);
step 206, the mobile device calculates s ═ t-r ═ dm) × dm-1, if s ═ 0, go to step 207, otherwise go to step 208;
step 207, the mobile device sends a failure message of generating the key to the cloud cryptographic service, and goes to step 202 to sign again.
Step 208, the mobile device sends a signature success message to the cloud cryptographic service, and the signature value of SM2 is (r, s);
and step 209, the mobile device verifies the signature value by using the public key certificate of the mobile device.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.