0

I have set a connection with facebook.com and I need the point that is used in the signature. I have the public key and the certificate. Also with the command:

openssl ec -pubin -in facebook_pub.key -noout -text -param_enc explicit

I get that output:

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

With this output I can see the prime, A,B and the generator. But I can see Px and Py. Anyone knows how I can find it?

1 Answer 1

3

Here's a dreadfully inelegant way of getting the coordinates.

According to RFC 5480 section 2.2 the definition of ECPoint is inside SEC1 (section 2.3.4).

And the essence of that section is simply:

  • remove 0x04 tag byte
  • take remaining bytes and
  • set left half as X
  • and right half as Y.

I've done this below with the fastecdsa Python module.

###Grab X component Ignore first byte. (Just a tag value.)

$ 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 component ("Y" must be the rest of the string after the "X" component. I. e. after the "22ea" part.)

$ openssl ec -pubin -in facebook_pub.key -noout -text 2>/dev/null | grep '^    ' | sed 's/://g' | xargs echo | sed 's/ //g'

04a0f18cafa73988685b13560e1515b4a745ef1bc7e5853c2b04d4658a313122eaa392ed649dba6581e3b61276d8b30b45f1ff0a28149c4fdc73a9b3492da076d3

###Install "fastecdsa" python package
$ time pip install fastecdsa Collecting fastecdsa Downloading fastecdsa-1.6.1.tar.gz Building wheels for collected packages: fastecdsa Running setup.py bdist_wheel for fastecdsa ... done Stored in directory: /home/User/.cache/pip/wheels/93/8a/d3/be7fc222c030383ac6313be85c602762daafc2cac8fd547e44 Successfully built fastecdsa Installing collected packages: fastecdsa Successfully installed fastecdsa-1.6.1

real    0m19.002s
user    0m4.909s
sys     0m4.102s

###Use inside ipython $ 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)
<ipython-input-18-fb7bd27a246d> in <module>()
----> 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 <P256>

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]: <fastecdsa.curve.Curve instance at 0x6fffeb1b5a8>

As you can see above: fastecdsa will throw an error if you supply invalid arguments (such as "1, 2, curve=P256") to the "Point(...)" constructor.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .