M2Crypto and OpenSSL CLI doesn't seem to create the same digital signature. Here is the code that I use in Python:
import M2Crypto
rsa = M2Crypto.RSA.load_key("privkey.pem")
open("sig_m2crypto", "w").write(rsa.sign("md5-digest", "md5"))
Here is the command line with OpenSSL:
echo "md5-digest" | openssl rsautl -sign -inkey privkey.pem > sig_openssl
With the same input, the result of sig_m2crypto
and sig_openssl
are always different. The significance would be I can not verify signatures generated using M2Crypto with OpenSSL and vice versa.
Is there anything missing in my code that makes them not compatible with each other?
Additional info: I am using M2Crypto 0.21.1 and OpenSSL 1.0.0 under Windows 7.
"wb"
when opening a file in Windows since it differentiates between text mode and binary mode. Good call on the-n
, almost forgot. I'm using MinGW under Windows. – Casework