Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a Curve25519 key pair in Terminal?

How can we generate a Curve25519 key pair from the command line?

We have a MacBook Air with Homebrew installed.

  1. Should we use OpenSSL or another command line tool?

  2. How do we use that tool to generate a Curve25519 key pair?

like image 621
ma11hew28 Avatar asked Apr 21 '17 15:04

ma11hew28


2 Answers

You can use the following command for generating the key pair:

openssl genpkey -algorithm x25519 -out x25519-priv.pem

And for extracting public key:

openssl pkey -in x25519-priv.pem -pubout -out x25519-pub.pem
like image 156
harryjohn Avatar answered Nov 11 '22 20:11

harryjohn


openssl in MacOS is apples own openssl that does not support Curve25519 you need to install it with brew

brew install openssl

and then link using PATH or using brew link --force openssl(not recommended) for example if you are using zsh

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

to check. if it worked just use the which command

which openssl

now if you see output like this you are good to go

/usr/local/opt/[email protected]/bin/openssl

now you can generate Curve25519 keys with using openssl

openssl genpkey -algorithm x25519 -out x25519-priv.pem
like image 1
Akbar30bill Avatar answered Nov 11 '22 21:11

Akbar30bill