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

Throw on truncation in the X25519 and X448 derive bits operation #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

javifernandez
Copy link

@javifernandez javifernandez commented Sep 30, 2024

We have been discussing in webcrypto issue 369 about the possibility of throwing an OperationError exception when the ECDH deriveBits operation receives 'length' value that implies truncate the derived key material.

There is a PR 351 to implement that change in the Web Cryptography AP spec and this is a similar change for X25519 and X448.


Preview | Diff

@twiss
Copy link
Collaborator

twiss commented Oct 1, 2024

Thanks! Yeah, seems reasonable to me.

Since the length of the derived bits is fixed for both algorithms (256 for X25519 and 448 for X448) and doesn't depend on the algorithm's parameters like with ECDH, perhaps we could hoist this step up to be the first step in the algorithm, and just check that length is null or equal to that value?

(Otherwise I can also do so but next week, I'm officially speaking off this week ^.^)

@javifernandez
Copy link
Author

javifernandez commented Oct 2, 2024

Thanks! Yeah, seems reasonable to me.

Since the length of the derived bits is fixed for both algorithms (256 for X25519 and 448 for X448) and doesn't depend on the algorithm's parameters like with ECDH, perhaps we could hoist this step up to be the first step in the algorithm, and just check that length is null or equal to that value?

Yeah, that's precisely how I've implemented it.

@panva
Copy link
Contributor

panva commented Oct 3, 2024

Please see w3c/webcrypto#351 (comment), this should not land in this state.

@javifernandez
Copy link
Author

Please see w3c/webcrypto#351 (comment), this should not land in this state.

The idea is that this PR is dependent on the result of the discussion in issue #351.

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

Successfully merging this pull request may close these issues.

3 participants