Commit 8c59288
authored
Fix P-521 ECDSA verification and add curve coverage tests (#1956)
* Fix P-521 curve name typo and signature length check in ECDSA verifier
hashForCurve matched "P-512" instead of "P-521", making the P-521 path
unreachable. verifyECDSASignature used hash length (64 for SHA-512) to
determine signature component size, but P-521 COSE signatures use 66-byte
components (ceil(521/8)). Derive component size from the curve order instead.
Add verify_test.go with sign/verify roundtrips for all four NIST curves,
rejection tests (wrong key, wrong payload, tampered sig, wrong length,
DER format), and an explicit test proving P-521 key size != hash size.
* Add COSE Sign1 verification tests against RFC 8152 / cose-wg vectors
Verify the ECDSA signature pipeline (CBOR parse, Sig_structure build,
verifyECDSASignature) against official test vectors from the COSE Working
Group Examples repository (normative suite for RFC 9052/9053):
- ES256: RFC 8152 Appendix C.2.1 (sign-pass-03)
- ES384: ecdsa-sig-02
- ES512: ecdsa-sig-03 (exercises the P-521 fix from previous commit)
- Tampered payload: sign-fail-02
- Modified protected header: sign-fail-06
- Wrong key: valid ES256 vector verified with P-384 key
* Address review: reuse curveKeySize in test, use ecdsa.SignASN1 for DER test1 parent 8add112 commit 8c59288
2 files changed
Lines changed: 377 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
223 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
224 | 237 | | |
225 | | - | |
| 238 | + | |
226 | 239 | | |
227 | 240 | | |
228 | 241 | | |
229 | | - | |
230 | | - | |
| 242 | + | |
| 243 | + | |
231 | 244 | | |
232 | 245 | | |
233 | 246 | | |
| |||
242 | 255 | | |
243 | 256 | | |
244 | 257 | | |
245 | | - | |
| 258 | + | |
246 | 259 | | |
247 | 260 | | |
248 | 261 | | |
| |||
0 commit comments