| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="resources/common.js"></script> | 5 <script src="resources/common.js"></script> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <p id="description"></p> | 8 <p id="description"></p> |
| 9 <div id="console"></div> | 9 <div id="console"></div> |
| 10 | 10 |
| 11 <script> | 11 <script> |
| 12 description("Tests bad algorithm inputs for AES-CTR"); | 12 description("Tests generateKey() with bad RSASSA-PKCS1-v1_5 parameters."); |
| 13 | |
| 14 jsTestIsAsync = true; | 13 jsTestIsAsync = true; |
| 15 | 14 |
| 16 var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c"); | 15 extractable = true; |
| 17 var data = asciiToUint8Array("hello"); | 16 keyUsages = ['sign', 'verify']; |
| 18 var key = null; | |
| 19 | 17 |
| 20 Promise.resolve(null).then(function(result) { | 18 Promise.resolve(null).then(function() { |
| 21 var usages = ['encrypt', 'decrypt']; | 19 return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength:
-30}, extractable , keyUsages); |
| 22 var extractable = false; | |
| 23 // FIXME: Should use aes-ctr here. | |
| 24 var algorithm = {name: 'aes-cbc'}; | |
| 25 | |
| 26 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s); | |
| 27 }).then(function(result) { | |
| 28 key = result; | |
| 29 | |
| 30 return crypto.subtle.encrypt({name: 'AES-CTR', counter: null}, key, data); | |
| 31 }).then(failAndFinishJSTest, function(result) { | 20 }).then(failAndFinishJSTest, function(result) { |
| 32 error = result; | 21 error = result; |
| 33 shouldBeNull("error"); | 22 shouldBeNull("error"); |
| 34 | 23 |
| 35 return crypto.subtle.encrypt({name: 'AES-CTR'}, key, data); | 24 return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength:
NaN}, extractable , keyUsages); |
| 36 }).then(failAndFinishJSTest, function(result) { | 25 }).then(failAndFinishJSTest, function(result) { |
| 37 error = result; | 26 error = result; |
| 38 shouldBeNull("error"); | 27 shouldBeNull("error"); |
| 39 | 28 |
| 40 return crypto.subtle.encrypt({name: 'AES-CTR', counter: new Uint8Array(0)},
key, data); | 29 return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5'}, extractable ,
keyUsages); |
| 41 }).then(failAndFinishJSTest, function(result) { | 30 }).then(failAndFinishJSTest, function(result) { |
| 42 error = result; | 31 error = result; |
| 43 shouldBeNull("error"); | 32 shouldBeNull("error"); |
| 44 | 33 |
| 45 return crypto.subtle.encrypt({name: 'AES-CTR', counter: new Uint8Array(16),
length: 256}, key, data); | 34 return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength:
10}, extractable , keyUsages); |
| 46 }).then(failAndFinishJSTest, function(result) { | 35 }).then(failAndFinishJSTest, function(result) { |
| 47 error = result; | 36 error = result; |
| 48 shouldBeNull("error"); | 37 shouldBeNull("error"); |
| 49 | 38 |
| 50 return crypto.subtle.encrypt({name: 'AES-CTR', counter: new Uint8Array(16),
length: -3}, key, data); | 39 return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength:
10, publicExponent: 10}, extractable , keyUsages); |
| 51 }).then(failAndFinishJSTest, function(result) { | 40 }).then(failAndFinishJSTest, function(result) { |
| 52 error = result; | 41 error = result; |
| 53 shouldBeNull("error"); | 42 shouldBeNull("error"); |
| 54 | 43 |
| 55 return crypto.subtle.encrypt({name: 'AES-CTR', counter: new Uint8Array(16),
length: Infinity}, key, data); | 44 return crypto.subtle.generateKey({name: 'RSASSA-PKCS1-v1_5', modulusLength:
10, publicExponent: null}, extractable , keyUsages); |
| 56 }).then(failAndFinishJSTest, function(result) { | 45 }).then(failAndFinishJSTest, function(result) { |
| 57 error = result; | 46 error = result; |
| 58 shouldBeNull("error"); | 47 shouldBeNull("error"); |
| 59 }).then(finishJSTest, failAndFinishJSTest); | 48 }).then(finishJSTest, failAndFinishJSTest); |
| 60 | 49 |
| 61 </script> | 50 </script> |
| 62 | 51 |
| 63 </body> | 52 </body> |
| 64 </html> | 53 </html> |
| OLD | NEW |