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 |
(...skipping 29 matching lines...) Expand all Loading... |
40 }).then(failAndFinishJSTest, function(result) { | 40 }).then(failAndFinishJSTest, function(result) { |
41 logError(result); | 41 logError(result); |
42 | 42 |
43 // Should throw an OperationError if the key derivation operation | 43 // Should throw an OperationError if the key derivation operation |
44 // fails. The key derivation operation will fail here because the length | 44 // fails. The key derivation operation will fail here because the length |
45 // is too long. | 45 // is too long. |
46 // | 46 // |
47 // The maximum length (in bytes) of output material for HKDF is 255 times | 47 // The maximum length (in bytes) of output material for HKDF is 255 times |
48 // the digest length. In this case, the digest length (in bytes) of | 48 // the digest length. In this case, the digest length (in bytes) of |
49 // SHA-256 is 32; 32*255 = 8160. deriveBits expects the length to be in | 49 // SHA-256 is 32; 32*255 = 8160. deriveBits expects the length to be in |
50 // bits, so 8160*8=65280 and add 1 to exceed the maximum length. | 50 // bits, so 8160*8=65280 and add 8 to exceed the maximum length. |
51 debug("\nderiveBits() with length of 65281..."); | 51 debug("\nderiveBits() with length of 65281..."); |
52 return crypto.subtle.deriveBits({name: "HKDF", hash: "SHA-256", salt: new Ui
nt8Array(), info: new Uint8Array()}, hkdfKey, 65281); | 52 return crypto.subtle.deriveBits({name: "HKDF", hash: "SHA-256", salt: new Ui
nt8Array(), info: new Uint8Array()}, hkdfKey, 65288); |
| 53 }).then(failAndFinishJSTest, function(result) { |
| 54 logError(result); |
| 55 |
| 56 // Use a bit length that is not a multiple of 8. |
| 57 debug("\nderiveBits() with length of 15..."); |
| 58 return crypto.subtle.deriveBits({name: "HKDF", hash: "SHA-256", salt: new Ui
nt8Array(), info: new Uint8Array()}, hkdfKey, 15); |
53 }).then(failAndFinishJSTest, function(result) { | 59 }).then(failAndFinishJSTest, function(result) { |
54 logError(result); | 60 logError(result); |
55 }).then(finishJSTest, failAndFinishJSTest); | 61 }).then(finishJSTest, failAndFinishJSTest); |
56 | 62 |
57 </script> | 63 </script> |
58 | 64 |
59 </body> | 65 </body> |
60 </html> | 66 </html> |
OLD | NEW |