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

Side by Side Diff: LayoutTests/crypto/aes-kw-wrapKey-unwrapKey-raw.html

Issue 806913006: [WebCrypto] Move LayoutTests from crypto to crypto/subtle (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update path for deserialize legacy tests Created 6 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10
11 <script>
12 description("Tests wrapping and unwrapping of AES-CBC keys using AES-KW and raw format");
13
14 jsTestIsAsync = true;
15
16 var kWrappingTestCases = [
17 // AES-KW test vectors from http://www.ietf.org/rfc/rfc3394.txt
18 // 4.1 Wrap 128 bits of Key Data with a 128-bit KEK
19 {
20 "wrappingKey": "000102030405060708090A0B0C0D0E0F",
21 "key": "00112233445566778899AABBCCDDEEFF",
22 "ciphertext": "1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5"
23 },
24 // 4.3 Wrap 128 bits of Key Data with a 256-bit KEK
25 {
26 "wrappingKey": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D 1E1F",
27 "key": "00112233445566778899AABBCCDDEEFF",
28 "ciphertext": "64E8C3F9CE0F5BA263E9777905818A2A93C8191E7D6E8AE7"
29 },
30 // 4.5 Wrap 192 bits of Key Data with a 256-bit KEK
31 {
32 "wrappingKey": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D 1E1F",
33 "key": "00112233445566778899AABBCCDDEEFF0001020304050607",
34 "ciphertext": "A8F9BC1612C68B3FF6E6F4FBE30E71E4769C8B80A32CB8958CD5D17D6B254 DA1"
35 },
36 // 4.6 Wrap 256 bits of Key Data with a 256-bit KEK
37 {
38 "wrappingKey": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D 1E1F",
39 "key": "00112233445566778899AABBCCDDEEFF000102030405060708090A0B0C0D0E0F",
40 "ciphertext": "28C9F404C4B810F4CBCCB35CFB87F8263F5786E2D80ED326CBC7F0E71A99F 43BFB988B9B7A02DD21"
41 }
42 ]
43
44 function runTestCase(testCase)
45 {
46 var wrappingKey = null;
47 var key = null;
48
49 return Promise.resolve(null).then(function(result) {
50 // Import the wrapping key
51 var importAlgorithm = {name: 'aes-kw'};
52 var keyData = hexStringToUint8Array(testCase.wrappingKey);
53 var usages = ['wrapKey', 'unwrapKey'];
54 var extractable = false;
55
56 return crypto.subtle.importKey('raw', keyData, importAlgorithm, extracta ble, usages);
57 }).then(function(result) {
58 wrappingKey = result;
59
60 // Import the key to be wrapped.
61 var importAlgorithm = {name: 'HMAC', hash: {name: 'sha-1'}};
62 var keyData = hexStringToUint8Array(testCase.key);
63 var usages = ['sign', 'verify'];
64 var extractable = true;
65
66 return crypto.subtle.importKey('raw', keyData, importAlgorithm, extracta ble, usages);
67 }).then(function(result) {
68 key = result;
69
70 // Wrap the key.
71 var wrapAlgorithm = {name: 'aes-kw'};
72 return crypto.subtle.wrapKey('raw', key, wrappingKey, wrapAlgorithm);
73 }).then(function(result) {
74 bytesShouldMatchHexString("Wrapped key data", testCase.ciphertext, resul t);
75
76 // Unwrap the key.
77 var wrappedKeyData = hexStringToUint8Array(testCase.ciphertext);
78 var unwrapAlgorithm = {name: 'aes-kw'};
79 var unwrappedKeyAlgorithm = {name: 'HMAC', hash: {name: 'sha-1'}};
80 var extractable = true;
81 var usages = ['sign'];
82 return crypto.subtle.unwrapKey('raw', wrappedKeyData, wrappingKey, unwra pAlgorithm, unwrappedKeyAlgorithm, extractable, usages);
83 }).then(function(result) {
84 unwrappedKey = result;
85
86 shouldEvaluateAs("unwrappedKey.algorithm.name", "HMAC");
87 shouldEvaluateAs("unwrappedKey.algorithm.hash.name", "SHA-1");
88 shouldEvaluateAs("unwrappedKey.algorithm.length", testCase.key.length * 4);
89 shouldEvaluateAs("unwrappedKey.extractable", true);
90 shouldEvaluateAs("unwrappedKey.usages.join(',')", "sign");
91
92 return crypto.subtle.exportKey('raw', unwrappedKey);
93 }).then(function(result) {
94 bytesShouldMatchHexString("Unwrapped key data", testCase.key, result);
95 });
96 }
97
98 var lastPromise = Promise.resolve(null);
99
100 kWrappingTestCases.forEach(function(test) {
101 lastPromise = lastPromise.then(runTestCase.bind(null, test));
102 });
103
104 lastPromise.then(finishJSTest, failAndFinishJSTest);
105
106 </script>
107
108 </body>
109 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/aes-kw-wrap-unwrap-aes-expected.txt ('k') | LayoutTests/crypto/aes-kw-wrapKey-unwrapKey-raw-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698