枚举Java中可用的所有椭圆曲线名称的方法? [英] Way to enumerate all elliptic curve names available in Java?

查看:65
本文介绍了枚举Java中可用的所有椭圆曲线名称的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有某种方法可以枚举所有可以赋予的椭圆曲线名称 ECGenParameterSpec 构造函数?还是只需要在墙上扔一大堆曲线名称,看看当您尝试使用它们时,哪些会或哪些不会引起误解?

Is there some way to enumerate all of the elliptic curve names that can be given to the ECGenParameterSpec constructor? Or do you have to just throw a big list of curve names at the wall and see which ones do or don't throw execeptions when you try to use them?

推荐答案

这在很大程度上取决于您要使用的提供程序.如 user69513 所述,您需要查阅文档.这是最基本的问题.

It depends very much on the provider you want to use. As stated by user69513, you'll want to consult the documentation. And there lies the most basic of problems.

对于SunEC提供商,找不到该文档,也没有公开的信息来源.但是通过浏览sunec.jar中的公开类,我们找到了 CurveDB 类和一个方法 getSupportedCurves .可以使用反射来称呼它:

For the SunEC provider, the documentation is nowhere to be found, nor are the sources available to the public. But by going through the exposed classes in sunec.jar we find the CurveDB class and a method getSupportedCurves. One could call that using reflection:

public static void main(String[] args) throws Exception {
    Method method = sun.security.ec.CurveDB.class.getDeclaredMethod("getSupportedCurves", null);
    method.setAccessible(true);
    Collection result = (Collection) method.invoke(null, null);
    for (Object object : result) {
        System.out.println(object);
    }
}

这为您提供了充分的保密性:

This provides you with full discolure:

secp112r1 (1.3.132.0.6)
secp112r2 (1.3.132.0.7)
secp128r1 (1.3.132.0.28)
secp128r2 (1.3.132.0.29)
secp160k1 (1.3.132.0.9)
secp160r1 (1.3.132.0.8)
secp160r2 (1.3.132.0.30)
secp192k1 (1.3.132.0.31)
secp192r1 [NIST P-192, X9.62 prime192v1] (1.2.840.10045.3.1.1)
secp224k1 (1.3.132.0.32)
secp224r1 [NIST P-224] (1.3.132.0.33)
secp256k1 (1.3.132.0.10)
secp256r1 [NIST P-256, X9.62 prime256v1] (1.2.840.10045.3.1.7)
secp384r1 [NIST P-384] (1.3.132.0.34)
secp521r1 [NIST P-521] (1.3.132.0.35)
X9.62 prime192v2 (1.2.840.10045.3.1.2)
X9.62 prime192v3 (1.2.840.10045.3.1.3)
X9.62 prime239v1 (1.2.840.10045.3.1.4)
X9.62 prime239v2 (1.2.840.10045.3.1.5)
X9.62 prime239v3 (1.2.840.10045.3.1.6)
sect113r1 (1.3.132.0.4)
sect113r2 (1.3.132.0.5)
sect131r1 (1.3.132.0.22)
sect131r2 (1.3.132.0.23)
sect163k1 [NIST K-163] (1.3.132.0.1)
sect163r1 (1.3.132.0.2)
sect163r2 [NIST B-163] (1.3.132.0.15)
sect193r1 (1.3.132.0.24)
sect193r2 (1.3.132.0.25)
sect233k1 [NIST K-233] (1.3.132.0.26)
sect233r1 [NIST B-233] (1.3.132.0.27)
sect239k1 (1.3.132.0.3)
sect283k1 [NIST K-283] (1.3.132.0.16)
sect283r1 [NIST B-283] (1.3.132.0.17)
sect409k1 [NIST K-409] (1.3.132.0.36)
sect409r1 [NIST B-409] (1.3.132.0.37)
sect571k1 [NIST K-571] (1.3.132.0.38)
sect571r1 [NIST B-571] (1.3.132.0.39)
X9.62 c2tnb191v1 (1.2.840.10045.3.0.5)
X9.62 c2tnb191v2 (1.2.840.10045.3.0.6)
X9.62 c2tnb191v3 (1.2.840.10045.3.0.7)
X9.62 c2tnb239v1 (1.2.840.10045.3.0.11)
X9.62 c2tnb239v2 (1.2.840.10045.3.0.12)
X9.62 c2tnb239v3 (1.2.840.10045.3.0.13)
X9.62 c2tnb359v1 (1.2.840.10045.3.0.18)
X9.62 c2tnb431r1 (1.2.840.10045.3.0.20)

这篇关于枚举Java中可用的所有椭圆曲线名称的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆