Repository navigation
require the x-only choice for rSig in ECDSAEncoder.toX962 - #2496
rootvector2 wants to merge 1 commit into
Conversation
…nd hash certificates with rSig as x-only via ITSCertificate.getCanonicalEncoding(), relates to github #2496.
|
Thanks for the report, merged with revisions. The issue was IEEE 1609.2 doesn't restrict rSig to x-only. The EcdsaP256Signature / EcdsaP384Signature text says x-only is used when the signer outputs the integer r. When the signer outputs the point R, it is carried as compressed-y-0, compressed-y-1 or uncompressed "at the sender's discretion". Rejecting those forms would refuse conformant signatures. On the other hand, the HashedId8 problem you found is real. The fix belongs where the standard puts it: "If hashing, theEccP256CurvePoint in rSig shall be taken to be of form x-only." ITSCertificate.getCanonicalEncoding() now does this, and every place that hashes a certificate uses it. A re-encoded, rSig therefore no longer changes a certificate's HashedId8. |
ECDSAEncoder.toX962reads the ITS signature'srwithout checking whichEccP256CurvePointorEccP384CurvePointchoice carried it, so a signature re-encoded withrSigascompressed-y-0orcompressed-y-1(the same 32 x octets) yields an identicalrand still verifies, giving one signature three interchangeable encodings and letting a re-encoded certificate keep verifying under a differentHashedId8, while thefillanduncompressedchoices escapesignatureValidandisSignatureValidas an uncheckedIllegalArgumentException; found checking the IEEE 1609.2 sec. 6.3.29 x-only requirement against the decoder, andris now required to be of form x-only in both branches.AI tooling was used to help prepare this change.