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

Unified Diff: content/test/data/webcrypto/ecdsa.json

Issue 698363002: webcrypto: Add ECDSA algorithm (chromium-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extract_more
Patch Set: sigh, more android pedantry 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
« no previous file with comments | « content/test/data/webcrypto/ec_private_keys.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/data/webcrypto/ecdsa.json
diff --git a/content/test/data/webcrypto/ecdsa.json b/content/test/data/webcrypto/ecdsa.json
new file mode 100644
index 0000000000000000000000000000000000000000..f6dd4c3f95056a837343d9703ffe004c193f6dce
--- /dev/null
+++ b/content/test/data/webcrypto/ecdsa.json
@@ -0,0 +1,318 @@
+// This file contains known answers for ECDSA verify() testing.
+// The tests include successful verifications, as well as malformed inputs -- bad keys, malformed signature, etc.
+//
+// These are the possible fields for each test:
+// "key_format" -- The format of the key data. Can be one of: {"jwk", "spki", "nist".
+// "key" -- The public key data. Either a dictionary JWK, or hex encoded bytes (for SPKI)
+// "msg" -- The hex-encoded message to be verified
+// "sig" -- The hex-encoded ECDSA signature as a concatenation of "r" and "s".
+// "error" -- Optional. If provided, either the importKey() or verify() is expected to fail with the indicated error.
+// "verify_result" -- Expected boolean result from verify().
+[
+
+// --------------------------------------------------------------------------
+// Successful verifications (P256, P384, P521)
+// --------------------------------------------------------------------------
+
+ // From http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3ecdsatestvectors.zip (SigVer.rsp)
+ {
+ "curve": "P-256",
+ "hash": "sha-512",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-256",
+ "x": "nLDPaTA9r8dh1ORoe07PA55tNKuWSvgIENjVWKSo1vc",
+ "y": "LVEjOheIkgqG7gihlix576MX-3h54pfa0hRtuZX6HHg"
+ },
+ "msg": "6e2932153301a4eef680e6428929adae988c108d668a31ff55d0489947d75ff81a46bf89e84d6401f023be6e87688fbcd784d785ca846735524acb52d00452c84040a479e7cc330936441d93bbe722a9432a6e1db112b5c9403b10272cb1347fd619d463f7a9d223ad76fde06d8a6883500fb843235abff98e241bdfb5538c3e",
+ "sig": "4b9f91e4285287261a1d1c923cf619cd52c175cfe7f1be60a5258c610348ba3d28c45f901d71c41b298638ec0d6a85d7fcb0c33bbfec5a9c810846b639289a84",
+ "verify_result": true
+ },
+
+ // Same test as above, except the key format is SPKI.
+ {
+ "curve": "P-256",
+ "hash": "sha-512",
+ "key_format": "spki",
+ "key": "3059301306072A8648CE3D020106082A8648CE3D030107034200049CB0CF69303DAFC761D4E4687B4ECF039E6D34AB964AF80810D8D558A4A8D6F72D51233A1788920A86EE08A1962C79EFA317FB7879E297DAD2146DB995FA1C78",
+ "msg": "6e2932153301a4eef680e6428929adae988c108d668a31ff55d0489947d75ff81a46bf89e84d6401f023be6e87688fbcd784d785ca846735524acb52d00452c84040a479e7cc330936441d93bbe722a9432a6e1db112b5c9403b10272cb1347fd619d463f7a9d223ad76fde06d8a6883500fb843235abff98e241bdfb5538c3e",
+ "sig": "4b9f91e4285287261a1d1c923cf619cd52c175cfe7f1be60a5258c610348ba3d28c45f901d71c41b298638ec0d6a85d7fcb0c33bbfec5a9c810846b639289a84",
+ "verify_result": true
+ },
+
+ // From http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3ecdsatestvectors.zip (SigVer.rsp)
+ {
+ "curve": "P-384",
+ "hash": "sha-1",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-384",
+ "x": "CHSi4Lj_RI8OVDIeJ_Tx5k0GTN630m9FjDLpMBIPTlfchcJpP5d-7UqOzI25gbTZ",
+ "y": "H2lEbfT0xvXeGQA_RfiR0OvNL__bXIHAQOjWmUxDx_7tuYpKMe37NeiaMAE8O5Jn"
+ },
+ "msg": "3f0783a58e66f3d2c0ccfb5fac3f09db6f8609d0592bc77fdffed9cf0e137d26a867057665f3ad81beebbbdb723d5a47c580828f10f7347ab8a9c24d195f736dfae6eae37d88fe3b4735e7c669a80ac1913e5c24c8c1d5cdb15f994f3ec2f1c774752e14f596b38c2fbf037616d608244d3da7d4badf351330f947e04cc350e7",
+ "sig": "8d9d3e3d0b2b2871ea2f03f27ba8699f214be8d875c0d770b0fff1c4ce341f0c834ac11f9ec12bfdb8320b1724c8c22062150dfba8e65c0c7be7ef81c87241d2c37a83c27eb31ccc2b3c3957670a744c81be6d741340b5189cc0c547df81b0d2",
+ "verify_result": true
+ },
+
+ // From http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3ecdsatestvectors.zip (SigVer.rsp)
+ {
+ "curve": "P-384",
+ "hash": "sha-256",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-384",
+ "x": "hqwS3Qp_5bgf2uhrEkNdMW75OSo_ULMHq2XZxged0NLYGdwJ4ihhRZwu2Z-6tm-u",
+ "y": "rIREB3qu1tbMrL5npMqs7gtaCUo1dcoS6ktHdMAw_hyHDJJJAj9dxNmtbjM2aMw4"
+ },
+ "msg": "862cf14c65ff85f4fdd8a39302056355c89c6ea1789c056262b077dab33abbfda0070fce188c6330de84dfc512744e9fa0f7b03ce0c14858db1952750d7bbe6bd9c8726c0eae61e6cf2877c655b1f0e0ce825430a9796e7420e5c174eab7a50459e291510bc515141738900d390217c5a522e4bde547e57287d8139dc916504e",
+ "sig": "798065f1d1cbd3a1897794f4a025ed47565df773843f4fa74c85fe4d30e3a394783ec5723b530fc5f57906f946ce15e8b57166044c57c7d9582066805b5885abc06e0bfc02433850c2b74973205ca357a2da94a65172086f5a1580baa697400b",
+ "verify_result": true
+ },
+
+ // From http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3ecdsatestvectors.zip (SigVer.rsp)
+ {
+ "curve": "P-521",
+ "hash": "sha-1",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-521",
+ "x": "APUKCHAyUMFfBDyMRumXg0NSRc-Y9PJpSw4vjQKaUU3W8LCG1O2JIADNVZAQeq5pxMCnqV98905XcKB9XbVbzkq0",
+ "y": "APLHcLq4ub5M227NPcJsaY2g0lmc6_PZBPf5yjpV5kcxgQ1zzTFyZOULq6S8KGCFfhbWy7eVAbyeOjK9Fy6opx3u"
+ },
+ "msg": "9bbbbe8a72130e1f023fb77be4648c80e1722d98bd478882383026c5c4e8748873997c5a38e0a173ed461546422d7691393dc2aceb0c0775068bc7145e33bf6a9e34f7fc6acc8f079a265168e54d3cca8d40aa04c1afd0909aa3df50908d7324aa7861b50f471fbfa5d615b0d718132c81957b178ad936deb89fde37147f8ae6",
+ "sig": "001e7cbb20c9a66abf149c79d11859051d35cfddd04f420dd23bd3206c82b29e782453cabfefe792e4e3e68c9bf6bf50d5a00ba5dd73b41378fb46e91ca797dbb25000f1e9252573c003cb77f22c8c6d56f2149f7e8d88d699983da9250c8edfd4b9f864a46c48819524651886e3fd56492f4b6c75fb50a1d59e8bfc25f9fd42dc4e1d37",
+ "verify_result": true
+ },
+
+// --------------------------------------------------------------------------
+// Bad public keys (import fails)
+// --------------------------------------------------------------------------
+
+ // Import Error: P-521 is requested by importKey(), however the JWK's curve is for P-256.
+ {
+ "curve": "P-521",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-256",
+ "x": "APUKCHAyUMFfBDyMRumXg0NSRc-Y9PJpSw4vjQKaUU3W8LCG1O2JIADNVZAQeq5pxMCnqV98905XcKB9XbVbzkq0",
+ "y": "APLHcLq4ub5M227NPcJsaY2g0lmc6_PZBPf5yjpV5kcxgQ1zzTFyZOULq6S8KGCFfhbWy7eVAbyeOjK9Fy6opx3u"
+ },
+ "error": "DataError: The JWK's \"crv\" member specifies a different curve than requested"
+ },
+
+ // Import Error: P-521 is requested by importKey(), however the JWK's algorithm implies P-256
+ {
+ "curve": "P-521",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "alg": "ES256",
+ "crv": "P-521",
+ "x": "APUKCHAyUMFfBDyMRumXg0NSRc-Y9PJpSw4vjQKaUU3W8LCG1O2JIADNVZAQeq5pxMCnqV98905XcKB9XbVbzkq0",
+ "y": "APLHcLq4ub5M227NPcJsaY2g0lmc6_PZBPf5yjpV5kcxgQ1zzTFyZOULq6S8KGCFfhbWy7eVAbyeOjK9Fy6opx3u"
+ },
+ "error": "DataError: The JWK \"alg\" property was inconsistent with that specified by the Web Crypto call"
+ },
+
+ // Import Error: crv is missing
+ {
+ "curve": "P-384",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "x": "hqwS3Qp_5bgf2uhrEkNdMW75OSo_ULMHq2XZxged0NLYGdwJ4ihhRZwu2Z-6tm-u",
+ "y": "rIREB3qu1tbMrL5npMqs7gtaCUo1dcoS6ktHdMAw_hyHDJJJAj9dxNmtbjM2aMw4"
+ },
+ "error": "DataError: The required JWK property \"crv\" was missing"
+ },
+
+ // Import Error: x is missing
+ {
+ "curve": "P-384",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-384",
+ "y": "rIREB3qu1tbMrL5npMqs7gtaCUo1dcoS6ktHdMAw_hyHDJJJAj9dxNmtbjM2aMw4"
+ },
+ "error": "DataError: The required JWK property \"x\" was missing"
+ },
+
+ // Import Error: Invalid key (x was corrupted)
+ {
+ "curve": "P-256",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-256",
+ "x": "nLPPaTA9r8dh1ORoe07PA55tNKuWSvgIENjVWKSo1vc",
+ "y": "LVEjOheIkgqG7gihlix576MX-3h54pfa0hRtuZX6HHg"
+ },
+ "error": "OperationError"
+ },
+
+ // Import Error: Incorrect kty.
+ {
+ "curve": "P-384",
+ "key_format": "jwk",
+ "key": {
+ "kty": "RSA",
+ "crv": "P-384",
+ "x": "hqwS3Qp_5bgf2uhrEkNdMW75OSo_ULMHq2XZxged0NLYGdwJ4ihhRZwu2Z-6tm-u",
+ "y": "rIREB3qu1tbMrL5npMqs7gtaCUo1dcoS6ktHdMAw_hyHDJJJAj9dxNmtbjM2aMw4"
+ },
+ "error": "DataError: The JWK \"kty\" property was not \"EC\""
+ },
+
+ // Import Error: SPKI data is empty.
+ {
+ "curve": "P-384",
+ "key_format": "spki",
+ "key": "",
+ "error": "DataError: No key data was provided"
+ },
+
+ // Import Error: SPKI data is invalid.
+ {
+ "curve": "P-384",
+ "key_format": "spki",
+ "key": "00010203",
+ "error": "DataError"
+ },
+
+ // Import Error: SPKI data is invalid (1 byte was corrupted)
+ {
+ "curve": "P-256",
+ "key_format": "spki",
+ "key": "3059301306072A8648CE3D020106082A8748CE3D030107034200049CB0CF69303DAFC761D4E4687B4ECF039E6D34AB964AF80810D8D558A4A8D6F72D51233A1788920A86EE08A1962C79EFA317FB7879E297DAD2146DB995FA1C78",
+ "error": "DataError"
+ },
+
+ // Import Error: SPKI data is invalid (1 byte truncated from end)
+ {
+ "curve": "P-256",
+ "key_format": "spki",
+ "key": "3059301306072A8648CE3D020106082A8648CE3D030107034200049CB0CF69303DAFC761D4E4687B4ECF039E6D34AB964AF80810D8D558A4A8D6F72D51233A1788920A86EE08A1962C79EFA317FB7879E297DAD2146DB995FA1C",
+ "error": "DataError"
+ },
+
+ // Import Error: Valid SPKI data was provided, however it is for an RSA key
+ {
+ "curve": "P-256",
+ "key_format": "spki",
+ "key": "30819f300d06092a864886f70d010101050003818d0030818902818100a56e4a0e701017589a5187dc7ea841d156f2ec0e36ad52a44dfeb1e61f7ad991d8c51056ffedb162b4c0f283a12a88a394dff526ab7291cbb307ceabfce0b1dfd5cd9508096d5b2b8b6df5d671ef6377c0921cb23c270a70e2598e6ff89d19f105acc2d3f0cb35f29280e1386b6f64c4ef22e1e1f20d0ce8cffb2249bd9a21370203010001",
+ "error": "DataError"
+ },
+
+ // Import Error: JWK was given where the "x" member is not zero-padded.
+ {
+ "curve": "P-256",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-256",
+ "x": "2A0aLWA8otEPMLZFAksn2h5JC3HrJNNu4MRksc-b2Q",
+ "y": "lZYURbYRHyeqmHQOEKxrVVJZzL0_BByXwMCwRKzAN_k"
+ },
+ "error": "DataError: The JWK's \"x\" member defines an octet string of length 31 bytes but should be 32"
+ },
+
+ // Import Error: JWK was given where the "x" member is not zero-padded.
+ {
+ "curve": "P-256",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-256",
+ "x": "V_S9kHyUTFiXiIJNovS89K0ctDtXe2qthCWjs4J7Bb0",
+ "y": "e-6aI45DddCJGrGWqgH83fFjn_eS7s8ygoeZJbh2Bg"
+ },
+ "error": "DataError: The JWK's \"y\" member defines an octet string of length 31 bytes but should be 32"
+ },
+
+ // Import Error: The SPKI is valid, however contains 3 trailing bytes.
+ {
+ "curve": "P-256",
+ "key_format": "spki",
+ "key": "3059301306072A8648CE3D020106082A8648CE3D030107034200049CB0CF69303DAFC761D4E4687B4ECF039E6D34AB964AF80810D8D558A4A8D6F72D51233A1788920A86EE08A1962C79EFA317FB7879E297DAD2146DB995FA1C78000000",
+ "error": "DataError"
+ },
+
+// --------------------------------------------------------------------------
+// Bad signature
+// --------------------------------------------------------------------------
+
+ // The signature was truncated by 1 byte. Verification should fail (with false, not an operation error).
+ {
+ "curve": "P-256",
+ "hash": "sha-512",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-256",
+ "x": "nLDPaTA9r8dh1ORoe07PA55tNKuWSvgIENjVWKSo1vc",
+ "y": "LVEjOheIkgqG7gihlix576MX-3h54pfa0hRtuZX6HHg"
+ },
+ "msg": "6e2932153301a4eef680e6428929adae988c108d668a31ff55d0489947d75ff81a46bf89e84d6401f023be6e87688fbcd784d785ca846735524acb52d00452c84040a479e7cc330936441d93bbe722a9432a6e1db112b5c9403b10272cb1347fd619d463f7a9d223ad76fde06d8a6883500fb843235abff98e241bdfb5538c3e",
+ "sig": "4b9f91e4285287261a1d1c923cf619cd52c175cfe7f1be60a5258c610348ba3d28c45f901d71c41b298638ec0d6a85d7fcb0c33bbfec5a9c810846b639289a",
+ "verify_result": false
+ },
+
+ // The signature was made using SHA-512, however verification is being done
+ // using SHA-1. Verification using SHA-1 should therefore fail.
+ {
+ "curve": "P-256",
+ "hash": "sha-1",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-256",
+ "x": "nLDPaTA9r8dh1ORoe07PA55tNKuWSvgIENjVWKSo1vc",
+ "y": "LVEjOheIkgqG7gihlix576MX-3h54pfa0hRtuZX6HHg"
+ },
+ "msg": "6e2932153301a4eef680e6428929adae988c108d668a31ff55d0489947d75ff81a46bf89e84d6401f023be6e87688fbcd784d785ca846735524acb52d00452c84040a479e7cc330936441d93bbe722a9432a6e1db112b5c9403b10272cb1347fd619d463f7a9d223ad76fde06d8a6883500fb843235abff98e241bdfb5538c3e",
+ "sig": "4b9f91e4285287261a1d1c923cf619cd52c175cfe7f1be60a5258c610348ba3d28c45f901d71c41b298638ec0d6a85d7fcb0c33bbfec5a9c810846b639289a84",
+ "verify_result": false
+ },
+
+ // Signature is zero-padded.
+ // The siganture is the concatenation of "r" and "s". In this test case both
+ // "r" and "s" are zero-padded by 1. It would be possible to support such a
+ // signature, however the expectation is that it fails.
+ {
+ "curve": "P-384",
+ "hash": "sha-1",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-384",
+ "x": "CHSi4Lj_RI8OVDIeJ_Tx5k0GTN630m9FjDLpMBIPTlfchcJpP5d-7UqOzI25gbTZ",
+ "y": "H2lEbfT0xvXeGQA_RfiR0OvNL__bXIHAQOjWmUxDx_7tuYpKMe37NeiaMAE8O5Jn"
+ },
+ "msg": "3f0783a58e66f3d2c0ccfb5fac3f09db6f8609d0592bc77fdffed9cf0e137d26a867057665f3ad81beebbbdb723d5a47c580828f10f7347ab8a9c24d195f736dfae6eae37d88fe3b4735e7c669a80ac1913e5c24c8c1d5cdb15f994f3ec2f1c774752e14f596b38c2fbf037616d608244d3da7d4badf351330f947e04cc350e7",
+ "sig": "008d9d3e3d0b2b2871ea2f03f27ba8699f214be8d875c0d770b0fff1c4ce341f0c834ac11f9ec12bfdb8320b1724c8c2200062150dfba8e65c0c7be7ef81c87241d2c37a83c27eb31ccc2b3c3957670a744c81be6d741340b5189cc0c547df81b0d2",
+ "verify_result": false
+ },
+
+ // Empty signature.
+ {
+ "curve": "P-384",
+ "hash": "sha-1",
+ "key_format": "jwk",
+ "key": {
+ "kty": "EC",
+ "crv": "P-384",
+ "x": "CHSi4Lj_RI8OVDIeJ_Tx5k0GTN630m9FjDLpMBIPTlfchcJpP5d-7UqOzI25gbTZ",
+ "y": "H2lEbfT0xvXeGQA_RfiR0OvNL__bXIHAQOjWmUxDx_7tuYpKMe37NeiaMAE8O5Jn"
+ },
+ "msg": "3f0783a58e66f3d2c0ccfb5fac3f09db6f8609d0592bc77fdffed9cf0e137d26a867057665f3ad81beebbbdb723d5a47c580828f10f7347ab8a9c24d195f736dfae6eae37d88fe3b4735e7c669a80ac1913e5c24c8c1d5cdb15f994f3ec2f1c774752e14f596b38c2fbf037616d608244d3da7d4badf351330f947e04cc350e7",
+ "sig": "",
+ "verify_result": false
+ }
+]
« no previous file with comments | « content/test/data/webcrypto/ec_private_keys.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698