diff --git a/java/com/google/security/wycheproof/EcUtil.java b/java/com/google/security/wycheproof/EcUtil.java
index 0986729..56c6548 100644
--- a/java/com/google/security/wycheproof/EcUtil.java
+++ b/java/com/google/security/wycheproof/EcUtil.java
@@ -37,7 +37,7 @@ import java.util.Arrays;
public class EcUtil {
/**
* Returns the ECParameterSpec for a named curve. Not every provider implements the
- * AlgorithmParameters. Therefore, most test use alternative functions.
+ * AlgorithmParameters. Therefore, most tests use alternative functions.
*/
public static ECParameterSpec getCurveSpec(String name)
throws NoSuchAlgorithmException, InvalidParameterSpecException {
@@ -46,6 +46,61 @@ public class EcUtil {
return parameters.getParameterSpec(ECParameterSpec.class);
}
+ public static void printParameters(ECParameterSpec spec) {
+ System.out.println("cofactor:" + spec.getCofactor());
+ EllipticCurve curve = spec.getCurve();
+ System.out.println("A:" + curve.getA());
+ System.out.println("B:" + curve.getB());
+ ECField field = curve.getField();
+ System.out.println("field size:" + field.getFieldSize());
+ if (field instanceof ECFieldFp) {
+ ECFieldFp fp = (ECFieldFp) field;
+ System.out.println("P:" + fp.getP());
+ }
+ ECPoint generator = spec.getGenerator();
+ System.out.println("Gx:" + generator.getAffineX());
+ System.out.println("Gy:" + generator.getAffineY());
+ System.out.println("order:" + spec.getOrder());
+ }
+
+ /** Returns the bit size of a given curve. TODO(bleichen): add all curves that are tested. */
+ public static int getCurveSize(String name) throws NoSuchAlgorithmException {
+ name = name.toLowerCase();
+ if (name.equals("secp224r1")) {
+ return 224;
+ } else if (name.equals("secp256r1")) {
+ return 256;
+ } else if (name.equals("secp384r1")) {
+ return 384;
+ } else if (name.equals("secp521r1")) {
+ return 521;
+ } else if (name.equals("secp256k1")) {
+ return 256;
+ } else if (name.equals("brainpoolp224r1")) {
+ return 224;
+ } else if (name.equals("brainpoolp224t1")) {
+ return 224;
+ } else if (name.equals("brainpoolp256r1")) {
+ return 256;
+ } else if (name.equals("brainpoolp256t1")) {
+ return 256;
+ } else if (name.equals("brainpoolp320r1")) {
+ return 320;
+ } else if (name.equals("brainpoolp320t1")) {
+ return 320;
+ } else if (name.equals("brainpoolp384r1")) {
+ return 384;
+ } else if (name.equals("brainpoolp384t1")) {
+ return 384;
+ } else if (name.equals("brainpoolp512r1")) {
+ return 512;
+ } else if (name.equals("brainpoolp512t1")) {
+ return 512;
+ } else {
+ throw new NoSuchAlgorithmException("Curve not implemented:" + name);
+ }
+ }
+
/**
* Returns the ECParameterSpec for a named curve. Only a handful curves that are used in the tests
* are implemented.
@@ -59,6 +114,8 @@ public class EcUtil {
return getNistP384Params();
} else if (name.equals("secp521r1")) {
return getNistP521Params();
+ } else if (name.equals("brainpoolp224r1")) {
+ return getBrainpoolP224r1Params();
} else if (name.equals("brainpoolp256r1")) {
return getBrainpoolP256r1Params();
} else {
@@ -131,6 +188,23 @@ public class EcUtil {
+ "62c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650");
}
+ public static ECParameterSpec getBrainpoolP224r1Params() {
+ // name = "brainpoolP224r1",
+ // oid = '2b2403030208010105',
+ // ref = "RFC 5639",
+ BigInteger p = new BigInteger("D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF", 16);
+ BigInteger a = new BigInteger("68A5E62CA9CE6C1C299803A6C1530B514E182AD8B0042A59CAD29F43", 16);
+ BigInteger b = new BigInteger("2580F63CCFE44138870713B1A92369E33E2135D266DBB372386C400B", 16);
+ BigInteger x = new BigInteger("0D9029AD2C7E5CF4340823B2A87DC68C9E4CE3174C1E6EFDEE12C07D", 16);
+ BigInteger y = new BigInteger("58AA56F772C0726F24C6B89E4ECDAC24354B9E99CAA3F6D3761402CD", 16);
+ BigInteger n = new BigInteger("D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F", 16);
+ final int h = 1;
+ ECFieldFp fp = new ECFieldFp(p);
+ EllipticCurve curve = new EllipticCurve(fp, a, b);
+ ECPoint g = new ECPoint(x, y);
+ return new ECParameterSpec(curve, g, n, h);
+ }
+
public static ECParameterSpec getBrainpoolP256r1Params() {
BigInteger p =
new BigInteger("A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5377", 16);
diff --git a/java/com/google/security/wycheproof/testcases/DsaTest.java b/java/com/google/security/wycheproof/testcases/DsaTest.java
index 46a9393..d26a272 100644
--- a/java/com/google/security/wycheproof/testcases/DsaTest.java
+++ b/java/com/google/security/wycheproof/testcases/DsaTest.java
@@ -28,7 +28,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.google.security.wycheproof.WycheproofRunner.NoPresubmitTest;
import com.google.security.wycheproof.WycheproofRunner.ProviderType;
import com.google.security.wycheproof.WycheproofRunner.SlowTest;
import java.lang.management.ManagementFactory;
@@ -40,14 +39,11 @@ import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
import java.security.Signature;
-import java.security.SignatureException;
import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPrivateKey;
import java.security.interfaces.DSAPublicKey;
import java.security.spec.DSAPrivateKeySpec;
-import java.security.spec.DSAPublicKeySpec;
import java.util.Arrays;
import javax.crypto.Cipher;
import org.junit.Test;
@@ -62,693 +58,6 @@ import org.junit.runners.JUnit4;
*/
@RunWith(JUnit4.class)
public class DsaTest {
- static final String MESSAGE = "Hello";
-
- static final DSAPrivateKeySpec privateKey1 =
- new DSAPrivateKeySpec(
- // x
- new BigInteger("15382583218386677486843706921635237927801862255437148328980464126979"),
- // p
- new BigInteger(
- "181118486631420055711787706248812146965913392568235070235446058914"
- + "1170708161715231951918020125044061516370042605439640379530343556"
- + "4101919053459832890139496933938670005799610981765220283775567361"
- + "4836626483403394052203488713085936276470766894079318754834062443"
- + "1033792580942743268186462355159813630244169054658542719322425431"
- + "4088256212718983105131138772434658820375111735710449331518776858"
- + "7867938758654181244292694091187568128410190746310049564097068770"
- + "8161261634790060655580211122402292101772553741704724263582994973"
- + "9109274666495826205002104010355456981211025738812433088757102520"
- + "562459649777989718122219159982614304359"),
- // q
- new BigInteger("19689526866605154788513693571065914024068069442724893395618704484701"),
- // g
- new BigInteger(
- "2859278237642201956931085611015389087970918161297522023542900348"
- + "0877180630984239764282523693409675060100542360520959501692726128"
- + "3149190229583566074777557293475747419473934711587072321756053067"
- + "2532404847508798651915566434553729839971841903983916294692452760"
- + "2490198571084091890169933809199002313226100830607842692992570749"
- + "0504363602970812128803790973955960534785317485341020833424202774"
- + "0275688698461842637641566056165699733710043802697192696426360843"
- + "1736206792141319514001488556117408586108219135730880594044593648"
- + "9237302749293603778933701187571075920849848690861126195402696457"
- + "4111219599568903257472567764789616958430"));
-
- static final DSAPublicKeySpec publicKey1 =
- new DSAPublicKeySpec(
- new BigInteger(
- "3846308446317351758462473207111709291533523711306097971550086650"
- + "2577333637930103311673872185522385807498738696446063139653693222"
- + "3528823234976869516765207838304932337200968476150071617737755913"
- + "3181601169463467065599372409821150709457431511200322947508290005"
- + "1780020974429072640276810306302799924668893998032630777409440831"
- + "4314588994475223696460940116068336991199969153649625334724122468"
- + "7497038281983541563359385775312520539189474547346202842754393945"
- + "8755803223951078082197762886933401284142487322057236814878262166"
- + "5072306622943221607031324846468109901964841479558565694763440972"
- + "5447389416166053148132419345627682740529"),
- privateKey1.getP(),
- privateKey1.getQ(),
- privateKey1.getG());
-
- // Signatures for Key1.
- static final String[] VALID_SIGNATURES = {
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- };
-
- /**
- * The following test vectos are derived from a valid signature by using alternative BER encoding
- * as well as legacy formats. Accepting such signatures is in many cases benign. Hence the tests
- * below will pass if such signatures are accepted as valid. The test vectors could be used to
- * check for signature malleability. An example where this kind of signature malleability was a
- * problem is https://en.bitcoin.it/wiki/Transaction_Malleability
- */
- static final String[] MODIFIED_SIGNATURES = {
- // BER:long form encoding of length
- "30813d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9"
- + "cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303e02811c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9"
- + "cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303e021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "02811d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- // BER:length contains leading 0
- "3082003d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8"
- + "c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- "303f0282001c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8"
- + "c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "0282001d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- // BER:prepending 0's to integer
- "303f021e00001e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8"
- + "c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021f000000ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- // The Sun provider accepts DSA signatures where a leading 00 has
- // been omitted in the ASN encoding.
- "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021cade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- };
-
- /**
- * The following test vectors are invalid DSA signatures. According to {@link
- * java.security.Signature#verify(byte[])} verifying an invalid signature may either return false
- * or throw a SignatureException. We expect that a correct implementation of DSA signatures
- * satisfies this contract. Throwing a RuntimeException instead of a SignatureException could for
- * example result in a denial of service attack.
- *
- *
CVE-2016-5546: OpenJDK8 throwed java.lang.ArrayIndexOutOfBoundsException for some invalid
- * DSA signatures.
- *
- */
- static final String[] INVALID_SIGNATURES = {
- // wrong length
- "303e021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021d1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021b1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021e00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021c00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- // uint32 overflow in length
- "3085010000003d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916"
- + "173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813f"
- + "e8786236",
- "30420285010000001c1e41b479ad576905b960fe14eadb91b0ccf34843dab916"
- + "173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813f"
- + "e8786236",
- "3042021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "0285010000001d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813f"
- + "e8786236",
- // uint64 overflow in length
- "308901000000000000003d021c1e41b479ad576905b960fe14eadb91b0ccf348"
- + "43dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf"
- + "3365813fe8786236",
- "3046028901000000000000001c1e41b479ad576905b960fe14eadb91b0ccf348"
- + "43dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf"
- + "3365813fe8786236",
- "3046021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "028901000000000000001d00ade65988d237d30f9ef41dd424a4e1c8f16967cf"
- + "3365813fe8786236",
- // length = 2**31 - 1
- "30847fffffff021c1e41b479ad576905b960fe14eadb91b0ccf34843dab91617"
- + "3bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- "304102847fffffff1e41b479ad576905b960fe14eadb91b0ccf34843dab91617"
- + "3bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- "3041021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "02847fffffff00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- // length = 2**32 - 1
- "3084ffffffff021c1e41b479ad576905b960fe14eadb91b0ccf34843dab91617"
- + "3bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- "30410284ffffffff1e41b479ad576905b960fe14eadb91b0ccf34843dab91617"
- + "3bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- "3041021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "0284ffffffff00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- // length = 2**64 - 1
- "3088ffffffffffffffff021c1e41b479ad576905b960fe14eadb91b0ccf34843"
- + "dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf33"
- + "65813fe8786236",
- "30450288ffffffffffffffff1e41b479ad576905b960fe14eadb91b0ccf34843"
- + "dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf33"
- + "65813fe8786236",
- "3045021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "0288ffffffffffffffff00ade65988d237d30f9ef41dd424a4e1c8f16967cf33"
- + "65813fe8786236",
- // removing sequence
- "",
- // appending 0's to sequence
- "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe878623600"
- + "00",
- // prepending 0's to sequence
- "303f0000021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8"
- + "c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- // appending unused 0's
- "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "0000021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- // appending null value
- "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe878623605"
- + "00",
- "303f021e1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "0500021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021f00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe878623605"
- + "00",
- // including garbage
- "3042498177303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916"
- + "173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813f"
- + "e8786236",
- "30412500303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab91617"
- + "3bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- "303f303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8"
- + "c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "360004deadbeef",
- "30422221498177021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916"
- + "173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813f"
- + "e8786236",
- "304122202500021c1e41b479ad576905b960fe14eadb91b0ccf34843dab91617"
- + "3bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- "3045221e021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8"
- + "c9cd0004deadbeef021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf33"
- + "65813fe8786236",
- "3042021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "2222498177021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813f"
- + "e8786236",
- "3041021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "22212500021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- "3045021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "221f021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "360004deadbeef",
- // including undefined tags
- "3045aa00bb00cd00303d021c1e41b479ad576905b960fe14eadb91b0ccf34843"
- + "dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf33"
- + "65813fe8786236",
- "3043aa02aabb303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab9"
- + "16173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf336581"
- + "3fe8786236",
- "30452224aa00bb00cd00021c1e41b479ad576905b960fe14eadb91b0ccf34843"
- + "dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf33"
- + "65813fe8786236",
- "30432222aa02aabb021c1e41b479ad576905b960fe14eadb91b0ccf34843dab9"
- + "16173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf336581"
- + "3fe8786236",
- "3045021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "2225aa00bb00cd00021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf33"
- + "65813fe8786236",
- "3043021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "2223aa02aabb021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf336581"
- + "3fe8786236",
- // changing tag value
- "2e3d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "323d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "ff3d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d001c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d041c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303dff1c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "001d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "041d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "ff1d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- // dropping value of sequence
- "3000",
- // using composition
- "3041300102303c1c1e41b479ad576905b960fe14eadb91b0ccf34843dab91617"
- + "3bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- "3041222002011e021b41b479ad576905b960fe14eadb91b0ccf34843dab91617"
- + "3bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- "3041021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "2221020100021cade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8"
- + "786236",
- // truncate sequence
- "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862",
- "303c1c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd02"
- + "1d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- // indefinite length with no delimiter
- "3080021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- // prepend empty sequence
- "303f3000021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8"
- + "c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- // append empty sequence
- "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe878623630"
- + "00",
- // sequence of sequence
- "303f303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8"
- + "c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- // truncated sequence
- "301e021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd",
- // repeat element in sequence
- "305c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe878623602"
- + "1d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- // removing integer
- "301f021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- // appending 0's to integer
- "303f021e1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "0000021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862"
- + "36",
- "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021f00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe878623600"
- + "00",
- // dropping value of integer
- "30210200021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "3020021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0200",
- // modify first byte of integer
- "303d021c1f41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d01ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- // modify last byte of integer
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cc"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786237",
- // truncate integer
- "303c021b1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c902"
- + "1d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303c021b41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd02"
- + "1d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021c00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862",
- // leading ff in integer
- "303e021dff1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9"
- + "cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303e021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021eff00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- // infinity
- "3022090180021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "3021021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd090180",
- // Vectors where r or s have been modified e.g. by adding or subtracting the order of the
- // group and hence violate the range check for r and s required by DSA.
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d0168dcf02f57b0caef7ddc183bee1ca94ee09c1a02ee4b0200a54dcb93",
- "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021cf2efc2e24cbedb2fc00c236c5b2d1a430236b59b7880007f2ba2f8d9",
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021dff5219a6772dc82cf0610be22bdb5b1e370e969830cc9a7ec017879dca",
- "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd"
- + "021d01ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303e021d00d9384b2032d060e59848f87cb4535936bc25fa77959e96d7f88e33"
- + "2a021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303e021d00d9384b2032d060e59848f87cb4535936bc25fa77959e96d7f88e33"
- + "2a021d0168dcf02f57b0caef7ddc183bee1ca94ee09c1a02ee4b0200a54dcb93",
- "303d021d00d9384b2032d060e59848f87cb4535936bc25fa77959e96d7f88e33"
- + "2a021cf2efc2e24cbedb2fc00c236c5b2d1a430236b59b7880007f2ba2f8d9",
- "303e021d00d9384b2032d060e59848f87cb4535936bc25fa77959e96d7f88e33"
- + "2a021dff5219a6772dc82cf0610be22bdb5b1e370e969830cc9a7ec017879dca",
- "303e021d00d9384b2032d060e59848f87cb4535936bc25fa77959e96d7f88e33"
- + "2a021d01ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303e021dff634b1dd327de7125da7903ad2163ca2addc096101fd395567ee360"
- + "70021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303e021dff634b1dd327de7125da7903ad2163ca2addc096101fd395567ee360"
- + "70021d0168dcf02f57b0caef7ddc183bee1ca94ee09c1a02ee4b0200a54dcb93",
- "303d021dff634b1dd327de7125da7903ad2163ca2addc096101fd395567ee360"
- + "70021cf2efc2e24cbedb2fc00c236c5b2d1a430236b59b7880007f2ba2f8d9",
- "303e021dff634b1dd327de7125da7903ad2163ca2addc096101fd395567ee360"
- + "70021dff5219a6772dc82cf0610be22bdb5b1e370e969830cc9a7ec017879dca",
- "303e021dff634b1dd327de7125da7903ad2163ca2addc096101fd395567ee360"
- + "70021d01ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021ce1be4b8652a896fa469f01eb15246e4f330cb7bc2546e9e8c4473633"
- + "021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303d021ce1be4b8652a896fa469f01eb15246e4f330cb7bc2546e9e8c4473633"
- + "021d0168dcf02f57b0caef7ddc183bee1ca94ee09c1a02ee4b0200a54dcb93",
- "303c021ce1be4b8652a896fa469f01eb15246e4f330cb7bc2546e9e8c4473633"
- + "021cf2efc2e24cbedb2fc00c236c5b2d1a430236b59b7880007f2ba2f8d9",
- "303d021ce1be4b8652a896fa469f01eb15246e4f330cb7bc2546e9e8c4473633"
- + "021dff5219a6772dc82cf0610be22bdb5b1e370e969830cc9a7ec017879dca",
- "303d021ce1be4b8652a896fa469f01eb15246e4f330cb7bc2546e9e8c4473633"
- + "021d01ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303e021d011e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9"
- + "cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- "303e021d011e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9"
- + "cd021d0168dcf02f57b0caef7ddc183bee1ca94ee09c1a02ee4b0200a54dcb93",
- "303d021d011e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9"
- + "cd021cf2efc2e24cbedb2fc00c236c5b2d1a430236b59b7880007f2ba2f8d9",
- "303e021d011e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9"
- + "cd021dff5219a6772dc82cf0610be22bdb5b1e370e969830cc9a7ec017879dca",
- "303e021d011e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9"
- + "cd021d01ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
- // Signatures with special case values for r and s. E.g. r=1, s=0 are values that can lead to
- // forgeries if the DSA implementation does not check boundaries and computes s^(-1) == 0.
- "3022020100021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
- "3006020100020101",
- "30060201000201ff",
- "3022020100021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
- "3022020100021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
- "3022020100021d0100000000000000000000000000000000000000000000000000000000",
- "3082010802010002820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e"
- + "3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b"
- + "85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a99345"
- + "3409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f"
- + "9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d"
- + "8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f"
- + "803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de"
- + "4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e3"
- + "42be484c05763939601cd667",
- "3008020100090380fe01",
- "3022020101021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
- "3006020101020101",
- "30060201010201ff",
- "3022020101021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
- "3022020101021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
- "3022020101021d0100000000000000000000000000000000000000000000000000000000",
- "3082010802010102820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e"
- + "3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b"
- + "85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a99345"
- + "3409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f"
- + "9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d"
- + "8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f"
- + "803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de"
- + "4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e3"
- + "42be484c05763939601cd667",
- "3008020101090380fe01",
- "30220201ff021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
- "30060201ff020101",
- "30060201ff0201ff",
- "30220201ff021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
- "30220201ff021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
- "30220201ff021d0100000000000000000000000000000000000000000000000000000000",
- "308201080201ff02820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e"
- + "3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b"
- + "85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a99345"
- + "3409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f"
- + "9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d"
- + "8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f"
- + "803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de"
- + "4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e3"
- + "42be484c05763939601cd667",
- "30080201ff090380fe01",
- "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd569"
- + "5d021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
- "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d020100",
- "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d020101",
- "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d0201ff",
- "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd569"
- + "5d021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
- "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd569"
- + "5d021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
- "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd569"
- + "5d021d0100000000000000000000000000000000000000000000000000000000",
- "30820124021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bc"
- + "d5695d02820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718"
- + "e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011ad"
- + "b8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe"
- + "696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef8"
- + "83448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e733"
- + "8db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4"
- + "c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04"
- + "903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c"
- + "05763939601cd667",
- "3024021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d090380fe01",
- "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd569"
- + "5e021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
- "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e020100",
- "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e020101",
- "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e0201ff",
- "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd569"
- + "5e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
- "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd569"
- + "5e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
- "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd569"
- + "5e021d0100000000000000000000000000000000000000000000000000000000",
- "30820124021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bc"
- + "d5695e02820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718"
- + "e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011ad"
- + "b8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe"
- + "696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef8"
- + "83448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e733"
- + "8db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4"
- + "c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04"
- + "903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c"
- + "05763939601cd667",
- "3024021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e090380fe01",
- "303e021d01000000000000000000000000000000000000000000000000000000"
- + "00021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
- "3022021d0100000000000000000000000000000000000000000000000000000000020100",
- "3022021d0100000000000000000000000000000000000000000000000000000000020101",
- "3022021d01000000000000000000000000000000000000000000000000000000000201ff",
- "303e021d01000000000000000000000000000000000000000000000000000000"
- + "00021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
- "303e021d01000000000000000000000000000000000000000000000000000000"
- + "00021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
- "303e021d01000000000000000000000000000000000000000000000000000000"
- + "00021d0100000000000000000000000000000000000000000000000000000000",
- "30820124021d0100000000000000000000000000000000000000000000000000"
- + "00000002820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718"
- + "e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011ad"
- + "b8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe"
- + "696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef8"
- + "83448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e733"
- + "8db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4"
- + "c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04"
- + "903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c"
- + "05763939601cd667",
- "3024021d0100000000000000000000000000000000000000000000000000000000090380fe01",
- "3082012402820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf37"
- + "18e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011"
- + "adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0"
- + "fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648e"
- + "f883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7"
- + "338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32"
- + "a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff"
- + "04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be48"
- + "4c05763939601cd667021dff450969597a870820211805983688387a10cd4dcc"
- + "451a7f3f432a96a3",
- "3082010802820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf37"
- + "18e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011"
- + "adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0"
- + "fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648e"
- + "f883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7"
- + "338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32"
- + "a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff"
- + "04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be48"
- + "4c05763939601cd667020100",
- "3082010802820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf37"
- + "18e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011"
- + "adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0"
- + "fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648e"
- + "f883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7"
- + "338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32"
- + "a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff"
- + "04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be48"
- + "4c05763939601cd667020101",
- "3082010802820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf37"
- + "18e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011"
- + "adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0"
- + "fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648e"
- + "f883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7"
- + "338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32"
- + "a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff"
- + "04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be48"
- + "4c05763939601cd6670201ff",
- "3082012402820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf37"
- + "18e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011"
- + "adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0"
- + "fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648e"
- + "f883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7"
- + "338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32"
- + "a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff"
- + "04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be48"
- + "4c05763939601cd667021d00baf696a68578f7dfdee7fa67c977c785ef32b233"
- + "bae580c0bcd5695d",
- "3082012402820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf37"
- + "18e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011"
- + "adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0"
- + "fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648e"
- + "f883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7"
- + "338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32"
- + "a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff"
- + "04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be48"
- + "4c05763939601cd667021d00baf696a68578f7dfdee7fa67c977c785ef32b233"
- + "bae580c0bcd5695e",
- "3082012402820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf37"
- + "18e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011"
- + "adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0"
- + "fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648e"
- + "f883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7"
- + "338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32"
- + "a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff"
- + "04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be48"
- + "4c05763939601cd667021d010000000000000000000000000000000000000000"
- + "0000000000000000",
- "3082020a02820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf37"
- + "18e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011"
- + "adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0"
- + "fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648e"
- + "f883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7"
- + "338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32"
- + "a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff"
- + "04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be48"
- + "4c05763939601cd66702820101008f7935d9b9aae9bfabed887acf4951b6f32e"
- + "c59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7"
- + "475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a9"
- + "93453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6"
- + "291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9f"
- + "fa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633"
- + "458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea1"
- + "43de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f8"
- + "22e342be484c05763939601cd667",
- "3082010a02820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf37"
- + "18e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011"
- + "adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0"
- + "fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648e"
- + "f883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7"
- + "338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32"
- + "a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff"
- + "04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be48"
- + "4c05763939601cd667090380fe01",
- "3024090380fe01021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
- "3008090380fe01020100",
- "3008090380fe01020101",
- "3008090380fe010201ff",
- "3024090380fe01021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
- "3024090380fe01021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
- "3024090380fe01021d0100000000000000000000000000000000000000000000000000000000",
- "3082010a090380fe0102820101008f7935d9b9aae9bfabed887acf4951b6f32e"
- + "c59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7"
- + "475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a9"
- + "93453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6"
- + "291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9f"
- + "fa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633"
- + "458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea1"
- + "43de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f8"
- + "22e342be484c05763939601cd667",
- "300a090380fe01090380fe01",
- };
-
- @SuppressWarnings("InsecureCryptoUsage")
- public void testVectors(
- String[] signatures,
- DSAPublicKeySpec key,
- String message,
- String algorithm,
- String signatureType,
- boolean isValidDER,
- boolean isValidBER)
- throws Exception {
- byte[] messageBytes = message.getBytes("UTF-8");
- Signature verifier = Signature.getInstance(algorithm);
- KeyFactory kf = KeyFactory.getInstance("DSA");
- PublicKey pub = kf.generatePublic(key);
- int errors = 0;
- for (String signature : signatures) {
- byte[] signatureBytes = TestUtil.hexToBytes(signature);
- verifier.initVerify(pub);
- verifier.update(messageBytes);
- boolean verified = false;
- try {
- verified = verifier.verify(signatureBytes);
- } catch (SignatureException ex) {
- // verify can throw SignatureExceptions if the signature is malformed.
- // We don't flag these cases and simply consider the signature as invalid.
- verified = false;
- } catch (Exception ex) {
- // Other exceptions indicate some internal error, e.g. careless ASN parsing.
- // We count these as errors.
- System.out.println(signatureType + ":" + signature + " throws:" + ex.toString());
- errors++;
- continue;
- }
- if (isValidDER && !verified) {
- System.out.println(signatureType + " was not verified:" + signature);
- errors++;
- } else if (!isValidBER && verified) {
- System.out.println(signatureType + " was verified:" + signature);
- errors++;
- }
- }
- assertEquals(0, errors);
- }
-
- @Test
- public void testValidSignatures() throws Exception {
- testVectors(
- VALID_SIGNATURES, publicKey1, "Hello", "SHA224WithDSA", "Valid DSA signature", true, true);
- }
-
- @Test
- public void testModifiedSignatures() throws Exception {
- testVectors(
- MODIFIED_SIGNATURES,
- publicKey1,
- "Hello",
- "SHA224WithDSA",
- "Modified DSA signature",
- false,
- true);
- }
-
- @Test
- public void testInvalidSignatures() throws Exception {
- testVectors(
- INVALID_SIGNATURES,
- publicKey1,
- "Hello",
- "SHA224WithDSA",
- "Invalid DSA signature",
- false,
- false);
- }
-
// Extract the integer r from a DSA signature.
// This method implicitely assumes that the DSA signature is DER encoded.
BigInteger extractR(byte[] signature) throws Exception {
@@ -804,8 +113,8 @@ public class DsaTest {
/**
* This is just a test for basic functionality of DSA. The test generates a public and private
- * key, generates a signature, verifies it and prints the whole thing out. This test is useful
- * when an implementation is seriously broken.
+ * key, generates a signature and verifies it. This test is slow with some providers, since
+ * some providers generate new DSA parameters (p and q) for each new key.
*/
@SlowTest(providers = {ProviderType.BOUNCY_CASTLE, ProviderType.SPONGY_CASTLE})
@SuppressWarnings("InsecureCryptoUsage")
@@ -813,7 +122,6 @@ public class DsaTest {
public void testBasic() throws Exception {
int keySize = 2048;
String algorithm = "SHA256WithDSA";
- String hashAlgorithm = "SHA-256";
String message = "Hello";
byte[] messageBytes = message.getBytes("UTF-8");
@@ -830,27 +138,6 @@ public class DsaTest {
verifier.initVerify(pub);
verifier.update(messageBytes);
assertTrue(verifier.verify(signature));
-
- // Extract some parameters.
- byte[] rawHash = MessageDigest.getInstance(hashAlgorithm).digest(messageBytes);
- DSAParams params = priv.getParams();
-
- // Print keys and signature, so that it can be used to generate new test vectors.
- System.out.println("Message:" + message);
- System.out.println("Hash:" + TestUtil.bytesToHex(rawHash));
- System.out.println("Params:");
- System.out.println("p:" + params.getP().toString());
- System.out.println("q:" + params.getQ().toString());
- System.out.println("g:" + params.getG().toString());
- System.out.println("Private key:");
- System.out.println("X:" + priv.getX().toString());
- System.out.println("encoded:" + TestUtil.bytesToHex(priv.getEncoded()));
- System.out.println("Public key:");
- System.out.println("Y:" + pub.getY().toString());
- System.out.println("encoded:" + TestUtil.bytesToHex(pub.getEncoded()));
- System.out.println("Signature:" + TestUtil.bytesToHex(signature));
- System.out.println("r:" + extractR(signature).toString());
- System.out.println("s:" + extractS(signature).toString());
}
@SuppressWarnings("InsecureCryptoUsage")
@@ -913,14 +200,11 @@ public class DsaTest {
*
* While smaller keys may still be used for legacy cases, we think that such a choice should
* always be made by providing the desired key length during the initalization of the
- * KeyPairGenerator. Unfortunately the JCE documentation is outdated.
- * https://docs.oracle.com/javase/7/docs/api/java/security/KeyPairGenerator.html only requires
- * that 1024 bits are supported.
+ * KeyPairGenerator.
+ *
+ *
This test may fail with old jdk versions. Oracle has changed the default size for DSA keys
+ * from 1024 bits to 2048 bits with https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8184341 .
*/
- @NoPresubmitTest(
- providers = {ProviderType.OPENJDK},
- bugs = {"b/33190860"}
- )
@Test
public void testDefaultKeySize() throws Exception {
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
diff --git a/java/com/google/security/wycheproof/testcases/EcdsaTest.java b/java/com/google/security/wycheproof/testcases/EcdsaTest.java
index 5fb0032..01ce13a 100644
--- a/java/com/google/security/wycheproof/testcases/EcdsaTest.java
+++ b/java/com/google/security/wycheproof/testcases/EcdsaTest.java
@@ -13,7 +13,6 @@
*/
package com.google.security.wycheproof;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -23,534 +22,30 @@ import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.math.BigInteger;
import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.security.Signature;
-import java.security.SignatureException;
import java.security.interfaces.ECPrivateKey;
import java.security.interfaces.ECPublicKey;
import java.security.spec.ECGenParameterSpec;
import java.security.spec.ECParameterSpec;
-import java.security.spec.ECPoint;
-import java.security.spec.ECPublicKeySpec;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
- * Tests ECDSA against invalid signatures.
+ * Tests ECDSA signatures.
+ *
+ *
Tests for signature verification with test vectors are in JsonSignatureTest.java toghether
+ * with other signature schemes.
*
* @author bleichen@google.com (Daniel Bleichenbacher)
*/
-// Tested providers:
-// SunEC: accepts a few alternative encodings and throws run time exceptions.
-// The implementation does not protect against timing attacks.
-// BC: accepts alternative encoding, and additional arguments
-// AndroidOpenSSL: OK
-// TODO(bleichen):
-// - CVE-2015-2730: Firefox failed to handle some signatures correctly because of incorrect
-// point multiplication. (I don't have enough information here.)
@RunWith(JUnit4.class)
public class EcdsaTest {
- // ECDSA-Key1
- static final String MESSAGE = "Hello";
- static final String CURVE = "secp256r1";
- static final BigInteger PubX =
- new BigInteger(
- "33903964965861532023650245008903090201819051686264021958530366090984128098564");
- static final BigInteger PubY =
- new BigInteger(
- "113542129898393725739068316260085522189065290079050903091108740065052129055287");
-
- // Valid signatures for MESSAGE
- static final String[] VALID_SIGNATURES = {
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- };
-
- /**
- * The following test vectors contain a valid signature that use alternative BER encoding. Whether
- * such signatures are accepted as valid or rejected depends on the implementation. Allowing
- * alternative BER encodings is in many cases benign. However, there are cases where this kind of
- * signature malleability was a problem. See for example
- * https://en.bitcoin.it/wiki/Transaction_Malleability
- */
- // NOTE(bleichen): The following test vectors were generated with some python code.
- // New test vectors should best be done by extending this code. Some of the signatures
- // can be moved to INVALID_SIGNATURES, when b/31572415 is fixed.
- static final String[] MODIFIED_SIGNATURES = {
- // BER:long form encoding of length
- "308145022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d"
- + "491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e762"
- + "85cd59f43260ecce",
- "304602812100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d"
- + "491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e762"
- + "85cd59f43260ecce",
- "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f028120747291dd2f3f44af7ace68ea33431d6f94e418c106a6e762"
- + "85cd59f43260ecce",
- // BER:length contains leading 0
- "30820045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a"
- + "3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- "30470282002100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a"
- + "3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f02820020747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- // BER:prepending 0's to integer
- "30470223000000b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a"
- + "3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f02220000747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- // NOTE (bleichen): belongs into INVALID_SIGNATURES. We only keep these
- // sigantures here because of b/31572415.
- // length = 2**31 - 1
- "30847fffffff022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7"
- + "db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "304902847fffffff00b7babae9332b54b8a3a05b7004579821a887a1b21465f7"
- + "db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f02847fffffff747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- };
-
- /**
- * Test vectors with invalid signatures. The motivation for these test vectors are previously
- * broken implementations. E.g.
- *
- *
- * - The implementation of DSA in gpg4browsers accepted signatures with r=1 and s=q as valid.
- * Similar bugs in ECDSA are thinkable, hence the test vectors contain a number of tests
- * with edge case integers.
- *
- CVE-2013-2944: strongSwan 5.0.4 accepts invalid ECDSA signatures when openssl is used.
- * (Not sure if the following interpretation is correct, because of missing details).
- * OpenSSLs error codes are easy to misinterpret. For many functions the result can be 0
- * (verification failed), 1 (verification succeded) or -1 (invalid format). A simple
- * if (result) { ... } will be incorrect in such situations. The test vectors below
- * contain incorrectly encoded signatures.
- *
- *
- * {@link java.security.Signature#verify(byte[])} should either return false or throw a
- * SignatureException. Other behaviour such as throwing a RuntimeException might allow a denial of
- * service attack:
- *
- *
- * - CVE-2016-5546: OpenJDK8 throwed an OutOfmemoryError on some signatures.
- *
- *
- * Some of the test vectors were derived from a valid signature by corrupting the DER encoding. If
- * providers accepts such modified signatures for legacy purpose, then these signatures should be
- * moved to MODIFIED_SIGNATURES.
- */
- // NOTE(bleichen): The following test vectors were generated with some python code. New test
- // vectors should best be done by extending the python code.
- static final String[] INVALID_SIGNATURES = {
- // wrong length
- "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3044022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022200b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022000b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0221747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f021f747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- // uint32 overflow in length
- "30850100000045022100b7babae9332b54b8a3a05b7004579821a887a1b21465"
- + "f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c1"
- + "06a6e76285cd59f43260ecce",
- "304a0285010000002100b7babae9332b54b8a3a05b7004579821a887a1b21465"
- + "f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c1"
- + "06a6e76285cd59f43260ecce",
- "304a022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f02850100000020747291dd2f3f44af7ace68ea33431d6f94e418c1"
- + "06a6e76285cd59f43260ecce",
- // uint64 overflow in length
- "3089010000000000000045022100b7babae9332b54b8a3a05b7004579821a887"
- + "a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f"
- + "94e418c106a6e76285cd59f43260ecce",
- "304e028901000000000000002100b7babae9332b54b8a3a05b7004579821a887"
- + "a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f"
- + "94e418c106a6e76285cd59f43260ecce",
- "304e022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0289010000000000000020747291dd2f3f44af7ace68ea33431d6f"
- + "94e418c106a6e76285cd59f43260ecce",
- // length = 2**32 - 1
- "3084ffffffff022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7"
- + "db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "30490284ffffffff00b7babae9332b54b8a3a05b7004579821a887a1b21465f7"
- + "db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0284ffffffff747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- // length = 2**64 - 1
- "3088ffffffffffffffff022100b7babae9332b54b8a3a05b7004579821a887a1"
- + "b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94"
- + "e418c106a6e76285cd59f43260ecce",
- "304d0288ffffffffffffffff00b7babae9332b54b8a3a05b7004579821a887a1"
- + "b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94"
- + "e418c106a6e76285cd59f43260ecce",
- "304d022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0288ffffffffffffffff747291dd2f3f44af7ace68ea33431d6f94"
- + "e418c106a6e76285cd59f43260ecce",
- // removing sequence
- "",
- // appending 0's to sequence
- "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce0000",
- // prepending 0's to sequence
- "30470000022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a"
- + "3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- // appending unused 0's
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce0000",
- "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f00000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- // appending null value
- "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce0500",
- "3047022300b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f05000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0222747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce0500",
- // including garbage
- "304949803045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7"
- + "db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "304925003045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7"
- + "db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "30473045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a"
- + "3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce0004deadbeef",
- "304922254980022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7"
- + "db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "304922252500022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7"
- + "db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "304d2223022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a"
- + "3d491b39fd2c3f0004deadbeef0220747291dd2f3f44af7ace68ea33431d6f94"
- + "e418c106a6e76285cd59f43260ecce",
- "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f222449800220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f222425000220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "304d022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f22220220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce0004deadbeef",
- // including undefined tags
- "304daa00bb00cd003045022100b7babae9332b54b8a3a05b7004579821a887a1"
- + "b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94"
- + "e418c106a6e76285cd59f43260ecce",
- "304baa02aabb3045022100b7babae9332b54b8a3a05b7004579821a887a1b214"
- + "65f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418"
- + "c106a6e76285cd59f43260ecce",
- "304d2229aa00bb00cd00022100b7babae9332b54b8a3a05b7004579821a887a1"
- + "b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94"
- + "e418c106a6e76285cd59f43260ecce",
- "304b2227aa02aabb022100b7babae9332b54b8a3a05b7004579821a887a1b214"
- + "65f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418"
- + "c106a6e76285cd59f43260ecce",
- "304d022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f2228aa00bb00cd000220747291dd2f3f44af7ace68ea33431d6f94"
- + "e418c106a6e76285cd59f43260ecce",
- "304b022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f2226aa02aabb0220747291dd2f3f44af7ace68ea33431d6f94e418"
- + "c106a6e76285cd59f43260ecce",
- // changing tag value
- "2e45022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3245022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "ff45022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045002100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045042100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045ff2100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0020747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0420747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3fff20747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- // dropping value of sequence
- "3000",
- // using composition
- "304930010230442100b7babae9332b54b8a3a05b7004579821a887a1b21465f7"
- + "db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "304922250201000220b7babae9332b54b8a3a05b7004579821a887a1b21465f7"
- + "db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f2224020174021f7291dd2f3f44af7ace68ea33431d6f94e418c106"
- + "a6e76285cd59f43260ecce",
- // truncate sequence
- "3044022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ec",
- "30442100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b"
- + "39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd"
- + "59f43260ecce",
- // prepend empty sequence
- "30473000022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a"
- + "3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- // append empty sequence
- "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce3000",
- // sequence of sequence
- "30473045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a"
- + "3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- // truncated sequence
- "3023022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f",
- // repeat element in sequence
- "3067022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- // removing integer
- "30220220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
- // appending 0's to integer
- "3047022300b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f00000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e7"
- + "6285cd59f43260ecce",
- "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0222747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce0000",
- // dropping value of integer
- "302402000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
- "3025022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0200",
- // modify first byte of integer
- "3045022101b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220757291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- // modify last byte of integer
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3e0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260eccf",
- // truncate integer
- "3044022000b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd"
- + "59f43260ecce",
- "30440220b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b"
- + "39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd"
- + "59f43260ecce",
- "3044022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f021f747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ec",
- "3044022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f021f7291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd"
- + "59f43260ecce",
- // leading ff in integer
- "30460222ff00b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d"
- + "491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e762"
- + "85cd59f43260ecce",
- "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f0221ff747291dd2f3f44af7ace68ea33431d6f94e418c106a6e762"
- + "85cd59f43260ecce",
- // infinity
- "30250901800220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
- "3026022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f090180",
- // Vectors where r or s have been modified e.g. by adding or subtracting the order of the
- // group or field and hence violate the range check for r and s required by ECDSA.
- "30450221ff48454516ccd4ab475c5fa48ffba867de57785e4deb9a082475c2b6"
- + "e4c602d3c10220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022101b7babae8332b54b9a3a05b7004579821656e9c5fbb7d96607df713"
- + "de366051900220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3044022048454515ccd4ab485c5fa48ffba867de145f58fb92b1a6a9697c81a7"
- + "c265f9120220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd"
- + "59f43260ecce",
- "3045022101b7babae8332b54b9a3a05b7004579821a887a1b31465f7db8a3d49"
- + "1b39fd2c3e0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
- + "cd59f43260ecce",
- "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f02208b8d6e22d0c0bb5085319715ccbce2906b1be73ef959189d7a"
- + "32a60bcd9f1332",
- "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f022101747291dc2f3f44b07ace68ea33431d6f51cb136eadbe85e7"
- + "798724b72ec4121f",
- "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
- + "1b39fd2c3f022101747291dc2f3f44b07ace68ea33431d6f94e418c206a6e762"
- + "85cd59f43260eccd",
- // Signatures with special case values for r and s (such as 0 and 1). Such values often
- // uncover implementation errors.
- "3006020100020100",
- "3006020100020101",
- "30060201000201ff",
- "3026020100022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
- "3026020100022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
- "3026020100022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
- "3026020100022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
- "3026020100022100ffffffff00000001000000000000000000000001000000000000000000000000",
- "3008020100090380fe01",
- "3006020101020100",
- "3006020101020101",
- "30060201010201ff",
- "3026020101022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
- "3026020101022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
- "3026020101022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
- "3026020101022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
- "3026020101022100ffffffff00000001000000000000000000000001000000000000000000000000",
- "3008020101090380fe01",
- "30060201ff020100",
- "30060201ff020101",
- "30060201ff0201ff",
- "30260201ff022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
- "30260201ff022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
- "30260201ff022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
- "30260201ff022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
- "30260201ff022100ffffffff00000001000000000000000000000001000000000000000000000000",
- "30080201ff090380fe01",
- "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551020100",
- "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551020101",
- "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325510201ff",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632551022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632551",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632551022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632550",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632551022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632552",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632551022100ffffffff00000001000000000000000000000000ffffffff"
- + "ffffffffffffffff",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632551022100ffffffff0000000100000000000000000000000100000000"
- + "0000000000000000",
- "3028022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca" + "c2fc632551090380fe01",
- "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550020100",
- "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550020101",
- "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325500201ff",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632550022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632551",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632550022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632550",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632550022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632552",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632550022100ffffffff00000001000000000000000000000000ffffffff"
- + "ffffffffffffffff",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632550022100ffffffff0000000100000000000000000000000100000000"
- + "0000000000000000",
- "3028022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca" + "c2fc632550090380fe01",
- "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552020100",
- "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552020101",
- "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325520201ff",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632552022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632551",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632552022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632550",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632552022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632552",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632552022100ffffffff00000001000000000000000000000000ffffffff"
- + "ffffffffffffffff",
- "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca"
- + "c2fc632552022100ffffffff0000000100000000000000000000000100000000"
- + "0000000000000000",
- "3028022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9ca" + "c2fc632552090380fe01",
- "3026022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff020100",
- "3026022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff020101",
- "3026022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff0201ff",
- "3046022100ffffffff00000001000000000000000000000000ffffffffffffff"
- + "ffffffffff022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632551",
- "3046022100ffffffff00000001000000000000000000000000ffffffffffffff"
- + "ffffffffff022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632550",
- "3046022100ffffffff00000001000000000000000000000000ffffffffffffff"
- + "ffffffffff022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632552",
- "3046022100ffffffff00000001000000000000000000000000ffffffffffffff"
- + "ffffffffff022100ffffffff00000001000000000000000000000000ffffffff"
- + "ffffffffffffffff",
- "3046022100ffffffff00000001000000000000000000000000ffffffffffffff"
- + "ffffffffff022100ffffffff0000000100000000000000000000000100000000"
- + "0000000000000000",
- "3028022100ffffffff00000001000000000000000000000000ffffffffffffff" + "ffffffffff090380fe01",
- "3026022100ffffffff00000001000000000000000000000001000000000000000000000000020100",
- "3026022100ffffffff00000001000000000000000000000001000000000000000000000000020101",
- "3026022100ffffffff000000010000000000000000000000010000000000000000000000000201ff",
- "3046022100ffffffff0000000100000000000000000000000100000000000000"
- + "0000000000022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632551",
- "3046022100ffffffff0000000100000000000000000000000100000000000000"
- + "0000000000022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632550",
- "3046022100ffffffff0000000100000000000000000000000100000000000000"
- + "0000000000022100ffffffff00000000ffffffffffffffffbce6faada7179e84"
- + "f3b9cac2fc632552",
- "3046022100ffffffff0000000100000000000000000000000100000000000000"
- + "0000000000022100ffffffff00000001000000000000000000000000ffffffff"
- + "ffffffffffffffff",
- "3046022100ffffffff0000000100000000000000000000000100000000000000"
- + "0000000000022100ffffffff0000000100000000000000000000000100000000"
- + "0000000000000000",
- "3028022100ffffffff0000000100000000000000000000000100000000000000" + "0000000000090380fe01",
- };
/**
* Determines the Hash name from the ECDSA algorithm. There is a small inconsistency in the naming
@@ -598,134 +93,96 @@ public class EcdsaTest {
return k;
}
- public ECPublicKeySpec publicKey1() throws Exception {
- ECParameterSpec params = EcUtil.getNistP256Params();
- ECPoint w = new ECPoint(PubX, PubY);
- return new ECPublicKeySpec(w, params);
- }
-
- public void testVectors(
- String[] signatures,
- ECPublicKeySpec pubSpec,
- String message,
- String algorithm,
- String signatureType,
- boolean isValidDER,
- boolean isValidBER)
- throws Exception {
- byte[] messageBytes = message.getBytes("UTF-8");
- Signature verifier = Signature.getInstance(algorithm);
- KeyFactory kf = KeyFactory.getInstance("EC");
- ECPublicKey pub = (ECPublicKey) kf.generatePublic(pubSpec);
- int errors = 0;
- for (String signature : signatures) {
- byte[] signatureBytes = TestUtil.hexToBytes(signature);
- verifier.initVerify(pub);
- verifier.update(messageBytes);
- boolean verified = false;
- try {
- verified = verifier.verify(signatureBytes);
- } catch (SignatureException ex) {
- // verify can throw SignatureExceptions if the signature is malformed.
- // We don't flag these cases and simply consider the signature as invalid.
- verified = false;
- }
- if (!verified && isValidDER) {
- System.out.println(signatureType + " was not verified:" + signature);
- errors++;
- }
- if (verified && !isValidBER) {
- System.out.println(signatureType + " was verified:" + signature);
- errors++;
- }
+ /**
+ * Computes the bias of samples as
+ *
+ * abs(sum(e^(2 pi i s m / modulus) for s in samples) / sqrt(samples.length).
+ *
+ * If the samples are taken from a uniform distribution in the range 0 .. modulus - 1
+ * and the number of samples is significantly larger than L^2
+ * then the probability that the result is larger than L is approximately e^(-L^2).
+ * The approximation can be derived from the assumption that samples taken from
+ * a uniform distribution give a result that approximates a standard complex normal
+ * distribution Z. I.e. Z has a density f_Z(z) = exp(-abs(z)^2) / pi.
+ * https://en.wikipedia.org/wiki/Complex_normal_distribution
+ */
+ double bias(BigInteger[] samples, BigInteger modulus, BigInteger m) {
+ double sumReal = 0.0;
+ double sumImag = 0.0;
+ for (BigInteger s : samples) {
+ BigInteger r = s.multiply(m).mod(modulus);
+ // multiplier = 2 * pi / 2^52
+ double multiplier = 1.3951473992034527e-15;
+ // computes the quotent 2 * pi * r / modulus
+ double quot = r.shiftLeft(52).divide(modulus).doubleValue() * multiplier;
+ sumReal += Math.cos(quot);
+ sumImag += Math.sin(quot);
}
- assertEquals(0, errors);
- }
-
- @Test
- public void testValidSignatures() throws Exception {
- testVectors(
- VALID_SIGNATURES,
- publicKey1(),
- "Hello",
- "SHA256WithECDSA",
- "Valid ECDSA signature",
- true,
- true);
- }
-
- @Test
- public void testModifiedSignatures() throws Exception {
- testVectors(
- MODIFIED_SIGNATURES,
- publicKey1(),
- "Hello",
- "SHA256WithECDSA",
- "Modified ECDSA signature",
- false,
- true);
- }
-
- @Test
- public void testInvalidSignatures() throws Exception {
- testVectors(
- INVALID_SIGNATURES,
- publicKey1(),
- "Hello",
- "SHA256WithECDSA",
- "Invalid ECDSA signature",
- false,
- false);
+ return Math.sqrt((sumReal * sumReal + sumImag * sumImag) / samples.length);
}
/**
- * This test checks the basic functionality of ECDSA. It can also be used to generate simple test
- * vectors.
+ * This test checks the basic functionality of ECDSA. It simply tries to generate a key, sign and
+ * verify a message for a given, algorithm and curve.
+ *
+ * @param algorithm the algorithm to test (e.g. "SHA256WithECDSA")
+ * @param curve the curve to test (e.g. "secp256r1")
+ * @return whether the algorithm and curve are supported.
+ * @throws Exception if an unexpected error occurred.
*/
- @Test
- public void testBasic() throws Exception {
- String algorithm = "SHA256WithECDSA";
- String hashAlgorithm = "SHA-256";
- String message = "Hello";
- String curve = "secp256r1";
+ boolean testParameters(String algorithm, String curve) throws Exception {
+ String message = "123400";
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
- ECGenParameterSpec ecSpec = new ECGenParameterSpec("secp256r1");
- keyGen.initialize(ecSpec);
- KeyPair keyPair = keyGen.generateKeyPair();
+ ECGenParameterSpec ecSpec = new ECGenParameterSpec(curve);
+ KeyPair keyPair;
+ try {
+ keyGen.initialize(ecSpec);
+ keyPair = keyGen.generateKeyPair();
+ } catch (InvalidAlgorithmParameterException ex) {
+ // The curve is not supported.
+ // The documentation does not specify whether the method initialize
+ // has to reject unsupported curves or if only generateKeyPair checks
+ // whether the curve is supported.
+ return false;
+ }
ECPublicKey pub = (ECPublicKey) keyPair.getPublic();
ECPrivateKey priv = (ECPrivateKey) keyPair.getPrivate();
+ // Print the parameters.
+ System.out.println("Parameters for curve:" + curve);
+ EcUtil.printParameters(pub.getParams());
+
+ Signature signer;
+ Signature verifier;
+ try {
+ signer = Signature.getInstance(algorithm);
+ verifier = Signature.getInstance(algorithm);
+ } catch (NoSuchAlgorithmException ex) {
+ // The algorithm is not supported.
+ return false;
+ }
+ // Both algorithm and curve are supported.
+ // Hence, we expect that signing and verifying properly works.
byte[] messageBytes = message.getBytes("UTF-8");
- Signature signer = Signature.getInstance(algorithm);
- Signature verifier = Signature.getInstance(algorithm);
signer.initSign(priv);
signer.update(messageBytes);
byte[] signature = signer.sign();
verifier.initVerify(pub);
verifier.update(messageBytes);
assertTrue(verifier.verify(signature));
+ return true;
+ }
- // Extract some parameters.
- byte[] rawHash = MessageDigest.getInstance(hashAlgorithm).digest(messageBytes);
- ECParameterSpec params = priv.getParams();
-
- // Print keys and signature, so that it can be used to generate new test vectors.
- System.out.println("Message:" + message);
- System.out.println("Hash:" + TestUtil.bytesToHex(rawHash));
- System.out.println("Curve:" + curve);
- System.out.println("Order:" + params.getOrder().toString());
- System.out.println("Private key:");
- System.out.println("S:" + priv.getS().toString());
- System.out.println("encoded:" + TestUtil.bytesToHex(priv.getEncoded()));
- System.out.println("Public key:");
- ECPoint w = pub.getW();
- System.out.println("X:" + w.getAffineX().toString());
- System.out.println("Y:" + w.getAffineY().toString());
- System.out.println("encoded:" + TestUtil.bytesToHex(pub.getEncoded()));
- System.out.println("Signature:" + TestUtil.bytesToHex(signature));
- System.out.println("r:" + extractR(signature).toString());
- System.out.println("s:" + extractS(signature).toString());
+ /**
+ * This test checks the basic functionality of ECDSA. This mainly checks that the provider follows
+ * the JCA interface.
+ */
+ @Test
+ public void testBasic() throws Exception {
+ String algorithm = "SHA256WithECDSA";
+ String curve = "secp256r1";
+ assertTrue(testParameters(algorithm, curve));
}
/** Checks whether the one time key k in ECDSA is biased. */
@@ -759,12 +216,18 @@ public class EcdsaTest {
Signature signer = Signature.getInstance(algorithm);
signer.initSign(priv);
- int countLsb = 0; // count the number of k's with msb set
- int countMsb = 0; // count the number of k's with lsb set
+ BigInteger[] kList = new BigInteger[tests];
for (int i = 0; i < tests; i++) {
signer.update(messageBytes);
byte[] signature = signer.sign();
- BigInteger k = extractK(signature, h, priv);
+ kList[i] = extractK(signature, h, priv);
+ }
+
+ // Checks whether the most significant bits and the least significant bits
+ // of the value k are unbiased.
+ int countMsb = 0; // count the number of k's with lsb set
+ int countLsb = 0; // count the number of k's with msb set
+ for (BigInteger k : kList) {
if (k.testBit(0)) {
countLsb++;
}
@@ -772,20 +235,38 @@ public class EcdsaTest {
countMsb++;
}
}
- System.out.println(
- signer.getProvider().getName()
- + " curve:"
- + curve
- + " countLsb:"
- + countLsb
- + " countMsb:"
- + countMsb);
if (countLsb < mincount || countLsb > tests - mincount) {
fail("Bias detected in the least significant bit of k:" + countLsb);
}
if (countMsb < mincount || countMsb > tests - mincount) {
fail("Bias detected in the most significant bit of k:" + countMsb);
}
+
+ // One situation where the bits above are not biased even if k itself is
+ // badly distributed is the case where the signer replaces s by
+ // min(s, q - s). Such a replacement is sometimes done to avoid signature
+ // malleability of ECDSA.
+ // Breitner and Heninger describe such cases in the paper
+ // "Biased Nonce Sense: Lattice Attacks against Weak ECDSA Signatures in Cryptocurrencies",
+ // https://eprint.iacr.org/2019/023.pdf
+ // The following tests should catch the bugs described in this paper.
+ // The threshold below has been chosen to give false positives with probability < 2^{-32}.
+ double threshold = 5;
+
+ // This test detects for example the case when either k or q-k is small.
+ double bias1 = bias(kList, q, BigInteger.ONE);
+ if (bias1 > threshold) {
+ fail("Bias for k detected. bias1 = " + bias1);
+ }
+ // Same as above but shifing by one bit.
+ double bias2 = bias(kList, q, BigInteger.valueOf(2));
+ if (bias2 > threshold) {
+ fail("Bias for k detected. bias2 = " + bias2);
+ }
+ double bias3 = bias(kList, q, qHalf);
+ if (bias3 > threshold) {
+ fail("Bias for k detected. bias3 = " + bias3);
+ }
}
@SlowTest(
diff --git a/java/com/google/security/wycheproof/testcases/JsonSignatureTest.java b/java/com/google/security/wycheproof/testcases/JsonSignatureTest.java
index 14a7d33..deefd1f 100644
--- a/java/com/google/security/wycheproof/testcases/JsonSignatureTest.java
+++ b/java/com/google/security/wycheproof/testcases/JsonSignatureTest.java
@@ -45,8 +45,13 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class JsonSignatureTest {
+ /**
+ * Defines the format of the signatures. RAW is used when the signature scheme already
+ * defines an encoding (e.g. this is used for RSA signatures).
+ */
+ public enum Format { RAW, ASN, P1363 };
- /** Convenience mehtod to get a String from a JsonObject */
+ /** Convenience method to get a String from a JsonObject */
protected static String getString(JsonObject object, String name) throws Exception {
return object.get(name).getAsString();
}
@@ -63,18 +68,21 @@ public class JsonSignatureTest {
* names for digital signatures (e.g. "SHA256WITHECDSA"). Providers sometimes use distinct
* algorithm names for the same cryptographic primitive.
*
- * See http://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html
+ *
See https://docs.oracle.com/en/java/javase/11/docs/specs/security/standard-names.html
*
* @param md the name of the message digest (e.g. "SHA-256")
* @param signatureAlgorithm the name of the signature algorithm (e.g. "ECDSA")
- * @param signatureFormat the format of the signatures. This should be "P1363Format" for
- * P1363 encoded ECDSA signatures or "" otherwise.
+ * @param signatureFormat the format of the signatures.
* @return an instance of java.security.Signature if the algorithm is known
* @throws NoSuchAlgorithmException if the algorithm is not known
*/
protected static Signature getSignatureInstance(
- String md, String signatureAlgorithm, String signatureFormat)
+ String md, String signatureAlgorithm, Format signatureFormat)
throws NoSuchAlgorithmException {
+ // Convert hash names, so that they can be used in an algorithm name for a signature.
+ // I.e. in a number of cases a hyphen needs to be removed to get correct names.
+ // No conversion is necessary for SHA-3 hashes. E.g, "SHA3-256WithECDSA" is the ECDSA
+ // algorithm name for md = "SHA3-256".
if (md.equalsIgnoreCase("SHA-1")) {
md = "SHA1";
} else if (md.equalsIgnoreCase("SHA-224")) {
@@ -86,31 +94,81 @@ public class JsonSignatureTest {
} else if (md.equalsIgnoreCase("SHA-512")) {
md = "SHA512";
}
- if (signatureFormat.equalsIgnoreCase("P1363Format")
- && signatureAlgorithm.equalsIgnoreCase("ECDSA")) {
- // The algorithm names for signature schemes with P1363 format have distinct names
- // in distinct providers. This is mainly the case since the P1363 format has only
- // been added in jdk11, while providers such as BouncyCastle added the format earlier
- // than that. Hence the code below just tries known algorithm names.
- try {
- String jdkName = md + "WITH" + signatureAlgorithm + "inP1363Format";
- return Signature.getInstance(jdkName);
- } catch (NoSuchAlgorithmException ex) {
- // jdkName is not known.
- }
- try {
- String bcName = md + "WITHPLAIN-" + signatureAlgorithm;
- return Signature.getInstance(bcName);
- } catch (NoSuchAlgorithmException ex) {
- // bcName is not known.
- }
- }
- if (!signatureFormat.isEmpty()) {
- throw new NoSuchAlgorithmException("Invalid signatureFormat:" + signatureFormat);
+ switch (signatureFormat) {
+ case RAW:
+ case ASN:
+ return Signature.getInstance(md + "WITH" + signatureAlgorithm);
+ case P1363:
+ if (signatureAlgorithm.equals("ECDSA") || signatureAlgorithm.equals("DSA")) {
+ // The algorithm names for signature schemes with P1363 format have distinct names
+ // in distinct providers. This is mainly the case since the P1363 format has only
+ // been added in jdk11, while providers such as BouncyCastle added the format earlier
+ // than that. Hence the code below just tries known algorithm names.
+ try {
+ String jdkName = md + "WITH" + signatureAlgorithm + "inP1363Format";
+ return Signature.getInstance(jdkName);
+ } catch (NoSuchAlgorithmException ex) {
+ // jdkName is not known.
+ }
+ try {
+ String bcName = md + "WITHPLAIN-" + signatureAlgorithm;
+ return Signature.getInstance(bcName);
+ } catch (NoSuchAlgorithmException ex) {
+ // bcName is not known.
+ }
+ }
+ break;
}
- return Signature.getInstance(md + "WITH" + signatureAlgorithm);
+ throw new NoSuchAlgorithmException(
+ "Algorithm "
+ + signatureAlgorithm
+ + " with format "
+ + signatureFormat
+ + " is not supported");
}
+ /**
+ * Returns the expected JSON schema for a given test or "" if the schema is undefined.
+ * The purpose of this function is to perform a sanity test with the goal to recognize
+ * incorrect test setups.
+ * @param signatureAlgorithm the signataure algorithm (e.g. "ECDSA")
+ * @param signatureFormat the format of the signatures
+ * @param verify true if verification is tested, false if signature generations is tested.
+ */
+ protected static String expectedSchema(String signatureAlgorithm, Format signatureFormat,
+ boolean verify) {
+ if (verify) {
+ if (signatureAlgorithm.equals("ECDSA")) {
+ switch (signatureFormat) {
+ case ASN: return "ecdsa_verify_schema.json";
+ case P1363: return "ecdsa_p1363_verify_schema.json";
+ default: break;
+ }
+ } else if (signatureAlgorithm.equals("DSA")) {
+ switch (signatureFormat) {
+ case ASN: return "dsa_verify_schema.json";
+ case P1363: return "dsa_p1363_verify_schema.json";
+ default: break;
+ }
+ } else if (signatureAlgorithm.equals("RSA")) {
+ // Only RSA-PKCS1 is implemented in this unit test.
+ // RSA-PSS signatures have their own unit test, because the algorithm parameters
+ // require a setup that is a little different.
+ switch (signatureFormat) {
+ case RAW: return "rsassa_pkcs1_verify_schema.json";
+ default: break;
+ }
+ }
+ } else {
+ // signature generation
+ if (signatureAlgorithm.equals("RSA")) {
+ return "rsassa_pkcs1_generate_schema.json";
+ }
+ }
+ // If the schema is not defined then the tests below still run. The only drawback is that
+ // incorrect test setups are not recognized and will probably lead to failures later.
+ return "";
+ }
/**
* Get a PublicKey from a JsonObject.
*
@@ -176,34 +234,28 @@ public class JsonSignatureTest {
*
* @param filename the filename of the test vectors
* @param signatureAlgorithm the algorithm name of the test vectors
- * @param signatureFormat the format of the signatures. This should be "P1363Format" for
- * P1363 encoded ECDSA signatures or "" otherwise.
+ * @param signatureFormat the format of the signatures. This should be Format.P1363 for
+ * P1363 encoded signatures Format.ASN for ASN.1 encoded signature and Format.RAW
+ otherwise.
* @param allowSkippingKeys if true then keys that cannot be constructed will not fail the test.
* This is for example used for files with test vectors that use elliptic curves that are not
* commonly supported.
**/
public void testVerification(
- String filename, String signatureAlgorithm, String signatureFormat, boolean allowSkippingKeys)
+ String filename, String signatureAlgorithm, Format signatureFormat, boolean allowSkippingKeys)
throws Exception {
- // Testing with old test vectors may be a reason for a test failure.
- // Generally mismatched version numbers are of little or no concern, since
- // the test vector version change much more frequently than the format.
- //
- // Version numbers have the format major.minor[.subversion].
- // Versions before 1.0 are experimental and use formats that are expected to change.
- // Versions after 1.0 change the major number if the format changes and change
- // the minor number if only the test vectors (but not the format) changes.
- // Subversions are release canddiate for the next version.
- final String expectedVersion = "0.6";
JsonObject test = JsonUtil.getTestVectors(filename);
- String generatorVersion = getString(test, "generatorVersion");
- if (!generatorVersion.equals(expectedVersion)) {
+ // Checks whether the test vectors in the file use the expected algorithm and the expected
+ // format for the signatures.
+ String schema = expectedSchema(signatureAlgorithm, signatureFormat, true);
+ String actualSchema = getString(test, "schema");
+ if (!schema.isEmpty() && !schema.equals(actualSchema)) {
System.out.println(
signatureAlgorithm
- + ": expecting test vectors with version "
- + expectedVersion
- + " found vectors with version "
- + generatorVersion);
+ + ": expecting test vectors with schema "
+ + schema
+ + " found vectors with schema "
+ + actualSchema);
}
int numTests = test.get("numberOfTests").getAsInt();
int cntTests = 0;
@@ -307,9 +359,11 @@ public class JsonSignatureTest {
}
}
}
- System.out.println("Number of skipped keys:" + skippedKeys);
- for (String s : skippedGroups) {
- System.out.println("Skipped groups where " + s);
+ if (skippedKeys > 0 || !skippedGroups.isEmpty()) {
+ System.out.println("File:" + filename + " number of skipped keys:" + skippedKeys);
+ for (String s : skippedGroups) {
+ System.out.println("Skipped groups where " + s);
+ }
}
assertEquals(0, errors);
if (skippedKeys == 0) {
@@ -329,23 +383,24 @@ public class JsonSignatureTest {
*
* @param filename the filename of the test vectors
* @param signatureAlgorithm the algorithm name of the test vectors (e.g. "RSA")
- * @param signatureFormat the format of the signatures. This should be "P1363Format" for
- * P1363 encoded ECDSA signatures or "" otherwise.
+ * @param signatureFormat the format of the signatures.
* @param allowSkippingKeys if true then keys that cannot be constructed will not fail the test.
*/
public void testSigning(
- String filename, String signatureAlgorithm, String signatureFormat,
+ String filename, String signatureAlgorithm, Format signatureFormat,
boolean allowSkippingKeys) throws Exception {
- final String expectedVersion = "0.6";
JsonObject test = JsonUtil.getTestVectors(filename);
- String generatorVersion = getString(test, "generatorVersion");
- if (!generatorVersion.equals(expectedVersion)) {
+ // Checks whether the test vectors in the file use the expected algorithm and the expected
+ // format for the signatures.
+ String schema = expectedSchema(signatureAlgorithm, signatureFormat, false);
+ String actualSchema = getString(test, "schema");
+ if (!schema.isEmpty() && !schema.equals(actualSchema)) {
System.out.println(
signatureAlgorithm
- + ": expecting test vectors with version "
- + expectedVersion
- + " found vectors with version "
- + generatorVersion);
+ + ": expecting test vectors with schema "
+ + schema
+ + " found vectors with schema "
+ + actualSchema);
}
int cntTests = 0;
int errors = 0;
@@ -407,68 +462,69 @@ public class JsonSignatureTest {
}
}
}
- System.out.println("Number of skipped keys:" + skippedKeys);
- System.out.println("Number of signatures verified:" + cntTests);
assertEquals(0, errors);
- if (!allowSkippingKeys) {
- assertEquals(0, skippedKeys);
+ if (skippedKeys > 0) {
+ System.out.println("File:" + filename);
+ System.out.println("Number of signatures verified:" + cntTests);
+ System.out.println("Number of skipped keys:" + skippedKeys);
+ assertTrue(allowSkippingKeys);
}
}
@Test
public void testEcdsa() throws Exception {
- testVerification("ecdsa_test.json", "ECDSA", "", true);
+ testVerification("ecdsa_test.json", "ECDSA", Format.ASN, true);
}
@Test
public void testSecp224r1Sha224() throws Exception {
- testVerification("ecdsa_secp224r1_sha224_test.json", "ECDSA", "", false);
+ testVerification("ecdsa_secp224r1_sha224_test.json", "ECDSA", Format.ASN, false);
}
@Test
public void testSecp224r1Sha256() throws Exception {
- testVerification("ecdsa_secp224r1_sha256_test.json", "ECDSA", "", false);
+ testVerification("ecdsa_secp224r1_sha256_test.json", "ECDSA", Format.ASN, false);
}
@Test
public void testSecp224r1Sha512() throws Exception {
- testVerification("ecdsa_secp224r1_sha512_test.json", "ECDSA", "", false);
+ testVerification("ecdsa_secp224r1_sha512_test.json", "ECDSA", Format.ASN, false);
}
@Test
public void testSecp256r1Sha256() throws Exception {
- testVerification("ecdsa_secp256r1_sha256_test.json", "ECDSA", "", false);
+ testVerification("ecdsa_secp256r1_sha256_test.json", "ECDSA", Format.ASN, false);
}
@Test
public void testSecp256r1Sha512() throws Exception {
- testVerification("ecdsa_secp256r1_sha512_test.json", "ECDSA", "", false);
+ testVerification("ecdsa_secp256r1_sha512_test.json", "ECDSA", Format.ASN, false);
}
@Test
public void testSecp384r1Sha384() throws Exception {
- testVerification("ecdsa_secp384r1_sha384_test.json", "ECDSA", "", false);
+ testVerification("ecdsa_secp384r1_sha384_test.json", "ECDSA", Format.ASN, false);
}
@Test
public void testSecp384r1Sha512() throws Exception {
- testVerification("ecdsa_secp384r1_sha512_test.json", "ECDSA", "", false);
+ testVerification("ecdsa_secp384r1_sha512_test.json", "ECDSA", Format.ASN, false);
}
@Test
public void testSecp521r1Sha512() throws Exception {
- testVerification("ecdsa_secp521r1_sha512_test.json", "ECDSA", "", false);
+ testVerification("ecdsa_secp521r1_sha512_test.json", "ECDSA", Format.ASN, false);
}
// Testing curves that may not be supported by a provider.
@Test
public void testSecp256k1Sha256() throws Exception {
- testVerification("ecdsa_secp256k1_sha256_test.json", "ECDSA", "", true);
+ testVerification("ecdsa_secp256k1_sha256_test.json", "ECDSA", Format.ASN, true);
}
@Test
public void testSecp256k1Sha512() throws Exception {
- testVerification("ecdsa_secp256k1_sha512_test.json", "ECDSA", "", true);
+ testVerification("ecdsa_secp256k1_sha512_test.json", "ECDSA", Format.ASN, true);
}
@NoPresubmitTest(
@@ -477,78 +533,78 @@ public class JsonSignatureTest {
)
@Test
public void testBrainpoolP224r1Sha224() throws Exception {
- testVerification("ecdsa_brainpoolP224r1_sha224_test.json", "ECDSA", "", true);
+ testVerification("ecdsa_brainpoolP224r1_sha224_test.json", "ECDSA", Format.ASN, true);
}
@Test
public void testBrainpoolP256r1Sha256() throws Exception {
- testVerification("ecdsa_brainpoolP256r1_sha256_test.json", "ECDSA", "", true);
+ testVerification("ecdsa_brainpoolP256r1_sha256_test.json", "ECDSA", Format.ASN, true);
}
@Test
public void testBrainpoolP320r1Sha384() throws Exception {
- testVerification("ecdsa_brainpoolP320r1_sha384_test.json", "ECDSA", "", true);
+ testVerification("ecdsa_brainpoolP320r1_sha384_test.json", "ECDSA", Format.ASN, true);
}
@Test
public void testBrainpoolP384r1Sha384() throws Exception {
- testVerification("ecdsa_brainpoolP384r1_sha384_test.json", "ECDSA", "", true);
+ testVerification("ecdsa_brainpoolP384r1_sha384_test.json", "ECDSA", Format.ASN, true);
}
@Test
public void testBrainpoolP512r1Sha512() throws Exception {
- testVerification("ecdsa_brainpoolP512r1_sha512_test.json", "ECDSA", "", true);
+ testVerification("ecdsa_brainpoolP512r1_sha512_test.json", "ECDSA", Format.ASN, true);
}
// jdk11 adds P1363 encoded signatures.
@Test
public void testSecp224r1Sha224inP1363Format() throws Exception {
- testVerification("ecdsa_secp224r1_sha224_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_secp224r1_sha224_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testSecp224r1Sha256inP1363Format() throws Exception {
- testVerification("ecdsa_secp224r1_sha256_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_secp224r1_sha256_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testSecp224r1Sha512inP1363Format() throws Exception {
- testVerification("ecdsa_secp224r1_sha512_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_secp224r1_sha512_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testSecp256r1Sha256inP1363Format() throws Exception {
- testVerification("ecdsa_secp256r1_sha256_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_secp256r1_sha256_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testSecp256r1Sha512inP1363Format() throws Exception {
- testVerification("ecdsa_secp256r1_sha512_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_secp256r1_sha512_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testSecp384r1Sha384inP1363Format() throws Exception {
- testVerification("ecdsa_secp384r1_sha384_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_secp384r1_sha384_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testSecp384r1Sha512inP1363Format() throws Exception {
- testVerification("ecdsa_secp384r1_sha512_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_secp384r1_sha512_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testSecp521r1Sha512inP1363Format() throws Exception {
- testVerification("ecdsa_secp521r1_sha512_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_secp521r1_sha512_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testSecp256k1Sha256inP1363Format() throws Exception {
- testVerification("ecdsa_secp256k1_sha256_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_secp256k1_sha256_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testSecp256k1Sha512inP1363Format() throws Exception {
- testVerification("ecdsa_secp256k1_sha512_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_secp256k1_sha512_p1363_test.json", "ECDSA", Format.P1363, true);
}
@NoPresubmitTest(
@@ -557,78 +613,78 @@ public class JsonSignatureTest {
)
@Test
public void testBrainpoolP224r1Sha224inP1363Format() throws Exception {
- testVerification("ecdsa_brainpoolP224r1_sha224_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_brainpoolP224r1_sha224_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testBrainpoolP256r1Sha256inP1363Format() throws Exception {
- testVerification("ecdsa_brainpoolP256r1_sha256_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_brainpoolP256r1_sha256_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testBrainpoolP320r1Sha384inP1363Format() throws Exception {
- testVerification("ecdsa_brainpoolP320r1_sha384_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_brainpoolP320r1_sha384_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testBrainpoolP384r1Sha384inP1363Format() throws Exception {
- testVerification("ecdsa_brainpoolP384r1_sha384_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_brainpoolP384r1_sha384_p1363_test.json", "ECDSA", Format.P1363, true);
}
@Test
public void testBrainpoolP512r1Sha512inP1363Format() throws Exception {
- testVerification("ecdsa_brainpoolP512r1_sha512_p1363_test.json", "ECDSA", "P1363Format", true);
+ testVerification("ecdsa_brainpoolP512r1_sha512_p1363_test.json", "ECDSA", Format.P1363, true);
}
// Testing RSA PKCS#1 v1.5 signatures.
@Test
public void testRsaSigning() throws Exception {
- testSigning("rsa_sig_gen_misc_test.json", "RSA", "", false);
+ testSigning("rsa_sig_gen_misc_test.json", "RSA", Format.RAW, false);
}
@Test
public void testRsaSignatures() throws Exception {
- testVerification("rsa_signature_test.json", "RSA", "", false);
+ testVerification("rsa_signature_test.json", "RSA", Format.RAW, false);
}
@Test
public void testRsaSignature2048sha224() throws Exception {
- testVerification("rsa_signature_2048_sha224_test.json", "RSA", "", false);
+ testVerification("rsa_signature_2048_sha224_test.json", "RSA", Format.RAW, false);
}
@Test
public void testRsaSignatures2048sha256() throws Exception {
- testVerification("rsa_signature_2048_sha256_test.json", "RSA", "", false);
+ testVerification("rsa_signature_2048_sha256_test.json", "RSA", Format.RAW, false);
}
@Test
public void testRsaSignatures2048sha512() throws Exception {
- testVerification("rsa_signature_2048_sha512_test.json", "RSA", "", false);
+ testVerification("rsa_signature_2048_sha512_test.json", "RSA", Format.RAW, false);
}
@Test
public void testRsaSignatures3072sha256() throws Exception {
- testVerification("rsa_signature_3072_sha256_test.json", "RSA", "", false);
+ testVerification("rsa_signature_3072_sha256_test.json", "RSA", Format.RAW, false);
}
@Test
public void testRsaSignatures3072sha384() throws Exception {
- testVerification("rsa_signature_3072_sha384_test.json", "RSA", "", false);
+ testVerification("rsa_signature_3072_sha384_test.json", "RSA", Format.RAW, false);
}
@Test
public void testRsaSignatures3072sha512() throws Exception {
- testVerification("rsa_signature_3072_sha512_test.json", "RSA", "", false);
+ testVerification("rsa_signature_3072_sha512_test.json", "RSA", Format.RAW, false);
}
@Test
public void testRsaSignatures4096sha384() throws Exception {
- testVerification("rsa_signature_4096_sha384_test.json", "RSA", "", false);
+ testVerification("rsa_signature_4096_sha384_test.json", "RSA", Format.RAW, false);
}
@Test
public void testRsaSignatures4096sha512() throws Exception {
- testVerification("rsa_signature_4096_sha512_test.json", "RSA", "", false);
+ testVerification("rsa_signature_4096_sha512_test.json", "RSA", Format.RAW, false);
}
// Testing DSA signatures.
@@ -641,7 +697,7 @@ public class JsonSignatureTest {
comment = "Conscrypt does not support DSA.")
@Test
public void testDsa() throws Exception {
- testVerification("dsa_test.json", "DSA", "", false);
+ testVerification("dsa_test.json", "DSA", Format.ASN, false);
}
}
diff --git a/java/com/google/security/wycheproof/testcases/RsaOaepTest.java b/java/com/google/security/wycheproof/testcases/RsaOaepTest.java
index 5fb8a41..201dfbc 100644
--- a/java/com/google/security/wycheproof/testcases/RsaOaepTest.java
+++ b/java/com/google/security/wycheproof/testcases/RsaOaepTest.java
@@ -28,8 +28,6 @@ import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.MGF1ParameterSpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
-import java.util.HashSet;
-import java.util.Set;
import javax.crypto.Cipher;
import javax.crypto.spec.OAEPParameterSpec;
import javax.crypto.spec.PSource;
@@ -168,7 +166,8 @@ public class RsaOaepTest {
*
*
Example format for test vectors
* { "algorithm" : "RSA-OAEP",
- * "generatorVersion" : "0.5",
+ * "schema" : "rsaes_oaep_decrypt_schema.json",
+ * "generatorVersion" : "0.7",
* ...
* "testGroups" : [
* {
@@ -206,27 +205,27 @@ public class RsaOaepTest {
**/
public void testOaep(String filename, boolean allowSkippingKeys)
throws Exception {
- // Testing with old test vectors may be a reason for a test failure.
- // Generally mismatched version numbers are of little or no concern, since
- // the test vector version change much more frequently than the format.
- //
- // Version numbers have the format major.minor[status].
- // Versions before 1.0 are experimental and use formats that are expected to change.
- // Versions after 1.0 change the major number if the format changes and change
- // the minor number if only the test vectors (but not the format) changes.
- // Versions meant for distribution have no status.
- final String expectedVersion = "0.5";
- JsonObject test = JsonUtil.getTestVectors(filename);
+ JsonObject test = JsonUtil.getTestVectors(filename);
+
+ // Compares the expected and actual JSON schema of the test vector file.
+ // Mismatched JSON schemas will likely lead to a test failure.
String generatorVersion = getString(test, "generatorVersion");
- if (!generatorVersion.equals(expectedVersion)) {
- System.out.printf("Expecting test vectors with version %s found version %s\n",
- expectedVersion, generatorVersion);
+ String expectedSchema = "rsaes_oaep_decrypt_schema.json";
+ String actualSchema = getString(test, "schema");
+ if (!expectedSchema.equals(actualSchema)) {
+ System.out.println(
+ "Expecting test vectors with schema "
+ + expectedSchema
+ + " found vectors with schema "
+ + actualSchema
+ + " generatorVersion:"
+ + generatorVersion);
}
+
int numTests = test.get("numberOfTests").getAsInt();
int cntTests = 0;
int errors = 0;
int skippedKeys = 0;
- Set skippedGroups = new HashSet();
for (JsonElement g : test.getAsJsonArray("testGroups")) {
JsonObject group = g.getAsJsonObject();
PrivateKey key;
@@ -288,15 +287,12 @@ public class RsaOaepTest {
}
}
}
- System.out.println("OAEP: Number of skipped keys:" + skippedKeys);
- for (String s : skippedGroups) {
- System.out.println("Skipped groups where " + s);
- }
assertEquals(0, errors);
- if (skippedKeys == 0) {
- assertEquals(numTests, cntTests);
- } else {
+ if (skippedKeys > 0) {
+ System.out.println("RSAES-OAEP: file:" + filename + " skipped key:" + skippedKeys);
assertTrue(allowSkippingKeys);
+ } else {
+ assertEquals(numTests, cntTests);
}
}