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:
parent
dd89369538
commit
a831374b72
@ -253,7 +253,10 @@ public class ECKey implements Serializable {
|
|||||||
DERInteger r = (DERInteger) seq.getObjectAt(0);
|
DERInteger r = (DERInteger) seq.getObjectAt(0);
|
||||||
DERInteger s = (DERInteger) seq.getObjectAt(1);
|
DERInteger s = (DERInteger) seq.getObjectAt(1);
|
||||||
decoder.close();
|
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) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user