mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +00:00
ECDSASignature.decodeFromDER(): Now throws IllegalArgumentException if something with the input bytes is wrong. RuntimeException is bad!
This commit is contained in:
@@ -574,13 +574,13 @@ public class ECKey implements EncryptableItem {
|
||||
}
|
||||
}
|
||||
|
||||
public static ECDSASignature decodeFromDER(byte[] bytes) {
|
||||
public static ECDSASignature decodeFromDER(byte[] bytes) throws IllegalArgumentException {
|
||||
ASN1InputStream decoder = null;
|
||||
try {
|
||||
decoder = new ASN1InputStream(bytes);
|
||||
DLSequence seq = (DLSequence) decoder.readObject();
|
||||
if (seq == null)
|
||||
throw new RuntimeException("Reached past end of ASN.1 stream.");
|
||||
throw new IllegalArgumentException("Reached past end of ASN.1 stream.");
|
||||
ASN1Integer r, s;
|
||||
try {
|
||||
r = (ASN1Integer) seq.getObjectAt(0);
|
||||
@@ -592,7 +592,7 @@ public class ECKey implements EncryptableItem {
|
||||
// Thus, we always use the positive versions. See: http://r6.ca/blog/20111119T211504Z.html
|
||||
return new ECDSASignature(r.getPositiveValue(), s.getPositiveValue());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new IllegalArgumentException(e);
|
||||
} finally {
|
||||
if (decoder != null)
|
||||
try { decoder.close(); } catch (IOException x) {}
|
||||
|
@@ -183,7 +183,7 @@ public class DefaultRiskAnalysis implements RiskAnalysis {
|
||||
ECDSASignature signature;
|
||||
try {
|
||||
signature = ECKey.ECDSASignature.decodeFromDER(chunk.data);
|
||||
} catch (RuntimeException x) {
|
||||
} catch (IllegalArgumentException x) {
|
||||
// Doesn't look like a signature.
|
||||
signature = null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user