diff options
Diffstat (limited to 'pipermail/pycrypto/attachments/20110821/dc133a09/attachment.html')
-rw-r--r-- | pipermail/pycrypto/attachments/20110821/dc133a09/attachment.html | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pipermail/pycrypto/attachments/20110821/dc133a09/attachment.html b/pipermail/pycrypto/attachments/20110821/dc133a09/attachment.html new file mode 100644 index 0000000..b1a9c43 --- /dev/null +++ b/pipermail/pycrypto/attachments/20110821/dc133a09/attachment.html @@ -0,0 +1,9 @@ +<tt> +Hi, I&#39;m trying to generate signatures in a way openssl can verify using pycrypto, but when I decode it with openssl, it doesn&#39;t produce usable results. This has been my workflow so far:<br><br>------------------------------------<br><br> +<br>openssl genrsa -out privkey.pem 2048<br>openssl rsa -pubout -in privkey.pem -out pubkey.pem<br><br>echo &quot;message text&quot; &gt; data<br><br>python &lt;&lt;!<br>#!/usr/bin/env python<br><br>from Crypto.PublicKey import RSA<br><br> +import Crypto.Random<br>from Crypto.Util import number<br>import sys,ctypes<br><br>def make_OPENSSL_PKCS1_padding(k,msglen):<br> if msglen &gt; k - 11:<br> return None<br> PS = &#39;\xff&#39;* (k-msglen-3)<br><br> + E = &#39;&#39;.join((chr(0x00), chr(0x01), PS, chr(0x00)))<br><br> return E<br><br>prk = RSA.importKey(file(&#39;privkey.pem&#39;).read())<br><br>data = file(&#39;data&#39;).read()<br>E = make_OPENSSL_PKCS1_padding((prk.size()+1)/8,len(data))<br><br> +EM = &#39;&#39;.join((E,data))<br><br>sigout = prk.sign(EM,&#39;&#39;)<br><br>f = open(&#39;signature&#39;,&#39;wb&#39;)<br>f.write(number.long_to_bytes(sigout[0]))<br>f.close()<br>!<br><br>openssl rsautl -verify -raw -pubin -inkey pubkey.pem -in signature -out de_signature<br><br> +<br>cat de_signature<br><br>------------------<br><br>I expect to see a whole bunch of 0xFFs followed by &quot;message text&quot; when I cat de_signature, but that&#39;s not what I get at all. Any idea what I might be doing wrong here?<br><br> + +</tt> |