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

[2/3] Implement the exportKey and importKey operations with support for AES algorithms #31

Merged
merged 6 commits into from
Mar 28, 2023

Conversation

oleiade
Copy link
Member

@oleiade oleiade commented Mar 20, 2023

What this is

This PR implements to support the importKey and exportKey operations. To keep Pull Requests as small and manageable as possible, It only implements support for the AES family of algorithms.

⚠️ This PR is based on #30 and should only be merged once it is itself merged in main ✋🏻

The exportKey operation allows exporting an existing CryptoKey object into its raw format representation (note that this PR does not support the JWK format) as an ArrayBuffer, for being either written down to storage or reimported in a different context.

The importKey operation does the opposite. It allows importing of a key in its raw (note that here too, this PR does not support the JWK format) representation format (an ArrayBuffer) as a CryptoKey object.

🟢 While the PR shows +400 changes, roughly half of them are from the official test suites, which do not need to be reviewed 🟢

Review

Test suite

While the PR might look big at first glance, you can safely disregard and ignore the files in the webcrypto/tests folder. Those files are directly imported and slightly adapted from the official test suite so that they are runnable in k6, but we haven't written those originally. We won't make any functional changes to them, as they are our safety net, ensuring that our implementation matches the specifications expectation (and that what we do is 🥁 safe).

References

This PR is the second chain of 3 implementing support for key generation (1.), import/export (2.), and encryption/decryption using them. We intend to merge these in order in master: 1->2->3.

@oleiade oleiade added the enhancement New feature or request label Mar 20, 2023
@oleiade oleiade self-assigned this Mar 20, 2023
@oleiade oleiade changed the title [2/3] Feature/import key export key symmetric [2/3] Implement the exportKey and importKey operations with support for AES algorithms Mar 20, 2023
@mstoykov
Copy link
Contributor

Comment on the PR description: Can we update the README in all of those PRs and

  1. put the stuff that is now supported
  2. add all the things that do not work in there as well. Like for example here the support for jwk format.

Copy link

@imiric imiric left a comment

Choose a reason for hiding this comment

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

Nice work 👍

The only blocker for me is the panic. The other comments are minor suggestions.

webcrypto/subtle_crypto.go Outdated Show resolved Hide resolved
webcrypto/tests/import_export/symmetric.js Outdated Show resolved Hide resolved
webcrypto/subtle_crypto.go Outdated Show resolved Hide resolved
@oleiade oleiade force-pushed the feature/generateKey-symmetric branch 4 times, most recently from 68abb91 to a2cd5eb Compare March 27, 2023 15:32
@oleiade oleiade force-pushed the feature/importKey-exportKey-symmetric branch 4 times, most recently from d5d54c8 to 9060976 Compare March 27, 2023 16:15
@oleiade oleiade force-pushed the feature/generateKey-symmetric branch from a2cd5eb to 34fa553 Compare March 27, 2023 16:18
@oleiade oleiade force-pushed the feature/importKey-exportKey-symmetric branch from 9060976 to b30f6cc Compare March 27, 2023 16:33
Copy link

@imiric imiric left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@oleiade oleiade force-pushed the feature/generateKey-symmetric branch from 575c685 to 86e837f Compare March 28, 2023 08:41
@oleiade oleiade force-pushed the feature/importKey-exportKey-symmetric branch from 9de2272 to a2a2a71 Compare March 28, 2023 08:42
Base automatically changed from feature/generateKey-symmetric to main March 28, 2023 08:48
Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

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

My only request can likely be fixed later, on some kind of polishing pass

webcrypto/goja.go Show resolved Hide resolved
This commit imports and adapts the WebCrypto test suite to work within
the k6 context. We also commented out algorithms that are not yet
implemented.
@oleiade oleiade force-pushed the feature/importKey-exportKey-symmetric branch from a2a2a71 to f5585b0 Compare March 28, 2023 08:56
@oleiade oleiade merged commit ae80034 into main Mar 28, 2023
@oleiade oleiade deleted the feature/importKey-exportKey-symmetric branch March 28, 2023 08:57
@oleiade oleiade mentioned this pull request Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants