Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320)
[chromium-blink-merge.git] / content / test / data / webcrypto / ecdsa.json
blob4c16136bd17398f0c17f552c905d589e668c0d57
1 // This file contains known answers for ECDSA verify() testing.
2 // The tests include successful and unsuccessful verifications.
3 //
4 // These are the possible fields for each test:
5 //   "key_format" -- The format of the key data. Can be one of: {"jwk", "spki", "nist".
6 //   "key" -- The public key data. Either a dictionary JWK, or hex encoded bytes (for SPKI)
7 //   "msg" -- The hex-encoded message to be verified
8 //   "sig" -- The hex-encoded ECDSA signature as a concatenation of "r" and "s".
9 //   "error" -- Optional. If provided, verify() is expected to fail with the indicated error.
10 //   "verify_result" -- Expected boolean result from verify().
13 // --------------------------------------------------------------------------
14 // Successful verifications (P256, P384, P521)
15 // --------------------------------------------------------------------------
17   // From http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3ecdsatestvectors.zip (SigVer.rsp)
18   {
19     "crv": "P-256",
20     "hash": "sha-512",
21     "key_format": "jwk",
22     "key": {
23       "kty": "EC",
24       "crv": "P-256",
25       "x": "nLDPaTA9r8dh1ORoe07PA55tNKuWSvgIENjVWKSo1vc",
26       "y": "LVEjOheIkgqG7gihlix576MX-3h54pfa0hRtuZX6HHg"
27     },
28     "msg": "6e2932153301a4eef680e6428929adae988c108d668a31ff55d0489947d75ff81a46bf89e84d6401f023be6e87688fbcd784d785ca846735524acb52d00452c84040a479e7cc330936441d93bbe722a9432a6e1db112b5c9403b10272cb1347fd619d463f7a9d223ad76fde06d8a6883500fb843235abff98e241bdfb5538c3e",
29     "sig": "4b9f91e4285287261a1d1c923cf619cd52c175cfe7f1be60a5258c610348ba3d28c45f901d71c41b298638ec0d6a85d7fcb0c33bbfec5a9c810846b639289a84",
30     "verify_result": true
31   },
33   // Same test as above, except the key format is SPKI.
34   {
35     "crv": "P-256",
36     "hash": "sha-512",
37     "key_format": "spki",
38     "key": "3059301306072A8648CE3D020106082A8648CE3D030107034200049CB0CF69303DAFC761D4E4687B4ECF039E6D34AB964AF80810D8D558A4A8D6F72D51233A1788920A86EE08A1962C79EFA317FB7879E297DAD2146DB995FA1C78",
39     "msg": "6e2932153301a4eef680e6428929adae988c108d668a31ff55d0489947d75ff81a46bf89e84d6401f023be6e87688fbcd784d785ca846735524acb52d00452c84040a479e7cc330936441d93bbe722a9432a6e1db112b5c9403b10272cb1347fd619d463f7a9d223ad76fde06d8a6883500fb843235abff98e241bdfb5538c3e",
40     "sig": "4b9f91e4285287261a1d1c923cf619cd52c175cfe7f1be60a5258c610348ba3d28c45f901d71c41b298638ec0d6a85d7fcb0c33bbfec5a9c810846b639289a84",
41     "verify_result": true
42   },
44   // From http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3ecdsatestvectors.zip (SigVer.rsp)
45   {
46     "crv": "P-384",
47     "hash": "sha-1",
48     "key_format": "jwk",
49     "key": {
50       "kty": "EC",
51       "crv": "P-384",
52       "x": "CHSi4Lj_RI8OVDIeJ_Tx5k0GTN630m9FjDLpMBIPTlfchcJpP5d-7UqOzI25gbTZ",
53       "y": "H2lEbfT0xvXeGQA_RfiR0OvNL__bXIHAQOjWmUxDx_7tuYpKMe37NeiaMAE8O5Jn"
54     },
55     "msg": "3f0783a58e66f3d2c0ccfb5fac3f09db6f8609d0592bc77fdffed9cf0e137d26a867057665f3ad81beebbbdb723d5a47c580828f10f7347ab8a9c24d195f736dfae6eae37d88fe3b4735e7c669a80ac1913e5c24c8c1d5cdb15f994f3ec2f1c774752e14f596b38c2fbf037616d608244d3da7d4badf351330f947e04cc350e7",
56     "sig": "8d9d3e3d0b2b2871ea2f03f27ba8699f214be8d875c0d770b0fff1c4ce341f0c834ac11f9ec12bfdb8320b1724c8c22062150dfba8e65c0c7be7ef81c87241d2c37a83c27eb31ccc2b3c3957670a744c81be6d741340b5189cc0c547df81b0d2",
57     "verify_result": true
58   },
60   // From http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3ecdsatestvectors.zip (SigVer.rsp)
61   {
62     "crv": "P-384",
63     "hash": "sha-256",
64     "key_format": "jwk",
65     "key": {
66       "kty": "EC",
67       "crv": "P-384",
68       "x": "hqwS3Qp_5bgf2uhrEkNdMW75OSo_ULMHq2XZxged0NLYGdwJ4ihhRZwu2Z-6tm-u",
69       "y": "rIREB3qu1tbMrL5npMqs7gtaCUo1dcoS6ktHdMAw_hyHDJJJAj9dxNmtbjM2aMw4"
70     },
71     "msg": "862cf14c65ff85f4fdd8a39302056355c89c6ea1789c056262b077dab33abbfda0070fce188c6330de84dfc512744e9fa0f7b03ce0c14858db1952750d7bbe6bd9c8726c0eae61e6cf2877c655b1f0e0ce825430a9796e7420e5c174eab7a50459e291510bc515141738900d390217c5a522e4bde547e57287d8139dc916504e",
72     "sig": "798065f1d1cbd3a1897794f4a025ed47565df773843f4fa74c85fe4d30e3a394783ec5723b530fc5f57906f946ce15e8b57166044c57c7d9582066805b5885abc06e0bfc02433850c2b74973205ca357a2da94a65172086f5a1580baa697400b",
73     "verify_result": true
74   },
76   // From http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3ecdsatestvectors.zip (SigVer.rsp)
77   {
78     "crv": "P-521",
79     "hash": "sha-1",
80     "key_format": "jwk",
81     "key": {
82       "kty": "EC",
83       "crv": "P-521",
84       "x": "APUKCHAyUMFfBDyMRumXg0NSRc-Y9PJpSw4vjQKaUU3W8LCG1O2JIADNVZAQeq5pxMCnqV98905XcKB9XbVbzkq0",
85       "y": "APLHcLq4ub5M227NPcJsaY2g0lmc6_PZBPf5yjpV5kcxgQ1zzTFyZOULq6S8KGCFfhbWy7eVAbyeOjK9Fy6opx3u"
86     },
87     "msg": "9bbbbe8a72130e1f023fb77be4648c80e1722d98bd478882383026c5c4e8748873997c5a38e0a173ed461546422d7691393dc2aceb0c0775068bc7145e33bf6a9e34f7fc6acc8f079a265168e54d3cca8d40aa04c1afd0909aa3df50908d7324aa7861b50f471fbfa5d615b0d718132c81957b178ad936deb89fde37147f8ae6",
88     "sig": "001e7cbb20c9a66abf149c79d11859051d35cfddd04f420dd23bd3206c82b29e782453cabfefe792e4e3e68c9bf6bf50d5a00ba5dd73b41378fb46e91ca797dbb25000f1e9252573c003cb77f22c8c6d56f2149f7e8d88d699983da9250c8edfd4b9f864a46c48819524651886e3fd56492f4b6c75fb50a1d59e8bfc25f9fd42dc4e1d37",
89     "verify_result": true
90   },
92 // --------------------------------------------------------------------------
93 // Bad signature
94 // --------------------------------------------------------------------------
96   // The signature was truncated by 1 byte. Verification should fail (with false, not an operation error).
97   {
98     "crv": "P-256",
99     "hash": "sha-512",
100     "key_format": "jwk",
101     "key": {
102       "kty": "EC",
103       "crv": "P-256",
104       "x": "nLDPaTA9r8dh1ORoe07PA55tNKuWSvgIENjVWKSo1vc",
105       "y": "LVEjOheIkgqG7gihlix576MX-3h54pfa0hRtuZX6HHg"
106     },
107     "msg": "6e2932153301a4eef680e6428929adae988c108d668a31ff55d0489947d75ff81a46bf89e84d6401f023be6e87688fbcd784d785ca846735524acb52d00452c84040a479e7cc330936441d93bbe722a9432a6e1db112b5c9403b10272cb1347fd619d463f7a9d223ad76fde06d8a6883500fb843235abff98e241bdfb5538c3e",
108     "sig": "4b9f91e4285287261a1d1c923cf619cd52c175cfe7f1be60a5258c610348ba3d28c45f901d71c41b298638ec0d6a85d7fcb0c33bbfec5a9c810846b639289a",
109     "verify_result": false
110   },
112   // The signature was made using SHA-512, however verification is being done
113   // using SHA-1. Verification using SHA-1 should therefore fail.
114   {
115     "crv": "P-256",
116     "hash": "sha-1",
117     "key_format": "jwk",
118     "key": {
119       "kty": "EC",
120       "crv": "P-256",
121       "x": "nLDPaTA9r8dh1ORoe07PA55tNKuWSvgIENjVWKSo1vc",
122       "y": "LVEjOheIkgqG7gihlix576MX-3h54pfa0hRtuZX6HHg"
123     },
124     "msg": "6e2932153301a4eef680e6428929adae988c108d668a31ff55d0489947d75ff81a46bf89e84d6401f023be6e87688fbcd784d785ca846735524acb52d00452c84040a479e7cc330936441d93bbe722a9432a6e1db112b5c9403b10272cb1347fd619d463f7a9d223ad76fde06d8a6883500fb843235abff98e241bdfb5538c3e",
125     "sig": "4b9f91e4285287261a1d1c923cf619cd52c175cfe7f1be60a5258c610348ba3d28c45f901d71c41b298638ec0d6a85d7fcb0c33bbfec5a9c810846b639289a84",
126     "verify_result": false
127   },
129   // Signature is zero-padded.
130   // The siganture is the concatenation of "r" and "s". In this test case both
131   // "r" and "s" are zero-padded by 1. It would be possible to support such a
132   // signature, however the expectation is that it fails.
133   {
134     "crv": "P-384",
135     "hash": "sha-1",
136     "key_format": "jwk",
137     "key": {
138       "kty": "EC",
139       "crv": "P-384",
140       "x": "CHSi4Lj_RI8OVDIeJ_Tx5k0GTN630m9FjDLpMBIPTlfchcJpP5d-7UqOzI25gbTZ",
141       "y": "H2lEbfT0xvXeGQA_RfiR0OvNL__bXIHAQOjWmUxDx_7tuYpKMe37NeiaMAE8O5Jn"
142     },
143     "msg": "3f0783a58e66f3d2c0ccfb5fac3f09db6f8609d0592bc77fdffed9cf0e137d26a867057665f3ad81beebbbdb723d5a47c580828f10f7347ab8a9c24d195f736dfae6eae37d88fe3b4735e7c669a80ac1913e5c24c8c1d5cdb15f994f3ec2f1c774752e14f596b38c2fbf037616d608244d3da7d4badf351330f947e04cc350e7",
144     "sig": "008d9d3e3d0b2b2871ea2f03f27ba8699f214be8d875c0d770b0fff1c4ce341f0c834ac11f9ec12bfdb8320b1724c8c2200062150dfba8e65c0c7be7ef81c87241d2c37a83c27eb31ccc2b3c3957670a744c81be6d741340b5189cc0c547df81b0d2",
145     "verify_result": false
146   },
148   // Empty signature.
149   {
150     "crv": "P-384",
151     "hash": "sha-1",
152     "key_format": "jwk",
153     "key": {
154       "kty": "EC",
155       "crv": "P-384",
156       "x": "CHSi4Lj_RI8OVDIeJ_Tx5k0GTN630m9FjDLpMBIPTlfchcJpP5d-7UqOzI25gbTZ",
157       "y": "H2lEbfT0xvXeGQA_RfiR0OvNL__bXIHAQOjWmUxDx_7tuYpKMe37NeiaMAE8O5Jn"
158     },
159     "msg": "3f0783a58e66f3d2c0ccfb5fac3f09db6f8609d0592bc77fdffed9cf0e137d26a867057665f3ad81beebbbdb723d5a47c580828f10f7347ab8a9c24d195f736dfae6eae37d88fe3b4735e7c669a80ac1913e5c24c8c1d5cdb15f994f3ec2f1c774752e14f596b38c2fbf037616d608244d3da7d4badf351330f947e04cc350e7",
160     "sig": "",
161     "verify_result": false
162   }