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
path: root/core/src
diff options
context:
space:
mode:
authorDavid Hook <dgh@cryptoworkshop.com>2014-05-20 01:47:44 +0400
committerDavid Hook <dgh@cryptoworkshop.com>2014-05-20 01:47:44 +0400
commitc62a3096dcca229bb0df169fcc8a143cdb00200b (patch)
treee74d3926e049265e7a7fa8bfc2d31f0dd69e8628 /core/src
parentb2af52be1c1251f7c0b613e4ad300faa3e262e74 (diff)
parentbd6b39bf60e6609e377becaaefc632c0097e4796 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/java/org/bouncycastle/math/ec/ECCurve.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java b/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java
index 066c950b..78577b78 100644
--- a/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java
+++ b/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java
@@ -331,16 +331,33 @@ public abstract class ECCurve
break;
}
case 0x04: // uncompressed
+ {
+ if (encoded.length != (2 * expectedLength + 1))
+ {
+ throw new IllegalArgumentException("Incorrect length for uncompressed encoding");
+ }
+
+ BigInteger X = BigIntegers.fromUnsignedByteArray(encoded, 1, expectedLength);
+ BigInteger Y = BigIntegers.fromUnsignedByteArray(encoded, 1 + expectedLength, expectedLength);
+
+ p = createPoint(X, Y);
+ break;
+ }
case 0x06: // hybrid
case 0x07: // hybrid
{
if (encoded.length != (2 * expectedLength + 1))
{
- throw new IllegalArgumentException("Incorrect length for uncompressed/hybrid encoding");
+ throw new IllegalArgumentException("Incorrect length for hybrid encoding");
}
BigInteger X = BigIntegers.fromUnsignedByteArray(encoded, 1, expectedLength);
BigInteger Y = BigIntegers.fromUnsignedByteArray(encoded, 1 + expectedLength, expectedLength);
+
+ if (Y.testBit(0) != (encoded[0] == 0x07))
+ {
+ throw new IllegalArgumentException("Inconsistent Y coordinate in hybrid encoding");
+ }
p = createPoint(X, Y);
break;