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-03-17 12:39:54 +0400
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-03-17 12:39:54 +0400
commitb7a6b8b749c8159eb29371f6bc3b1c91467e8d63 (patch)
tree2240832c70bfe9537369fd91712696b0b68899ab /core/src/main/java/org
parentf577847df5786c0a9d82b023abe747e40cacc2e3 (diff)
A few small follow-ups to the Curve25519 stuff
Diffstat (limited to 'core/src/main/java/org')
-rw-r--r--core/src/main/java/org/bouncycastle/crypto/ec/CustomNamedCurves.java19
-rw-r--r--core/src/main/java/org/bouncycastle/math/ec/custom/djb/Curve25519FieldElement.java2
-rw-r--r--core/src/main/java/org/bouncycastle/math/ec/custom/djb/Curve25519Point.java10
3 files changed, 15 insertions, 16 deletions
diff --git a/core/src/main/java/org/bouncycastle/crypto/ec/CustomNamedCurves.java b/core/src/main/java/org/bouncycastle/crypto/ec/CustomNamedCurves.java
index 6d88f1be..5bfe96d7 100644
--- a/core/src/main/java/org/bouncycastle/crypto/ec/CustomNamedCurves.java
+++ b/core/src/main/java/org/bouncycastle/crypto/ec/CustomNamedCurves.java
@@ -245,6 +245,13 @@ public class CustomNamedCurves
oidToCurve.put(oid, holder);
}
+ static void defineCurveAlias(String alias, ASN1ObjectIdentifier oid)
+ {
+ alias = Strings.toLowerCase(alias);
+ nameToOID.put(alias, oid);
+ nameToCurve.put(alias, oidToCurve.get(oid));
+ }
+
static
{
defineCurve("curve25519", curve25519);
@@ -258,16 +265,16 @@ public class CustomNamedCurves
defineCurveWithOID("secp384r1", SECObjectIdentifiers.secp384r1, secp384r1);
defineCurveWithOID("secp521r1", SECObjectIdentifiers.secp521r1, secp521r1);
- nameToOID.put(Strings.toLowerCase("P-192"), SECObjectIdentifiers.secp192r1);
- nameToOID.put(Strings.toLowerCase("P-224"), SECObjectIdentifiers.secp224r1);
- nameToOID.put(Strings.toLowerCase("P-256"), SECObjectIdentifiers.secp256r1);
- nameToOID.put(Strings.toLowerCase("P-384"), SECObjectIdentifiers.secp384r1);
- nameToOID.put(Strings.toLowerCase("P-521"), SECObjectIdentifiers.secp521r1);
+ defineCurveAlias("P-192", SECObjectIdentifiers.secp192r1);
+ defineCurveAlias("P-224", SECObjectIdentifiers.secp224r1);
+ defineCurveAlias("P-256", SECObjectIdentifiers.secp256r1);
+ defineCurveAlias("P-384", SECObjectIdentifiers.secp384r1);
+ defineCurveAlias("P-521", SECObjectIdentifiers.secp521r1);
}
public static X9ECParameters getByName(String name)
{
- X9ECParametersHolder holder = (X9ECParametersHolder)nameToCurve.get(name);
+ X9ECParametersHolder holder = (X9ECParametersHolder)nameToCurve.get(Strings.toLowerCase(name));
return holder == null ? null : holder.getParameters();
}
diff --git a/core/src/main/java/org/bouncycastle/math/ec/custom/djb/Curve25519FieldElement.java b/core/src/main/java/org/bouncycastle/math/ec/custom/djb/Curve25519FieldElement.java
index 470b92c8..6e3d9cfa 100644
--- a/core/src/main/java/org/bouncycastle/math/ec/custom/djb/Curve25519FieldElement.java
+++ b/core/src/main/java/org/bouncycastle/math/ec/custom/djb/Curve25519FieldElement.java
@@ -141,7 +141,7 @@ public class Curve25519FieldElement extends ECFieldElement
* { 251 1s } { 1 0s }
*
* Therefore we need an addition chain containing 251 (the lengths of the repunits)
- * We use: 1, 2, 3, 4, 7, 11, 15, 30, 60, 120, 131, 251
+ * We use: 1, 2, 3, 4, 7, 11, 15, 30, 60, 120, 131, [251]
*/
int[] x1 = this.x;
diff --git a/core/src/main/java/org/bouncycastle/math/ec/custom/djb/Curve25519Point.java b/core/src/main/java/org/bouncycastle/math/ec/custom/djb/Curve25519Point.java
index f2341314..2913af99 100644
--- a/core/src/main/java/org/bouncycastle/math/ec/custom/djb/Curve25519Point.java
+++ b/core/src/main/java/org/bouncycastle/math/ec/custom/djb/Curve25519Point.java
@@ -253,15 +253,7 @@ public class Curve25519Point extends ECPoint
return this;
}
- ECCurve curve = this.getCurve();
- int coord = curve.getCoordinateSystem();
-
- if (ECCurve.COORD_AFFINE != coord)
- {
- return new Curve25519Point(curve, this.x, this.y.negate(), this.zs, this.withCompression);
- }
-
- return new Curve25519Point(curve, this.x, this.y.negate(), this.withCompression);
+ return new Curve25519Point(this.getCurve(), this.x, this.y.negate(), this.zs, this.withCompression);
}
protected ECFieldElement calculateJacobianModifiedW(ECFieldElement Z, ECFieldElement ZSquared)