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:
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.
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.
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
andverify
operations to the module.Just like with
encrypt
anddecrypt
, thesign
andverify
operations test suite rely on the ability to import and export a key of a support algorithm. As a result to supportsign
andverify
with a scope reduced to the HMAC algorithm, we need to implementimportKey
andexportKey
first.As
generateKey
laid a good base foundation for implementingimportKey
andexportKey
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:KeyGenerator
interface to be able to transparently generate a key, without having to resort to much preparation in theSubtleCrypto.GenerateKey
method itself, making us even closer to the specification.