I created a brainpool EC on a nitro key hsm and want to use this for crypto operations with the .NET Framework e.g. System.Security.Cryptography.ECDiffieHellman
.
I extracted with pkcs11-tool --list-objects
the public key but get only one value, the EC_POINT.
So, how to I get the coordinate of this point?
Public Key Object; EC EC_POINT 320 bits
EC_POINT: 0451040defed7988b095679e5aca422382d949c2e7fd937646def25cf7eb5140d41f12d077ac615773952da53efad266c8642c6877b8b215d091ba687acafd3c33f35ffb5ca6aadaf248ef1a126cd55e0d0598
EC_PARAMS: 06092b2403030208010109
label: Brainpool #1
ID: 10
Usage: verify
This EC_POINT is DER encoded, I used this to extract the true value of the EC_POINT.
040defed7988b095679e5aca422382d949c2e7fd937646def25cf7
eb5140d41f12d077ac615773952da53efad266c8642c6877b8b215
d091ba687acafd3c33f35ffb5ca6aadaf248ef1a126cd55e0d0598
040defed7988b095679e5aca422382d949c2e7fd937646def25cf7
eb5140d41f12d077ac615773952da53efad266c8642c6877b8b215
d091ba687acafd3c33f35ffb5ca6aadaf248ef1a126cd55e0d0598
Is your public key. The first byte indicates that it is an uncompressed key (04
), which means that of the remaining bytes, the first half are the X coordinate and the second half are the Y coordinate.
Qx = 0defed7988b095679e5aca422382d949c2e7fd937646def25cf7eb5140d41f12d077ac615773952d
Qy = a53efad266c8642c6877b8b215d091ba687acafd3c33f35ffb5ca6aadaf248ef1a126cd55e0d0598
http://www.secg.org/sec1-v2.pdf, section 2.3.4 (Octet-String-to-Elliptic-Curve-Point Conversion).
(And since the parameters (06092b2403030208010109
) is the DER-oid 1.3.36.3.3.2.8.1.1.9 (brainpoolP320r1) everything looks correct, since Qx/Qy are 320-bit values)