[pycrypto] RSA exportKey question with bcrypt?
Legrandin
helderijs at gmail.com
Tue Jul 16 13:08:01 PDT 2013
Hi Manuel,
Yes, that is my understanding as well.
The current code uses the PEM headers you indicate for the various
cases (see below for actual output).
I also find this link quite useful:
https://polarssl.org/kb/cryptography/asn1-key-structures-in-der-and-pem
>>> from Crypto.PublicKey import RSA
>>> k = RSA.generate(1024)
>>> print k.exportKey('PEM', pkcs=1)
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC+2fP2il/1+Yvr1ctB67+sFPq5hs0bOZ9R4l/Pt9cRKxFAKGDY
[...]
>>> print k.exportKey('PEM', passphrase='rr', pkcs=1)
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,FEE6839853DD42B2
MWIPA268NMYw4kFCc5wVn/Dscb8adCpJnFZOF/8CZay+3ik6wIu8yAvlDrUiKguI
[...]
>>> print k.exportKey('PEM', passphrase='rr', pkcs=8)
-----BEGIN PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,E95D4DA9934F6C0E
HZxEFCZq5Qixt08u2Td8etx5poaN7NxwrrP4zlfcNuYb0gyA/4QYc/1FOEFqjWbQ
[...]
>>> print k.exportKey('PEM', passphrase='rr', pkcs=8, protection='PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC')
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIICxjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIt4O8Lxapq8MCAgPo
[...]
2013/7/16 Manuel Pégourié-Gonnard <mpg at elzevir.fr>:
> On 16/07/2013 08:48, Manuel Pégourié-Gonnard wrote:
>> -----BEGIN RSA RIVATE KEY----- PKCS#1 in a PEM envelope
>> -----BEGIN RIVATE KEY----- unencrypted PKCS#8 in a PEM envelope
>> -----BEGIN RSA RIVATE KEY----- encryptedd PKCS#8 in a PEM envelope
>>
> Oops, I meant:
>
> -----BEGIN RSA RIVATE KEY----- PKCS#1 in a PEM envelope
> -----BEGIN PRIVATE KEY----- unencrypted PKCS#8 in a PEM envelope
> -----BEGIN ENCRYPTED PRIVATE KEY----- encrypted PKCS#8 in a PEM envelope
>
> Manuel.
> _______________________________________________
> pycrypto mailing list
> pycrypto at lists.dlitz.net
> http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto
More information about the pycrypto
mailing list