<div dir="ltr">Hi,<div>Thank you, it works!</div><div><br></div><div>пятница, 25 октября 2013 г., 15:28:01 UTC+4 пользователь Ingela Andin написал:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr"><div><div><br>Hi!<br><br></div><div>The new API does not want any "mpint" values (binaries with size tags) . <br></div>If you try inputing the data according to the new API it will work much better.<br>
<br>1> PrivateKey = [<<2,1>>,<<0,194,170,51,214,<wbr>70,17,25,24,39,11,190,238,251,<wbr>171,164,221,80,251,171,85,16,<wbr>134,227,199,246,113,207,194,<wbr>211,53,68,253,54,195,192,2,93,<wbr>91,107,118,147,218,227,151,<wbr>148,3,165,184,26,199,213,68,<wbr>18,25,35,249,207,196,111,26,<wbr>201,150,255,69>>,<br>
1> <<104,90,61,184,186,69,12,116,<wbr>62,217,98,92,46,21,166,57,194,<wbr>30,29,119,116,166,32,71,194,<wbr>252,162,197,193,144,84,98,223,<wbr>170,137,84,25,86,2,237,128,<wbr>201,216,139,98,173,122,229,3,<wbr>62,100,69,241,18,186,249,170,<wbr>25,156,172,32,228,180,129>>].<br>
[<<2,1>>,<br> <<0,194,170,51,214,70,17,25,<wbr>24,39,11,190,238,251,171,164,<br>   221,80,251,171,85,16,134,227,<wbr>199,246,113,...>>,<br> <<104,90,61,184,186,69,12,<wbr>116,62,217,98,92,46,21,166,57,<br>   194,30,29,119,116,166,32,71,<wbr>194,252,...>>]<br>
2> <br>2>  PublicKey = [<<2,1>>,<<0,194,170,51,214,<wbr>70,17,25,24,39,11,190,238,251,<wbr>171,164,221,80,251,171,85,16,<wbr>134,227,199,246,113,207,194,<wbr>211,53,68,253,54,195,192,2,93,<wbr>91,107,118,147,218,227,151,<wbr>148,3,165,184,26,199,213,68,<wbr>18,25,35,249,207,196,111,26,<wbr>201,150,255,69>>].<br>
[<<2,1>>,<br> <<0,194,170,51,214,70,17,25,<wbr>24,39,11,190,238,251,171,164,<br>   221,80,251,171,85,16,134,227,<wbr>199,246,113,...>>]<br>3> Payload = <<"Launch the nukes.">>.<br><<"Launch the nukes.">><br>
4> Hash = crypto:hash(sha, Payload).<br><<241,220,196,57,84,10,43,93,<wbr>89,232,208,46,247,79,76,207,<br>  109,47,141,175>><br>5> Signature1 = crypto:sign(rsa, sha, {digest, Hash}, PrivateKey). <br><<190,229,211,137,209,154,2,<wbr>175,188,165,201,12,206,80,75,<br>
  148,11,78,207,14,214,170,105,<wbr>252,63,128,61,191,217,...>><br>6> <br>6> crypto:verify(rsa, sha, {digest, Hash}, Signature1, PublicKey). <br>true<br><br></div>Regards Ingela Erlang/OTP team - Ericsson AB<br><div>
<br><div><br><div class="gmail_quote">2013/10/24 John Doe <span dir="ltr"><<a href="javascript:" target="_blank" gdf-obfuscated-mailto="NSJAetnlSHMJ">donped...@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>Hi,</div><div><br></div><div>Is it possible to make RSA signatures compatible between old and new crypto methods? I can't find a way how to do this. </div><div>Here's an example, run in R16B02:</div>

<div><br></div><div>crypto:start().</div><div><br></div><div>%% these two keys are valid RSA keypair</div><div>PrivateKey = [<<0,0,0,2,2,1>>,<<0,0,0,65,0,<wbr>194,170,51,214,70,17,25,24,39,<wbr>11,190,238,251,171,164,221,80,<wbr>251,171,85,16,134,227,199,246,<wbr>113,207,194,211,53,68,253,54,<wbr>195,192,2,93,91,107,118,147,<wbr>218,227,151,148,3,165,184,26,<wbr>199,213,68,18,25,35,249,207,<wbr>196,111,26,201,150,255,69>>,<<<wbr>0,0,0,64,104,90,61,184,186,69,<wbr>12,116,62,217,98,92,46,21,166,<wbr>57,194,30,29,119,116,166,32,<wbr>71,194,252,162,197,193,144,84,<wbr>98,223,170,137,84,25,86,2,237,<wbr>128,201,216,139,98,173,122,<wbr>229,3,62,100,69,241,18,186,<wbr>249,170,25,156,172,32,228,180,<wbr>129>>].</div>

<div>PublicKey = [<<0,0,0,2,2,1>>,<<0,0,0,65,0,<wbr>194,170,51,214,70,17,25,24,39,<wbr>11,190,238,251,171,164,221,80,<wbr>251,171,85,16,134,227,199,246,<wbr>113,207,194,211,53,68,253,54,<wbr>195,192,2,93,91,107,118,147,<wbr>218,227,151,148,3,165,184,26,<wbr>199,213,68,18,25,35,249,207,<wbr>196,111,26,201,150,255,69>>].</div>

<div><br></div><div>SizedBinary = fun(Binary) -> <<(size(Binary)):32/integer,  Binary/binary>> end.</div><div><br></div><div>Payload = <<"Launch the nukes.">>.</div><div><br></div><div>

Hash =  crypto:sha(Payload).</div><div><br></div><div>%%signed with old method</div><div>Signature = crypto:rsa_sign(SizedBinary(<wbr>Hash), PrivateKey).</div><div><br></div><div>%%verify with old method - returns true</div><div>

crypto:rsa_verify(SizedBinary(<wbr>Hash), SizedBinary(Signature), PublicKey).</div><div><br></div><div>%%new method - returns false</div><div>crypto:verify(rsa, sha, {digest, Hash}, Signature, PublicKey).  </div><div><br></div>

<div>%%another try of new method - throws an 'bad argument' exception</div><div>crypto:verify(rsa, sha, {digest, SizedBinary(Hash)}, SizedBinary(Signature), PublicKey).</div><div><br></div><div>%%new method yet again - returns false</div>

<div>crypto:verify(rsa, sha, {digest, Hash}, SizedBinary(Signature), PublicKey). </div></div>
<br>______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="NSJAetnlSHMJ">erlang-q...@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div></div></div>
</blockquote></div></div>