Program: 52532
Project: 52532
Buggy source:
private void tbsV3CertGen() throws IOException {
  V3TBSCertificateGenerator gen=new V3TBSCertificateGenerator();
  Date startDate=new Date(1000);
  Date endDate=new Date(2000);
  gen.setSerialNumber(new ASN1Integer(2));
  gen.setStartDate(new Time(startDate));
  gen.setEndDate(new Time(endDate));
  gen.setIssuer(new X500Name("String_Node_Str"));
  gen.setSubject(new X500Name("String_Node_Str"));
  gen.setSignature(new AlgorithmIdentifier(PKCSObjectIdentifiers.md5WithRSAEncryption,DERNull.INSTANCE));
  SubjectPublicKeyInfo info=new SubjectPublicKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm,new ElGamalParameter(BigInteger.valueOf(1),BigInteger.valueOf(2))),new ASN1Integer(3));
  gen.setSubjectPublicKeyInfo(info);
  Vector order=new Vector();
  Hashtable extensions=new Hashtable();
  order.addElement(X509Extension.authorityKeyIdentifier);
  order.addElement(X509Extension.subjectKeyIdentifier);
  order.addElement(X509Extension.keyUsage);
  extensions.put(X509Extension.authorityKeyIdentifier,new X509Extension(true,new DEROctetString(createAuthorityKeyId(info,new X500Name("String_Node_Str"),2))));
  extensions.put(X509Extension.subjectKeyIdentifier,new X509Extension(true,new DEROctetString(new SubjectKeyIdentifier(new byte[20]))));
  extensions.put(X509Extension.keyUsage,new X509Extension(false,new DEROctetString(new KeyUsage(KeyUsage.dataEncipherment))));
  X509Extensions ex=new X509Extensions(order,extensions);
  gen.setExtensions(ex);
  TBSCertificate tbs=gen.generateTBSCertificate();
  ByteArrayOutputStream bOut=new ByteArrayOutputStream();
  ASN1OutputStream aOut=new ASN1OutputStream(bOut);
  aOut.writeObject(tbs);
  if (!Arrays.areEqual(bOut.toByteArray(),v3Cert)) {
    fail("String_Node_Str");
  }
  ASN1InputStream aIn=new ASN1InputStream(new ByteArrayInputStream(v3Cert));
  ASN1Primitive o=aIn.readObject();
  bOut=new ByteArrayOutputStream();
  aOut=new ASN1OutputStream(bOut);
  aOut.writeObject(o);
  if (!Arrays.areEqual(bOut.toByteArray(),v3Cert)) {
    fail("String_Node_Str");
  }
}

Fixed version (ground truth):
private void tbsV3CertGen() throws IOException {
  V3TBSCertificateGenerator gen=new V3TBSCertificateGenerator();
  Date startDate=new Date(1000);
  Date endDate=new Date(2000);
  gen.setSerialNumber(new ASN1Integer(2));
  gen.setStartDate(new Time(startDate));
  gen.setEndDate(new Time(endDate));
  gen.setIssuer(new X500Name("String_Node_Str"));
  gen.setSubject(new X500Name("String_Node_Str"));
  gen.setSignature(new AlgorithmIdentifier(PKCSObjectIdentifiers.md5WithRSAEncryption,DERNull.INSTANCE));
  SubjectPublicKeyInfo info=new SubjectPublicKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm,new ElGamalParameter(BigInteger.valueOf(1),BigInteger.valueOf(2))),new ASN1Integer(3));
  gen.setSubjectPublicKeyInfo(info);
  Vector order=new Vector();
  Hashtable extensions=new Hashtable();
  order.addElement(X509Extension.authorityKeyIdentifier);
  order.addElement(X509Extension.subjectKeyIdentifier);
  order.addElement(X509Extension.keyUsage);
  extensions.put(X509Extension.authorityKeyIdentifier,new X509Extension(true,new DEROctetString(createAuthorityKeyId(info,new X500Name("String_Node_Str"),2))));
  extensions.put(X509Extension.subjectKeyIdentifier,new X509Extension(true,new DEROctetString(new SubjectKeyIdentifier(getDigest(info)))));
  extensions.put(X509Extension.keyUsage,new X509Extension(false,new DEROctetString(new KeyUsage(KeyUsage.dataEncipherment))));
  X509Extensions ex=new X509Extensions(order,extensions);
  gen.setExtensions(ex);
  TBSCertificate tbs=gen.generateTBSCertificate();
  ByteArrayOutputStream bOut=new ByteArrayOutputStream();
  ASN1OutputStream aOut=new ASN1OutputStream(bOut);
  aOut.writeObject(tbs);
  if (!Arrays.areEqual(bOut.toByteArray(),v3Cert)) {
    fail("String_Node_Str");
  }
  ASN1InputStream aIn=new ASN1InputStream(new ByteArrayInputStream(v3Cert));
  ASN1Primitive o=aIn.readObject();
  bOut=new ByteArrayOutputStream();
  aOut=new ASN1OutputStream(bOut);
  aOut.writeObject(o);
  if (!Arrays.areEqual(bOut.toByteArray(),v3Cert)) {
    fail("String_Node_Str");
  }
}