latchset / kryoptic

a pkcs#11 software token written in Rust
GNU General Public License v3.0
10 stars 4 forks source link

Add support for ECDH #61

Closed Jakuje closed 3 months ago

Jakuje commented 3 months ago

This adds a support for the simple ECDH with and without cofactor and with some possible shared data and hashing.

Test vectors I found now cover just the raw ECDH without shared data as I did not find usable vectors for the other variants. The vectors inform about failure reason, which can be in the following steps, which we do not execute (they are also in the pyca test vectors but I was not able to figure out how they are filtered out).

I am also not sure if it makes sense to run both init and resp test vectors (I saw both of them included in the pyca, but only one executed?).

I would also like to do some tests shared data to at least execute the code paths to OpenSSL.

Possible extension might be the MQV (not sure if implemented in OpenSSL though).

Opening now as a draft as it will most likely need some final touches.

Jakuje commented 3 months ago

Addressed the comments. I would like to add some more tests for different configuration (shared data, cofactor, digests before merging (and fix the UNIQUE_ID as mentioned in your review).

Jakuje commented 3 months ago

The X963KDF variant is obviously broken: openssl/openssl/issues/24750 -- not sure if it is important though. I can workaround the tests with setting the expected key length ...

simo5 commented 3 months ago

The X963KDF variant is obviously broken: openssl/openssl/issues/24750 -- not sure if it is important though. I can workaround the tests with setting the expected key length ...

I buy the upstream argument that X963KDF requires to explicitly request for a length, I do not like that it has to be passed in as a param ... but well ...what can you do, that's their API.