aboutsummaryrefslogtreecommitdiff
path: root/src/cz/crcs/ectester/common
diff options
context:
space:
mode:
authorJ08nY2018-05-02 20:08:49 +0200
committerJ08nY2018-05-02 20:08:49 +0200
commit87c4accbecc2f37a42c96e2bbc3c90618bfa2fdc (patch)
treef24d78af5e7a14e1a322a2b3978b0204bb0e5ec3 /src/cz/crcs/ectester/common
parent92c28a15e018e55b8f195993414f769ecf96a663 (diff)
downloadECTester-87c4accbecc2f37a42c96e2bbc3c90618bfa2fdc.tar.gz
ECTester-87c4accbecc2f37a42c96e2bbc3c90618bfa2fdc.tar.zst
ECTester-87c4accbecc2f37a42c96e2bbc3c90618bfa2fdc.zip
Add compression test suite.
Diffstat (limited to '')
-rw-r--r--src/cz/crcs/ectester/common/ec/EC_Curve.java8
-rw-r--r--src/cz/crcs/ectester/common/test/TestSuite.java4
-rw-r--r--src/cz/crcs/ectester/common/util/ByteUtil.java4
-rw-r--r--src/cz/crcs/ectester/common/util/CardUtil.java2
4 files changed, 14 insertions, 4 deletions
diff --git a/src/cz/crcs/ectester/common/ec/EC_Curve.java b/src/cz/crcs/ectester/common/ec/EC_Curve.java
index 173fd29..8338a93 100644
--- a/src/cz/crcs/ectester/common/ec/EC_Curve.java
+++ b/src/cz/crcs/ectester/common/ec/EC_Curve.java
@@ -54,7 +54,7 @@ public class EC_Curve extends EC_Params {
return "<" + getId() + "> " + (field == KeyPair.ALG_EC_FP ? "Prime" : "Binary") + " field Elliptic curve (" + String.valueOf(bits) + "b)" + (desc == null ? "" : ": " + desc);
}
- public ECParameterSpec toSpec() {
+ public EllipticCurve toCurve() {
ECField field;
if (this.field == KeyPair.ALG_EC_FP) {
field = new ECFieldFp(new BigInteger(1, getData(0)));
@@ -71,7 +71,11 @@ public class EC_Curve extends EC_Params {
BigInteger a = new BigInteger(1, getParam(EC_Consts.PARAMETER_A)[0]);
BigInteger b = new BigInteger(1, getParam(EC_Consts.PARAMETER_B)[0]);
- EllipticCurve curve = new EllipticCurve(field, a, b);
+ return new EllipticCurve(field, a, b);
+ }
+
+ public ECParameterSpec toSpec() {
+ EllipticCurve curve = toCurve();
byte[][] G = getParam(EC_Consts.PARAMETER_G);
BigInteger gx = new BigInteger(1, G[0]);
diff --git a/src/cz/crcs/ectester/common/test/TestSuite.java b/src/cz/crcs/ectester/common/test/TestSuite.java
index 3b3cd4b..9e08891 100644
--- a/src/cz/crcs/ectester/common/test/TestSuite.java
+++ b/src/cz/crcs/ectester/common/test/TestSuite.java
@@ -40,7 +40,7 @@ public abstract class TestSuite {
* @return The test that was run.
* @throws TestException
*/
- protected Test runTest(Test t) {
+ protected <T extends Test> T runTest(T t) {
running = t;
t.run();
running = null;
@@ -54,7 +54,7 @@ public abstract class TestSuite {
* @return The test that was run.
* @throws TestException
*/
- protected Test doTest(Test t) {
+ protected <T extends Test> T doTest(T t) {
runTest(t);
writer.outputTest(t);
return t;
diff --git a/src/cz/crcs/ectester/common/util/ByteUtil.java b/src/cz/crcs/ectester/common/util/ByteUtil.java
index 0de8dc7..daacabb 100644
--- a/src/cz/crcs/ectester/common/util/ByteUtil.java
+++ b/src/cz/crcs/ectester/common/util/ByteUtil.java
@@ -172,4 +172,8 @@ public class ByteUtil {
}
return out;
}
+
+ public static byte[] prependLength(byte[] data) {
+ return concatenate(ByteUtil.shortToBytes((short) data.length), data);
+ }
}
diff --git a/src/cz/crcs/ectester/common/util/CardUtil.java b/src/cz/crcs/ectester/common/util/CardUtil.java
index 2501e47..85a4a35 100644
--- a/src/cz/crcs/ectester/common/util/CardUtil.java
+++ b/src/cz/crcs/ectester/common/util/CardUtil.java
@@ -197,6 +197,8 @@ public class CardUtil {
return "INFINITY";
case EC_Consts.TRANSFORMATION_COMPRESS:
return "COMPRESSED";
+ case EC_Consts.TRANSFORMATION_COMPRESS_HYBRID:
+ return "HYBRID";
case EC_Consts.TRANSFORMATION_MAX:
return "MAX";
default: