OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../fast/js/resources/js-test-pre.js"></script> | 4 <script src="../fast/js/resources/js-test-pre.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 |
(...skipping 29 matching lines...) Expand all Loading... |
40 shouldThrow("crypto.subtle.sign({name: 'hmac'}, keys.hmacSha1, data)"); | 40 shouldThrow("crypto.subtle.sign({name: 'hmac'}, keys.hmacSha1, data)"); |
41 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: 3}, keys.hmacSha1, data
)"); | 41 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: 3}, keys.hmacSha1, data
)"); |
42 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: null}, keys.hmacSha1, d
ata)"); | 42 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: null}, keys.hmacSha1, d
ata)"); |
43 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {}}, keys.hmacSha1, dat
a)"); | 43 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {}}, keys.hmacSha1, dat
a)"); |
44 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'foo'}}, keys.hm
acSha1, data)"); | 44 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'foo'}}, keys.hm
acSha1, data)"); |
45 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'AES-CBC'}}, key
s.hmacSha1, data)"); | 45 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'AES-CBC'}}, key
s.hmacSha1, data)"); |
46 | 46 |
47 // --------------------------------------------------- | 47 // --------------------------------------------------- |
48 // RSASSA-PKCS1-v1_5 normalization failures (RsaSsaParams) | 48 // RSASSA-PKCS1-v1_5 normalization failures (RsaSsaParams) |
49 // --------------------------------------------------- | 49 // --------------------------------------------------- |
| 50 // TODO(eroman): Re-enable once can import RSA keys. |
| 51 /* |
50 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5'}, keys.rsaSsaSha1
, data)"); | 52 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5'}, keys.rsaSsaSha1
, data)"); |
51 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: 3}, keys.r
saSsaSha1, data)"); | 53 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: 3}, keys.r
saSsaSha1, data)"); |
52 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: null}, key
s.rsaSsaSha1, data)"); | 54 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: null}, key
s.rsaSsaSha1, data)"); |
53 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: {}}, keys.
rsaSsaSha1, data)"); | 55 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: {}}, keys.
rsaSsaSha1, data)"); |
54 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: {name: 'fo
o'}}, keys.rsaSsaSha1, data)"); | 56 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: {name: 'fo
o'}}, keys.rsaSsaSha1, data)"); |
55 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: {name: 'AE
S-CBC'}}, keys.rsaSsaSha1, data)"); | 57 shouldThrow("crypto.subtle.sign({name: 'RSASSA-PKCS1-v1_5', hash: {name: 'AE
S-CBC'}}, keys.rsaSsaSha1, data)"); |
| 58 */ |
56 | 59 |
57 return crypto.subtle.sign(hmacSha1, keys.hmacSha1, data); | 60 return crypto.subtle.sign(hmacSha1, keys.hmacSha1, data); |
58 }).then(function(result) { | 61 }).then(function(result) { |
59 signResult = result; | 62 signResult = arrayBufferToHexString(result); |
60 shouldBe("signResult.byteLength", "17"); | 63 shouldBe("signResult", "'[89 0d 9b 89 4b 23 97 69 ac 77 25 04 66 dc e4 2a f9
26 ed 76]'"); |
61 | |
62 expectedSignature = asciiToArrayBuffer("signed HMAC:hello"); | |
63 return crypto.subtle.verify(hmacSha1, keys.hmacSha1, expectedSignature, data
); | |
64 }).then(function(result) { | |
65 verifyResult = result; | |
66 shouldBe("verifyResult", "true"); | |
67 | 64 |
68 return crypto.subtle.verify(hmacSha1, keys.hmacSha1, asciiToArrayBuffer("bad
signature"), data); | 65 return crypto.subtle.verify(hmacSha1, keys.hmacSha1, asciiToArrayBuffer("bad
signature"), data); |
69 }).then(function(result) { | 66 }).then(function(result) { |
70 verifyResult = result; | 67 verifyResult = result; |
71 shouldBe("verifyResult", "false"); | 68 shouldBe("verifyResult", "false"); |
72 | 69 |
| 70 /* |
| 71 TODO(eroman): generateKey() not implemented. |
| 72 |
73 return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-1' }, leng
th: 48}, false, ['sign']); | 73 return crypto.subtle.generateKey({name: 'hmac', hash: {name: 'sha-1' }, leng
th: 48}, false, ['sign']); |
74 }).then(function(result) { | 74 }).then(function(result) { |
75 generatedHmacSha1Key = result; | 75 generatedHmacSha1Key = result; |
76 | 76 |
77 // Cannot use an HMAC SHA-1 key for signing HMAC SHA-256 | |
78 shouldThrow("crypto.subtle.sign({name: 'hmac', hash: {name: 'sha-256'}}, gen
eratedHmacSha1Key, data)"); | |
79 | 77 |
80 // However it can be used to sign for HMAC SHA-1 | 78 // However it can be used to sign for HMAC SHA-1 |
81 shouldNotThrow("crypto.subtle.sign(hmacSha1, generatedHmacSha1Key, data)"); | 79 shouldNotThrow("crypto.subtle.sign(hmacSha1, generatedHmacSha1Key, data)"); |
| 80 */ |
82 }).then(finishJSTest, failAndFinishJSTest); | 81 }).then(finishJSTest, failAndFinishJSTest); |
83 | 82 |
84 </script> | 83 </script> |
85 | 84 |
86 <script src="../fast/js/resources/js-test-post.js"></script> | 85 <script src="../fast/js/resources/js-test-post.js"></script> |
87 </body> | 86 </body> |
OLD | NEW |