[crypto]-53-openssl命令行的使用(aes/rsa签名校验/rsa加密解密/hmac)

常用技巧

如何编写一个二进制规律性的文件, 比如你可以编写一个"0123456789abcdef"的文本文件,记得删除换行符然后用ultraedit打开,ctrl+H就可以看到二进制文件,对应的0x30 0x31 0x32…或者使用xxd -i 1.txt查看

AES

openssl enc -aes-128-cbc -in mingwen.data -K 000102030405060708090A0B0C0D0E0F -iv a0a1a2a3a4a5a6a7a8a9aAaBaCaDaEaF -out miwen.data

openssl aes-128-cbc -d -in miwen.data -K 000102030405060708090A0B0C0D0E0F -iv a0a1a2a3a4a5a6a7a8a9aAaBaCaDaEaF -out mingwen.data

RSA

产生公私密钥对
openssl genrsa -out test_priv.pem 2048
openssl rsa -pubout -in test_priv.pem -out test_pub.pem

公钥加密、私钥解密
openssl rsautl -encrypt -in hello -inkey test_pub.key -pubin -out hello.en
openssl rsautl -decrypt -in hello.en -inkey test_priv.key -out hello.de

私钥签名、公钥验签
openssl dgst -sign test_priv.pem -sha256 -out sign.txt file.txt
openssl dgst -verify test_pub.pem -sha256 -signature sign.txt file.txt

公钥中提取N和E
1、openssl rsa -inform PEM -in Key0_pub.pem -pubin -text -out Key1_pub.txt
2、或使用网页:https://the-x.cn/base64

私钥中提取N和E
1、openssl rsa -in test_priv.pem -text -out 1.txt
2、或使用网页:https://the-x.cn/base64

HMAC

1、openssl dgst -hmac hmackey -sha256 -out out.hash in.data
2、或者在线计算: https://1024tools.com/hmac

在这里插入图片描述


相关推荐:
         [crypto]-01-对称加解密AES原理概念详解
         [crypto]-02-非对称加解密RSA原理概念详解
         [crypto]-03-数字摘要HASH原理概念详解
         [crypto]-04-国产密码算法(国密算法sm2/sm3/sm4)介绍
         [crypto]-05-转载:PKCS #1 RSA Encryption Version 1.5介绍
         [crypto]-05.1-PKCS PKCS#1 PKCS#7 PKCS#11的介绍
         [crypto]-06-CA证书介绍和使用方法


         [crypto]-30-The Armv8 Cryptographic Extension在linux中的应用
         [crypto]-31-crypto engion的学习和总结


         [crypto]-50-base64_encode和base64_decode的C语言实现
         [crypto]-51-RSA私钥pem转换成der, 在将der解析出n e d p q dp dq qp
         [crypto]-52-python3中rsa(签名验签加密解密)aes(ecb cbc ctr)hmac的使用,以及unittest测试用
         [crypto]-53-openssl命令行的使用(aes/rsa签名校验/rsa加密解密/hmac)


         [crypto]-90-crypto的一些术语和思考


版权声明:本文为weixin_42135087原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。