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

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

Issue 21561004: WebCrypto: Add crypto.subtle.verify() to the platform interfaces. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missing file common.js 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/normalize-algorithm.html ('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
(Empty)
1 function importHmacSha1Key()
2 {
3 var keyFormat = "spki";
4 var data = new Uint8Array([]);
5 var algorithm = {name: 'hmac', hash: {name: 'sha-1'}};
6 var extractable = false;
7 var keyUsages = ['encrypt', 'decrypt', 'sign', 'verify'];
8
9 return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU sages);
10 }
11
12 // Builds a hex string representation of any array-like input (array or
13 // ArrayBufferView). The output looks like this:
14 // [ab 03 4c 99]
15 function byteArrayToHexString(bytes)
16 {
17 var hexBytes = [];
18
19 for (var i = 0; i < bytes.length; ++i) {
20 var byteString = bytes[i].toString(16);
21 if (byteString.length < 2)
22 byteString = "0" + byteString;
23 hexBytes.push(byteString);
24 }
25
26 return "[" + hexBytes.join(" ") + "]";
27 }
28
29 function asciiToArrayBuffer(str)
30 {
31 var chars = [];
32 for (var i = 0; i < str.length; ++i)
33 chars.push(str.charCodeAt(i));
34 return new Uint8Array(chars);
35 }
36
OLDNEW
« no previous file with comments | « LayoutTests/crypto/normalize-algorithm.html ('k') | LayoutTests/crypto/sign-verify.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698