diafygi / diafygi/webcrypto-examples

ECDH deriveKey example should use HKDF

Open
#49 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
1.7k
Forks
191
PR merge metrics
No merged PRs in 30d

Description

The [ECDH examples](https://github.com/diafygi/webcrypto-examples#ecdh---derivekey) output the raw bits from the ECDH secret value, either directly or into the importKey operation of AES-CTR. As I pointed out [on the WebCrypto spec page](https://github.com/w3c/webcrypto/issues/193) this is not secure as the secret value is not uniformly random. The recommendation is usually to pass the value through some key derivation function such as HKDF including some context information such as the public keys used in the agreement (better: a hash of the full transcript of messages exchanged up to that point). See for instance Chapter 11 of [Serious Cryptography](https://nostarch.com/seriouscrypto) for a discussion of the issues with using the shared secret directly.

I think it should be possible to create an example that passes the ECDH secret bits into HKDF and then into AES-CTR importKey.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.