3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-12 10:15:52 +00:00

Fix handling of improperly-encoded DER signatures to match OpenSSL

This always reads variables in DER signatures as positive, even
when they are encoded as negative.
This commit is contained in:
Matt Corallo 2012-08-06 03:46:34 +02:00 committed by Mike Hearn
parent dd89369538
commit a831374b72

View File

@ -253,7 +253,10 @@ public class ECKey implements Serializable {
DERInteger r = (DERInteger) seq.getObjectAt(0);
DERInteger s = (DERInteger) seq.getObjectAt(1);
decoder.close();
return signer.verifySignature(data, r.getValue(), s.getValue());
// OpenSSL deviates from the DER spec by interpreting these values as unsigned, though they should not be
// Thus, we always use the positive versions.
// See: http://r6.ca/blog/20111119T211504Z.html
return signer.verifySignature(data, r.getPositiveValue(), s.getPositiveValue());
} catch (IOException e) {
throw new RuntimeException(e);
}