I have a binary signed with ECDSA384
and I need to verify it using a particular cryptography library.
The first thing that needs to be done is to initialize the EC public key, which involves setting several parameters 'manually'. These parameters are the ones that make the following EC equation:
Elliptic Curve equation over $\operatorname{GF}(p): y^2=x^3+ax+b \pmod{p}.$
I need the parameters $a$, $b$, $p$ and $n$. (no idea what $n$ is)
The key I'm using is in PEM
format. I'm aware that the EC parameters can be extracted by doing:
openssl ec -in ec384.pem -noout -text
and I get
read EC key
Private-Key: (384 bit)
priv:
5d:b1:ef:88:fe:7b:f2:af:d8:cc:3a:04:89:09:34:
15:c4:17:7b:41:72:ee:32:7b:54:9a:e2:aa:fa:1d:
d1:47:1a:ef:fe:dc:d3:6b:51:fa:bd:c2:5e:66:c4:
42:d0:16
pub:
04:5e:ff:47:19:80:be:93:5f:8f:51:14:45:d5:40:
41:79:ca:48:be:85:97:bd:e2:0f:2b:a0:b2:7d:6c:
37:74:39:44:ff:50:67:74:30:a8:10:ac:89:a6:6a:
80:5a:1a:c9:82:ff:2a:51:84:38:c8:f6:af:e0:46:
e7:9f:d5:66:1b:20:75:7f:87:42:46:d9:6e:12:4f:
74:38:4d:f4:9f:b1:13:27:9a:10:a8:0c:6b:4b:1f:
f6:6c:bf:32:ee:a3:10
ASN1 OID: secp384r1
NIST CURVE: P-384
Still, I don't get the parameters I need from that output. It's not very clear to me if these parameters change from key to key or they are inherent to the curve being used, in my case, P-384
.
How can I get the parameters I need?
EDIT - might help
Apart from the fantastic answers, I have found this that might help:
The python
library ecpy
contains this information, e.g:
pip3 install ecpy
python3
>>> import ecpy.curves as ec
>>> ec.Curve.get_curve_names()
['stark256', 'frp256v1', 'secp521r1', 'secp384r1', ...]
>>> p384 = ec.Curve.get_curve('secp384r1')
>>> hex(p384.a)
'0xffff...ffc'
>>> hex(p384.b)
'0xb3312f...3ec2aef'
>>> hex(p384.order)
'0xfffffff...cc52973'
>>> hex(p384.field) # This is the modulus
'0xfffffff...00ffffffff'