OpenSSL3.0.1下载

wget https://www.openssl.org/source/openssl-3.0.1.tar.gz

OpenSSL3.0.1解压

tar xvf openssl-3.0.1.tar.gz

OpenSSL3.0.1编译

cd openssl-3.0.1
./Configure --prefix=/opt/openssl --openssldir=/usr/local/ssl
make -j12
sudo make install
sudo ln -s /opt/openssl/bin/openssl /usr/bin/openssl3
echo "/opt/openssl/lib64/" > /etc/ld.so.conf.d/openssl3.0.1.conf
sudo ldconfig

OpenSSL3.0.1运行

openssl3 version
OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021)

OpenSSL3.0.1 生成 SM2 密钥

openssl3 ecparam -genkey -name SM2 
-----BEGIN SM2 PARAMETERS-----
BggqgRzPVQGCLQ==
-----END SM2 PARAMETERS-----
-----BEGIN PRIVATE KEY-----
MIGIAgEAMBQGCCqBHM9VAYItBggqgRzPVQGCLQRtMGsCAQEEIL/8jEekBeJc8bjW
96Xd0xiyqlE8cpq5wdr2GTRog4C+oUQDQgAE45bfR1XYxfUN8cc0gHzRQfbfbxXB
sb6eGcWHhhofO9c4smNcqsioh0aZCrD5e0iNKE/wpNQ5ySP7xiz7RlpxEQ==
-----END PRIVATE KEY-----

openssl3 ecparam -genkey -name SM2 -out sm2.key

OpenSSL3.0.1 命令行SM2签名

openssl3 pkeyutl -sign -inkey sm2.key -in test.data -rawin  -digest sm3 -pkeyopt distid:1234567812345678 |hexdump -C

00000000 30 44 02 20 26 c4 c1 3f 0f 45 01 eb 1c 42 03 c7 |0D. &..?.E...B..|
00000010 3d 82 2b c9 70 84 94 af ba 69 8f 4a 61 32 b6 98 |=.+.p....i.Ja2..|
00000020 72 b1 d2 91 02 20 5f 02 75 9c 0a 13 0e bb a7 4d |r.... _.u......M|
00000030 b6 64 4d 37 63 6b 75 df 83 ab 40 90 e7 7f a9 d0 |.dM7cku...@.....|
00000040 8e 80 5a 87 32 84 |..Z.2.|
00000046

本文链接地址:https://const.net.cn/649.html

标签: none

添加新评论