Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions webcrypto/subtle_crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (sc *SubtleCrypto) Sign(algorithm, key, data goja.Value) *goja.Promise {
// 10.
switch normalized.Name {
case HMAC:
keyAlgorithm, ok := ck.Algorithm.(HMACKeyAlgorithm)
keyAlgorithm, ok := ck.Algorithm.(hasHash)
if !ok {
reject(NewError(InvalidAccessError, "key algorithm does not describe a HMAC key"))
return
Expand All @@ -278,9 +278,9 @@ func (sc *SubtleCrypto) Sign(algorithm, key, data goja.Value) *goja.Promise {
return
}

hashFn, err := keyAlgorithm.HashFn()
if err != nil {
reject(err)
hashFn, ok := getHashFn(keyAlgorithm.hash())
if !ok {
reject(NewError(NotSupportedError, "unsupported hash algorithm "+keyAlgorithm.hash()))
return
}

Expand Down Expand Up @@ -374,7 +374,7 @@ func (sc *SubtleCrypto) Verify(algorithm, key, signature, data goja.Value) *goja

switch normalizedAlgorithm.Name {
case HMAC:
keyAlgorithm, ok := ck.Algorithm.(HMACKeyAlgorithm)
keyAlgorithm, ok := ck.Algorithm.(hasHash)
if !ok {
reject(NewError(InvalidAccessError, "key algorithm does not describe a HMAC key"))
return
Expand All @@ -386,9 +386,9 @@ func (sc *SubtleCrypto) Verify(algorithm, key, signature, data goja.Value) *goja
return
}

hashFn, err := keyAlgorithm.HashFn()
if err != nil {
reject(err)
hashFn, ok := getHashFn(keyAlgorithm.hash())
if !ok {
reject(NewError(NotSupportedError, "unsupported hash algorithm "+keyAlgorithm.hash()))
return
}

Expand Down