[erlang-questions] exception error: bad argument in function crypto:ec_key_generate/2

Gabriele Santomaggio g.santomaggio@REDACTED
Sun Jul 24 16:43:25 CEST 2016


On 07/23/2016 09:29 AM, Gabriele Santomaggio wrote:
>> Executing this code:
>> 
>> crypto:generate_key(ecdh, secp112r2).
>> 
>> on centos 6/7 I get this error:

>This is a shot in the dark, but does the list returned by
>crypto:ec_curves() contain secp112r2 on your CentOS machine?

Hi,  

6> crypto:ec_curves().
[secp112r1,secp112r2,secp128r1,secp128r2,secp160k1,
 secp160r1,secp160r2,secp192r1,secp192k1,secp224k1,secp224r1,
 secp256k1,secp256r1,secp384r1,secp521r1,prime192v1,
 prime192v2,prime192v3,prime239v1,prime239v2,prime239v3,

The main problem btw is a ssl connection to an LDPAs
if i execute openssl s_client -connect my server:636 in the same machine it works correctly. 
If I try using  {ok, Socket} = ssl:connect("my server", 636, [], infinity). I get the exception exception error: bad argument

After a few debug I found that this is the problem:

Args={{prime_field,<<255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,0,0,0,0,0,0,0,0,
0,0,0,1>>},
{<<"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿþ">>,
<<180,5,10,133,12,4,179,171,245,65,50,86,80,68,176,183,
215,191,216,186,39,11,57,67,35,85,255,180>>,
<<189,113,52,71,153,213,199,252,220,69,181,159,163,185,
171,143,106,148,139,197>>},
<<4,183,14,12,189,107,180,191,127,50,19,144,185,74,3,193,
211,86,194,17,34,52,50,128,214,17,92,29,33,189,55,99,
136,181,247,35,251,76,34,223,230,205,67,117,160,90,7,
71,100,68,213,129,153,133,0,126,52>>,
<<255,255,255,255,255,255,255,255,255,255,255,255,255,
255,22,162,224,184,240,62,19,221,41,69,92,92,42,61>>,
<<1>>}.

crypto:generate_key(ecdh, Args).
* exception error: bad argument
     in function  crypto:ec_key_generate/2
        called as crypto:ec_key_generate({{prime_field,

<<219,124,42,191,98,227,94,102,128,118,190,173,32,139>>},

{<<97,39,194,76,5,243,138,10,170,246,92,14,240,44>>,

<<81,222,241,129,93,181,237,116,252,195,76,133,215,9>>,

<<0,39,87,161,17,77,105,110,103,104,117,97,81,117,83,22,
                                             192,94,11,212>>},

<<4,75,163,10,181,232,146,180,225,100,157,208,146,134,67,

173,205,70,245,136,46,55,71,222,243,...>>,

<<54,223,10,175,216,184,215,89,124,161,5,32,208,75>>,
                                          <<4>>},
                                         undefined)

I suppose that there is a general problem when I try to use crypto:generate_key(ecdh,…)
Tried it on Centos 6 and 7. Same errors 
  


Thank you.

GaS



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160724/2d396f5e/attachment.htm>


More information about the erlang-questions mailing list