- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试在 Java Card 的椭圆曲线上实现密码算法。
首先,我在 256 位椭圆曲线(NIST 椭圆曲线)上实现了它并且运行良好。
现在我想在 512 位曲线上测试它(而不是像 NIST 那样的 521)。我的卡支持这个大小,我找到了一个这个大小的椭圆曲线数据库(为密码学明确定义)。但是我遇到了一个奇怪的问题......
当我尝试初始化我的 key 时:
ECPublicKey pubKey = (ECPublicKey) KeyBuilder.buildKey(
KeyBuilder.TYPE_EC_FP_PUBLIC, (short) 0x0200, false);
pubKey.setFieldFP(new byte[] { (byte) 0x25, (byte) 0x37,
(byte) 0xD2, (byte) 0x9C, (byte) 0x8B, (byte) 0xFE,
(byte) 0x7D, (byte) 0x9F, (byte) 0x48, (byte) 0x98,
(byte) 0xF7, (byte) 0x60, (byte) 0xF8, (byte) 0x7D,
(byte) 0xBF, (byte) 0x63, (byte) 0x90, (byte) 0x6E,
(byte) 0x28, (byte) 0x99, (byte) 0x0A, (byte) 0x27,
(byte) 0x0C, (byte) 0xA6, (byte) 0x15, (byte) 0xD9,
(byte) 0x1D, (byte) 0xC4, (byte) 0x89, (byte) 0xA8,
(byte) 0xD0, (byte) 0xA1, (byte) 0xA0, (byte) 0xE7,
(byte) 0x52, (byte) 0x43, (byte) 0xB0, (byte) 0x39,
(byte) 0x01, (byte) 0x6A, (byte) 0x61, (byte) 0x43,
(byte) 0x5C, (byte) 0xA5, (byte) 0x91, (byte) 0xE9,
(byte) 0x4B, (byte) 0x1A, (byte) 0xF7, (byte) 0x60,
(byte) 0xC9, (byte) 0xAE, (byte) 0xE2, (byte) 0xCE,
(byte) 0xE0, (byte) 0x15, (byte) 0x53, (byte) 0x51,
(byte) 0x1C, (byte) 0x93, (byte) 0x0E, (byte) 0xF3,
(byte) 0xBA, (byte) 0x0B }, (short) 0x0000, (short) 0x0040);
函数 setFieldFP
引发了一个 CryptoException
,原因代码为 ILLEGAL_VALUE
,这意味着 key 长度不匹配......但是它确实(0x0200
是以位为单位的曲线大小,0X0040
是以字节为单位的素数长度)!
我说这真的很奇怪,因为如果我尝试使用以下值:
ECPublicKey pubKey = (ECPublicKey) KeyBuilder.buildKey(
KeyBuilder.TYPE_EC_FP_PUBLIC, (short) 0x0200, false);
pubKey.setFieldFP(new byte[] { (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF}, (short) 0x0000, (short) 0x0040);
工作正常...
所以我不得不得出结论,引发的 CryptoException
并不真正涉及参数的大小,因为在这两种情况下,大小是相同的...
那又怎样?我的卡只支持特定字段的椭圆曲线吗?有人遇到过这种问题吗?
最佳答案
您的质数不够大。对于 512 位 F(p) 上的曲线,您应该使用 512 位素数。但是,您的第一个字节 (byte) 0x25
以十六进制数字 2
开头。这意味着第一个字节首先以设置为 0
的 2 个二进制数字开头,这意味着您已经定义了一个 512 - 2 = 510 位素数。
请仅使用明确定义的曲线,例如 NIST P521 曲线或 BrainpoolP512r1 曲线。
关于java - Java Card 中的受限椭圆曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31185206/
我有 n 个圆圈,它们必须完美地围绕着一个椭圆,如下图所示: 在这张图片中,我需要找出椭圆周围每个圆的位置,并且还能够计算出完全适合这些周围圆的椭圆。 我知道的信息是每个圆的半径(都一样),以及圆的个
如何在three.js 中创建一个椭圆? 我看过这个: Drawing an ellipse in THREE.js 但是如果有人可以提供一个工作示例会很酷。 我试过这个: ellipse = new
我将使用哪种 SKPhysicsBody 主体类型来创建椭圆物理主体? 我知道我可以用直线做一条曲线,只是让它不是一个真正的椭圆,但似乎必须有某种方法来挤压一个圆或创建一个圆? 最佳答案 Create
我有一堆二维点。您可以在左图中看到它们。它们形成了某种带有几只兔子耳朵的环。我的目标是找到大的内循环/椭圆,您可以在右侧看到它。 什么样的算法对这种情况有用。 我尝试了 RANSAC 算法的变体(取
这个问题在这里已经有了答案: Ellipsis in the middle of a text (Mac style) (16 个答案) 关闭 7 年前。
我是 XAML 新手。我遇到了这个问题,我需要将符号图标或字体图标放入椭圆形状(因此它显示为圆圈内的图标)。但是,似乎 Ellipse 的 Fill 属性只需要 ImageBrush 和 ColorB
我是 OpenCV 的新手,正在学习进行一些图像处理。作为我项目的一部分,我遇到了将椭圆形式的图像补丁变形为目标椭圆的问题。据我所知,我需要计算两个补丁之间的仿射变换,然后将此变换扭曲到目标补丁中。浏
我希望能够使用 Graphics2D 实例在 BufferedImage 上绘图,并在形状的外部 填充颜色。如果这是矩形之类的形状,那会很容易,但我需要使用的形状是圆形。 用颜色填充一个圆很容易,只需
我正在尝试在 box2D (Cocos2D) 中创建一个椭圆对象。到目前为止,我已经为此使用了 b2CircleShape,但我意识到它不会再削减它了,我必须拥有椭圆形的 body 。可能吗?我试过使
我只是想知道是否有一种方法可以像我在绘画中制作的这个例子那样用拇指制作椭圆 slider : 现在我正在使用 style 但只适用于水平的silders。这是示例代码:
本文讲述了java实现画线、矩形、椭圆、字符串功能的实例代码。分享给大家供大家参考,具体如下: ?
我一直在阅读有关将圆拟合到数据的一些方法(如 this )。我想看看这些方法如何处理真实数据并考虑使用 R 来实现这一点。我尝试在 rseek 中搜索可以帮助解决此问题的软件包,但没有找到任何有用的信
当椭圆不使用此公式1旋转时。如果value = 1-指向椭圆,如果value> 1-外部,如果value #include #include struct Pt {int x, y;
已尝试搜索,但找不到任何内容。 我正在尝试使用数组和 for 循环绘制多个 2D 椭圆,我每秒都会重新绘制框架。问题是,我每次重新绘制时只得到一个椭圆,有人可以告诉我我的代码有什么问题吗? impor
是否可以在 Altair 图表内按照图表 x 和 y 变量的测量单位绘制线条和几何形状?图表可能是多面的,形状和线条取决于每个特定面中的数据。 可重现的示例: import pandas as pd
我有两个系列及其交点。我想在图表上有一个椭圆形(椭圆形),中心位于交叉点。应根据轴单位设置椭圆半径,以显示每个轴的感兴趣区域。 Highcharts.chart('container', {
有没有办法调整 Highcharts 中轴标签的行高?有时,对于断行标签,可能会出现重叠/间距问题,如果可以降低行高,这些问题会得到缓解。 正如您在下图中较长的红色标签中所见,自定义行高会很有帮助。有
我想在 android 中画一个椭圆/圆,但我无法让它显示出来。我可以使用低效的循环和 glVertex 在 C 的 OpenGL 中(而不是在 android 中)做得很好,但是 OpenGL ES
本文实例讲述了Android编程开发之在Canvas中利用Path绘制基本图形的方法。分享给大家供大家参考,具体如下: 在Android中绘制基本的集合图形,本程序就是自定义一个View组件,程序
<ellipse> 元素可以画一个椭圆 SVG 椭圆 - <ellipse> <ellipse> 元素可以画一个椭圆 椭圆与圆很相似。不同之处在于椭圆有不同的
我是一名优秀的程序员,十分优秀!