生成使用AES包装的RSA私钥
I am new to encryption and been playing with openssl. There's a command in openssl to generate an RSA private key wrapped using AES:
我是加密新手并且一直在玩openssl。 openssl中有一个命令用于生成使用AES包装的RSA私钥:
openssl genrsa -aes128
And the sample result will be:
样本结果将是:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,7787EC23BAB71A7E339FA4BB5B197362
Sqmr8Zb8..bla..blaa
-----END RSA PRIVATE KEY-----
In PyCrypto, we can build the similar private key using:
在PyCrypto中,我们可以使用以下方法构建类似的私钥:
from Crypto.PublicKey import RSA
key = RSA.generate(1024).exportKey('PEM', 'secret')
Which will produce
哪个会产生
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,760A8103AA096360
HxGmbla..blaa
-----END RSA PRIVATE KEY-----
Notice the result is wrapped using triple DES. What is the proper way to create a private key wrapped using AES such as the one above using PyCrypto?
请注意,结果使用三重DES进行包装。创建使用AES包装的私钥的正确方法是什么,例如上面使用PyCrypto?
2 个解决方案
#1
1
None it seems, looking through the source code, you quickly find a hard-coded part for PKCS#8 encrypted private key in exportKey
:
看来没有,通过源代码查看,您可以快速找到exportKey中PKCS#8加密私钥的硬编码部分:
protection = 'PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC'
Which seems to comply with the information in the PEM header.
这似乎符合PEM标题中的信息。
更多相关文章
- Python 学习笔记【list的操作方法】
- 使用pip安装tensorflow 0.80,python 使用tensorflow 0.80遇到的问
- 在save方法中创建两个对象
- 基于Python的XSS测试工具XSStrike使用方法
- 关于Python的属性、参数、方法的解释、区别
- 集成erlang和python的最佳方法
- python中查看变量内存地址的方法
- RHEL6误安装RHEL7的包导致glibc被升级后系统崩溃处理方法
- Linux selinux关闭方法和防火墙关闭方法