Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch with openssl private-key/public key generation #19

Open
davesyntiant opened this issue Sep 10, 2019 · 0 comments
Open

Mismatch with openssl private-key/public key generation #19

davesyntiant opened this issue Sep 10, 2019 · 0 comments

Comments

@davesyntiant
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant