So the answer comes from reading a little more source pyOpenSSL with an exarkun pointer. pyOpenSSL can indeed replace the M2Crypto dependency here, with very minor changes to the base code.
Unittest for the crypto.verify () function here shows the call:
verify(good_cert, sig, content, digest)
Therefore, there was an error in my code above:
crypto.verify(cert, self.sig, hashed, 'sha1')
Which should have just taken the โdataโ and not hashed it, since the signature was applied to the original data string:
# NB cert = X509 object (from crypto.load_certificate()) crypto.verify(cert, self.sig, data, 'sha1')
This behavior is different from the M2Crypto behavior, which executes a hashed data string to perform validation. Note. I didnโt dig very deep into the M2Crypto functions to work out what was going on.
Thanks to exarkun for his tip on the pyOpenSSL mailing list , which pointed me to an error being in my verify () call, and not in my understanding of what check () does.
jvc26 source share