Current location - Quotes Website - Signature design - Public key and private key generation
Public key and private key generation
Step 1: install Win64OpenSSL software on windows operating system; Step 2: Open Win64OpenSSL software, first generate the private key, command: ecparam-genkey-namesm2-outpriv.key;

Step 3: generate a public key through the generated private key, and the command is: EC-inpriva.key-pub out-output.key.

Verify the public and private keys generated by SM2 Step 1: First, create a file.txt file (the samples are placed in the same directory as the public and private keys);

Step 2: Open Win64OpenSSL software, and first generate a signature according to the private key. The command is: dgst-signpriv.key-sha1-outsha1_ sm2 _ file.signfile.txt.

Step 3: Verify the generated signature according to the public key. If the public key and private key match, the public key and private key of SM2 are successfully generated. The command is: dgst-verify pub. key-sha 1-signature sha 1 _ sm2 _ file . sign file . txt

The file address needs to be modified. The above should be put directly on the d disk, and finally it should be. The key is still. pem。

Download (GmSSL-master.zip), unzip and go to the source code folder. On Linux and OS X, run the following command:

After installation, enter the gmssl version and report the error:

Add two soft connections:

Generate private key

Generate public key

Reference (/Qoros /GmSSL)

Neither the public key nor the private key generated above can be used by gmss sm2, and can be encrypted and decrypted, but the result is wrong.

Because the provided public key and private key are in base64 format, it needs to be transcoded.

Fourth, other formats are converted to each other

String and base64 cannot be directly converted, so you need to go to bytes first.