Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-01-05 12:21:44 +0400
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-01-05 12:21:44 +0400
commitcc05f027855d6165470d2dc697e6096e0779b644 (patch)
treeec2ac458ae11b007001b487cefbccd603fede1ce /core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java
parentf3fac8898e6557b5d3fd403c833a1db791c044d1 (diff)
More custom curve temporary fixes
Diffstat (limited to 'core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java')
-rw-r--r--core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java b/core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java
index 5adf06cf..017ab881 100644
--- a/core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java
+++ b/core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java
@@ -21,6 +21,8 @@ import org.bouncycastle.crypto.params.ECPublicKeyParameters;
import org.bouncycastle.math.ec.ECCurve;
import org.bouncycastle.math.ec.ECFieldElement;
import org.bouncycastle.math.ec.ECPoint;
+import org.bouncycastle.math.ec.custom.sec.SecP256K1Curve;
+import org.bouncycastle.math.ec.custom.sec.SecP256R1Curve;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.util.BigIntegers;
import org.bouncycastle.util.Integers;
@@ -326,7 +328,8 @@ public class TlsECCUtils
{
compressed = isCompressionPreferred(ecPointFormats, ECPointFormat.ansiX962_compressed_char2);
}
- else if (curve instanceof ECCurve.Fp)
+ // TODO: need a better indicator for a custom curve
+ else if (curve instanceof ECCurve.Fp || curve instanceof SecP256K1Curve || curve instanceof SecP256R1Curve)
{
compressed = isCompressionPreferred(ecPointFormats, ECPointFormat.ansiX962_compressed_prime);
}
@@ -557,6 +560,7 @@ public class TlsECCUtils
OutputStream output) throws IOException
{
ECCurve curve = ecParameters.getCurve();
+
if (curve instanceof ECCurve.Fp)
{
TlsUtils.writeUint8(ECCurveType.explicit_prime, output);
@@ -564,6 +568,22 @@ public class TlsECCUtils
ECCurve.Fp fp = (ECCurve.Fp) curve;
writeECParameter(fp.getQ(), output);
}
+ // TODO: need a better indicator for a custom curve
+ else if (curve instanceof SecP256K1Curve)
+ {
+ TlsUtils.writeUint8(ECCurveType.explicit_prime, output);
+
+ SecP256K1Curve fp = (SecP256K1Curve) curve;
+ writeECParameter(fp.getQ(), output);
+ }
+ // TODO: need a better indicator for a custom curve
+ else if (curve instanceof SecP256R1Curve)
+ {
+ TlsUtils.writeUint8(ECCurveType.explicit_prime, output);
+
+ SecP256R1Curve fp = (SecP256R1Curve) curve;
+ writeECParameter(fp.getQ(), output);
+ }
else if (curve instanceof ECCurve.F2m)
{
TlsUtils.writeUint8(ECCurveType.explicit_char2, output);