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标题中的信息。

更多相关文章

  1. Python 学习笔记【list的操作方法】
  2. 使用pip安装tensorflow 0.80,python 使用tensorflow 0.80遇到的问
  3. 在save方法中创建两个对象
  4. 基于Python的XSS测试工具XSStrike使用方法
  5. 关于Python的属性、参数、方法的解释、区别
  6. 集成erlang和python的最佳方法
  7. python中查看变量内存地址的方法
  8. RHEL6误安装RHEL7的包导致glibc被升级后系统崩溃处理方法
  9. Linux selinux关闭方法和防火墙关闭方法

随机推荐

  1. Android(安卓)Launcher2 icon大小修改
  2. Android手机操作系统中的常用术语
  3. Android 核心分析(13) -----Android GWES
  4. 对 android apk 进行重新签名操作
  5. 理解Android Binder机制(3/3):Java层
  6. android MK文件简介
  7. android:layout_gravity和android:gravit
  8. [Android] 基于 Linux 命令行构建 Androi
  9. Android 4层框架
  10. Android(安卓)打造RxBus2.x的全面详解