生活随笔
收集整理的這篇文章主要介紹了
GMSSL学习总结
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Win10編譯
Win10 VS2015 openssl
實測VS2019編譯GMSSL是沒問題的,老哥資源很好。
在這里總結以下
GMSSL源碼OpenSSL源碼安裝ActivePrel
安裝完成后通過cmd命令: perl -version 查看是否安裝成功和安裝版本安裝NASM
需要手動添加到系統目錄,安裝完成后通過cmd命令:nasm -version 查看是否安裝成功和安裝版本下載dmake
解壓到一個路徑,然后將路徑添加到path系統變量開始菜單vs文件夾找到 x64_x86 Cross Tools Command Prompt for VS,切換到你的 OpenSSL /GMSSL解壓的目錄下面,prefix指定成果物路徑,no-shared不生成靜態庫
perl configure VC-WIN32 no-shared --prefix=D:\OpenSSL\Win32執行 nmake 命令,開始編譯,經過十幾分鐘的等待編譯完成執行:nmake install ,完成進入成果物 GMSSL\Win32\bin\gmssl.exe ,命令碼 version 獲取版本號,help 獲取幫助上述源碼,軟件下載
常用指令
GMSSL源碼
$ gmssl genpkey
-algorithm EC
-pkeyopt ec_paramgen_curve
:sm2p256v1
-out signkey
.pem
$ gmssl pkeyutl
-sign
-pkeyopt ec_scheme
:sm2
-inkey signkey
.pem
-in
<yourfile
> -out
<yourfile
>.sig
$ gmssl pkey
-pubout
-in signkey
.pem
-out vrfykey
.pem
$ gmssl pkeyutl
-verify
-pkeyopt ec_scheme
:sm2
-pubin
-inkey vrfykey
.pem
-in
<yourfile
> -sigfile
<yourfile
>.sig
$ gmssl ecparam
-genkey
-name sm2p256v1
-text
-out user
.key
$ gmssl req
-new -key user
.key
-out user
.req
$ gmssl req
-in user
.req
-noout
-text
-subject
$ gmssl sm3
<yourfile
>
SM3(yourfile
)= 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0
$ gmssl sms4
-e
-in
<yourfile
> -out
<yourfile
>.sms4
enter sms4
-cbc encryption password
: <your
-password
>
Verifying
- enter sms4
-cbc encryption password
: <your
-password
>
$ gmssl sms4
-d
-in
<yourfile
>.sms4
enter sms4
-cbc decryption password
: <your
-password
>
- RSA
openssl的RSA使用
RSA在線計算
$ gmssl genrsa
-out privkey
.pem
1024
$ gmssl rsa
-in privkey
.pem
-pubout
-out pubkey
.pem
$ gmssl rsa
-in privkey
.pem
-RSAPublicKey_out
-out pubkey
.pem
$ gmssl rsa
-inform PEM
-in pubkey
.pem
-pubin
-text
-out Key1_pub
.txt
$ gmssl rsa
-in privkey
.pem
-text
-out Key1_priv
.txt
$ gmssl rsautl
-encrypt
-in input
.file
-inkey pubkey
.pem
-pubin
-out output
.file
$ gmssl rsautl
-decrypt
-in input
.file
-inkey privkey
.pem
-out output
.file
$ gmssl dgst
-sign privkey
.pem
-sha256
-out sign
.txt file
.txt
$ gmssl dgst
-verify pubkey
.pem
-sha256
-signature sign
.txt file
.txt
$ gmssl req
-new -key privkey
.pem
-out rsacert
.csr
$ gmssl x509
-req
-days
3650 -in rsacert
.csr
-signkey privkey
.pem
-out rsacert
.crt
$ gmssl x509
-in rsacert
.crt
-text
-noout
$ gmssl x509
-outform der
-in rsacert
.crt
-out rsacert
.der
$ gmssl pkcs12
-export -out p
.p12
-inkey privkey
.pem
-in rsacert
.crt
$ gmssl enc
-des
-ecb
-K
616263 -nosalt
-in message
.txt
-out msg1
.bin
$ gmssl enc
-des
-cbc
-iv
0102030405060708 -K
616263 -nosalt
-in message
.txt
-out msg2
.bin
$ gmssl enc
-aes
-128-cbc
-in mingwen
.data
-K
000102030405060708090A0B0C0D0E0F
-iv a0a1a2a3a4a5a6a7a8a9aAaBaCaDaEaF
-out miwen
.data
$ gmssl aes
-128-cbc
-d
-in miwen
.data
-K
000102030405060708090A0B0C0D0E0F
-iv a0a1a2a3a4a5a6a7a8a9aAaBaCaDaEaF
-out mingwen
.data
$ gmssl dgst
-hmac hmackey
-sha256
-out out
.hash in
.data
總結
以上是生活随笔為你收集整理的GMSSL学习总结的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。