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

Unified Diff: LayoutTests/crypto/ecdh-deriveBits.html

Issue 754563003: Add LayoutTests for WebCrypto's ECDH algorithm. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase onto master Created 6 years, 1 month 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
Index: LayoutTests/crypto/ecdh-deriveBits.html
diff --git a/LayoutTests/crypto/ecdh-deriveBits.html b/LayoutTests/crypto/ecdh-deriveBits.html
new file mode 100644
index 0000000000000000000000000000000000000000..c14ab3e8bfd0c61bcc83bdf57c4a236b19c36f9d
--- /dev/null
+++ b/LayoutTests/crypto/ecdh-deriveBits.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../resources/js-test.js"></script>
+<script src="resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Tests ECDH's deriveBits() using P-521");
+
+jsTestIsAsync = true;
+
+// The test data uses a public key and private key (from different key pairs) for the P-521 curve.
+var privateKeyJwk = {
+ "kty":"EC",
+ "crv":"P-521",
+ "d":"AI_Zu5xisuK-IIz85dTSoqaQSTxN1I88l05myJJ0ZYFMdQ2VmjFOIUTonKGG97yOGmikyid-6F48d7iI1zF6VRk7",
+ "x":"ACw6DX7wqwHVO-JzyOet0B-r10YVLv5R5q_IfiWCzclg0u_x57NCtOcFCFpM2ZnS22tyYjZb0gBHGcgUE_I-h-6s",
+ "y":"Actm2tCHBPOKLZMpJV3DaVOluln9zBsE2I0g6iV73I4M-liqA1rLSJN8q-vcSQtZF0JvzwuvGkGuTbvT_DaRQ2pf"
+ };
+
+var publicKeyJwk = {
+ "kty":"EC",
+ "crv":"P-521",
+ "x":"ADRllQ0B7icrnJ7ib2r-CXvymGFiC_3f6_o0SzLMBIggM8ndQm9l768SToMy1hUo64JsofGSQ37P4CRqT_QeivBD",
+ "y":"ALKEzew1Xe4Sv86lZVqb2xxZ0l7WrE3DPJ93fUtSPih5iH8jg0GPDKMVoA5ffFmqPwbdgS2BK18PBFIT7QDGb2Zx"
+};
+
+// This is the expected 521 bits (full output is 528 bits, the last 7 bits have been set to zero).
+var derivedBytesHex = "0117D54D84379D0FD385BE068455A77A5366AB534FF172AB0A121F37D180DCCD19607ABB0C41CB9F6F12B01303AC4A69DC2D1D05180181FD496D9769B46BFFEC3400";
+var numBitsToDerive = 521;
+
+function importKeys() {
+ var keys = {};
+
+ debug("Importing the private key...\n");
+
+ return crypto.subtle.importKey("jwk", privateKeyJwk, {name: 'ECDH', namedCurve: "P-521"}, false, ["deriveBits"]).then(function(result) {
+ keys.private = result;
+
+ debug("Importing the public key...\n");
+ return crypto.subtle.importKey("jwk", publicKeyJwk, {name: 'ECDH', namedCurve: "P-521"}, false, []);
+ }).then(function(result) {
+ keys.public = result;
+ return keys;
+ });
+}
+
+importKeys().then(function(keys) {
+ debug("Deriving 521 bits...\n");
+ return crypto.subtle.deriveBits({name: 'ecdh', public: keys.public}, keys.private, numBitsToDerive);
+}).then(function(result) {
+ bytesShouldMatchHexString("Derived Bytes", derivedBytesHex, result);
+}).then(finishJSTest, failAndFinishJSTest);
+
+</script>
+
+</body>
+</html>
« no previous file with comments | « LayoutTests/crypto/clone-ecKey-private-expected.txt ('k') | LayoutTests/crypto/ecdh-deriveBits-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698