| OLD | NEW |
| (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 ECDH's deriveBits() using P-521"); | |
| 13 | |
| 14 jsTestIsAsync = true; | |
| 15 | |
| 16 // The test data uses a public key and private key (from different key pairs) fo
r the P-521 curve. | |
| 17 var privateKeyJwk = { | |
| 18 "kty":"EC", | |
| 19 "crv":"P-521", | |
| 20 "d":"AI_Zu5xisuK-IIz85dTSoqaQSTxN1I88l05myJJ0ZYFMdQ2VmjFOIUTonKGG97yOGmikyi
d-6F48d7iI1zF6VRk7", | |
| 21 "x":"ACw6DX7wqwHVO-JzyOet0B-r10YVLv5R5q_IfiWCzclg0u_x57NCtOcFCFpM2ZnS22tyYj
Zb0gBHGcgUE_I-h-6s", | |
| 22 "y":"Actm2tCHBPOKLZMpJV3DaVOluln9zBsE2I0g6iV73I4M-liqA1rLSJN8q-vcSQtZF0Jvzw
uvGkGuTbvT_DaRQ2pf" | |
| 23 }; | |
| 24 | |
| 25 var publicKeyJwk = { | |
| 26 "kty":"EC", | |
| 27 "crv":"P-521", | |
| 28 "x":"ADRllQ0B7icrnJ7ib2r-CXvymGFiC_3f6_o0SzLMBIggM8ndQm9l768SToMy1hUo64JsofGS
Q37P4CRqT_QeivBD", | |
| 29 "y":"ALKEzew1Xe4Sv86lZVqb2xxZ0l7WrE3DPJ93fUtSPih5iH8jg0GPDKMVoA5ffFmqPwbdgS2B
K18PBFIT7QDGb2Zx" | |
| 30 }; | |
| 31 | |
| 32 // This is the expected 521 bits (full output is 528 bits, the last 7 bits have
been set to zero). | |
| 33 var derivedBytesHex = "0117D54D84379D0FD385BE068455A77A5366AB534FF172AB0A121F37D
180DCCD19607ABB0C41CB9F6F12B01303AC4A69DC2D1D05180181FD496D9769B46BFFEC3400"; | |
| 34 var numBitsToDerive = 521; | |
| 35 | |
| 36 function importKeys() { | |
| 37 var keys = {}; | |
| 38 | |
| 39 debug("Importing the private key...\n"); | |
| 40 | |
| 41 return crypto.subtle.importKey("jwk", privateKeyJwk, {name: 'ECDH', namedCur
ve: "P-521"}, false, ["deriveBits"]).then(function(result) { | |
| 42 keys.private = result; | |
| 43 | |
| 44 debug("Importing the public key...\n"); | |
| 45 return crypto.subtle.importKey("jwk", publicKeyJwk, {name: 'ECDH', named
Curve: "P-521"}, false, []); | |
| 46 }).then(function(result) { | |
| 47 keys.public = result; | |
| 48 return keys; | |
| 49 }); | |
| 50 } | |
| 51 | |
| 52 importKeys().then(function(keys) { | |
| 53 debug("Deriving 521 bits...\n"); | |
| 54 return crypto.subtle.deriveBits({name: 'ecdh', public: keys.public}, keys.pr
ivate, numBitsToDerive); | |
| 55 }).then(function(result) { | |
| 56 bytesShouldMatchHexString("Derived Bytes", derivedBytesHex, result); | |
| 57 }).then(finishJSTest, failAndFinishJSTest); | |
| 58 | |
| 59 </script> | |
| 60 | |
| 61 </body> | |
| 62 </html> | |
| OLD | NEW |