OpenSSL在使用X25519时的小坑
来源:互联网 发布:linux ping命令 编辑:程序博客网 时间:2024/06/06 04:33
OpenSSL从v1.1.0开始,就支持椭圆曲线密钥交换(ECDH)使用X25519曲线。
而OpenSSL里生成EC密钥对的示例程序大致是这样的:
EVP_PKEY_CTX *pctx, *kctx;EVP_PKEY *pkey = NULL, *params = NULL;/* Create the context for parameter generation */if(NULL == (pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL))) handleErrors();/* Initialise the parameter generation */if(1 != EVP_PKEY_paramgen_init(pctx)) handleErrors();/* We're going to use the ANSI X9.62 Prime 256v1 curve */if(1 != EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, NID_X9_62_prime256v1)) handleErrors();/* Create the parameter object params */if (!EVP_PKEY_paramgen(pctx, ¶ms)) handleErrors();/* Create the context for the key generation */if(NULL == (kctx = EVP_PKEY_CTX_new(params, NULL))) handleErrors();/* Generate the key */if(1 != EVP_PKEY_keygen_init(kctx)) handleErrors();if (1 != EVP_PKEY_keygen(kctx, &pkey)) handleErrors();
但是当你想把曲线从prime256v1改成X25519时,问题就出现了,OpenSSL会提示unknown group
。乍一看好像OpenSSL并不支持X25519。
其实只是X25519曲线的使用方式和其它曲线有点不太一样:
EVP_PKEY_CTX *pctx;EVP_PKEY *pkey= NULL;/* Create the context for parameter generation */if (NULL == (pctx = EVP_PKEY_CTX_new_id(NID_X25519, NULL))) handleErrors();/* Generate the key */if (1 != EVP_PKEY_keygen_init(pctx)) handleErrors();if (1 != EVP_PKEY_keygen(pctx, &pkey) handleErrors();
阅读全文
0 0
- OpenSSL在使用X25519时的小坑
- 关于OPENSSL在WINDOWS下编译和使用的坑
- OpenSSL 在Windows 下的使用
- openssl在tomcat里面的使用
- 在asio中使用OpenSSL
- OpenSSL在Windows下使用vs2010的编译安装
- 在你的 iOS App中 使用 OpenSSL 库
- 在你的 iOS App中 使用 OpenSSL 库
- 在你的 iOS App中 使用 OpenSSL 库 转发
- OpenSSL在linux下的编译安装与使用
- 在你的 iOS App中 使用 OpenSSL 库
- 在Java中使用openssl制作的双向认证
- 在vs2012的编译环境下使用openssl
- 在你的 iOS App中 使用 OpenSSL 库
- 在你的 iOS App中 使用 OpenSSL 库
- 在你的 iOS App中 使用 OpenSSL 库
- 如何在编译Python指定使用自定义安装的openssl
- 超级小白记录一下初次在ubuntu使用openssl库
- 8、使用setup设置网络
- linux 下 apache启动、停止、重启命令
- GemFire/Geode中的国际化(一)
- 安装VirtualBox的时候遇到的问题
- Spring 深入浅出核心技术(二)
- OpenSSL在使用X25519时的小坑
- 奶牛异或
- bootstrap
- Unity 脚本生命周期
- 设计模式之原型模式(Prototype)
- ManualResetEvent(转)
- 欢迎使用CSDN-markdown编辑器
- 经典算法分析与设计——最短加法链
- Android中通过Socket直接与RILD进行通信