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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/crypto/normalize-algorithm.html ('k') | LayoutTests/crypto/sign-verify.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/resources/common.js
diff --git a/LayoutTests/crypto/resources/common.js b/LayoutTests/crypto/resources/common.js
new file mode 100644
index 0000000000000000000000000000000000000000..301cc2b7a6d6563618536c8e14c9e49b866bf680
--- /dev/null
+++ b/LayoutTests/crypto/resources/common.js
@@ -0,0 +1,36 @@
+function importHmacSha1Key()
+{
+ var keyFormat = "spki";
+ var data = new Uint8Array([]);
+ var algorithm = {name: 'hmac', hash: {name: 'sha-1'}};
+ var extractable = false;
+ var keyUsages = ['encrypt', 'decrypt', 'sign', 'verify'];
+
+ return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyUsages);
+}
+
+// Builds a hex string representation of any array-like input (array or
+// ArrayBufferView). The output looks like this:
+// [ab 03 4c 99]
+function byteArrayToHexString(bytes)
+{
+ var hexBytes = [];
+
+ for (var i = 0; i < bytes.length; ++i) {
+ var byteString = bytes[i].toString(16);
+ if (byteString.length < 2)
+ byteString = "0" + byteString;
+ hexBytes.push(byteString);
+ }
+
+ return "[" + hexBytes.join(" ") + "]";
+}
+
+function asciiToArrayBuffer(str)
+{
+ var chars = [];
+ for (var i = 0; i < str.length; ++i)
+ chars.push(str.charCodeAt(i));
+ return new Uint8Array(chars);
+}
+
« 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