[erlang-questions] crypto.generate_key() with PrivKeyIn fails

Bernard Kolobara <>
Thu Jul 18 12:57:40 CEST 2019


Hi,

 

I’m trying to generate a public key out of a private one, but I get a bad argument exception.

Without passing in a private key everything works as expected:

 

5> {A, B} = crypto:generate_key(ecdh, x25519).

{<<88,216,213,80,104,49,248,233,208,241,195,111,5,45,82,

   92,137,30,43,41,127,9,104,22,219,147,147,160,...>>,

 <<248,251,237,26,106,194,122,49,49,147,162,189,80,223,

   224,216,21,126,161,1,101,38,43,21,161,98,92,...>>}

 

But if I add a private key to the function:

 

6> crypto:generate_key(ecdh, x25519, B).      

** exception error: bad argument

     in function  crypto:ec_key_generate/2

        called as crypto:ec_key_generate({evp,x25519},

                                         <<248,251,237,26,106,194,122,49,49,147,162,189,80,223,

                                           224,216,21,126,161,1,101,38,43,21,161,98,92,...>>)

 

Also being new to this I’m a bit confused with the output of:

7> crypto:info_lib().

[{<<"OpenSSL">>,269488191,

  <<"OpenSSL 1.1.1c  28 May 2019">>}]

 

But my system openssl command reports a different version, but same date:

sh> openssl version

OpenSSL 1.0.2s  28 May 2019

 

Cheers,

Bernard

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190718/e22ee849/attachment.html>


More information about the erlang-questions mailing list