views:

46

answers:

1

Using M2Crypto I'd like to create a DSA_pub object for verifying a DSA signature. I know q, p, g, and the public key, but the only way I know to instantiate a DSA object is using:

dsa = DSA.set_params(q,p,g)
dsa.gen_key()

How do I assign the known public key?

A: 

There are many factory functions in module DSA beyond get_params, and I think you want load_pub_key (if you have public key and params in a PEM file) or load_pub (if you have them in a BIO object). See also the BIO module for various kinds of BIO objects.

Alex Martelli
How might I take the raw params and key and create a BIO or PEM to in turn create a the public key using load_*?
casey
I don't know of Python functions to write PEM files from arbitrarily "obtained" params and keys (how did you "obtain" them in the first place BTW?) -- there may be some but if so I've never heard of any. PEM is documented at RFC 1422, http://tools.ietf.org/html/rfc1422.html , and is unfortunately a complicated format:-(.
Alex Martelli
Hmm, doesn't sound fun.Where did I obtain them? from DNSKEY RRs using algorithm 3 (RFC 2536)
casey