Commit c53b8222 authored by eroman@chromium.org's avatar eroman@chromium.org

[refactor] Split up generateKey.html into multiple files, and test errors directly.

BUG=245025

Review URL: https://codereview.chromium.org/215153005

git-svn-id: svn://svn.chromium.org/blink/trunk@170252 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2c11afbc
CONSOLE ERROR: Invalid keyUsages argument
CONSOLE ERROR: Algorithm: AES-CBC: AesKeyGenParams: length: Missing required property
CONSOLE ERROR: Algorithm: AES-CBC: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-CBC: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-CBC: AesKeyGenParams: length: Outside of numeric range
Tests generateKey() with bad AES-CBC parameters.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS crypto.subtle.generateKey({ name: 'aes-cbc', length: 1024 }, extractable, -1) threw exception TypeError: The 3rd argument is neither an array, nor does it have indexed properties..
PASS crypto.subtle.generateKey({ name: 'aes-cbc', length: 1024 }, extractable, null) threw exception TypeError: The 3rd argument is neither an array, nor does it have indexed properties..
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests generateKey() with bad AES-CBC parameters.");
jsTestIsAsync = true;
extractable = true;
keyUsages = ['encrypt', 'decrypt'];
// Invalid keyUsages
shouldThrow("crypto.subtle.generateKey({ name: 'aes-cbc', length: 1024 }, extractable, -1)");
shouldThrow("crypto.subtle.generateKey({ name: 'aes-cbc', length: 1024 }, extractable, null)");
Promise.resolve(null).then(function() {
// Bad key usage "boo".
return crypto.subtle.generateKey({ name: 'aes-cbc', length: 1024 }, extractable, ['boo']);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({ name: 'aes-cbc' }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({ name: 'aes-cbc', length: 70000 }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({ name: 'aes-cbc', length: -3 }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({ name: 'aes-cbc', length: -Infinity }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
}).then(finishJSTest, failAndFinishJSTest);
</script>
</body>
</html>
CONSOLE ERROR: Algorithm: AES-CTR: AesKeyGenParams: length: Missing required property
CONSOLE ERROR: Algorithm: AES-CTR: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-CTR: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-CTR: AesKeyGenParams: length: Outside of numeric range
Tests generateKey() with bad AES-CTR parameters.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests generateKey() with bad AES-CTR parameters.");
jsTestIsAsync = true;
extractable = true;
keyUsages = ['encrypt', 'decrypt'];
Promise.resolve(null).then(function() {
return crypto.subtle.generateKey({ name: 'aes-ctr' }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({ name: 'aes-ctr', length: 70000 }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({ name: 'aes-ctr', length: -3 }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({ name: 'aes-ctr', length: -Infinity }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
}).then(finishJSTest, failAndFinishJSTest);
</script>
</body>
</html>
CONSOLE ERROR: Algorithm: AES-KW: AesKeyGenParams: length: Missing required property
CONSOLE ERROR: Algorithm: AES-KW: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-KW: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-KW: AesKeyGenParams: length: Outside of numeric range
Tests generateKey() with bad AES-KW parameters.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests generateKey() with bad AES-KW parameters.");
jsTestIsAsync = true;
extractable = true;
keyUsages = ['wrapKey', 'unwrapKey'];
Promise.resolve(null).then(function() {
return crypto.subtle.generateKey({ name: 'aes-kw' }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({ name: 'aes-kw', length: 70000 }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({ name: 'aes-kw', length: -3 }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({ name: 'aes-kw', length: -Infinity }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
}).then(finishJSTest, failAndFinishJSTest);
</script>
</body>
</html>
CONSOLE ERROR: Invalid keyUsages argument
CONSOLE ERROR: Algorithm: AES-CBC: AesKeyGenParams: length: Missing required property
CONSOLE ERROR: Algorithm: AES-CBC: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-CBC: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-CBC: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-CTR: AesKeyGenParams: length: Missing required property
CONSOLE ERROR: Algorithm: AES-CTR: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-CTR: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-CTR: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-KW: AesKeyGenParams: length: Missing required property
CONSOLE ERROR: Algorithm: AES-KW: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-KW: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: AES-KW: AesKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: hash: Algorithm: Unrecognized algorithm name
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Is not a number
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Is not a number
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Is not a number
CONSOLE ERROR: Invalid key length: it is either zero or not a multiple of 8 bits
CONSOLE ERROR: Invalid key length: it is either zero or not a multiple of 8 bits
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: modulusLength: Outside of numeric range
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: modulusLength: Is not a number
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: modulusLength: Missing required property
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: publicExponent: Missing or not a Uint8Array
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: publicExponent: Missing or not a Uint8Array
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: publicExponent: Missing or not a Uint8Array
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: modulusLength: Outside of numeric range
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: modulusLength: Is not a number
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: modulusLength: Missing required property
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: publicExponent: Missing or not a Uint8Array
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: publicExponent: Missing or not a Uint8Array
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: publicExponent: Missing or not a Uint8Array
Tests crypto.subtle.generateKey.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS crypto.subtle.generateKey(aesCbc, extractable, -1) threw exception TypeError: The 3rd argument is neither an array, nor does it have indexed properties..
PASS crypto.subtle.generateKey(aesCbc, extractable, null) threw exception TypeError: The 3rd argument is neither an array, nor does it have indexed properties..
PASS: 'crypto.subtle.generateKey(aesCbc, extractable, ['boo'])' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-cbc' }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-cbc', length: 70000 }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-cbc', length: -3 }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-cbc', length: -Infinity }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-ctr' }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-ctr', length: 70000 }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-ctr', length: -3 }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-ctr', length: -Infinity }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-kw' }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-kw', length: 70000 }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-kw', length: -3 }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({ name: 'aes-kw', length: -Infinity }, extractable, keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: -3}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: ''}, length: 48}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: 5000000000}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: NaN}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: Infinity}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: -Infinity}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: crypto}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: undefined}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: null}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: true}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: -30}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: NaN}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5'}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: 10}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: 10, publicExponent: 10}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: 10, publicExponent: null}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: -30}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: NaN}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5'}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: 10}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: 10, publicExponent: 10}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: 10, publicExponent: null}, extractable , keyUsages)' rejected with null
PASS: 'crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: '48'}, extractable , keyUsages)' accepted with [object Key]
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests crypto.subtle.generateKey.");
jsTestIsAsync = true;
extractable = true;
keyUsages = ['encrypt', 'decrypt'];
// Invalid keyUsages
aesCbc = { name: 'aes-cbc', length: 1024 };
shouldThrow("crypto.subtle.generateKey(aesCbc, extractable, -1)");
shouldThrow("crypto.subtle.generateKey(aesCbc, extractable, null)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey(aesCbc, extractable, ['boo'])");
// ---------------------------------------------------
// AES-CBC normalization failures (AesKeyGenParams)
// ---------------------------------------------------
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-cbc' }, extractable, keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-cbc', length: 70000 }, extractable, keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-cbc', length: -3 }, extractable, keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-cbc', length: -Infinity }, extractable, keyUsages)");
// ---------------------------------------------------
// AES-CTR normalization failures (AesKeyGenParams)
// ---------------------------------------------------
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-ctr' }, extractable, keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-ctr', length: 70000 }, extractable, keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-ctr', length: -3 }, extractable, keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-ctr', length: -Infinity }, extractable, keyUsages)");
// ---------------------------------------------------
// AES-KW normalization failures (AesKeyGenParams)
// ---------------------------------------------------
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-kw' }, extractable, keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-kw', length: 70000 }, extractable, keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-kw', length: -3 }, extractable, keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({ name: 'aes-kw', length: -Infinity }, extractable, keyUsages)");
// ---------------------------------------------------
// HMAC normalization failures (HmacKeyParams)
// ---------------------------------------------------
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: -3}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'hmac', hash: {name: ''}, length: 48}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: 5000000000}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: NaN}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: Infinity}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: -Infinity}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: crypto}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: undefined}, extractable , keyUsages)");
// The length property doesn't strictly need to be a number according to WebIDL.
// It just has to be convertable with ToNumber().
shouldAcceptPromise("crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: '48'}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: null}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: true}, extractable , keyUsages)");
// ---------------------------------------------------
// RSASSA-PKCS1-v1_5 normalization failures (RsaKeyGenParams)
// ---------------------------------------------------
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: -30}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: NaN}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5'}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: 10}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: 10, publicExponent: 10}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: 10, publicExponent: null}, extractable , keyUsages)");
// ---------------------------------------------------
// RSAES-PKCS1-v1_5 normalization failures (RsaKeyGenParams)
// ---------------------------------------------------
// Note: these are the same tests as for RSASSA-PKCS1-v1_5 above.
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: -30}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: NaN}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5'}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: 10}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: 10, publicExponent: 10}, extractable , keyUsages)");
shouldRejectPromiseWithNull("crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: 10, publicExponent: null}, extractable , keyUsages)");
completeTestWhenAllTasksDone();
</script>
</body>
</html>
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: hash: Algorithm: Unrecognized algorithm name
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Is not a number
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Outside of numeric range
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Is not a number
CONSOLE ERROR: Algorithm: HMAC: HmacKeyGenParams: length: Is not a number
CONSOLE ERROR: Invalid key length: it is either zero or not a multiple of 8 bits
Tests generateKey() with bad HMAC parameters.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests generateKey() with bad HMAC parameters.");
jsTestIsAsync = true;
extractable = true;
keyUsages = ['sign', 'verify'];
Promise.resolve(null).then(function() {
return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: -3}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'hmac', hash: {name: ''}, length: 48}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: 5000000000}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: NaN}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: Infinity}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: -Infinity}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: crypto}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: undefined}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-256'}, length: true}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
}).then(finishJSTest, failAndFinishJSTest);
</script>
</body>
</html>
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: modulusLength: Outside of numeric range
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: modulusLength: Is not a number
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: modulusLength: Missing required property
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: publicExponent: Missing or not a Uint8Array
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: publicExponent: Missing or not a Uint8Array
CONSOLE ERROR: Algorithm: RSAES-PKCS1-v1_5: RsaKeyGenParams: publicExponent: Missing or not a Uint8Array
Tests generateKey() with bad RSAES-PKCS1-v1_5 parameters
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests generateKey() with bad RSAES-PKCS1-v1_5 parameters");
jsTestIsAsync = true;
extractable = true;
keyUsages = ['encrypt', 'decrypt'];
Promise.resolve(null).then(function() {
return crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: -30}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: NaN}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5'}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: 10}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: 10, publicExponent: 10}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'RSAES-PKCS1-v1_5', modulusLength: 10, publicExponent: null}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
}).then(finishJSTest, failAndFinishJSTest);
</script>
</body>
</html>
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: modulusLength: Outside of numeric range
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: modulusLength: Is not a number
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: modulusLength: Missing required property
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: publicExponent: Missing or not a Uint8Array
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: publicExponent: Missing or not a Uint8Array
CONSOLE ERROR: Algorithm: RSASSA-PKCS1-v1_5: RsaHashedKeyGenParams: publicExponent: Missing or not a Uint8Array
Tests generateKey() with bad RSASSA-PKCS1-v1_5 parameters.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS error is null
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests generateKey() with bad RSASSA-PKCS1-v1_5 parameters.");
jsTestIsAsync = true;
extractable = true;
keyUsages = ['sign', 'verify'];
Promise.resolve(null).then(function() {
return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: -30}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: NaN}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5'}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: 10}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: 10, publicExponent: 10}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength: 10, publicExponent: null}, extractable , keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
}).then(finishJSTest, failAndFinishJSTest);
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment