ASN.1 Failure With OPENSSL Generated Key: Unexpected tag (got 30, expecting 02)

Bug #1756844 reported by Scott Kitterman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dkimpy
Invalid
High
Unassigned

Bug Description

Relayed from offline mail: The problem can be reproduced easily:

$ dkimsign.py test example.com testkey.key <dkim/tests/data/test.message
Unexpected tag (got 30, expecting 02)
Received: from localhost
Message-ID: <email address hidden>
Date: Mon, 01 Jan 2011 01:02:03 +0400
From: Test User <email address hidden>
To: <email address hidden>
Subject: Testing

This is a test message.

I went back and checked with older dkimpy versions (back to 0.5.2) and I get the same error for all of them, so whatever it is, it's not a recent change.

I can extract the public key from it manually using openssl 1.0.1f, so at least openssl appears to be able to parse the key.

The key was generated via OpenSSL (whatever version was current 3+ years ago) and had not caused any problems previously (though I probably had not tried to use it for over 18months and just updated to the latest dkimpy package yesterday).

Note: The key is used for examples, so it is not really a 'private key', no need to worry about it being in the bug tracker.

Revision history for this message
Scott Kitterman (kitterman) wrote :
Revision history for this message
Scott Kitterman (kitterman) wrote :

It looks like asn1 (on pypi) can parse this:

>>> decoder.start(bytes(data))
>>> tag, value = decoder.read()
>>> print tag
Tag(nr=16, typ=32, cls=0)
>>> decoder.start(bytes(value))
>>> tag, value = decoder.read()
>>> print tag
Tag(nr=2, typ=32, cls=64)
>>> decoder.start(bytes(value))
>>> tag, value = decoder.read()
>>> print tag
Tag(nr=22, typ=32, cls=0)
>>> decoder.start(bytes(value))
>>> tag, value = decoder.read()
>>> print tag
Tag(nr=19, typ=32, cls=0)

Revision history for this message
Scott Kitterman (kitterman) wrote :

The RSA private key structure (RFC 8017, Appendix A.1.2) is:

   RSAPrivateKey ::= SEQUENCE {
       version Version,
       modulus INTEGER, -- n
       publicExponent INTEGER, -- e
       privateExponent INTEGER, -- d
       prime1 INTEGER, -- p
       prime2 INTEGER, -- q
       exponent1 INTEGER, -- d mod (p-1)
       exponent2 INTEGER, -- d mod (q-1)
       coefficient INTEGER, -- (inverse of q) mod p
       otherPrimeInfos OtherPrimeInfos OPTIONAL
   }

This key is:

SEQUENCE {
INTEGER
IA5String
PrintableString
}

I don't think this is a valid RSA private key.

Changed in dkimpy:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.