我已经设置了与facebook.com的连接,我需要签名中使用的点。我有公钥和证书。也是通过以下命令:
openssl ec -pubin -in facebook_pub.key -noout -text -param_enc explicit我得到了输出:
read EC key
Public-Key: (256 bit)
pub:
04:a0:f1:8c:af:a7:39:88:68:5b:13:56:0e:15:15:
b4:a7:45:ef:1b:c7:e5:85:3c:2b:04:d4:65:8a:31:
31:22:ea:a3:92:ed:64:9d:ba:65:81:e3:b6:12:76:
d8:b3:0b:45:f1:ff:0a:28:14:9c:4f:dc:73:a9:b3:
49:2d:a0:76:d3
Field Type: prime-field
Prime:
00:ff:ff:ff:ff:00:00:00:01:00:00:00:00:00:00:
00:00:00:00:00:00:ff:ff:ff:ff:ff:ff:ff:ff:ff:
ff:ff:ff
A:
00:ff:ff:ff:ff:00:00:00:01:00:00:00:00:00:00:
00:00:00:00:00:00:ff:ff:ff:ff:ff:ff:ff:ff:ff:
ff:ff:fc
B:
5a:c6:35:d8:aa:3a:93:e7:b3:eb:bd:55:76:98:86:
bc:65:1d:06:b0:cc:53:b0:f6:3b:ce:3c:3e:27:d2:
60:4b
Generator (uncompressed):
04:6b:17:d1:f2:e1:2c:42:47:f8:bc:e6:e5:63:a4:
40:f2:77:03:7d:81:2d:eb:33:a0:f4:a1:39:45:d8:
98:c2:96:4f:e3:42:e2:fe:1a:7f:9b:8e:e7:eb:4a:
7c:0f:9e:16:2b:ce:33:57:6b:31:5e:ce:cb:b6:40:
68:37:bf:51:f5
Order:
00:ff:ff:ff:ff:00:00:00:00:ff:ff:ff:ff:ff:ff:
ff:ff:bc:e6:fa:ad:a7:17:9e:84:f3:b9:ca:c2:fc:
63:25:51
Cofactor: 1 (0x1)
Seed:
c4:9d:36:08:86:e7:04:93:6a:66:78:e1:13:9d:26:
b7:81:9f:7e:90有了这个输出,我可以看到素数A,B和发生器。但我能看到Px和Py。有人知道我怎么能找到它吗?
发布于 2018-01-05 23:42:20
这里有一种非常不雅致的方法来获取坐标。
根据RFC 5480节2.2,ECPoint的定义在SEC1 (第2.3.4条)中。
这一节的实质是:
0x04标记字节我在下面的坚牢 Python模块中完成了这一工作。
###Grab X组件忽略第一个字节。(只是一个标记值。)
$ openssl ec -pubin -in facebook_pub.key -noout -text -conv_form compressed 2>/dev/null | grep '^ ' | sed 's/://g' | xargs echo | sed 's/ //g'
03a0f18cafa73988685b13560e1515b4a745ef1bc7e5853c2b04d4658a313122ea###Grab Y组件("Y“必须是"X”组件之后的字符串的其余部分。即在“22 e.”部分之后)
$ openssl ec -pubin -in facebook_pub.key -noout -text 2>/dev/null | grep '^ ' | sed 's/://g' | xargs echo | sed 's/ //g'04a0f18cafa73988685b13560e1515b4a745ef1bc7e5853c2b04d4658a313122eaa392ed649dba6581e3b61276d8b30b45f1ff0a28149c4fdc73a9b3492da076d3
###Install“Collecting”python包$ time pip安装快速安装收集快件下载快捷键-1.6.1.tar.gz收集包的建筑车轮:运行setup.py bdist_wheel的快捷包。完成存储在目录中: /home/User/.cache/pip/wheels/93/8a/d3/be7fc222c030383ac6313be85c602762daafc2cac8fd547e44成功地构建了Successfully,安装了收集的软件包: Successfully成功地安装了Successfully 1.6.1
real 0m19.002s
user 0m4.909s
sys 0m4.102sipython内部的###Use $ ipython
In [1]: from fastecdsa.point import Point
In [2]: from fastecdsa.point import P256
In [3]: x=0xa0f18cafa73988685b13560e1515b4a745ef1bc7e5853c2b04d4658a313122ea
In [4]: y=0xa392ed649dba6581e3b61276d8b30b45f1ff0a28149c4fdc73a9b3492da076d3
In [5]: Point(1,2, curve=P256)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in ()
----> 1 Point(1,2, curve=P256)
/usr/lib/python2.7/site-packages/fastecdsa/point.pyc in __init__(self, x, y, curve)
12 def __init__(self, x, y, curve=P256):
13 if not curve.is_point_on_curve((x, y)):
---> 14 raise ValueError('(x, y) coordinates are not on curve <{}>'.format(curve.name))
15 else:
16 self.x = x
ValueError: (x, y) coordinates are not on curve
In [6]: p=Point(x, y, curve=P256)
In [7]: p.x
Out[7]: 72796836896024250540670287871159592541946330786250779466423542213376197337834L
In [8]: p.y
Out[8]: 73986592417019630365603572314878953642162012803095695018690968405918923912915L
In [9]: p.curve
Out[9]: 正如您在上面看到的:如果您向“Point(.)”提供无效的参数(如"1,2,curve=P256"),那么fastecdsa将引发错误。构造函数。
https://security.stackexchange.com/questions/176790
复制相似问题