X25519(Curve25519)椭圆曲线密钥生成

本文详细介绍了OpenSSL支持的各种椭圆曲线类型,包括secp256k1、secp384r1、secp521r1等,并提供了生成X25519、Ed25519和SM2椭圆曲线密钥的命令。同时,文章还解释了如何使用SM2进行数字签名和加密解密操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查询openssl当前版本支持的椭圆曲线类型(该列表虽并不包括x25519,实际上是支持的)

$ openssl ecparam -list_curves
  secp256k1 : SECG curve over a 256 bit prime field
  secp384r1 : NIST/SECG curve over a 384 bit prime field
  secp521r1 : NIST/SECG curve over a 521 bit prime field
  prime256v1: X9.62/SECG curve over a 256 bit prime field

生成Curve25519椭圆曲线密钥(该密钥专门用于ECDH密钥协商)

For X25519 and X448, it's treated as a distinct algorithm but not as one of the curves listed with ecparam -list_curves option. You can use the following command to generate an X25519 key:

openssl genpkey -algorithm X25519 -out xkey.pem

生成Ed25519椭圆曲线签名密钥(专用于数字签名)

备注:The ability to generate X25519 keys was added in OpenSSL 1.1.0. The ability to generate X448, ED25519 and ED448 keys was added in OpenSSL 1.1.1.

openssl genpkey -algorithm ED25519 -out xkey.pem

SM2椭圆数字签名/加解密密钥

The SM2 algorithm supports sign, verify, encrypt and decrypt operations. For the sign and verify operations, SM2 requires an ID string to be passed in.
Sign some data using an SM2(7) private key and a specific ID:

openssl pkeyutl -sign -in file -inkey sm2.key -out sig -rawin -digest sm3 -pkeyopt sm2_id:someid

Verify some data using an SM2(7) certificate and a specific ID:

openssl pkeyutl -verify -certin -in file -inkey sm2.cert -sigfile sig -rawin -digest sm3 -pkeyopt sm2_id:someid

参考资料:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值