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

[1/3] Implement the generateKey operation with support for HMAC algorithm #35

Merged
merged 9 commits into from
Mar 31, 2023

Conversation

oleiade
Copy link
Member

@oleiade oleiade commented Mar 30, 2023

What is this?

This Pull Request adds support for the HMAC algorithm to the subtle.crypto.generateKey operation.

Our plan moving forward is to go breadth first, and implement as much of the WebCrypto API's surface, and only later to add support for more algorithms. As a result this PR comes in with the intention to support the ability to implement the sign and verify operations to the module.

Just like with encrypt and decrypt, the sign and verify operations test suite rely on the ability to import and export a key of a support algorithm. As a result to support sign and verify with a scope reduced to the HMAC algorithm, we need to implement importKey and exportKey first.

As generateKey laid a good base foundation for implementing importKey and exportKey efficiently with AES support, I decided to once again start with that operation for HMAC.

Because this is the first algorithm past the AES family currently supported, it led to a few valuable redesigns of how the SubtleCrypto.GenerateKey method works at the moment:

  1. It led for instance to introducing the KeyGenerator interface to be able to transparently generate a key, without having to resort to much preparation in the SubtleCrypto.GenerateKey method itself, making us even closer to the specification.
  2. It also led to introduce constructors for the params object, so that we can handle the whole logic of converting goja objects in Go structs in an easier and more "hidden away" manner.

@oleiade oleiade self-assigned this Mar 30, 2023
@oleiade oleiade added the enhancement New feature or request label Mar 30, 2023
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.

LGTM!

did leave some comments that are not blocking

webcrypto/hmac.go Show resolved Hide resolved
webcrypto/hmac.go Outdated Show resolved Hide resolved
webcrypto/hmac.go Outdated Show resolved Hide resolved
@oleiade oleiade force-pushed the feature/generateKey-hmac branch 2 times, most recently from 135f983 to 4f79696 Compare March 30, 2023 15:09
@oleiade oleiade changed the title Add support for the HMAC algorithm to the subtle.crypto.generateKey operation [1/3] Implement the generateKey operation with support for HMAC algorithm Mar 30, 2023
Copy link

@codebien codebien left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, the null dependency should be addressed the rest are minor.

README.md Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
webcrypto/aes.go Show resolved Hide resolved
webcrypto/hmac.go Show resolved Hide resolved
@oleiade oleiade merged commit da6e943 into main Mar 31, 2023
@oleiade oleiade deleted the feature/generateKey-hmac branch March 31, 2023 08:39
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