2008-10-23 13:16:39

ASN.1 for DSA public and private keys

I spent some hours today looking for an adequate description of the ASN.1 structure of a DSA public and private key. In theory, RFC3279 should cover this, and it does, in some way or other: section 3.2.3 has very confusing information about the structure.

But even though I am coding Python at this point in time, Perl has once again saved me: the Crypt::DSA::Key::PEM module contains the ASN in its source code:

DSAPrivateKey ::= SEQUENCE {
    version INTEGER,
    p INTEGER,
    q INTEGER,
    g INTEGER,
    pub_key INTEGER,
    priv_key INTEGER
}

DSAPublicKey ::= SEQUENCE {
    inner SEQUENCE {
        objId OBJECT IDENTIFIER,
        DSAParams SEQUENCE {
            p INTEGER,
            q INTEGER,
            g INTEGER
        }
    }
    pub_key BIT STRING
}

DSAPubKeyInner ::= INTEGER
 

Thanks a ton, Perl!


Posted by Tonnerre Lombard | Permanent link | File under: programming