Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So I used puttygen to generate a DSA private key and then exported that to the OpenSSH format and here's what I got when I ran OpenSSL's asn1parse on it:

    0:d=0  hl=4 l= 443 cons: SEQUENCE
    4:d=1  hl=2 l=   1 prim:  INTEGER           :00
    7:d=1  hl=3 l= 129 prim:  INTEGER           :B9916796B7A3EFFD5CA36368186D0ED
193BE7FDD61CC6851174F3E9781A0C0CEA7473E528372F559A1DB2A7E049A9BEFAE2CAAC55527049
2A0CD55B59A48A53BCADD32181F519EA9E6A98EF8EF59DE314A2E69606C728F2F8DEE722B4C67BA6
8EB8A619B6006804F83740F9C74C38136522E7E83F22920AA39822FBDA0DF4D0B
  139:d=1  hl=2 l=  21 prim:  INTEGER           :D832F5B01F075FEC0F162B91982F34D
B26A0CC29
  162:d=1  hl=3 l= 129 prim:  INTEGER           :9B73F47AEFF8E39584FD10ACF81CCD5
75C96FC5558A5C94B941EF76318D132007ACAE1EA22E95CE0B13FC7875CE4D4ED33BA639CD8C2AC9
C0A0530FB7786F584A62EBAE5985E1C26ED0D0B9FDD5E8DB0142BE182A4E5359307007060C327FEE
C2F8D04EABB37D7B74076EB9BDB4885F627DE85708D5BDBF5177A05721E09A367
  294:d=1  hl=3 l= 128 prim:  INTEGER           :6BD9267D2D1E4546EE05F6CD087F311
93C0EEB13B1E139F5072E900AB2EEF68EEC28BF4D7D6CAE4DEE59005F00BAE07343EE520C217FF6E
7880DC788E4555F78CCB5E89A10CDC71A663DA696C5BC34E296CEB3518D65A79BF00B6D592B1399A
9F0D79AE3F3FB445EE1F2B4B72515F036C8E1D5C7FAD336FD3503874645C5C264
  425:d=1  hl=2 l=  20 prim:  INTEGER           :15295A12325E5F1A6F7243B7BB3BE74
6FE7B76E9

My question is... where is this format described? What does the first 0 integer value mean for example?

I guess I could look in the puttygen source code but is there an RFC describing this format or something?

share|improve this question

migrated from crypto.stackexchange.com Sep 24 '12 at 14:43

This question came from our site for software developers, mathematicians and others interested in cryptography.

    
This question is not on topic, since private key formats are often implementation specific and not necessarily standardized. The above dump of the der encoding shows that the format is at least not consistent with PKCS#8. –  Henrick Hellström Sep 24 '12 at 13:47
    
As Henrick pointed out, your question is more about key formats and less about crypto. So it is off topic on our site here. I talked to the moderators at our sister site SuperUser and we feel it might be better off on their site, so I'm moving it there. –  mikeazo Sep 24 '12 at 14:43
    
What command did you use to export the key to OpenSSH format? –  HeatfanJohn Sep 25 '12 at 16:49

1 Answer 1

Private-key formats aren't as standardized as public-key formats because, ideally, they are never sent or received— so interoperability isn't as big of a concern.

However, documentation on that format can be found in a couple of places. It's very similar to the RSAPrivateKey structure described in PKCS#1, which would normally be carried inside a PKCS#8 container. However, the normal way of storing a DSA key in a PKCS#8 container is just to store the private value x, not the whole structure that you have there. I'm guessing that it's a proposed-but-never-technically-standardized DSAPrivateKey format which OpenSSL implemented before the standards settled down. The OpenSSL dsa man page says:

The DER option with a private key uses an ASN1 DER encoded form of an ASN.1 SEQUENCE consisting of the values of version (currently zero), p, q, g, the public and private key components respectively as ASN.1 INTEGERs.

and I'm guessing that OpenSSH reused that format. The comments in PyCrypto's DSA key implementation reinforce this idea; there they call the structure "DSAPrivatKey_OpenSSL" and refer to it as "the custom OpenSSL/OpenSSH encoding".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.