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>2013-09-27 13:51:08 +0400
committerPeter Dettman <peter.dettman@bouncycastle.org>2013-09-27 13:51:08 +0400
commitde54694106821ac9d1da12d40ed5ba82288ff4fb (patch)
treeee57c2162a70344b4d7b607a04c265e709d37287 /core/src/main/java/org/bouncycastle/crypto/tls
parentc921fbecb4c8ef8dad70d278c1fed6e08cf66a61 (diff)
Use ECFieldElement.getEncoded() in place of X9IntegerConverter when we
have a field element already
Diffstat (limited to 'core/src/main/java/org/bouncycastle/crypto/tls')
-rw-r--r--core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java14
1 files changed, 9 insertions, 5 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 35562b84..46489c2d 100644
--- a/core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java
+++ b/core/src/main/java/org/bouncycastle/crypto/tls/TlsECCUtils.java
@@ -8,7 +8,6 @@ import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.Hashtable;
-import org.bouncycastle.asn1.sec.SECNamedCurves;
import org.bouncycastle.asn1.x9.ECNamedCurveTable;
import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
@@ -19,6 +18,7 @@ import org.bouncycastle.crypto.params.ECKeyGenerationParameters;
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
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.util.BigIntegers;
import org.bouncycastle.util.Integers;
@@ -309,8 +309,7 @@ public class TlsECCUtils
public static byte[] serializeECFieldElement(int fieldSize, BigInteger x) throws IOException
{
- int requiredLength = (fieldSize + 7) / 8;
- return BigIntegers.asUnsignedByteArray(requiredLength, x);
+ return BigIntegers.asUnsignedByteArray((fieldSize + 7) / 8, x);
}
public static byte[] serializeECPoint(short[] ecPointFormats, ECPoint point) throws IOException
@@ -541,6 +540,11 @@ public class TlsECCUtils
writeECParameter(K, output);
}
+ public static void writeECFieldElement(ECFieldElement x, OutputStream output) throws IOException
+ {
+ TlsUtils.writeOpaque8(x.getEncoded(), output);
+ }
+
public static void writeECFieldElement(int fieldSize, BigInteger x, OutputStream output) throws IOException
{
TlsUtils.writeOpaque8(serializeECFieldElement(fieldSize, x), output);
@@ -590,8 +594,8 @@ public class TlsECCUtils
throw new IllegalArgumentException("'ecParameters' not a known curve type");
}
- writeECFieldElement(curve.getFieldSize(), curve.getA().toBigInteger(), output);
- writeECFieldElement(curve.getFieldSize(), curve.getB().toBigInteger(), output);
+ writeECFieldElement(curve.getA(), output);
+ writeECFieldElement(curve.getB(), output);
TlsUtils.writeOpaque8(serializeECPoint(ecPointFormats, ecParameters.getG()), output);
writeECParameter(ecParameters.getN(), output);
writeECParameter(ecParameters.getH(), output);