简体   繁体   中英

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?

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

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

And for extracting pubic key:

openssl pkey -in x25519-priv.pem -pubout -out x25519-pub.pem

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/openssl@1.1/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/openssl@1.1/bin/openssl

now you can generate Curve25519 keys with using openssl

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM