Converting java to python: x509 / dsa / sha1withdsa crypto howto?
I have the following Java code that I'm trying to convert to python and I'm not sure how to do it:
import java.security.spec.X509EncodedKeySpec;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.Signature;
byte[] key = KeyReader.read(filestream)
//KeyReader.read(inputstream) just reads in the bytes 1 at a time from the filestream
X509EncodedKeySpec pubKey = new X509EncodedKeySpec(key);
KeyFactory keyFactory = KeyFactory.getInstance("DSA");
PublicKey pub = keyFactory.generatePublic(pubKey);
Signature signature = Signature.getInstance("SHA1withDSA");
signature.initVerify(pub)
signature.update(a_byte_string) //doesn't matter
I am a bit lost on how to do this in python. Particularly the SHA1withDSA part. I just don't know enough about the python crypto libs (m2crypto, to be precise) to map functions (and I couldn't find decent entries on how to do this).
+2
source to share