tiny-ECDH-c icon indicating copy to clipboard operation
tiny-ECDH-c copied to clipboard

Mismatch with openssl private-key/public key generation

Open davesyntiant opened this issue 4 years ago • 0 comments

I was trying to verify the implementation against openssl, and this library doesn't create the same public-key from a private key.

I generated reference data with the following command: openssl ecparam -name sect233k1 -out sect233k1.pem openssl genpkey -paramfile sect233k1.pem -text -out prv_key.pem

If I run tiny-ECDH with the -DECC_CURVE=NIST_K233, and I feed in the private key from below, (starting at 0x22), I get a different public key output.

**prva[0] = 0x22; prva[1] = 0xa0; ...

assert(ecdh_generate_keys(puba, prva));**

Is there anything in the order of private key bytes that I need to do?

prv_key.pem output -----BEGIN PRIVATE KEY----- MH4CAQAwEAYHKoZIzj0CAQYFK4EEABoEZzBlAgEBBB4AIqCLwypv1g0HbqYx3oGu nJ0NRy4SMico04gPkmGhQAM+AAQALdAhSNtJVEMAE1DU8P674eeCl50LY7uoC+xS spIB3H1RSLjsLFPUo5aHjY5IdgQlNFYPNXLTsn/tYGE= -----END PRIVATE KEY----- Private-Key: (232 bit) priv: 22:a0:8b:c3:2a:6f:d6:0d:07:6e:a6:31:de:81:ae: 9c:9d:0d:47:2e:12:32:27:28:d3:88:0f:92:61 pub: 04:00:2d:d0:21:48:db:49:54:43:00:13:50:d4:f0: fe:bb:e1:e7:82:97:9d:0b:63:bb:a8:0b:ec:52:b2: 92:01:dc:7d:51:48:b8:ec:2c:53:d4:a3:96:87:8d: 8e:48:76:04:25:34:56:0f:35:72:d3:b2:7f:ed:60: 61 ASN1 OID: sect233k1 NIST CURVE: K-233

davesyntiant avatar Sep 10 '19 15:09 davesyntiant