Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: LayoutTests/crypto/sign-verify.html

Issue 22849026: WebCrypto: Check for HmacKeyParams when seeing if a Key can be used for an Algorithm. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase onto master Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/crypto/encrypt-decrypt-expected.txt ('k') | LayoutTests/crypto/sign-verify-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/sign-verify.html
diff --git a/LayoutTests/crypto/sign-verify.html b/LayoutTests/crypto/sign-verify.html
index 147bd6795c2a43fe552bc17bc99f5261930789d7..cb2a00a840b439062c11b9acac231a8a75beb860 100644
--- a/LayoutTests/crypto/sign-verify.html
+++ b/LayoutTests/crypto/sign-verify.html
@@ -13,13 +13,12 @@ description("Tests cypto.subtle.sign and crypto.subtle.verify");
jsTestIsAsync = true;
+hmacSha1 = {name: 'hmac', hash: {name: 'sha-1'}};
+data = asciiToArrayBuffer("hello");
+
importTestKeys().then(function(importedKeys) {
keys = importedKeys;
- hmacSha1 = {name: 'hmac', hash: {name: 'sha-1'}};
-
- data = asciiToArrayBuffer("hello");
-
// Pass invalid signature parameters to verify()
shouldThrow("crypto.subtle.verify(hmacSha1, keys.hmacSha1, null, data)");
shouldThrow("crypto.subtle.verify(hmacSha1, keys.hmacSha1, 'a', data)");
@@ -66,6 +65,16 @@ importTestKeys().then(function(importedKeys) {
}).then(function(result) {
verifyResult = result;
shouldBe("verifyResult", "false");
+
+ return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-1' }, length: 48}, false, ['sign']);
+}).then(function(result) {
+ generatedHmacSha1Key = result;
+
+ // Cannot use an HMAC SHA-1 key for signing HMAC SHA-256
+ shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'sha-256'}}, generatedHmacSha1Key, data)");
+
+ // However it can be used to sign for HMAC SHA-1
+ shouldNotThrow("crypto.subtle.sign(hmacSha1, generatedHmacSha1Key, data)");
}).then(finishJSTest, failAndFinishJSTest);
</script>
« no previous file with comments | « LayoutTests/crypto/encrypt-decrypt-expected.txt ('k') | LayoutTests/crypto/sign-verify-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698