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

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

Issue 179353002: [webcrypto] Add the KeyAlgorithm interface. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase yet again (another conflict) Created 6 years, 10 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/resources/common.js ('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 8e4fcc1801027274d7f7d18c8fe6d8e726c98806..2b07f145f080f59bc5bfcf4ce1d3f93d1546d009 100644
--- a/LayoutTests/crypto/sign-verify.html
+++ b/LayoutTests/crypto/sign-verify.html
@@ -76,7 +76,8 @@ var kHmacTestVectors = [
function runSuccessTestCase(testCase)
{
- var algorithm = {name: 'HMAC', hash: {name: testCase.algorithm}};
+ var importAlgorithm = {name: 'HMAC', hash: {name: testCase.algorithm}};
+ var algorithm = {name: 'HMAC'};
var key = null;
var keyData = hexStringToUint8Array(testCase.key);
@@ -84,7 +85,7 @@ function runSuccessTestCase(testCase)
var extractable = false;
// (1) Import the key
- return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usages).then(function(result) {
+ return crypto.subtle.importKey('raw', keyData, importAlgorithm, extractable, usages).then(function(result) {
key = result;
// shouldBe() can only resolve variables in global context.
@@ -92,6 +93,7 @@ function runSuccessTestCase(testCase)
shouldBe("tmpKey.type", "'secret'")
shouldBe("tmpKey.extractable", "false")
shouldBe("tmpKey.algorithm.name", "'HMAC'")
+ shouldBe("tmpKey.algorithm.hash.name", "'" + testCase.algorithm + "'")
shouldBe("tmpKey.usages.join(',')", "'sign,verify'")
// (2) Sign.
@@ -119,16 +121,16 @@ for (var i = 0; i < kHmacTestVectors.length; ++i) {
allTests.push(runSuccessTestCase(kHmacTestVectors[i]));
}
-hmacSha1 = {name: 'hmac', hash: {name: 'sha-1'}};
+hmac = {name: 'hmac'};
data = asciiToUint8Array("hello");
allTests.push(importTestKeys().then(function(importedKeys) {
keys = importedKeys;
// Pass invalid signature parameters to verify()
- shouldThrow("crypto.subtle.verify(hmacSha1, keys.hmacSha1, null, data)");
- shouldThrow("crypto.subtle.verify(hmacSha1, keys.hmacSha1, 'a', data)");
- shouldThrow("crypto.subtle.verify(hmacSha1, keys.hmacSha1, [], data)");
+ shouldThrow("crypto.subtle.verify(hmac, keys.hmacSha1, null, data)");
+ shouldThrow("crypto.subtle.verify(hmac, keys.hmacSha1, 'a', data)");
+ shouldThrow("crypto.subtle.verify(hmac, keys.hmacSha1, [], data)");
// Operation does not support signing.
shouldRejectPromiseWithNull("crypto.subtle.sign({name: 'sha-1'}, keys.hmacSha1, data)");
@@ -136,19 +138,6 @@ allTests.push(importTestKeys().then(function(importedKeys) {
// Operation doesn't support signing (also given an invalid key, but the
// first failure takes priority)
shouldRejectPromiseWithNull("crypto.subtle.sign({name: 'RSAES-PKCS1-v1_5'}, keys.hmacSha1, data)");
-
- // Key's algorithm must match.
- shouldRejectPromiseWithNull("crypto.subtle.sign({name: 'hmac', hash: {name: 'sha-256'}}, keys.hmacSha1, data)");
-
- // ---------------------------------------------------
- // HMAC normalization failures (HmacParams)
- // ---------------------------------------------------
- shouldRejectPromiseWithNull("crypto.subtle.sign({name: 'hmac'}, keys.hmacSha1, data)");
- shouldRejectPromiseWithNull("crypto.subtle.sign({name: 'hmac', hash: 3}, keys.hmacSha1, data)");
- shouldRejectPromiseWithNull("crypto.subtle.sign({name: 'hmac', hash: null}, keys.hmacSha1, data)");
- shouldRejectPromiseWithNull("crypto.subtle.sign({name: 'hmac', hash: {}}, keys.hmacSha1, data)");
- shouldRejectPromiseWithNull("crypto.subtle.sign({name: 'hmac', hash: {name: 'foo'}}, keys.hmacSha1, data)");
- shouldRejectPromiseWithNull("crypto.subtle.sign({name: 'hmac', hash: {name: 'AES-CBC'}}, keys.hmacSha1, data)");
}));
// -------------------------------------------------
« no previous file with comments | « LayoutTests/crypto/resources/common.js ('k') | LayoutTests/crypto/sign-verify-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698