4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/common.js"></script>
8 <p id=
"description"></p>
9 <div id=
"console"></div>
12 description("Test verification using RSA-PSS and salt length of 10.");
16 var extractable
= true;
18 // This test data comes from:
19 // http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-2rsatestvectors.zip (SigVerPSS_186-3.rsp)
21 "publicKeySpki": "30819D300D06092A864886F70D010101050003818B0030818702818100BE499B5E7F06C83FA0293E31465C8EB6B58AF920BAE52A7B5B9BFEB7AA72DB1264112EB3FD431D31A2A7E50941566929494A0E891ED5613918B4B51B0D1FB97783B26ACF7D0F384CFB35F4D2824F5DD380623A26BF180B63961C619DCDB20CAE406F22F6E276C80A37259490CFEB72C1A71A84F1846D330877BA3E3101EC9C7B020111",
23 "message": "c7f5270fca725f9bd19f519a8d7cca3cc5c079024029f3bae510f9b02140fe238908e4f6c18f07a89c687c8684669b1f1db2baf9251a3c829faccb493084e16ec9e28d58868074a5d6221667dd6e528d16fe2c9f3db4cfaf6c4dce8c8439af38ceaaaa9ce2ecae7bc8f4a5a55e3bf96df9cd575c4f9cb327951b8cdfe4087168",
25 "signature": "11e169f2fd40b07641b9768a2ab19965fb6c27f10fcf0323fcc6d12eb4f1c06b330ddaa1ea504407afa29de9ebe0374fe9d1e7d0ffbd5fc1cf3a3446e4145415d2ab24f789b3464c5c43a256bbc1d692cf7f04801dac5bb401a4a03ab7d5728a860c19e1a4dc797ca542c8203cec2e601eb0c51f567f2eda022b0b9ebddeeefa"
28 var verifyAlgorithm
= { name
: "RSA-PSS", saltLength
: kTestData
.saltLength
};
29 var signature
= hexStringToUint8Array(kTestData
.signature
);
30 var message
= hexStringToUint8Array(kTestData
.message
);
32 crypto
.subtle
.importKey("spki", hexStringToUint8Array(kTestData
.publicKeySpki
), { name
: "RSA-PSS", hash
: {name
: kTestData
.hash
} }, extractable
, ["verify"]).then(function(result
) {
34 debug("\nVerifying known signature...");
35 return crypto
.subtle
.verify(verifyAlgorithm
, publicKey
, signature
, message
);
36 }).then(function(result
) {
37 verificationResult
= result
;
38 shouldBe("verificationResult", "true");
39 debug("\nVerifying a bad signature...");
40 return crypto
.subtle
.verify(verifyAlgorithm
, publicKey
, new Uint8Array(256), message
);
41 }).then(function(result
) {
42 verificationResult
= result
;
43 shouldBe("verificationResult", "false");
44 }).then(finishJSTest
, failAndFinishJSTest
);