From fb54451c0b9c7b7ea4eab6ff9ccc3c21bfaf0f18 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Tue, 22 Aug 2017 17:53:17 +0200 Subject: [PATCH] Update to SpongyCastle 1.58.0.0. --- core/pom.xml | 4 ++-- core/src/main/java/org/bitcoinj/core/ECKey.java | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 438304e0..aaf2d58a 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -196,7 +196,7 @@ com.google.protobuf:protobuf-java:2.6.1:jar:null:compile:d9521f2aecb909835746b7a5facf612af5e890e8 com.h2database:h2:1.3.167:jar:null:compile:d3867d586f087e53eb12fc65e5693d8ee9a5da17 com.lambdaworks:scrypt:1.4.0:jar:null:compile:906506b74f30c8c20bccd9ed4a11112d8941fe87 - com.madgag.spongycastle:core:1.52.0.0:jar:null:compile:99976d02054732e513eb2d884d9e20bec539e283 + com.madgag.spongycastle:core:1.58.0.0:jar:null:compile:e08789f8f1e74f155db8b69c3575b5cb213c156c junit:junit:4.12:jar:null:test:2973d150c0dc1fefe998f834810d68f278ea58ec mysql:mysql-connector-java:5.1.33:jar:null:compile:8af455a9a3267e6664cafc87ace71a4e4ef02837 net.jcip:jcip-annotations:1.0:jar:null:compile:afba4942caaeaf46aab0b976afd57cc7c181467e @@ -386,7 +386,7 @@ com.madgag.spongycastle core - 1.52.0.0 + 1.58.0.0 com.google.protobuf diff --git a/core/src/main/java/org/bitcoinj/core/ECKey.java b/core/src/main/java/org/bitcoinj/core/ECKey.java index 77f843cc..4b27d8e7 100644 --- a/core/src/main/java/org/bitcoinj/core/ECKey.java +++ b/core/src/main/java/org/bitcoinj/core/ECKey.java @@ -47,6 +47,7 @@ import org.spongycastle.math.ec.ECPoint; import org.spongycastle.math.ec.FixedPointCombMultiplier; import org.spongycastle.math.ec.FixedPointUtil; import org.spongycastle.math.ec.custom.sec.SecP256K1Curve; +import org.spongycastle.util.Properties; import org.spongycastle.util.encoders.Base64; import javax.annotation.Nullable; @@ -568,6 +569,9 @@ public class ECKey implements EncryptableItem { public static ECDSASignature decodeFromDER(byte[] bytes) throws IllegalArgumentException { ASN1InputStream decoder = null; try { + // BouncyCastle by default is strict about parsing ASN.1 integers. We relax this check, because some + // Bitcoin signatures would not parse. + Properties.setThreadOverride("org.spongycastle.asn1.allow_unsafe_integer", true); decoder = new ASN1InputStream(bytes); final ASN1Primitive seqObj = decoder.readObject(); if (seqObj == null) @@ -590,6 +594,7 @@ public class ECKey implements EncryptableItem { } finally { if (decoder != null) try { decoder.close(); } catch (IOException x) {} + Properties.removeThreadOverride("org.spongycastle.asn1.allow_unsafe_integer"); } }