diff options
| author | J08nY | 2016-11-28 22:34:50 +0100 |
|---|---|---|
| committer | J08nY | 2016-11-28 22:35:48 +0100 |
| commit | f4b67923063ca35ae1405d701b461bfda0c10515 (patch) | |
| tree | c521a0e64629f93d2ff577bd3abe69a0d2d5b882 /src/applets/EC_Consts.java | |
| parent | 0339a7ace66934d2aa21f7feccd16ae640c88b8d (diff) | |
| download | ECTester-f4b67923063ca35ae1405d701b461bfda0c10515.tar.gz ECTester-f4b67923063ca35ae1405d701b461bfda0c10515.tar.zst ECTester-f4b67923063ca35ae1405d701b461bfda0c10515.zip | |
Diffstat (limited to 'src/applets/EC_Consts.java')
| -rw-r--r-- | src/applets/EC_Consts.java | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/src/applets/EC_Consts.java b/src/applets/EC_Consts.java index 24d854c..bcf2b14 100644 --- a/src/applets/EC_Consts.java +++ b/src/applets/EC_Consts.java @@ -21,14 +21,16 @@ public class EC_Consts { private static byte[] EC_F2M_F2M = null; //[short i1, short i2, short i3], f = x^m + x^i1 + x^i2 + x^i3 + 1 - public static final byte PARAMETER_FP = 0x01; - public static final byte PARAMETER_F2M = 0x02; + public static final short PARAMETER_FP = 0x0001; + public static final short PARAMETER_F2M = 0x0002; - public static final byte PARAMETER_A = 0x04; - public static final byte PARAMETER_B = 0x08; - public static final byte PARAMETER_G = 0x10; - public static final byte PARAMETER_R = 0x20; - public static final byte PARAMETER_K = 0x40; + public static final short PARAMETER_A = 0x0004; + public static final short PARAMETER_B = 0x0008; + public static final short PARAMETER_G = 0x0010; + public static final short PARAMETER_R = 0x0020; + public static final short PARAMETER_K = 0x0040; + public static final short PARAMETER_S = 0x0080; + public static final short PARAMETER_W = 0x0100; public static RandomData m_random = null; @@ -1658,10 +1660,38 @@ public class EC_Consts { } else { ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED); } - return 0; //will not be reached + return 0; } - public static short getCurveParameter(byte curve, byte param, byte[] outputBuffer, short outputOffset) { + public static byte getAnomalousCurve(short keyClass, short keyLength) { + if (keyClass == KeyPair.ALG_EC_FP) { + switch (keyLength) { + case (short) 128: + return CURVE_sp128; + case (short) 160: + return CURVE_sp160; + case (short) 192: + return CURVE_sp192; + case (short) 224: + return CURVE_sp224; + case (short) 256: + return CURVE_sp256; + case (short) 384: + return CURVE_sp384; + case (short) 521: + return CURVE_sp521; + default: + ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED); + } + } else if (keyClass == KeyPair.ALG_EC_F2M) { + return 0; + } else { + ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED); + } + return 0; + } + + public static short getCurveParameter(byte curve, short param, byte[] outputBuffer, short outputOffset) { byte alg = getCurveType(curve); switch (curve) { case CURVE_secp128r1: { @@ -1905,7 +1935,7 @@ public class EC_Consts { return length; } - public static short getCorruptCurveParameter(byte curve, byte param, byte[] outputBuffer, short outputOffset, short corruptionType) { + public static short getCorruptCurveParameter(byte curve, short param, byte[] outputBuffer, short outputOffset, short corruptionType) { short length = getCurveParameter(curve, param, outputBuffer, outputOffset); if (length <= 0) { return length; |
