Implement crypto.subtle.sign/verify with HMAC (#34223)

* Allow importing HMAC keys

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Implement crypto.subtle.sign with HMAC

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Implement crypto.subtle.verify with HMAC

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2024-11-11 20:32:51 +01:00 committed by GitHub
parent deddcf2c7a
commit 8d3d7b7403
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 461 additions and 531 deletions

View file

@ -26,13 +26,13 @@ interface SubtleCrypto {
Promise<any> decrypt(AlgorithmIdentifier algorithm,
CryptoKey key,
BufferSource data);
// Promise<any> sign(AlgorithmIdentifier algorithm,
// CryptoKey key,
// BufferSource data);
// Promise<any> verify(AlgorithmIdentifier algorithm,
// CryptoKey key,
// BufferSource signature,
// BufferSource data);
Promise<any> sign(AlgorithmIdentifier algorithm,
CryptoKey key,
BufferSource data);
Promise<any> verify(AlgorithmIdentifier algorithm,
CryptoKey key,
BufferSource signature,
BufferSource data);
Promise<any> digest(AlgorithmIdentifier algorithm,
BufferSource data);
@ -92,6 +92,18 @@ dictionary AesCtrParams : Algorithm {
required [EnforceRange] octet length;
};
// https://w3c.github.io/webcrypto/#dfn-HmacImportParams
dictionary HmacImportParams : Algorithm {
required HashAlgorithmIdentifier hash;
[EnforceRange] unsigned long length;
};
// https://w3c.github.io/webcrypto/#dfn-HmacKeyAlgorithm
dictionary HmacKeyAlgorithm : KeyAlgorithm {
required KeyAlgorithm hash;
required unsigned long length;
};
// https://w3c.github.io/webcrypto/#hkdf-params
dictionary HkdfParams : Algorithm {
required HashAlgorithmIdentifier hash;