VYPR
High severityNVD Advisory· Published Jun 4, 2018· Updated Aug 6, 2024

CVE-2016-1000342

CVE-2016-1000342

Description

In the Bouncy Castle JCE Provider version 1.55 and earlier ECDSA does not fully validate ASN.1 encoding of signature on verification. It is possible to inject extra elements in the sequence making up the signature and still have it validate, which in some cases may allow the introduction of 'invisible' data into a signed structure.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Bouncy Castle JCE Provider ECDSA signature verification improperly validates ASN.1 encoding, allowing injection of extra data into a signed structure.

Vulnerability

In the Bouncy Castle JCE Provider version 1.55 and earlier, the ECDSA signature verification routine does not fully validate the ASN.1 encoding of the signature. Specifically, it permits extra elements to be injected into the SEQUENCE structure, meaning a malformed signature that includes additional data can still be accepted as valid. This affects versions prior to the fix in version 1.56 [1][3][4].

Exploitation

An attacker with the ability to present a crafted ECDSA signature to a verifier that relies on the Bouncy Castle library can exploit this flaw. The attacker does not need prior authentication or special network position beyond the ability to supply the signature to the verification process. The attacker constructs an ASN.1 DER SEQUENCE that includes not only the expected r and s integer elements but also additional, arbitrary elements. The verification algorithm incorrectly proceeds and returns success, effectively accepting the malformed signature.

Impact

Successful exploitation allows an attacker to create a signature that contains "invisible" data hidden within the ASN.1 structure while still validating as a legitimate signature. This undermines the integrity of signed data, potentially enabling injection of unsigned content into a signed message or certificate. The confidentiality and authenticity guarantees of ECDSA are weakened, and the trust in any system relying on Bouncy Castle's ECDSA verification is compromised [1][3][4].

Mitigation

The issue is fixed in Bouncy Castle JCE Provider version 1.56. Red Hat Satellite 6.4 and Red Hat Fuse 7.1 incorporate updated packages, and Ubuntu trusty (14.04) updated libbcmail-java and libbcpg-java to version 1.49+dfsg-2ubuntu0.1 [1][3][4]. Users should upgrade to the patched versions. If immediate upgrade is not possible, ensure that only trusted parties can supply signatures and monitor for unusual signature patterns.

AI Insight generated on May 22, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
org.bouncycastle:bcprov-jdk14Maven
< 1.561.56
org.bouncycastle:bcprov-jdk15Maven
< 1.561.56
org.bouncycastle:bcprov-jdk15onMaven
< 1.561.56

Affected products

4

Patches

1
843c2e60f67d

Added header validation for INTEGER/ENUMERATED

https://github.com/bcgit/bc-javaDavid HookOct 15, 2016via ghsa
7 files changed · +268 97
  • core/src/main/java/org/bouncycastle/asn1/ASN1Enumerated.java+11 0 modified
    @@ -99,6 +99,17 @@ public ASN1Enumerated(
         public ASN1Enumerated(
             byte[]   bytes)
         {
    +        if (bytes.length > 1)
    +        {
    +            if (bytes[0] == 0 && (bytes[1] & 0x80) == 0)
    +            {
    +                throw new IllegalArgumentException("malformed enumerated");
    +            }
    +            if (bytes[0] == (byte)0xff && (bytes[1] & 0x80) != 0)
    +            {
    +                throw new IllegalArgumentException("malformed enumerated");
    +            }
    +        }
             this.bytes = Arrays.clone(bytes);
         }
     
    
  • core/src/main/java/org/bouncycastle/asn1/ASN1Integer.java+11 0 modified
    @@ -89,6 +89,17 @@ public ASN1Integer(
     
         ASN1Integer(byte[] bytes, boolean clone)
         {
    +        if (bytes.length > 1)
    +        {
    +            if (bytes[0] == 0 && (bytes[1] & 0x80) == 0)
    +            {
    +                throw new IllegalArgumentException("malformed integer");
    +            }
    +            if (bytes[0] == (byte)0xff && (bytes[1] & 0x80) != 0)
    +            {
    +                throw new IllegalArgumentException("malformed integer");
    +            }
    +        }
             this.bytes = (clone) ? Arrays.clone(bytes) : bytes;
         }
     
    
  • core/src/test/java/org/bouncycastle/asn1/test/MiscTest.java+43 0 modified
    @@ -5,7 +5,9 @@
     import java.io.IOException;
     
     import org.bouncycastle.asn1.ASN1Encodable;
    +import org.bouncycastle.asn1.ASN1Enumerated;
     import org.bouncycastle.asn1.ASN1InputStream;
    +import org.bouncycastle.asn1.ASN1Integer;
     import org.bouncycastle.asn1.ASN1OutputStream;
     import org.bouncycastle.asn1.ASN1Primitive;
     import org.bouncycastle.asn1.BERSequence;
    @@ -67,6 +69,46 @@ public void shouldFailOnExtraData()
             }
         }
     
    +    public void derIntegerTest()
    +        throws Exception
    +    {
    +        try
    +        {
    +            new ASN1Integer(new byte[] { 0, 0, 0, 1});
    +        }
    +        catch (IllegalArgumentException e)
    +        {
    +            isTrue("wrong exc", "malformed integer".equals(e.getMessage()));
    +        }
    +
    +        try
    +        {
    +            new ASN1Integer(new byte[] {(byte)0xff, (byte)0x80, 0, 1});
    +        }
    +        catch (IllegalArgumentException e)
    +        {
    +            isTrue("wrong exc", "malformed integer".equals(e.getMessage()));
    +        }
    +
    +        try
    +        {
    +            new ASN1Enumerated(new byte[] { 0, 0, 0, 1});
    +        }
    +        catch (IllegalArgumentException e)
    +        {
    +            isTrue("wrong exc", "malformed enumerated".equals(e.getMessage()));
    +        }
    +
    +        try
    +        {
    +            new ASN1Enumerated(new byte[] {(byte)0xff, (byte)0x80, 0, 1});
    +        }
    +        catch (IllegalArgumentException e)
    +        {
    +            isTrue("wrong exc", "malformed enumerated".equals(e.getMessage()));
    +        }
    +    }
    +
         public void performTest()
             throws Exception
         {
    @@ -115,6 +157,7 @@ public void performTest()
             }
     
             shouldFailOnExtraData();
    +        derIntegerTest();
         }
     
         public String getName()
    
  • prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/dsa/DSASigner.java+5 0 modified
    @@ -29,6 +29,7 @@
     import org.bouncycastle.crypto.digests.SHA512Digest;
     import org.bouncycastle.crypto.params.ParametersWithRandom;
     import org.bouncycastle.crypto.signers.HMacDSAKCalculator;
    +import org.bouncycastle.util.Arrays;
     
     public class DSASigner
         extends SignatureSpi
    @@ -180,6 +181,10 @@ private BigInteger[] derDecode(
             {
                 throw new IOException("malformed signature");
             }
    +        if (!Arrays.areEqual(encoding, s.getEncoded(ASN1Encoding.DER)))
    +        {
    +            throw new IOException("malformed signature");
    +        }
     
             return new BigInteger[]{
                 ((ASN1Integer)s.getObjectAt(0)).getValue(),
    
  • prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/ec/SignatureSpi.java+10 1 modified
    @@ -23,14 +23,14 @@
     import org.bouncycastle.crypto.digests.SHA384Digest;
     import org.bouncycastle.crypto.digests.SHA3Digest;
     import org.bouncycastle.crypto.digests.SHA512Digest;
    -import org.bouncycastle.crypto.params.ECPublicKeyParameters;
     import org.bouncycastle.crypto.params.ParametersWithRandom;
     import org.bouncycastle.crypto.signers.ECDSASigner;
     import org.bouncycastle.crypto.signers.ECNRSigner;
     import org.bouncycastle.crypto.signers.HMacDSAKCalculator;
     import org.bouncycastle.jcajce.provider.asymmetric.util.DSABase;
     import org.bouncycastle.jcajce.provider.asymmetric.util.DSAEncoder;
     import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil;
    +import org.bouncycastle.util.Arrays;
     
     public class SignatureSpi
         extends DSABase
    @@ -367,6 +367,15 @@ public BigInteger[] decode(
                 throws IOException
             {
                 ASN1Sequence s = (ASN1Sequence)ASN1Primitive.fromByteArray(encoding);
    +            if (s.size() != 2)
    +            {
    +                throw new IOException("malformed signature");
    +            }
    +            if (!Arrays.areEqual(encoding, s.getEncoded(ASN1Encoding.DER)))
    +            {
    +                throw new IOException("malformed signature");
    +            }
    +
                 BigInteger[] sig = new BigInteger[2];
     
                 sig[0] = ASN1Integer.getInstance(s.getObjectAt(0)).getValue();
    
  • prov/src/test/java/org/bouncycastle/jce/provider/test/DSATest.java+2 1 modified
    @@ -143,7 +143,8 @@ public class DSATest
             + "9ef41dd424a4e1c8f16967cf3365813fe8786236",
             "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef4"
             + "1dd424a4e1c8f16967cf3365813fe87862360000",
    -        "3040021c57b10411b54ab248af03d8f2456676ebc6d3db5f1081492ac87e9ca8021d00942b117051d7d9d107fc42cac9c5a36a1fd7f0f8916ccca86cec4ed3040100"
    +        "3040021c57b10411b54ab248af03d8f2456676ebc6d3db5f1081492ac87e9ca8021d00942b117051d7d9d107fc42cac9c5a36a1fd7f0f8916ccca86cec4ed3040100",
    +        "303e021c57b10411b54ab248af03d8f2456676ebc6d3db5f1081492ac87e9ca802811d00942b117051d7d9d107fc42cac9c5a36a1fd7f0f8916ccca86cec4ed3"
         };
     
         private void testModified()
    
  • prov/src/test/java/org/bouncycastle/jce/provider/test/ECDSA5Test.java+186 95 modified
    @@ -48,6 +48,7 @@
     import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
     import org.bouncycastle.asn1.sec.SECObjectIdentifiers;
     import org.bouncycastle.asn1.teletrust.TeleTrusTObjectIdentifiers;
    +import org.bouncycastle.asn1.util.ASN1Dump;
     import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
     import org.bouncycastle.asn1.x9.X962Parameters;
     import org.bouncycastle.asn1.x9.X9ECParameters;
    @@ -58,6 +59,7 @@
     import org.bouncycastle.jce.ECNamedCurveTable;
     import org.bouncycastle.jce.ECPointUtil;
     import org.bouncycastle.jce.provider.BouncyCastleProvider;
    +import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec;
     import org.bouncycastle.math.ec.ECCurve;
     import org.bouncycastle.util.Arrays;
     import org.bouncycastle.util.BigIntegers;
    @@ -73,15 +75,103 @@ public class ECDSA5Test
         byte[] k1 = Hex.decode("d5014e4b60ef2ba8b6211b4062ba3224e0427dd3");
         byte[] k2 = Hex.decode("345e8d05c075c3a508df729a1685690e68fcfb8c8117847e89063bca1f85d968fd281540b6e13bd1af989a1fbf17e06462bf511f9d0b140fb48ac1b1baa5bded");
     
    -    SecureRandom    random = new FixedSecureRandom(
    -        new FixedSecureRandom.Source[] { new FixedSecureRandom.Data(k1), new FixedSecureRandom.Data(k2) });
    -    
    +    SecureRandom random = new FixedSecureRandom(
    +        new FixedSecureRandom.Source[]{new FixedSecureRandom.Data(k1), new FixedSecureRandom.Data(k2)});
    +    static final BigInteger PubX =
    +        new BigInteger("3390396496586153202365024500890309020181905168626402195853036609"
    +            + "0984128098564");
    +    static final BigInteger PubY =
    +        new BigInteger("1135421298983937257390683162600855221890652900790509030911087400"
    +            + "65052129055287");
    +    static final String[] VALID_SIGNATURES = {
    +        "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d49"
    +            + "1b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285"
    +            + "cd59f43260ecce",
    +    };
    +
    +    // The following test vectors check for signature malleability and bugs. That means the test
    +    // vectors are derived from a valid signature by modifying the ASN encoding. A correct
    +    // implementation of ECDSA should only accept correct DER encoding and properly handle the
    +    // others (e.g. integer overflow, infinity, redundant parameters, etc). Allowing alternative BER
    +    // encodings is in many cases benign. An example where this kind of signature malleability was a
    +    // problem: https://en.bitcoin.it/wiki/Transaction_Malleability
    +    static final String[] MODIFIED_SIGNATURES = {
    +        "304602812100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f"
    +            + "3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
    +        "30470282002100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd"
    +            + "2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
    +        "304602220000b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f"
    +            + "3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
    +        "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f028120747291dd2f"
    +            + "3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
    +        "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f02820020747291dd"
    +            + "2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
    +        "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f022100747291dd2f"
    +            + "3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
    +        "308145022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f"
    +            + "3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
    +        "30820045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd"
    +            + "2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
    +        "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f"
    +            + "44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce3000",
    +        "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f"
    +            + "44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce1000",
    +        "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f"
    +            + "44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0000",
    +        "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f"
    +            + "44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0000",
    +        "3048022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f"
    +            + "44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce058100",
    +        "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f"
    +            + "44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce05820000",
    +        "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f"
    +            + "44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce1100",
    +        "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f"
    +            + "44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0500",
    +        "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f"
    +            + "44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce2500",
    +        "3067022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f"
    +            + "44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0220747291dd2f3f44af7ace68ea33431d6f"
    +            + "94e418c106a6e76285cd59f43260ecce"
    +    };
    +
    +    private void testModified()
    +        throws Exception
    +    {
    +        ECNamedCurveParameterSpec namedCurve = ECNamedCurveTable.getParameterSpec("P-256");
    +        org.bouncycastle.jce.spec.ECPublicKeySpec pubSpec = new org.bouncycastle.jce.spec.ECPublicKeySpec(namedCurve.getCurve().createPoint(PubX, PubY), namedCurve);
    +        KeyFactory kFact = KeyFactory.getInstance("EC", "BC");
    +        PublicKey pubKey = kFact.generatePublic(pubSpec);
    +        Signature sig = Signature.getInstance("SHA256WithECDSA", "BC");
    +
    +        for (int i = 0; i != MODIFIED_SIGNATURES.length; i++)
    +        {
    +            sig.initVerify(pubKey);
    +
    +            sig.update(Strings.toByteArray("Hello"));
    +
    +            boolean failed;
    +
    +            try
    +            {
    +                failed = !sig.verify(Hex.decode(MODIFIED_SIGNATURES[i]));
    +                System.err.println(ASN1Dump.dumpAsString(ASN1Primitive.fromByteArray(Hex.decode(MODIFIED_SIGNATURES[i]))));
    +            }
    +            catch (SignatureException e)
    +            {
    +                failed = true;
    +            }
    +
    +            isTrue("sig verified when shouldn't: " + i, failed);
    +        }
    +    }
    +
         private void decodeTest()
         {
             EllipticCurve curve = new EllipticCurve(
    -                new ECFieldFp(new BigInteger("6277101735386680763835789423207666416083908700390324961279")), // q
    -                new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
    -                new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b
    +            new ECFieldFp(new BigInteger("6277101735386680763835789423207666416083908700390324961279")), // q
    +            new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
    +            new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b
     
             ECPoint p = ECPointUtil.decodePoint(curve, Hex.decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"));
     
    @@ -109,7 +199,7 @@ private void testECDSA239bitPrime()
     
             byte[] kData = BigIntegers.asUnsignedByteArray(new BigInteger("700000017569056646655505781757157107570501575775705779575555657156756655"));
     
    -        SecureRandom    k = new TestRandomBigInteger(kData);
    +        SecureRandom k = new TestRandomBigInteger(kData);
     
             EllipticCurve curve = new EllipticCurve(
                 new ECFieldFp(new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839")), // q
    @@ -121,7 +211,7 @@ private void testECDSA239bitPrime()
                 ECPointUtil.decodePoint(curve, Hex.decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
                 new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307"), // n
                 1); // h
    -        
    +
     
             ECPrivateKeySpec priKey = new ECPrivateKeySpec(
                 new BigInteger("876300101507107567501066130761671078357010671067781776716671676178726717"), // d
    @@ -131,18 +221,18 @@ private void testECDSA239bitPrime()
                 ECPointUtil.decodePoint(curve, Hex.decode("025b6dc53bc61a2548ffb0f671472de6c9521a9d2d2534e65abfcbd5fe0c70")), // Q
                 spec);
     
    -        Signature           sgr = Signature.getInstance("ECDSA", "BC");
    -        KeyFactory          f = KeyFactory.getInstance("ECDSA", "BC");
    -        PrivateKey          sKey = f.generatePrivate(priKey);
    -        PublicKey           vKey = f.generatePublic(pubKey);
    +        Signature sgr = Signature.getInstance("ECDSA", "BC");
    +        KeyFactory f = KeyFactory.getInstance("ECDSA", "BC");
    +        PrivateKey sKey = f.generatePrivate(priKey);
    +        PublicKey vKey = f.generatePublic(pubKey);
     
             sgr.initSign(sKey, k);
     
    -        byte[] message = new byte[] { (byte)'a', (byte)'b', (byte)'c' };
    +        byte[] message = new byte[]{(byte)'a', (byte)'b', (byte)'c'};
     
             sgr.update(message);
     
    -        byte[]  sigBytes = sgr.sign();
    +        byte[] sigBytes = sgr.sign();
     
             sgr.initVerify(vKey);
     
    @@ -153,7 +243,7 @@ private void testECDSA239bitPrime()
                 fail("239 Bit EC verification failed");
             }
     
    -        BigInteger[]  sig = derDecode(sigBytes);
    +        BigInteger[] sig = derDecode(sigBytes);
     
             if (!r.equals(sig[0]))
             {
    @@ -181,21 +271,21 @@ private void testBSI()
             KeyPair kp = kpGen.generateKeyPair();
     
             byte[] data = "Hello World!!!".getBytes();
    -        String[] cvcAlgs = { "SHA1WITHCVC-ECDSA", "SHA224WITHCVC-ECDSA",
    -                             "SHA256WITHCVC-ECDSA", "SHA384WITHCVC-ECDSA",
    -                             "SHA512WITHCVC-ECDSA" };
    -        String[] cvcOids = { EACObjectIdentifiers.id_TA_ECDSA_SHA_1.getId(), EACObjectIdentifiers.id_TA_ECDSA_SHA_224.getId(),
    -                             EACObjectIdentifiers.id_TA_ECDSA_SHA_256.getId(), EACObjectIdentifiers.id_TA_ECDSA_SHA_384.getId(),
    -                             EACObjectIdentifiers.id_TA_ECDSA_SHA_512.getId() };
    +        String[] cvcAlgs = {"SHA1WITHCVC-ECDSA", "SHA224WITHCVC-ECDSA",
    +            "SHA256WITHCVC-ECDSA", "SHA384WITHCVC-ECDSA",
    +            "SHA512WITHCVC-ECDSA"};
    +        String[] cvcOids = {EACObjectIdentifiers.id_TA_ECDSA_SHA_1.getId(), EACObjectIdentifiers.id_TA_ECDSA_SHA_224.getId(),
    +            EACObjectIdentifiers.id_TA_ECDSA_SHA_256.getId(), EACObjectIdentifiers.id_TA_ECDSA_SHA_384.getId(),
    +            EACObjectIdentifiers.id_TA_ECDSA_SHA_512.getId()};
     
             testBsiAlgorithms(kp, data, cvcAlgs, cvcOids);
     
    -        String[] plainAlgs = { "SHA1WITHPLAIN-ECDSA", "SHA224WITHPLAIN-ECDSA",
    -                             "SHA256WITHPLAIN-ECDSA", "SHA384WITHPLAIN-ECDSA",
    -                             "SHA512WITHPLAIN-ECDSA", "RIPEMD160WITHPLAIN-ECDSA" };
    -        String[] plainOids = { BSIObjectIdentifiers.ecdsa_plain_SHA1.getId(), BSIObjectIdentifiers.ecdsa_plain_SHA224.getId(),
    -                                BSIObjectIdentifiers.ecdsa_plain_SHA256.getId(), BSIObjectIdentifiers.ecdsa_plain_SHA384.getId(),
    -                                BSIObjectIdentifiers.ecdsa_plain_SHA512.getId(), BSIObjectIdentifiers.ecdsa_plain_RIPEMD160.getId() };
    +        String[] plainAlgs = {"SHA1WITHPLAIN-ECDSA", "SHA224WITHPLAIN-ECDSA",
    +            "SHA256WITHPLAIN-ECDSA", "SHA384WITHPLAIN-ECDSA",
    +            "SHA512WITHPLAIN-ECDSA", "RIPEMD160WITHPLAIN-ECDSA"};
    +        String[] plainOids = {BSIObjectIdentifiers.ecdsa_plain_SHA1.getId(), BSIObjectIdentifiers.ecdsa_plain_SHA224.getId(),
    +            BSIObjectIdentifiers.ecdsa_plain_SHA256.getId(), BSIObjectIdentifiers.ecdsa_plain_SHA384.getId(),
    +            BSIObjectIdentifiers.ecdsa_plain_SHA512.getId(), BSIObjectIdentifiers.ecdsa_plain_RIPEMD160.getId()};
     
             testBsiAlgorithms(kp, data, plainAlgs, plainOids);
         }
    @@ -235,42 +325,42 @@ private void testECDSA239bitBinary()
         {
             BigInteger r = new BigInteger("21596333210419611985018340039034612628818151486841789642455876922391552");
             BigInteger s = new BigInteger("197030374000731686738334997654997227052849804072198819102649413465737174");
    -    
    +
             byte[] kData = BigIntegers.asUnsignedByteArray(new BigInteger("171278725565216523967285789236956265265265235675811949404040041670216363"));
     
    -        SecureRandom    k = new TestRandomBigInteger(kData);
    +        SecureRandom k = new TestRandomBigInteger(kData);
     
             EllipticCurve curve = new EllipticCurve(
                 new ECFieldF2m(239, // m
    -                           new int[] { 36 }), // k
    +                new int[]{36}), // k
                 new BigInteger("32010857077C5431123A46B808906756F543423E8D27877578125778AC76", 16), // a
                 new BigInteger("790408F2EEDAF392B012EDEFB3392F30F4327C0CA3F31FC383C422AA8C16", 16)); // b
    -    
    +
             ECParameterSpec params = new ECParameterSpec(
                 curve,
                 ECPointUtil.decodePoint(curve, Hex.decode("0457927098FA932E7C0A96D3FD5B706EF7E5F5C156E16B7E7C86038552E91D61D8EE5077C33FECF6F1A16B268DE469C3C7744EA9A971649FC7A9616305")), // G
                 new BigInteger("220855883097298041197912187592864814557886993776713230936715041207411783"), // n
                 4); // h
    -    
    +
             ECPrivateKeySpec priKeySpec = new ECPrivateKeySpec(
                 new BigInteger("145642755521911534651321230007534120304391871461646461466464667494947990"), // d
                 params);
    -        
    +
             ECPublicKeySpec pubKeySpec = new ECPublicKeySpec(
                 ECPointUtil.decodePoint(curve, Hex.decode("045894609CCECF9A92533F630DE713A958E96C97CCB8F5ABB5A688A238DEED6DC2D9D0C94EBFB7D526BA6A61764175B99CB6011E2047F9F067293F57F5")), // Q
                 params);
    -    
    -        Signature   sgr = Signature.getInstance("ECDSA", "BC");
    -        KeyFactory  f = KeyFactory.getInstance("ECDSA", "BC");
    -        PrivateKey  sKey = f.generatePrivate(priKeySpec);
    -        PublicKey   vKey = f.generatePublic(pubKeySpec);
    -        byte[]      message = new byte[] { (byte)'a', (byte)'b', (byte)'c' };
    -       
    +
    +        Signature sgr = Signature.getInstance("ECDSA", "BC");
    +        KeyFactory f = KeyFactory.getInstance("ECDSA", "BC");
    +        PrivateKey sKey = f.generatePrivate(priKeySpec);
    +        PublicKey vKey = f.generatePublic(pubKeySpec);
    +        byte[] message = new byte[]{(byte)'a', (byte)'b', (byte)'c'};
    +
             sgr.initSign(sKey, k);
     
             sgr.update(message);
    -        
    -        byte[]  sigBytes = sgr.sign();
    +
    +        byte[] sigBytes = sgr.sign();
     
             sgr.initVerify(vKey);
     
    @@ -281,7 +371,7 @@ private void testECDSA239bitBinary()
                 fail("239 Bit EC verification failed");
             }
     
    -        BigInteger[]  sig = derDecode(sigBytes);
    +        BigInteger[] sig = derDecode(sigBytes);
     
             if (!r.equals(sig[0]))
             {
    @@ -297,14 +387,14 @@ private void testECDSA239bitBinary()
                     + " got      : " + sig[1]);
             }
         }
    -    
    +
         private void testGeneration()
             throws Exception
         {
             //
             // ECDSA generation test
             //
    -        byte[]              data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
    +        byte[] data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
             Signature s = Signature.getInstance("ECDSA", "BC");
             KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC");
     
    @@ -324,7 +414,7 @@ private void testGeneration()
             KeyPair p = g.generateKeyPair();
     
             PrivateKey sKey = p.getPrivate();
    -        PublicKey  vKey = p.getPublic();
    +        PublicKey vKey = p.getPublic();
     
             s.initSign(sKey);
     
    @@ -378,8 +468,8 @@ private void testKeyFactory(ECPublicKey pub, ECPrivateKey priv)
         {
             KeyFactory ecFact = KeyFactory.getInstance("ECDSA");
     
    -        ECPublicKeySpec  pubSpec = (ECPublicKeySpec)ecFact.getKeySpec(pub, ECPublicKeySpec.class);
    -        ECPrivateKeySpec  privSpec = (ECPrivateKeySpec)ecFact.getKeySpec(priv, ECPrivateKeySpec.class);
    +        ECPublicKeySpec pubSpec = (ECPublicKeySpec)ecFact.getKeySpec(pub, ECPublicKeySpec.class);
    +        ECPrivateKeySpec privSpec = (ECPrivateKeySpec)ecFact.getKeySpec(priv, ECPrivateKeySpec.class);
     
             if (!pubSpec.getW().equals(pub.getW()) || !pubSpec.getParams().getCurve().equals(pub.getParams().getCurve()))
             {
    @@ -391,8 +481,8 @@ private void testKeyFactory(ECPublicKey pub, ECPrivateKey priv)
                 fail("privSpec not correct");
             }
     
    -        ECPublicKey  pubKey = (ECPublicKey)ecFact.translateKey(pub);
    -        ECPrivateKey  privKey = (ECPrivateKey)ecFact.translateKey(priv);
    +        ECPublicKey pubKey = (ECPublicKey)ecFact.translateKey(pub);
    +        ECPrivateKey privKey = (ECPrivateKey)ecFact.translateKey(priv);
     
             if (!pubKey.getW().equals(pub.getW()) || !pubKey.getParams().getCurve().equals(pub.getParams().getCurve()))
             {
    @@ -454,7 +544,7 @@ private void testAdaptiveKeyConversion()
             KeyPair pair = kpGen.generateKeyPair();
     
             final PrivateKey privKey = pair.getPrivate();
    -        final PublicKey  pubKey = pair.getPublic();
    +        final PublicKey pubKey = pair.getPublic();
     
             Signature s = Signature.getInstance("ECDSA", "BC");
     
    @@ -669,7 +759,7 @@ public byte[] getEncoded()
             pair = kpGen.generateKeyPair();
     
             final PrivateKey privRsa = pair.getPrivate();
    -        final PublicKey  pubRsa = pair.getPublic();
    +        final PublicKey pubRsa = pair.getPublic();
     
             try
             {
    @@ -927,24 +1017,24 @@ private void testCustomNamedCurveSigning(String name)
         }
     
         /**
    -    COUNT = 1
    -    dsCAVS = 00000179557decd75b797bea9db656ce99c03a6e0ab13804b5b589644f7db41ceba05c3940c300361061074ca72a828428d9198267fa0b75e1e3e785a0ff20e839414be0
    -    QsCAVSx = 000001ce7da31681d5f176f3618f205969b9142520363dd26a596866c89988c932e3ce01904d12d1e9b105462e56163dbe7658ba3c472bf1f3c8165813295393ae346764
    -    QsCAVSy = 000000e70d6e55b76ebd362ff071ab819315593cec650276209a9fdc2c1c48e03c35945f04e74d958cabd3f5e4d1f096a991e807a8f9d217de306a6b561038ca15aea4b9
    -    NonceEphemCAVS = 4214a1a0a1d11679ae22f98d7ae483c1a74008a9cd7f7cf71b1f373a4226f5c58eb621ec56e2537797c01750dcbff07f613b9c58774f9af32aebeadd2226140dc7d56b1aa95c93ab1ec4412e2d0e42cdaac7bf9da3ddbf19fbb1edd0556d9c5a339808905fe8defd8b57ff8f34788192cc0cf7df17d1f351d69ac979a3a495931c287fb8
    -    dsIUT = 000000c14895dfcc5a6b24994828cfd0a0cc0a881a70173a3eb05c57b098046c8e60a868f6176284aa346eff1fd1b8b879052c5a6d5fd0ae146b35ed7ecee32e294103cd
    -    QsIUTx = 00000174a658695049db59f6bbe2ad23e1753bf58384a56fc9b3dec13eb873b33e1f4dbd24b6b4ca05a9a11ad531f6d99e9430a774980e8a8d9fd2d1e2a0d76fe3dd36c7
    -    QsIUTy = 00000030639849e1df341973db44e7bbba5bb597884a439f9ce54620c3ca73a9804cc26fcda3aaf73ae5a11d5b325cae0e95cfafe1985c6c2fdb892722e7dd2c5d744cf3
    -    deIUT = 00000138f54e986c7b44f49da389fa9f61bb7265f0cebdeddf09d47c72e55186e2520965fc2c31bb9c0a557e3c28e02a751f097e413c4252c7b0d22452d89f9ac314bc6e
    -    QeIUTx = 000001b9fbce9c9ebb31070a4a4ac7af54ec9189c1f98948cd24ca0a5029217e4784d3c8692da08a6a512d1c9875d20d8e03664c148fa5d34bbac6d42e499ee5dbf01120
    -    QeIUTy = 000000994a714b6d09afa896dbba9b4f436ab3cdb0d11dcd2aad28b7ba35d6fa6be537b6ffb0f9bf5fe1d594b8f8b8829687c9395c3d938c873f26c7100888c3aca2d59a
    -    OI = a1b2c3d4e54341565369646dbb63a273c81e0aad02f92699bf7baa28fd4509145b0096746894e98e209a85ecb415b8
    -    CAVSTag = 4ade5dc983cc1cf61c90fdbf726fa6a88e9bf411bbaf0015db06ff4348560e4d
    -    Z = 019a19a0a99f60221ee23323b3317292e8c10d57ba04e0b33f6241979ec3895945eed0bdcbc59ab576e7047061f0d63d1aaf78b1d442028605aa1c0f963a3bc9d61a
    -    MacData = 4b435f315f55a1b2c3d4e543415653696401b9fbce9c9ebb31070a4a4ac7af54ec9189c1f98948cd24ca0a5029217e4784d3c8692da08a6a512d1c9875d20d8e03664c148fa5d34bbac6d42e499ee5dbf0112000994a714b6d09afa896dbba9b4f436ab3cdb0d11dcd2aad28b7ba35d6fa6be537b6ffb0f9bf5fe1d594b8f8b8829687c9395c3d938c873f26c7100888c3aca2d59a4214a1a0a1d11679ae22f98d7ae483c1a74008a9cd7f7cf71b1f373a4226f5c58eb621ec56e2537797c01750dcbff07f613b9c58774f9af32aebeadd2226140dc7d56b1aa95c93ab1ec4412e2d0e42cdaac7bf9da3ddbf19fbb1edd0556d9c5a339808905fe8defd8b57ff8f34788192cc0cf7df17d1f351d69ac979a3a495931c287fb8
    -    DKM = 0744e1774149a8b8f88d3a1e20ac1517efd2f54ba4b5f178de99f33b68eea426
    -    Result = P (14 - DKM value should have leading 0 nibble )
    -    */
    +     * COUNT = 1
    +     * dsCAVS = 00000179557decd75b797bea9db656ce99c03a6e0ab13804b5b589644f7db41ceba05c3940c300361061074ca72a828428d9198267fa0b75e1e3e785a0ff20e839414be0
    +     * QsCAVSx = 000001ce7da31681d5f176f3618f205969b9142520363dd26a596866c89988c932e3ce01904d12d1e9b105462e56163dbe7658ba3c472bf1f3c8165813295393ae346764
    +     * QsCAVSy = 000000e70d6e55b76ebd362ff071ab819315593cec650276209a9fdc2c1c48e03c35945f04e74d958cabd3f5e4d1f096a991e807a8f9d217de306a6b561038ca15aea4b9
    +     * NonceEphemCAVS = 4214a1a0a1d11679ae22f98d7ae483c1a74008a9cd7f7cf71b1f373a4226f5c58eb621ec56e2537797c01750dcbff07f613b9c58774f9af32aebeadd2226140dc7d56b1aa95c93ab1ec4412e2d0e42cdaac7bf9da3ddbf19fbb1edd0556d9c5a339808905fe8defd8b57ff8f34788192cc0cf7df17d1f351d69ac979a3a495931c287fb8
    +     * dsIUT = 000000c14895dfcc5a6b24994828cfd0a0cc0a881a70173a3eb05c57b098046c8e60a868f6176284aa346eff1fd1b8b879052c5a6d5fd0ae146b35ed7ecee32e294103cd
    +     * QsIUTx = 00000174a658695049db59f6bbe2ad23e1753bf58384a56fc9b3dec13eb873b33e1f4dbd24b6b4ca05a9a11ad531f6d99e9430a774980e8a8d9fd2d1e2a0d76fe3dd36c7
    +     * QsIUTy = 00000030639849e1df341973db44e7bbba5bb597884a439f9ce54620c3ca73a9804cc26fcda3aaf73ae5a11d5b325cae0e95cfafe1985c6c2fdb892722e7dd2c5d744cf3
    +     * deIUT = 00000138f54e986c7b44f49da389fa9f61bb7265f0cebdeddf09d47c72e55186e2520965fc2c31bb9c0a557e3c28e02a751f097e413c4252c7b0d22452d89f9ac314bc6e
    +     * QeIUTx = 000001b9fbce9c9ebb31070a4a4ac7af54ec9189c1f98948cd24ca0a5029217e4784d3c8692da08a6a512d1c9875d20d8e03664c148fa5d34bbac6d42e499ee5dbf01120
    +     * QeIUTy = 000000994a714b6d09afa896dbba9b4f436ab3cdb0d11dcd2aad28b7ba35d6fa6be537b6ffb0f9bf5fe1d594b8f8b8829687c9395c3d938c873f26c7100888c3aca2d59a
    +     * OI = a1b2c3d4e54341565369646dbb63a273c81e0aad02f92699bf7baa28fd4509145b0096746894e98e209a85ecb415b8
    +     * CAVSTag = 4ade5dc983cc1cf61c90fdbf726fa6a88e9bf411bbaf0015db06ff4348560e4d
    +     * Z = 019a19a0a99f60221ee23323b3317292e8c10d57ba04e0b33f6241979ec3895945eed0bdcbc59ab576e7047061f0d63d1aaf78b1d442028605aa1c0f963a3bc9d61a
    +     * MacData = 4b435f315f55a1b2c3d4e543415653696401b9fbce9c9ebb31070a4a4ac7af54ec9189c1f98948cd24ca0a5029217e4784d3c8692da08a6a512d1c9875d20d8e03664c148fa5d34bbac6d42e499ee5dbf0112000994a714b6d09afa896dbba9b4f436ab3cdb0d11dcd2aad28b7ba35d6fa6be537b6ffb0f9bf5fe1d594b8f8b8829687c9395c3d938c873f26c7100888c3aca2d59a4214a1a0a1d11679ae22f98d7ae483c1a74008a9cd7f7cf71b1f373a4226f5c58eb621ec56e2537797c01750dcbff07f613b9c58774f9af32aebeadd2226140dc7d56b1aa95c93ab1ec4412e2d0e42cdaac7bf9da3ddbf19fbb1edd0556d9c5a339808905fe8defd8b57ff8f34788192cc0cf7df17d1f351d69ac979a3a495931c287fb8
    +     * DKM = 0744e1774149a8b8f88d3a1e20ac1517efd2f54ba4b5f178de99f33b68eea426
    +     * Result = P (14 - DKM value should have leading 0 nibble )
    +     */
         public void testMQVwithHMACOnePass()
             throws Exception
         {
    @@ -956,17 +1046,17 @@ public void testMQVwithHMACOnePass()
             KeyFactory keyFact = KeyFactory.getInstance("EC", "BC");
     
             ECPrivateKey dsCAVS = (ECPrivateKey)keyFact.generatePrivate(new ECPrivateKeySpec(new BigInteger("00000179557decd75b797bea9db656ce99c03a6e0ab13804b5b589644f7db41ceba05c3940c300361061074ca72a828428d9198267fa0b75e1e3e785a0ff20e839414be0", 16), ecSpec));
    -        ECPublicKey  qsCAVS = (ECPublicKey)keyFact.generatePublic(new ECPublicKeySpec(new ECPoint(
    -                            new BigInteger("000001ce7da31681d5f176f3618f205969b9142520363dd26a596866c89988c932e3ce01904d12d1e9b105462e56163dbe7658ba3c472bf1f3c8165813295393ae346764", 16),
    -                            new BigInteger("000000e70d6e55b76ebd362ff071ab819315593cec650276209a9fdc2c1c48e03c35945f04e74d958cabd3f5e4d1f096a991e807a8f9d217de306a6b561038ca15aea4b9", 16)), ecSpec));
    +        ECPublicKey qsCAVS = (ECPublicKey)keyFact.generatePublic(new ECPublicKeySpec(new ECPoint(
    +            new BigInteger("000001ce7da31681d5f176f3618f205969b9142520363dd26a596866c89988c932e3ce01904d12d1e9b105462e56163dbe7658ba3c472bf1f3c8165813295393ae346764", 16),
    +            new BigInteger("000000e70d6e55b76ebd362ff071ab819315593cec650276209a9fdc2c1c48e03c35945f04e74d958cabd3f5e4d1f096a991e807a8f9d217de306a6b561038ca15aea4b9", 16)), ecSpec));
     
             ECPrivateKey dsIUT = (ECPrivateKey)keyFact.generatePrivate(new ECPrivateKeySpec(new BigInteger("000000c14895dfcc5a6b24994828cfd0a0cc0a881a70173a3eb05c57b098046c8e60a868f6176284aa346eff1fd1b8b879052c5a6d5fd0ae146b35ed7ecee32e294103cd", 16), ecSpec));
    -        ECPublicKey  qsIUT = (ECPublicKey)keyFact.generatePublic(new ECPublicKeySpec(new ECPoint(
    -                            new BigInteger("00000174a658695049db59f6bbe2ad23e1753bf58384a56fc9b3dec13eb873b33e1f4dbd24b6b4ca05a9a11ad531f6d99e9430a774980e8a8d9fd2d1e2a0d76fe3dd36c7", 16),
    -                            new BigInteger("00000030639849e1df341973db44e7bbba5bb597884a439f9ce54620c3ca73a9804cc26fcda3aaf73ae5a11d5b325cae0e95cfafe1985c6c2fdb892722e7dd2c5d744cf3", 16)), ecSpec));
    +        ECPublicKey qsIUT = (ECPublicKey)keyFact.generatePublic(new ECPublicKeySpec(new ECPoint(
    +            new BigInteger("00000174a658695049db59f6bbe2ad23e1753bf58384a56fc9b3dec13eb873b33e1f4dbd24b6b4ca05a9a11ad531f6d99e9430a774980e8a8d9fd2d1e2a0d76fe3dd36c7", 16),
    +            new BigInteger("00000030639849e1df341973db44e7bbba5bb597884a439f9ce54620c3ca73a9804cc26fcda3aaf73ae5a11d5b325cae0e95cfafe1985c6c2fdb892722e7dd2c5d744cf3", 16)), ecSpec));
     
             ECPrivateKey deIUT = (ECPrivateKey)keyFact.generatePrivate(new ECPrivateKeySpec(new BigInteger("00000138f54e986c7b44f49da389fa9f61bb7265f0cebdeddf09d47c72e55186e2520965fc2c31bb9c0a557e3c28e02a751f097e413c4252c7b0d22452d89f9ac314bc6e", 16), ecSpec));
    -        ECPublicKey  qeIUT = (ECPublicKey)keyFact.generatePublic(new ECPublicKeySpec(new ECPoint(
    +        ECPublicKey qeIUT = (ECPublicKey)keyFact.generatePublic(new ECPublicKeySpec(new ECPoint(
                 new BigInteger("000001b9fbce9c9ebb31070a4a4ac7af54ec9189c1f98948cd24ca0a5029217e4784d3c8692da08a6a512d1c9875d20d8e03664c148fa5d34bbac6d42e499ee5dbf01120", 16),
                 new BigInteger("000000994a714b6d09afa896dbba9b4f436ab3cdb0d11dcd2aad28b7ba35d6fa6be537b6ffb0f9bf5fe1d594b8f8b8829687c9395c3d938c873f26c7100888c3aca2d59a", 16)), ecSpec));
     
    @@ -999,14 +1089,14 @@ public void testMQVwithHMACOnePass()
         }
     
         protected BigInteger[] derDecode(
    -        byte[]  encoding)
    +        byte[] encoding)
             throws IOException
         {
    -        ByteArrayInputStream    bIn = new ByteArrayInputStream(encoding);
    -        ASN1InputStream         aIn = new ASN1InputStream(bIn);
    -        ASN1Sequence            s = (ASN1Sequence)aIn.readObject();
    +        ByteArrayInputStream bIn = new ByteArrayInputStream(encoding);
    +        ASN1InputStream aIn = new ASN1InputStream(bIn);
    +        ASN1Sequence s = (ASN1Sequence)aIn.readObject();
     
    -        BigInteger[]            sig = new BigInteger[2];
    +        BigInteger[] sig = new BigInteger[2];
     
             sig[0] = ((ASN1Integer)s.getObjectAt(0)).getValue();
             sig[1] = ((ASN1Integer)s.getObjectAt(1)).getValue();
    @@ -1022,22 +1112,23 @@ public String getName()
         public void performTest()
             throws Exception
         {
    -        testKeyConversion();
    -        testAdaptiveKeyConversion();
    -        decodeTest();
    -        testECDSA239bitPrime();
    -        testECDSA239bitBinary();
    -        testGeneration();
    -        testKeyPairGenerationWithOIDs();
    -        testNamedCurveParameterPreservation();
    -        testNamedCurveSigning();
    -        testBSI();
    -        testMQVwithHMACOnePass();
    -        testAlgorithmParameters();
    +//        testKeyConversion();
    +//        testAdaptiveKeyConversion();
    +//        decodeTest();
    +//        testECDSA239bitPrime();
    +//        testECDSA239bitBinary();
    +//        testGeneration();
    +//        testKeyPairGenerationWithOIDs();
    +//        testNamedCurveParameterPreservation();
    +//        testNamedCurveSigning();
    +//        testBSI();
    +//        testMQVwithHMACOnePass();
    +//        testAlgorithmParameters();
    +        testModified();
         }
     
         public static void main(
    -        String[]    args)
    +        String[] args)
         {
             Security.addProvider(new BouncyCastleProvider());
     
    

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

11

News mentions

0

No linked articles in our index yet.