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

Side by Side Diff: LayoutTests/crypto/resources/common.js

Issue 23126008: WebCrypto: refactor layout tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/crypto/importKey-expected.txt ('k') | LayoutTests/crypto/sign-verify.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 function importHmacSha1Key() 1 function importTestKeys()
2 { 2 {
3 var keyFormat = "spki"; 3 var keyFormat = "spki";
4 var data = new Uint8Array([]); 4 var data = new Uint8Array([]);
5 var algorithm = {name: 'hmac', hash: {name: 'sha-1'}};
6 var extractable = false; 5 var extractable = false;
7 var keyUsages = ['encrypt', 'decrypt', 'sign', 'verify']; 6 var keyUsages = ['encrypt', 'decrypt', 'sign', 'verify'];
8 7
9 return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU sages); 8 var hmacPromise = crypto.subtle.importKey(keyFormat, data, {name: 'hmac', ha sh: {name: 'sha-1'}}, extractable, keyUsages);
9 var rsaSsaPromise = crypto.subtle.importKey(keyFormat, data, {name: 'RSASSA- PKCS1-v1_5', hash: {name: 'sha-1'}}, extractable, keyUsages);
10 var aesCbcPromise = crypto.subtle.importKey(keyFormat, data, {name: 'AES-CBC '}, extractable, keyUsages);
11 var aesCbcJustDecrypt = crypto.subtle.importKey(keyFormat, data, {name: 'AES -CBC'}, extractable, ['decrypt']);
12
13 return Promise.every(hmacPromise, rsaSsaPromise, aesCbcPromise, aesCbcJustDe crypt).then(function(results) {
14 return {
15 hmacSha1: results[0],
16 rsaSsaSha1: results[1],
17 aesCbc: results[2],
18 aesCbcJustDecrypt: results[3],
19 };
20 });
10 } 21 }
11 22
12 // Builds a hex string representation of any array-like input (array or 23 // Builds a hex string representation of any array-like input (array or
13 // ArrayBufferView). The output looks like this: 24 // ArrayBufferView). The output looks like this:
14 // [ab 03 4c 99] 25 // [ab 03 4c 99]
15 function byteArrayToHexString(bytes) 26 function byteArrayToHexString(bytes)
16 { 27 {
17 var hexBytes = []; 28 var hexBytes = [];
18 29
19 for (var i = 0; i < bytes.length; ++i) { 30 for (var i = 0; i < bytes.length; ++i) {
20 var byteString = bytes[i].toString(16); 31 var byteString = bytes[i].toString(16);
21 if (byteString.length < 2) 32 if (byteString.length < 2)
22 byteString = "0" + byteString; 33 byteString = "0" + byteString;
23 hexBytes.push(byteString); 34 hexBytes.push(byteString);
24 } 35 }
25 36
26 return "[" + hexBytes.join(" ") + "]"; 37 return "[" + hexBytes.join(" ") + "]";
27 } 38 }
28 39
29 function asciiToArrayBuffer(str) 40 function asciiToArrayBuffer(str)
30 { 41 {
31 var chars = []; 42 var chars = [];
32 for (var i = 0; i < str.length; ++i) 43 for (var i = 0; i < str.length; ++i)
33 chars.push(str.charCodeAt(i)); 44 chars.push(str.charCodeAt(i));
34 return new Uint8Array(chars); 45 return new Uint8Array(chars);
35 } 46 }
36 47
48 function failAndFinishJSTest(error)
49 {
50 if (error)
51 debug(error);
52 finishJSTest();
53 }
OLDNEW
« no previous file with comments | « LayoutTests/crypto/importKey-expected.txt ('k') | LayoutTests/crypto/sign-verify.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698