mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 09:20:04 +01: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
1 changed files with 4 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue