| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script src="../resources/common.js"></script> |
| </head> |
| <body> |
| <p id="description"></p> |
| <div id="console"></div> |
| |
| <script type="text/javascript"> |
| description("Test ECDSA verifying operation with malformed parameters"); |
| |
| jsTestIsAsync = true; |
| |
| var extractable = true; |
| var jwkPublicKey = { |
| kty: "EC", |
| crv: "P-256", |
| x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA", |
| y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI", |
| }; |
| var ecdsaParams = { |
| name: "ECDSA", |
| hash: "SHA-256", |
| } |
| var data = asciiToUint8Array("Hello, World!"); |
| var corruptedSignature = hexStringToUint8Array("d60737267c707deb1f3547c85d3f49b167fb3b4fd7ed7d974c2adc4f89171f9884a2637d5d5a7c5d475dc13d37522b958d5bf333a06e9ad445e831f220900a1b"); |
| var shortenSignature = hexStringToUint8Array("d60737267c707deb1f3547c85d3f49b167fb3b4fd7ed7d974c2adc4f89171f9884a2637d5d5a7c5d475dc13d37522b958d5bf333a06e9ad445e831f220900a"); |
| var invalidSignature1 = hexStringToUint8Array("000000000000000000000000000000000000000000000000000000000000000084a2637d5d5a7c5d475dc13d37522b958d5bf333a06e9ad445e831f220900a1b"); |
| var invalidSignature2 = hexStringToUint8Array("84a2637d5d5a7c5d475dc13d37522b958d5bf333a06e9ad445e831f220900a1b0000000000000000000000000000000000000000000000000000000000000000"); |
| |
| crypto.subtle.importKey("jwk", jwkPublicKey, { name: "ECDSA", namedCurve: "P-256" }, extractable, ["verify"]).then(function(result) { |
| key = result; |
| |
| return crypto.subtle.verify(ecdsaParams, key, corruptedSignature, data); |
| }).then(function(result) { |
| verified = result; |
| |
| shouldBeFalse("verified"); |
| |
| return crypto.subtle.verify(ecdsaParams, key, shortenSignature, data); |
| }).then(function(result) { |
| verified = result; |
| |
| shouldBeFalse("verified"); |
| |
| return crypto.subtle.verify(ecdsaParams, key, invalidSignature1, data); |
| }).then(function(result) { |
| verified = result; |
| |
| shouldBeFalse("verified"); |
| |
| return crypto.subtle.verify(ecdsaParams, key, invalidSignature2, data); |
| }).then(function(result) { |
| verified = result; |
| |
| shouldBeFalse("verified"); |
| |
| finishJSTest(); |
| }, failAndFinishJSTest); |
| |
| </script> |
| |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |