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

WebCrypto: Add test cases for deriveBits with too large and non-multiple of 8 lengths #48471

Merged

Conversation

javifernandez
Copy link
Contributor

No description provided.

@@ -9,25 +9,33 @@ var algorithms = {
privateKey: {format: "raw", data: rawKey},
deriveAlg: {name: "HKDF", salt: salt, hash: "SHA-256", info: info},
derivation: new Uint8Array([49, 183, 214, 133, 48, 168, 99, 231, 23, 192, 129, 202, 105, 23, 182, 134, 80, 179, 221, 154, 41, 243, 6, 6, 226, 202, 209, 153, 190, 193, 77, 19]),
derivation384: new Uint8Array([49, 183, 214, 133, 48, 168, 99, 231, 23, 192, 129, 202, 105, 23, 182, 134, 80, 179, 221, 154, 41, 243, 6, 6, 226, 202, 209, 153, 190, 193, 77, 19, 165, 50, 181, 8, 254, 59, 122, 199, 25, 224,146, 248, 105, 105, 75, 84]),
derivation230: new Uint8Array([]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit nitpicky but perhaps we should make this one undefined as well (and same for the others)? Otherwise it may look a bit confusing here, like we're expecting an empty Uint8Array for 230 bits or so.

Suggested change
derivation230: new Uint8Array([]),
derivation230: undefined,

(or we could just remove it altogether?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, thanks.

Comment on lines 22 to 32
{length: 384, expected: undefined}, // should throw an exception, bigger than the key size
{length: 230, expected: algorithms["ECDH"].derivation230},
{length: 0, expected: emptyArray},
{length: null, expected: algorithms["ECDH"].derivation},
{length: undefined, expected: algorithms["ECDH"].derivation},
{length: "omitted", expected: algorithms["ECDH"].derivation }, // default value is null
],
"X25519": [
{length: 256, expected: algorithms["X25519"].derivation},
{length: 384, expected: undefined}, // should throw an exception, bigger than the key size
{length: 230, expected: algorithms["X25519"].derivation230},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{length: 384, expected: undefined}, // should throw an exception, bigger than the key size
{length: 230, expected: algorithms["ECDH"].derivation230},
{length: 0, expected: emptyArray},
{length: null, expected: algorithms["ECDH"].derivation},
{length: undefined, expected: algorithms["ECDH"].derivation},
{length: "omitted", expected: algorithms["ECDH"].derivation }, // default value is null
],
"X25519": [
{length: 256, expected: algorithms["X25519"].derivation},
{length: 384, expected: undefined}, // should throw an exception, bigger than the key size
{length: 230, expected: algorithms["X25519"].derivation230},
{length: 384, expected: undefined}, // should throw an exception, bigger than the output size
{length: 230, expected: algorithms["ECDH"].derivation230},
{length: 0, expected: emptyArray},
{length: null, expected: algorithms["ECDH"].derivation},
{length: undefined, expected: algorithms["ECDH"].derivation},
{length: "omitted", expected: algorithms["ECDH"].derivation }, // default value is null
],
"X25519": [
{length: 256, expected: algorithms["X25519"].derivation},
{length: 384, expected: undefined}, // should throw an exception, bigger than the output size
{length: 230, expected: algorithms["X25519"].derivation230},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@javifernandez javifernandez force-pushed the derive-bits-length-too-big branch from 06b245b to 738c993 Compare October 23, 2024 12:33
@javifernandez javifernandez requested a review from twiss October 23, 2024 12:33
Copy link
Member

@twiss twiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks!

@twiss twiss merged commit 75db68b into web-platform-tests:master Oct 23, 2024
19 checks passed
@twiss twiss changed the title Add test cases for 'too long' and 'not multilpe of 8' lengths. WebCrypto: Add test cases for deriveBits with too large and non-multiple of 8 lengths Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants