diff --git a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp index 0d563b824132..b7b498b2a3b1 100644 --- a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp +++ b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp @@ -6205,19 +6205,22 @@ WebIDL::ExceptionOr, GC::Ref>> HMAC::g // 10. Set the hash attribute of algorithm to hash. algorithm->set_hash(hash); - // 11. Set the [[type]] internal slot of key to "secret". + // 11. Set the length attribute of algorithm to length. + algorithm->set_length(length); + + // 12. Set the [[type]] internal slot of key to "secret". key->set_type(Bindings::KeyType::Secret); - // 12. Set the [[algorithm]] internal slot of key to algorithm. + // 13. Set the [[algorithm]] internal slot of key to algorithm. key->set_algorithm(algorithm); - // 13. Set the [[extractable]] internal slot of key to be extractable. + // 14. Set the [[extractable]] internal slot of key to be extractable. key->set_extractable(extractable); - // 14. Set the [[usages]] internal slot of key to be usages. + // 15. Set the [[usages]] internal slot of key to be usages. key->set_usages(usages); - // 15. Return key. + // 16. Return key. return Variant, GC::Ref> { key }; } diff --git a/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/generateKey/successes_HMAC.https.any.txt b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/generateKey/successes_HMAC.https.any.txt new file mode 100644 index 000000000000..f794e837c640 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/generateKey/successes_HMAC.https.any.txt @@ -0,0 +1,198 @@ +Harness status: OK + +Found 192 tests + +96 Pass +96 Fail +Pass Success: generateKey({hash: SHA-1, length: 160, name: HMAC}, false, [sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: HMAC}, true, [sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: HMAC}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: HMAC}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: HMAC}, false, [verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: HMAC}, true, [verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: HMAC}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: HMAC}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: HMAC}, false, [sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: HMAC}, true, [sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: HMAC}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: HMAC}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: HMAC}, false, [verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: HMAC}, true, [verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: HMAC}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: HMAC}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: HMAC}, false, [sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: HMAC}, true, [sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: HMAC}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: HMAC}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: HMAC}, false, [verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: HMAC}, true, [verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: HMAC}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: HMAC}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: HMAC}, false, [sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: HMAC}, true, [sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: HMAC}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: HMAC}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: HMAC}, false, [verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: HMAC}, true, [verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: HMAC}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: HMAC}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-1, name: HMAC}, false, [sign]) +Fail Success: generateKey({hash: SHA-1, name: HMAC}, true, [sign]) +Fail Success: generateKey({hash: SHA-1, name: HMAC}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-1, name: HMAC}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-1, name: HMAC}, false, [verify]) +Fail Success: generateKey({hash: SHA-1, name: HMAC}, true, [verify]) +Fail Success: generateKey({hash: SHA-1, name: HMAC}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-1, name: HMAC}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-256, name: HMAC}, false, [sign]) +Fail Success: generateKey({hash: SHA-256, name: HMAC}, true, [sign]) +Fail Success: generateKey({hash: SHA-256, name: HMAC}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-256, name: HMAC}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-256, name: HMAC}, false, [verify]) +Fail Success: generateKey({hash: SHA-256, name: HMAC}, true, [verify]) +Fail Success: generateKey({hash: SHA-256, name: HMAC}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-256, name: HMAC}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-384, name: HMAC}, false, [sign]) +Fail Success: generateKey({hash: SHA-384, name: HMAC}, true, [sign]) +Fail Success: generateKey({hash: SHA-384, name: HMAC}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-384, name: HMAC}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-384, name: HMAC}, false, [verify]) +Fail Success: generateKey({hash: SHA-384, name: HMAC}, true, [verify]) +Fail Success: generateKey({hash: SHA-384, name: HMAC}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-384, name: HMAC}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-512, name: HMAC}, false, [sign]) +Fail Success: generateKey({hash: SHA-512, name: HMAC}, true, [sign]) +Fail Success: generateKey({hash: SHA-512, name: HMAC}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-512, name: HMAC}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-512, name: HMAC}, false, [verify]) +Fail Success: generateKey({hash: SHA-512, name: HMAC}, true, [verify]) +Fail Success: generateKey({hash: SHA-512, name: HMAC}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-512, name: HMAC}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: hmac}, false, [sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: hmac}, true, [sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: hmac}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: hmac}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: hmac}, false, [verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: hmac}, true, [verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: hmac}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: hmac}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: hmac}, false, [sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: hmac}, true, [sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: hmac}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: hmac}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: hmac}, false, [verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: hmac}, true, [verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: hmac}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: hmac}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: hmac}, false, [sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: hmac}, true, [sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: hmac}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: hmac}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: hmac}, false, [verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: hmac}, true, [verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: hmac}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: hmac}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: hmac}, false, [sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: hmac}, true, [sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: hmac}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: hmac}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: hmac}, false, [verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: hmac}, true, [verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: hmac}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: hmac}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-1, name: hmac}, false, [sign]) +Fail Success: generateKey({hash: SHA-1, name: hmac}, true, [sign]) +Fail Success: generateKey({hash: SHA-1, name: hmac}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-1, name: hmac}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-1, name: hmac}, false, [verify]) +Fail Success: generateKey({hash: SHA-1, name: hmac}, true, [verify]) +Fail Success: generateKey({hash: SHA-1, name: hmac}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-1, name: hmac}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-256, name: hmac}, false, [sign]) +Fail Success: generateKey({hash: SHA-256, name: hmac}, true, [sign]) +Fail Success: generateKey({hash: SHA-256, name: hmac}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-256, name: hmac}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-256, name: hmac}, false, [verify]) +Fail Success: generateKey({hash: SHA-256, name: hmac}, true, [verify]) +Fail Success: generateKey({hash: SHA-256, name: hmac}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-256, name: hmac}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-384, name: hmac}, false, [sign]) +Fail Success: generateKey({hash: SHA-384, name: hmac}, true, [sign]) +Fail Success: generateKey({hash: SHA-384, name: hmac}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-384, name: hmac}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-384, name: hmac}, false, [verify]) +Fail Success: generateKey({hash: SHA-384, name: hmac}, true, [verify]) +Fail Success: generateKey({hash: SHA-384, name: hmac}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-384, name: hmac}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-512, name: hmac}, false, [sign]) +Fail Success: generateKey({hash: SHA-512, name: hmac}, true, [sign]) +Fail Success: generateKey({hash: SHA-512, name: hmac}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-512, name: hmac}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-512, name: hmac}, false, [verify]) +Fail Success: generateKey({hash: SHA-512, name: hmac}, true, [verify]) +Fail Success: generateKey({hash: SHA-512, name: hmac}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-512, name: hmac}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: Hmac}, false, [sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: Hmac}, true, [sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: Hmac}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: Hmac}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: Hmac}, false, [verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: Hmac}, true, [verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: Hmac}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-1, length: 160, name: Hmac}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: Hmac}, false, [sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: Hmac}, true, [sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: Hmac}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: Hmac}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: Hmac}, false, [verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: Hmac}, true, [verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: Hmac}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-256, length: 256, name: Hmac}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: Hmac}, false, [sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: Hmac}, true, [sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: Hmac}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: Hmac}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: Hmac}, false, [verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: Hmac}, true, [verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: Hmac}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-384, length: 384, name: Hmac}, true, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: Hmac}, false, [sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: Hmac}, true, [sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: Hmac}, false, [verify, sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: Hmac}, true, [verify, sign]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: Hmac}, false, [verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: Hmac}, true, [verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: Hmac}, false, [sign, verify, sign, verify]) +Pass Success: generateKey({hash: SHA-512, length: 512, name: Hmac}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-1, name: Hmac}, false, [sign]) +Fail Success: generateKey({hash: SHA-1, name: Hmac}, true, [sign]) +Fail Success: generateKey({hash: SHA-1, name: Hmac}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-1, name: Hmac}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-1, name: Hmac}, false, [verify]) +Fail Success: generateKey({hash: SHA-1, name: Hmac}, true, [verify]) +Fail Success: generateKey({hash: SHA-1, name: Hmac}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-1, name: Hmac}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-256, name: Hmac}, false, [sign]) +Fail Success: generateKey({hash: SHA-256, name: Hmac}, true, [sign]) +Fail Success: generateKey({hash: SHA-256, name: Hmac}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-256, name: Hmac}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-256, name: Hmac}, false, [verify]) +Fail Success: generateKey({hash: SHA-256, name: Hmac}, true, [verify]) +Fail Success: generateKey({hash: SHA-256, name: Hmac}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-256, name: Hmac}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-384, name: Hmac}, false, [sign]) +Fail Success: generateKey({hash: SHA-384, name: Hmac}, true, [sign]) +Fail Success: generateKey({hash: SHA-384, name: Hmac}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-384, name: Hmac}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-384, name: Hmac}, false, [verify]) +Fail Success: generateKey({hash: SHA-384, name: Hmac}, true, [verify]) +Fail Success: generateKey({hash: SHA-384, name: Hmac}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-384, name: Hmac}, true, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-512, name: Hmac}, false, [sign]) +Fail Success: generateKey({hash: SHA-512, name: Hmac}, true, [sign]) +Fail Success: generateKey({hash: SHA-512, name: Hmac}, false, [verify, sign]) +Fail Success: generateKey({hash: SHA-512, name: Hmac}, true, [verify, sign]) +Fail Success: generateKey({hash: SHA-512, name: Hmac}, false, [verify]) +Fail Success: generateKey({hash: SHA-512, name: Hmac}, true, [verify]) +Fail Success: generateKey({hash: SHA-512, name: Hmac}, false, [sign, verify, sign, verify]) +Fail Success: generateKey({hash: SHA-512, name: Hmac}, true, [sign, verify, sign, verify]) \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/generateKey/successes_HMAC.https.any.html b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/generateKey/successes_HMAC.https.any.html new file mode 100644 index 000000000000..1c31cb4311c7 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/generateKey/successes_HMAC.https.any.html @@ -0,0 +1,18 @@ + + +WebCryptoAPI: generateKey() Successful Calls + + + + + + + +
+ diff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/generateKey/successes_HMAC.https.any.js b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/generateKey/successes_HMAC.https.any.js new file mode 100644 index 000000000000..18e0b271226f --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/generateKey/successes_HMAC.https.any.js @@ -0,0 +1,6 @@ +// META: title=WebCryptoAPI: generateKey() Successful Calls +// META: timeout=long +// META: script=../util/helpers.js +// META: script=/common/subset-tests.js +// META: script=successes.js +run_test(["HMAC"]);