openssl3.2 - exp - 选择最好的内建椭圆曲线

news2024/11/17 13:47:49

文章目录

    • openssl3.2 - exp - 选择最好的内建椭圆曲线
    • 概述
    • 笔记
    • 将 openssl ecparam -list_curves 实现迁移到自己的demo工程
    • 备注
    • END

openssl3.2 - exp - 选择最好的内建椭圆曲线

概述

在openssl中使用椭圆曲线, 只允许选择椭圆曲线的名字, 无法给定椭圆曲线的位数.
估计每种椭圆曲线都有固定的位数(bit prime field)
openssl.exe有命令可以列出全部的椭圆曲线列表

openssl ecparam -list_curves


D:\my_tmp>openssl ecparam -list_curves
  secp112r1 : SECG/WTLS curve over a 112 bit prime field
  secp112r2 : SECG curve over a 112 bit prime field
  secp128r1 : SECG curve over a 128 bit prime field
  secp128r2 : SECG curve over a 128 bit prime field
  secp160k1 : SECG curve over a 160 bit prime field
  secp160r1 : SECG curve over a 160 bit prime field
  secp160r2 : SECG/WTLS curve over a 160 bit prime field
  secp192k1 : SECG curve over a 192 bit prime field
  secp224k1 : SECG curve over a 224 bit prime field
  secp224r1 : NIST/SECG curve over a 224 bit prime field
  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
  prime192v1: NIST/X9.62/SECG curve over a 192 bit prime field
  prime192v2: X9.62 curve over a 192 bit prime field
  prime192v3: X9.62 curve over a 192 bit prime field
  prime239v1: X9.62 curve over a 239 bit prime field
  prime239v2: X9.62 curve over a 239 bit prime field
  prime239v3: X9.62 curve over a 239 bit prime field
  prime256v1: X9.62/SECG curve over a 256 bit prime field
  sect113r1 : SECG curve over a 113 bit binary field
  sect113r2 : SECG curve over a 113 bit binary field
  sect131r1 : SECG/WTLS curve over a 131 bit binary field
  sect131r2 : SECG curve over a 131 bit binary field
  sect163k1 : NIST/SECG/WTLS curve over a 163 bit binary field
  sect163r1 : SECG curve over a 163 bit binary field
  sect163r2 : NIST/SECG curve over a 163 bit binary field
  sect193r1 : SECG curve over a 193 bit binary field
  sect193r2 : SECG curve over a 193 bit binary field
  sect233k1 : NIST/SECG/WTLS curve over a 233 bit binary field
  sect233r1 : NIST/SECG/WTLS curve over a 233 bit binary field
  sect239k1 : SECG curve over a 239 bit binary field
  sect283k1 : NIST/SECG curve over a 283 bit binary field
  sect283r1 : NIST/SECG curve over a 283 bit binary field
  sect409k1 : NIST/SECG curve over a 409 bit binary field
  sect409r1 : NIST/SECG curve over a 409 bit binary field
  sect571k1 : NIST/SECG curve over a 571 bit binary field
  sect571r1 : NIST/SECG curve over a 571 bit binary field
  c2pnb163v1: X9.62 curve over a 163 bit binary field
  c2pnb163v2: X9.62 curve over a 163 bit binary field
  c2pnb163v3: X9.62 curve over a 163 bit binary field
  c2pnb176v1: X9.62 curve over a 176 bit binary field
  c2tnb191v1: X9.62 curve over a 191 bit binary field
  c2tnb191v2: X9.62 curve over a 191 bit binary field
  c2tnb191v3: X9.62 curve over a 191 bit binary field
  c2pnb208w1: X9.62 curve over a 208 bit binary field
  c2tnb239v1: X9.62 curve over a 239 bit binary field
  c2tnb239v2: X9.62 curve over a 239 bit binary field
  c2tnb239v3: X9.62 curve over a 239 bit binary field
  c2pnb272w1: X9.62 curve over a 272 bit binary field
  c2pnb304w1: X9.62 curve over a 304 bit binary field
  c2tnb359v1: X9.62 curve over a 359 bit binary field
  c2pnb368w1: X9.62 curve over a 368 bit binary field
  c2tnb431r1: X9.62 curve over a 431 bit binary field
  wap-wsg-idm-ecid-wtls1: WTLS curve over a 113 bit binary field
  wap-wsg-idm-ecid-wtls3: NIST/SECG/WTLS curve over a 163 bit binary field
  wap-wsg-idm-ecid-wtls4: SECG curve over a 113 bit binary field
  wap-wsg-idm-ecid-wtls5: X9.62 curve over a 163 bit binary field
  wap-wsg-idm-ecid-wtls6: SECG/WTLS curve over a 112 bit prime field
  wap-wsg-idm-ecid-wtls7: SECG/WTLS curve over a 160 bit prime field
  wap-wsg-idm-ecid-wtls8: WTLS curve over a 112 bit prime field
  wap-wsg-idm-ecid-wtls9: WTLS curve over a 160 bit prime field
  wap-wsg-idm-ecid-wtls10: NIST/SECG/WTLS curve over a 233 bit binary field
  wap-wsg-idm-ecid-wtls11: NIST/SECG/WTLS curve over a 233 bit binary field
  wap-wsg-idm-ecid-wtls12: WTLS curve over a 224 bit prime field
  Oakley-EC2N-3:
        IPSec/IKE/Oakley curve #3 over a 155 bit binary field.
        Not suitable for ECDSA.
        Questionable extension field!
  Oakley-EC2N-4:
        IPSec/IKE/Oakley curve #4 over a 185 bit binary field.
        Not suitable for ECDSA.
        Questionable extension field!
  brainpoolP160r1: RFC 5639 curve over a 160 bit prime field
  brainpoolP160t1: RFC 5639 curve over a 160 bit prime field
  brainpoolP192r1: RFC 5639 curve over a 192 bit prime field
  brainpoolP192t1: RFC 5639 curve over a 192 bit prime field
  brainpoolP224r1: RFC 5639 curve over a 224 bit prime field
  brainpoolP224t1: RFC 5639 curve over a 224 bit prime field
  brainpoolP256r1: RFC 5639 curve over a 256 bit prime field
  brainpoolP256t1: RFC 5639 curve over a 256 bit prime field
  brainpoolP320r1: RFC 5639 curve over a 320 bit prime field
  brainpoolP320t1: RFC 5639 curve over a 320 bit prime field
  brainpoolP384r1: RFC 5639 curve over a 384 bit prime field
  brainpoolP384t1: RFC 5639 curve over a 384 bit prime field
  brainpoolP512r1: RFC 5639 curve over a 512 bit prime field
  brainpoolP512t1: RFC 5639 curve over a 512 bit prime field
  SM2       : SM2 curve over a 256 bit prime field

比较每种椭圆曲线的质数域位数, 挑出最大的那个.

sect571k1 : NIST/SECG curve over a 571 bit binary field
sect571r1 : NIST/SECG curve over a 571 bit binary field

可知, 质数域位数最大的椭圆曲线有2个 : sect571k1 或者 sect571r1, 位数都是571位.

笔记

将 openssl ecparam -list_curves 实现迁移到自己的demo工程

想看看官方怎么实现的这个命令.

/*!
* \file exp017_ecparam_list_curves.cpp
* \note 看看openssl如何实现命令 openssl ecparam -list_curves
*/

#include "my_openSSL_lib.h"
#include <openssl/crypto.h>
#include <openssl/bio.h>
#include <openssl/ec.h>
#include <openssl/objects.h>

#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

#include "CMemHookRec.h"

void my_openssl_app();
int list_builtin_curves(BIO* out);

int main(int argc, char** argv)
{
	setvbuf(stdout, NULL, _IONBF, 0); // 清掉stdout缓存, 防止调用printf时阻塞
	mem_hook();

	my_openssl_app();

	mem_unhook();

    /*! run result
    list_builtin_curves, cnt = 82
    --------------------
    secp112r1           : -20SECG/WTLS curve over a 112 bit prime field
    secp112r2           : -20SECG curve over a 112 bit prime field
    secp128r1           : -20SECG curve over a 128 bit prime field
    secp128r2           : -20SECG curve over a 128 bit prime field
    secp160k1           : -20SECG curve over a 160 bit prime field
    secp160r1           : -20SECG curve over a 160 bit prime field
    secp160r2           : -20SECG/WTLS curve over a 160 bit prime field
    secp192k1           : -20SECG curve over a 192 bit prime field
    secp224k1           : -20SECG curve over a 224 bit prime field
    secp224r1           : -20NIST/SECG curve over a 224 bit prime field
    secp256k1           : -20SECG curve over a 256 bit prime field
    secp384r1           : -20NIST/SECG curve over a 384 bit prime field
    secp521r1           : -20NIST/SECG curve over a 521 bit prime field
    prime192v1          : -20NIST/X9.62/SECG curve over a 192 bit prime field
    prime192v2          : -20X9.62 curve over a 192 bit prime field
    prime192v3          : -20X9.62 curve over a 192 bit prime field
    prime239v1          : -20X9.62 curve over a 239 bit prime field
    prime239v2          : -20X9.62 curve over a 239 bit prime field
    prime239v3          : -20X9.62 curve over a 239 bit prime field
    prime256v1          : -20X9.62/SECG curve over a 256 bit prime field
    sect113r1           : -20SECG curve over a 113 bit binary field
    sect113r2           : -20SECG curve over a 113 bit binary field
    sect131r1           : -20SECG/WTLS curve over a 131 bit binary field
    sect131r2           : -20SECG curve over a 131 bit binary field
    sect163k1           : -20NIST/SECG/WTLS curve over a 163 bit binary field
    sect163r1           : -20SECG curve over a 163 bit binary field
    sect163r2           : -20NIST/SECG curve over a 163 bit binary field
    sect193r1           : -20SECG curve over a 193 bit binary field
    sect193r2           : -20SECG curve over a 193 bit binary field
    sect233k1           : -20NIST/SECG/WTLS curve over a 233 bit binary field
    sect233r1           : -20NIST/SECG/WTLS curve over a 233 bit binary field
    sect239k1           : -20SECG curve over a 239 bit binary field
    sect283k1           : -20NIST/SECG curve over a 283 bit binary field
    sect283r1           : -20NIST/SECG curve over a 283 bit binary field
    sect409k1           : -20NIST/SECG curve over a 409 bit binary field
    sect409r1           : -20NIST/SECG curve over a 409 bit binary field
    sect571k1           : -20NIST/SECG curve over a 571 bit binary field // !!! best one 
    sect571r1           : -20NIST/SECG curve over a 571 bit binary field // !!! best one
    c2pnb163v1          : -20X9.62 curve over a 163 bit binary field
    c2pnb163v2          : -20X9.62 curve over a 163 bit binary field
    c2pnb163v3          : -20X9.62 curve over a 163 bit binary field
    c2pnb176v1          : -20X9.62 curve over a 176 bit binary field
    c2tnb191v1          : -20X9.62 curve over a 191 bit binary field
    c2tnb191v2          : -20X9.62 curve over a 191 bit binary field
    c2tnb191v3          : -20X9.62 curve over a 191 bit binary field
    c2pnb208w1          : -20X9.62 curve over a 208 bit binary field
    c2tnb239v1          : -20X9.62 curve over a 239 bit binary field
    c2tnb239v2          : -20X9.62 curve over a 239 bit binary field
    c2tnb239v3          : -20X9.62 curve over a 239 bit binary field
    c2pnb272w1          : -20X9.62 curve over a 272 bit binary field
    c2pnb304w1          : -20X9.62 curve over a 304 bit binary field
    c2tnb359v1          : -20X9.62 curve over a 359 bit binary field
    c2pnb368w1          : -20X9.62 curve over a 368 bit binary field
    c2tnb431r1          : -20X9.62 curve over a 431 bit binary field
    wap-wsg-idm-ecid-wtls1: -20WTLS curve over a 113 bit binary field
    wap-wsg-idm-ecid-wtls3: -20NIST/SECG/WTLS curve over a 163 bit binary field
    wap-wsg-idm-ecid-wtls4: -20SECG curve over a 113 bit binary field
    wap-wsg-idm-ecid-wtls5: -20X9.62 curve over a 163 bit binary field
    wap-wsg-idm-ecid-wtls6: -20SECG/WTLS curve over a 112 bit prime field
    wap-wsg-idm-ecid-wtls7: -20SECG/WTLS curve over a 160 bit prime field
    wap-wsg-idm-ecid-wtls8: -20WTLS curve over a 112 bit prime field
    wap-wsg-idm-ecid-wtls9: -20WTLS curve over a 160 bit prime field
    wap-wsg-idm-ecid-wtls10: -20NIST/SECG/WTLS curve over a 233 bit binary field
    wap-wsg-idm-ecid-wtls11: -20NIST/SECG/WTLS curve over a 233 bit binary field
    wap-wsg-idm-ecid-wtls12: -20WTLS curve over a 224 bit prime field
    Oakley-EC2N-3       : -20
        IPSec/IKE/Oakley curve #3 over a 155 bit binary field.
        Not suitable for ECDSA.
        Questionable extension field!
    Oakley-EC2N-4       : -20
        IPSec/IKE/Oakley curve #4 over a 185 bit binary field.
        Not suitable for ECDSA.
        Questionable extension field!
    brainpoolP160r1     : -20RFC 5639 curve over a 160 bit prime field
    brainpoolP160t1     : -20RFC 5639 curve over a 160 bit prime field
    brainpoolP192r1     : -20RFC 5639 curve over a 192 bit prime field
    brainpoolP192t1     : -20RFC 5639 curve over a 192 bit prime field
    brainpoolP224r1     : -20RFC 5639 curve over a 224 bit prime field
    brainpoolP224t1     : -20RFC 5639 curve over a 224 bit prime field
    brainpoolP256r1     : -20RFC 5639 curve over a 256 bit prime field
    brainpoolP256t1     : -20RFC 5639 curve over a 256 bit prime field
    brainpoolP320r1     : -20RFC 5639 curve over a 320 bit prime field
    brainpoolP320t1     : -20RFC 5639 curve over a 320 bit prime field
    brainpoolP384r1     : -20RFC 5639 curve over a 384 bit prime field
    brainpoolP384t1     : -20RFC 5639 curve over a 384 bit prime field
    brainpoolP512r1     : -20RFC 5639 curve over a 512 bit prime field
    brainpoolP512t1     : -20RFC 5639 curve over a 512 bit prime field
    SM2                 : -20SM2 curve over a 256 bit prime field
    --------------------
    free map, g_mem_hook_map.size() = 0
    */

	return 0;
}

void my_openssl_app()
{
    BIO* bio_out = NULL;

    do {
        bio_out = BIO_new_fp(stdout, 0);
        if (NULL == bio_out)
        {
            break;
        }

        list_builtin_curves(bio_out);

    } while (false);

    if (NULL != bio_out)
    {
        BIO_free(bio_out);
        bio_out = NULL;
    }
}

int list_builtin_curves(BIO* out)
{
    int ret = 0;
    EC_builtin_curve* curves = NULL;
    size_t n, crv_len = EC_get_builtin_curves(NULL, 0);

    BIO_printf(out, "list_builtin_curves, cnt = %d\n", crv_len);

    curves = (EC_builtin_curve*)OPENSSL_malloc(sizeof(*curves) * crv_len);
    if (!EC_get_builtin_curves(curves, crv_len))
    {
        BIO_printf(out, "err\n");
        goto end;
    }
        
    
    BIO_printf(out, "--------------------\n");

    for (n = 0; n < crv_len; n++) {
        const char* comment = curves[n].comment;
        const char* sname = OBJ_nid2sn(curves[n].nid);

        if (comment == NULL)
            comment = "CURVE DESCRIPTION NOT AVAILABLE";
        if (sname == NULL)
            sname = "";

        BIO_printf(out, "  %-20s: -20%s\n", sname, comment);
    }

    BIO_printf(out, "--------------------\n");

    ret = 1;
end:
    OPENSSL_free(curves);
    return ret;
}

备注

在这里插入图片描述
从查到的资料看, ECC521就比普通的RSA位数强多了.
现在主流网站用的RSA证书位数都是4096(e.g. MS主站)
sect571k1, sect571r1的位数是571位, 强度应该更高吧.

END

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1506425.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

硬件工程师面试题梳理-百度硬件面试题

硬件工程师基本职责 在公司里面&#xff0c;硬件工程师的主要职责包括设计、开发和测试硬件系统&#xff0c;以满足产品需求和性能要求。他们负责确保硬件系统的可靠性、稳定性和可维护性&#xff0c;并与软件工程师和其他团队成员合作&#xff0c;以确保硬件和软件的协同工作…

22.网络游戏逆向分析与漏洞攻防-网络通信数据包分析工具-加载配置文件到分析工具界面

免责声明&#xff1a;内容仅供学习参考&#xff0c;请合法利用知识&#xff0c;禁止进行违法犯罪活动&#xff01; 如果看不懂、不知道现在做的什么&#xff0c;那就跟着做完看效果 内容参考于&#xff1a;易道云信息技术研究院VIP课 上一个内容&#xff1a;21.配置数据保存…

Django工具

一、分页器介绍 1.1、介绍 分页,就是当我们在页面中显示一些信息列表,内容过多,一个页面显示不完,需要分成多个页面进行显示时,使用的技术就是分页技术 在django项目中,一般是使用3种分页的技术: 自定义分页功能,所有的分页功能都是自己实现django的插件 django-pagin…

CSS常见用法 以及JS基础语法

CSS简介 首先我们要明白css对网页的页面效果就类似于化妆的效果,使得页面更好看 我们需要明白的就是CSS怎么使用即可 首先CSS的基本语法是<style></style>标签来修改 基本语法规范是选择器n条选择规范 例如 <style>p{color : red;} </style> 这里就是将…

ABAP接口-RFC连接(ABAP TO ABAP)

目录 ABAP接口-RFC连接&#xff08;ABAP TO ABAP&#xff09;创建ABAP连接RFC函数的调用 ABAP接口-RFC连接&#xff08;ABAP TO ABAP&#xff09; 创建ABAP连接 事务代码&#xff1a;SM59 点击创建&#xff0c;填写目标名称&#xff0c;选择连接类型&#xff1a; 填写主机名…

哈希表|242.有效的字母异位词

力扣题目链接 bool isAnagram(char* s, char* t) {int len_s strlen(s), len_t strlen(t);if(len_s ! len_t) {return false;}int table[26];memset(table, 0, sizeof(table));for(int i 0; i < len_s; i) {table[s[i] - a];}for(int i 0; i < len_t; i) {table[t[i…

Vue3中Vue Router的使用区别

在 Vue 3 中&#xff0c;useRouter 和 useRoute 是两个用于 Vue Router 的 Composition API 函数&#xff0c;它们的用途和返回的对象不同&#xff0c;接下来详细了解一下它们的区别以及如何正确使用它们。 useRouter useRouter 用于获取 router 实例&#xff0c;这个实例提供…

蓝桥杯每日一题(kmp)

//141 周期 求一个字符串的所有前缀的循环节出现的最大次数。也就是最小循环节 kmp算法求循环节&#xff1b; 将原串移动&#xff0c;移动后我们得知&#xff0c;四个黑色大括号完全相同。在下图所示的事例中&#xff0c;原串只有两个循环节&#xff0c;加一个红括号。k3加一…

线程的魔法:揭开现代操作系统并发执行的面纱

✨✨ 欢迎大家来访Srlua的博文&#xff08;づ&#xffe3;3&#xffe3;&#xff09;づ╭❤&#xff5e;✨✨ &#x1f31f;&#x1f31f; 欢迎各位亲爱的读者&#xff0c;感谢你们抽出宝贵的时间来阅读我的文章。 我是Srlua小谢&#xff0c;在这里我会分享我的知识和经验。&am…

WebMagic框架

1.webmagic框架 webmagic框架是一个Java实现的爬虫框架&#xff0c;底层依然是HttpClient和jsoup 组件&#xff1a; downloader&#xff1a;下载器组件PageProcessor&#xff1a;页面解析组件&#xff08;必须自定义&#xff09;scheculer&#xff1a;访问队列组件pipeline&am…

跨境电商三大趋势

跨境电商有着不断发展的三大趋势&#xff1a; 个性化定制&#xff1a;随着消费者需求的不断变化和个性化定制的潮流&#xff0c;跨境电商平台开始提供更多的定制化服务。消费者可以根据自己的需求选择产品的款式、材料和设计&#xff0c;从而获得更加个性化的产品体验。 无界销…

JDBC的学习记录

JDBC就是使用java语言操作关系型数据库的一套API。 JDBC&#xff08;Java Database Connectivity&#xff09;是Java语言中用于连接和操作数据库的一种标准接口。它提供了一组方法和类&#xff0c;使Java程序能够与各种不同类型的关系型数据库进行交互。 JDBC的主要功能包括建…

【notepad++工具使用之】批量加逗号

背景 在使用sql语句in关键字查询时&#xff0c;我们需要把数据用逗号进行隔开&#xff0c;在数据量非常少的时候&#xff08;十几二十个这样&#xff09;&#xff0c;可以手动的去加逗号分隔符&#xff1b; 但是遇到1000个怎么弄呢&#xff1f; 强大的Notepad 批量处理数据时…

讲解Python3内置模块之json编码解码方法

简介 JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式&#xff0c;它基于ECMAScript的一个子集。 JSON采用完全独立于语言的文本格式&#xff0c;这些特性使JSON成为理想的数据交换格式&#xff0c;易于人阅读和编写&#xff0c;同时也易于机器解析和生成&#…

学习笔记docker——容器通过网络通信

inspect-a&#xff1a;查看Linux中的网络细节。 docker inspect 容器id/容器名&#xff1a;查看容器的细节。 注意&#xff1a;上面有误&#xff0c;应该是接在docker0网桥上的容器只能通过容器的ip(eth0)之间进行通信&#xff0c;不能通过容器名称通信&#xff0c;要用容器名…

git搜索历史上曾经的文本内容

文章目录 问题在命令行搜索历史内容参考 问题 我们知道&#xff0c;github有文本搜索功能&#xff1a; 比如想搜哪些文件内容包括 aaa &#xff0c;在搜索框中输入 aaa &#xff1a; 但是&#xff0c;如果是历史上曾经有过的文本&#xff0c;这个办法貌似不行。 比如文件 tes…

Babel:现代JavaScript的桥梁

&#x1f90d; 前端开发工程师、技术日更博主、已过CET6 &#x1f368; 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 &#x1f560; 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 &#x1f35a; 蓝桥云课签约作者、上架课程《Vue.js 和 E…

实时工业控制系统的创新整合:PLC4X与CnosDB的高效数据采集与存储

在当代工业自动化系统中&#xff0c;实时监测和数据分析变得至关重要。本文将介绍如何通过集成Apache PLC4X与CnosDB&#xff0c;实现对工业控制系统中的PLC设备进行高效数据采集和存储&#xff0c;为工程师们提供更强大的数据分析和监测工具。 PLC的定义 PLC是可编程逻辑控制…

C++_lambda表达式

目录 前言-lambda表达式的介绍&#xff1a; 1、lambda表达式的作用 2、lambda表达式的优势 2.1 用lambda构建lambda变量 3、lambda表达式的类型 4、捕捉列表说明 4.1 传值捕捉 4.2 mutable 4.3 传引用捕捉 4.4 混合捕捉 5、lambda的大小 结语 前言-lambda表达…

基于springboot+vue实现早餐店点餐系统项目【项目源码+论文说明】计算机毕业设计

基于springbootvue实现早餐店点餐系统演示 摘要 多姿多彩的世界带来了美好的生活&#xff0c;行业的发展也是形形色色的离不开技术的发展。作为时代进步的发展方面&#xff0c;信息技术至始至终都是成就行业发展的重要秘密。不论何种行业&#xff0c;大到国家、企业&#xff0…