nus-yam/ex-repair huggingface dataset:
Program: 52545
Project: 52545
Buggy source:
private void implAddSubtractMultiplyTwiceEncodingTestAllCoords(X9ECParameters x9ECParameters){
  BigInteger n=x9ECParameters.getN();
  ECPoint G=x9ECParameters.getG();
  ECCurve C=x9ECParameters.getCurve();
  int[] coords=ECCurve.getAllCoordinateSystems();
  for (int i=0; i < coords.length; ++i) {
    int coord=coords[i];
    if (C.supportsCoordinateSystem(coord)) {
      ECCurve c=C;
      ECPoint g=G;
      if (c.getCoordinateSystem() != coord) {
        c=C.configure().setCoordinateSystem(coord).create();
        g=c.importPoint(G);
      }
      BigInteger b=new BigInteger(n.bitLength(),secRand);
      ECPoint q=g.multiply(b).normalize();
      implAddSubtractMultiplyTwiceEncodingTest(c,q,n);
    }
  }
}

Fixed version (ground truth):
private void implAddSubtractMultiplyTwiceEncodingTestAllCoords(X9ECParameters x9ECParameters){
  BigInteger n=x9ECParameters.getN();
  ECPoint G=x9ECParameters.getG();
  ECCurve C=x9ECParameters.getCurve();
  int[] coords=ECCurve.getAllCoordinateSystems();
  for (int i=0; i < coords.length; ++i) {
    int coord=coords[i];
    if (C.supportsCoordinateSystem(coord)) {
      ECCurve c=C;
      ECPoint g=G;
      if (c.getCoordinateSystem() != coord) {
        c=C.configure().setCoordinateSystem(coord).create();
        g=c.importPoint(G);
      }
      BigInteger b=new BigInteger(n.bitLength(),secRand);
      ECPoint q=g.multiply(b).normalize();
      implAddSubtractMultiplyTwiceEncodingTest(c,q,n);
      implSqrtTest(c);
    }
  }
}
Program: 52546
Project: 52546
Buggy source:
/** 
 * Create an iso7816Certificate structure from a body and its signature.
 * @param body the Iso7816CertificateBody object containing the body.
 * @param signature   the byte array containing the signature
 * @return the Iso7816CertificateStructure
 * @throws IOException if there is a problem parsing the data.
 */
public CVCertificate(CertificateBody body,byte[] signature) throws IOException {
  certificateBody=body;
  this.signature=signature;
  valid|=bodyValid;
  valid|=signValid;
}

Fixed version (ground truth):
/** 
 * Create an iso7816Certificate structure from a body and its signature.
 * @param body the Iso7816CertificateBody object containing the body.
 * @param signature   the byte array containing the signature
 * @throws IOException if there is a problem parsing the data.
 */
public CVCertificate(CertificateBody body,byte[] signature) throws IOException {
  certificateBody=body;
  this.signature=signature;
  valid|=bodyValid;
  valid|=signValid;
}
Program: 52547
Project: 52547
Buggy source:
/** 
 * Create an iso7816Certificate structure from an object.
 * @param obj the Object to extract the certificate from.
 * @return the Iso7816CertificateStructure represented by the byte stream.
 * @throws IOException if there is a problem parsing the data.
 */
public static CVCertificate getInstance(Object obj){
  if (obj instanceof CVCertificate) {
    return (CVCertificate)obj;
  }
 else   if (obj != null) {
    try {
      return new CVCertificate(DERApplicationSpecific.getInstance(obj));
    }
 catch (    IOException e) {
      throw new ASN1ParsingException("String_Node_Str" + e.getMessage(),e);
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Create an iso7816Certificate structure from an object.
 * @param obj the Object to extract the certificate from.
 * @return the Iso7816CertificateStructure represented by the byte stream.
 */
public static CVCertificate getInstance(Object obj){
  if (obj instanceof CVCertificate) {
    return (CVCertificate)obj;
  }
 else   if (obj != null) {
    try {
      return new CVCertificate(DERApplicationSpecific.getInstance(obj));
    }
 catch (    IOException e) {
      throw new ASN1ParsingException("String_Node_Str" + e.getMessage(),e);
    }
  }
  return null;
}
Program: 52548
Project: 52548
Buggy source:
/** 
 * create a "request" or "profile" type Iso7816CertificateBody according to the variables sets.
 * @return return the ASN1Primitive representing the "request" or "profile" type certificate body.
 * @throws IOException if the DERApplicationSpecific cannot be created or if data are missings to create a valid certificate.
 */
public ASN1Primitive toASN1Primitive(){
  try {
    if (certificateType == profileType) {
      return profileToASN1Object();
    }
    if (certificateType == requestType) {
      return requestToASN1Object();
    }
  }
 catch (  IOException e) {
    return null;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * create a "request" or "profile" type Iso7816CertificateBody according to the variables sets.
 * @return return the ASN1Primitive representing the "request" or "profile" type certificate body.
 */
public ASN1Primitive toASN1Primitive(){
  try {
    if (certificateType == profileType) {
      return profileToASN1Object();
    }
    if (certificateType == requestType) {
      return requestToASN1Object();
    }
  }
 catch (  IOException e) {
    return null;
  }
  return null;
}
Program: 52549
Project: 52549
Buggy source:
/** 
 * Produce an object suitable for an ASN1OutputStream. <p/> Returns: <p/> <pre> CertHash ::= SEQUENCE { hashAlgorithm AlgorithmIdentifier, certificateHash OCTET STRING } </pre>
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive(){
  ASN1EncodableVector vec=new ASN1EncodableVector();
  vec.add(hashAlgorithm);
  vec.add(new DEROctetString(certificateHash));
  return new DERSequence(vec);
}

Fixed version (ground truth):
/** 
 * Produce an object suitable for an ASN1OutputStream. <p> Returns: <pre> CertHash ::= SEQUENCE { hashAlgorithm AlgorithmIdentifier, certificateHash OCTET STRING } </pre>
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive(){
  ASN1EncodableVector vec=new ASN1EncodableVector();
  vec.add(hashAlgorithm);
  vec.add(new DEROctetString(certificateHash));
  return new DERSequence(vec);
}
Program: 52550
Project: 52550
Buggy source:
/** 
 * Produce an object suitable for an ASN1OutputStream. <p/> Returns: <p/> <pre> RequestedCertificate ::= CHOICE { Certificate Certificate, publicKeyCertificate [0] EXPLICIT OCTET STRING, attributeCertificate [1] EXPLICIT OCTET STRING } </pre>
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive(){
  if (publicKeyCert != null) {
    return new DERTaggedObject(0,new DEROctetString(publicKeyCert));
  }
  if (attributeCert != null) {
    return new DERTaggedObject(1,new DEROctetString(attributeCert));
  }
  return cert.toASN1Primitive();
}

Fixed version (ground truth):
/** 
 * Produce an object suitable for an ASN1OutputStream. <p> Returns: <pre> RequestedCertificate ::= CHOICE { Certificate Certificate, publicKeyCertificate [0] EXPLICIT OCTET STRING, attributeCertificate [1] EXPLICIT OCTET STRING } </pre>
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive(){
  if (publicKeyCert != null) {
    return new DERTaggedObject(0,new DEROctetString(publicKeyCert));
  }
  if (attributeCert != null) {
    return new DERTaggedObject(1,new DEROctetString(attributeCert));
  }
  return cert.toASN1Primitive();
}
Program: 52551
Project: 52551
Buggy source:
/** 
 * Produce an object suitable for an ASN1OutputStream. <p/> Returns: <p/> <pre> AdditionalInformationSyntax ::= DirectoryString (SIZE(1..2048)) </pre>
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive(){
  return information.toASN1Primitive();
}

Fixed version (ground truth):
/** 
 * Produce an object suitable for an ASN1OutputStream. <p> Returns: <pre> AdditionalInformationSyntax ::= DirectoryString (SIZE(1..2048)) </pre>
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive(){
  return information.toASN1Primitive();
}
Program: 52552
Project: 52552
Buggy source:
/** 
 * Produce an object suitable for an ASN1OutputStream. <p/> Returns: <p/> <pre> AdmissionSyntax ::= SEQUENCE { admissionAuthority GeneralName OPTIONAL, contentsOfAdmissions SEQUENCE OF Admissions } <p/> Admissions ::= SEQUENCE { admissionAuthority [0] EXPLICIT GeneralName OPTIONAL namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL professionInfos SEQUENCE OF ProfessionInfo } <p/> NamingAuthority ::= SEQUENCE { namingAuthorityId OBJECT IDENTIFIER OPTIONAL, namingAuthorityUrl IA5String OPTIONAL, namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL } <p/> ProfessionInfo ::= SEQUENCE { namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, addProfessionInfo OCTET STRING OPTIONAL } </pre>
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive(){
  ASN1EncodableVector vec=new ASN1EncodableVector();
  if (admissionAuthority != null) {
    vec.add(admissionAuthority);
  }
  vec.add(contentsOfAdmissions);
  return new DERSequence(vec);
}

Fixed version (ground truth):
/** 
 * Produce an object suitable for an ASN1OutputStream. <p> Returns: <pre> AdmissionSyntax ::= SEQUENCE { admissionAuthority GeneralName OPTIONAL, contentsOfAdmissions SEQUENCE OF Admissions } Admissions ::= SEQUENCE { admissionAuthority [0] EXPLICIT GeneralName OPTIONAL namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL professionInfos SEQUENCE OF ProfessionInfo } NamingAuthority ::= SEQUENCE { namingAuthorityId OBJECT IDENTIFIER OPTIONAL, namingAuthorityUrl IA5String OPTIONAL, namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL } ProfessionInfo ::= SEQUENCE { namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, addProfessionInfo OCTET STRING OPTIONAL } </pre>
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive(){
  ASN1EncodableVector vec=new ASN1EncodableVector();
  if (admissionAuthority != null) {
    vec.add(admissionAuthority);
  }
  vec.add(contentsOfAdmissions);
  return new DERSequence(vec);
}
Program: 52553
Project: 52553
Buggy source:
/** 
 * Produce an object suitable for an ASN1OutputStream. <p/> Returns: <p/> <pre> Admissions ::= SEQUENCE { admissionAuthority [0] EXPLICIT GeneralName OPTIONAL namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL professionInfos SEQUENCE OF ProfessionInfo } <p/> </pre>
 * @return an ASN1Primitive
 */
public ASN1Primitive toASN1Primitive(){
  ASN1EncodableVector vec=new ASN1EncodableVector();
  if (admissionAuthority != null) {
    vec.add(new DERTaggedObject(true,0,admissionAuthority));
  }
  if (namingAuthority != null) {
    vec.add(new DERTaggedObject(true,1,namingAuthority));
  }
  vec.add(professionInfos);
  return new DERSequence(vec);
}

Fixed version (ground truth):
/** 
 * Produce an object suitable for an ASN1OutputStream. <p> Returns: <pre> Admissions ::= SEQUENCE { admissionAuthority [0] EXPLICIT GeneralName OPTIONAL namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL professionInfos SEQUENCE OF ProfessionInfo } </pre>
 * @return an ASN1Primitive
 */
public ASN1Primitive toASN1Primitive(){
  ASN1EncodableVector vec=new ASN1EncodableVector();
  if (admissionAuthority != null) {
    vec.add(new DERTaggedObject(true,0,admissionAuthority));
  }
  if (namingAuthority != null) {
    vec.add(new DERTaggedObject(true,1,namingAuthority));
  }
  vec.add(professionInfos);
  return new DERSequence(vec);
}
Program: 52554
Project: 52554
Buggy source:
/** 
 * Constructor from a given details. <p/> Parameter <code>professionInfos</code> is mandatory.
 * @param admissionAuthority The admission authority.
 * @param namingAuthority    The naming authority.
 * @param professionInfos    The profession infos.
 */
public Admissions(GeneralName admissionAuthority,NamingAuthority namingAuthority,ProfessionInfo[] professionInfos){
  this.admissionAuthority=admissionAuthority;
  this.namingAuthority=namingAuthority;
  this.professionInfos=new DERSequence(professionInfos);
}

Fixed version (ground truth):
/** 
 * Constructor from a given details. <p> Parameter <code>professionInfos</code> is mandatory.
 * @param admissionAuthority The admission authority.
 * @param namingAuthority    The naming authority.
 * @param professionInfos    The profession infos.
 */
public Admissions(GeneralName admissionAuthority,NamingAuthority namingAuthority,ProfessionInfo[] professionInfos){
  this.admissionAuthority=admissionAuthority;
  this.namingAuthority=namingAuthority;
  this.professionInfos=new DERSequence(professionInfos);
}
Program: 52555
Project: 52555
Buggy source:
/** 
 * Produce an object suitable for an ASN1OutputStream. <p/> Returns: <p/> <pre> DeclarationOfMajoritySyntax ::= CHOICE { notYoungerThan [0] IMPLICIT INTEGER, fullAgeAtCountry [1] IMPLICIT SEQUENCE { fullAge BOOLEAN DEFAULT TRUE, country PrintableString (SIZE(2)) } dateOfBirth [2] IMPLICIT GeneralizedTime } </pre>
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive(){
  return declaration;
}

Fixed version (ground truth):
/** 
 * Produce an object suitable for an ASN1OutputStream. <p> Returns: <pre> DeclarationOfMajoritySyntax ::= CHOICE { notYoungerThan [0] IMPLICIT INTEGER, fullAgeAtCountry [1] IMPLICIT SEQUENCE { fullAge BOOLEAN DEFAULT TRUE, country PrintableString (SIZE(2)) } dateOfBirth [2] IMPLICIT GeneralizedTime } </pre>
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive(){
  return declaration;
}
Program: 52556
Project: 52556
Buggy source:
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _origDsaKP=CMSTestUtil.makeDsaKeyPair();
    _origDsaCert=CMSTestUtil.makeCertificate(_origDsaKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _signCrl=CMSTestUtil.makeCrl(_signKP);
    _origCrl=CMSTestUtil.makeCrl(_origKP);
  }
}

Fixed version (ground truth):
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _origDsaKP=CMSTestUtil.makeDsaKeyPair();
    _origDsaCert=CMSTestUtil.makeCertificate(_origDsaKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _signCrl=CMSTestUtil.makeCrl(_signKP);
    _origCrl=CMSTestUtil.makeCrl(_origKP);
  }
}
Program: 52557
Project: 52557
Buggy source:
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
  }
}

Fixed version (ground truth):
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
  }
}
Program: 52558
Project: 52558
Buggy source:
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
  }
}

Fixed version (ground truth):
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
  }
}
Program: 52559
Project: 52559
Buggy source:
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciDN2="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _reciCertOaep=CMSTestUtil.makeOaepCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
    _reciEcKP2=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert2=CMSTestUtil.makeCertificate(_reciEcKP2,_reciDN2,_signKP,_signDN);
  }
}

Fixed version (ground truth):
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciDN2="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _reciCertOaep=CMSTestUtil.makeOaepCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
    _reciEcKP2=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert2=CMSTestUtil.makeCertificate(_reciEcKP2,_reciDN2,_signKP,_signDN);
  }
}
Program: 52562
Project: 52562
Buggy source:
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _origDsaKP=CMSTestUtil.makeDsaKeyPair();
    _origDsaCert=CMSTestUtil.makeCertificate(_origDsaKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _signCrl=CMSTestUtil.makeCrl(_signKP);
    _origCrl=CMSTestUtil.makeCrl(_origKP);
  }
}

Fixed version (ground truth):
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _origDsaKP=CMSTestUtil.makeDsaKeyPair();
    _origDsaCert=CMSTestUtil.makeCertificate(_origDsaKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _signCrl=CMSTestUtil.makeCrl(_signKP);
    _origCrl=CMSTestUtil.makeCrl(_origKP);
  }
}
Program: 52563
Project: 52563
Buggy source:
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
  }
}

Fixed version (ground truth):
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
  }
}
Program: 52564
Project: 52564
Buggy source:
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
  }
}

Fixed version (ground truth):
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
  }
}
Program: 52565
Project: 52565
Buggy source:
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciDN2="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _reciCertOaep=CMSTestUtil.makeOaepCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
    _reciEcKP2=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert2=CMSTestUtil.makeCertificate(_reciEcKP2,_reciDN2,_signKP,_signDN);
  }
}

Fixed version (ground truth):
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _signCert=CMSTestUtil.makeCertificate(_signKP,_signDN,_signKP,_signDN);
    _origDN="String_Node_Str";
    _origKP=CMSTestUtil.makeKeyPair();
    _origCert=CMSTestUtil.makeCertificate(_origKP,_origDN,_signKP,_signDN);
    _reciDN="String_Node_Str";
    _reciDN2="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _reciCertOaep=CMSTestUtil.makeOaepCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _origEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcKP=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert=CMSTestUtil.makeCertificate(_reciEcKP,_reciDN,_signKP,_signDN);
    _reciEcKP2=CMSTestUtil.makeEcDsaKeyPair();
    _reciEcCert2=CMSTestUtil.makeCertificate(_reciEcKP2,_reciDN2,_signKP,_signDN);
  }
}
Program: 52566
Project: 52566
Buggy source:
public ECPoint createPoint(BigInteger x,BigInteger y,boolean withCompression){
  ECFieldElement X=fromBigInteger(x), Y=fromBigInteger(y);
switch (this.getCoordinateSystem()) {
case COORD_LAMBDA_AFFINE:
case COORD_LAMBDA_PROJECTIVE:
{
      if (!X.isZero()) {
        Y=Y.divide(X).add(X);
      }
      break;
    }
default :
{
    break;
  }
}
return createRawPoint(X,Y,withCompression);
}

Fixed version (ground truth):
public ECPoint createPoint(BigInteger x,BigInteger y,boolean withCompression){
  ECFieldElement X=fromBigInteger(x), Y=fromBigInteger(y);
switch (this.getCoordinateSystem()) {
case COORD_LAMBDA_AFFINE:
case COORD_LAMBDA_PROJECTIVE:
{
      if (X.isZero()) {
        if (!Y.square().equals(getB())) {
          throw new IllegalArgumentException();
        }
      }
 else {
        Y=Y.divide(X).add(X);
      }
      break;
    }
default :
{
    break;
  }
}
return createRawPoint(X,Y,withCompression);
}
Program: 52567
Project: 52567
Buggy source:
/** 
 * Decompresses a compressed point P = (xp, yp) (X9.62 s 4.2.2).
 * @param yTilde ~yp, an indication bit for the decompression of yp.
 * @param X1 The field element xp.
 * @return the decompressed point.
 */
protected ECPoint decompressPoint(int yTilde,BigInteger X1){
  ECFieldElement xp=fromBigInteger(X1);
  ECFieldElement yp=null;
  if (xp.isZero()) {
    yp=(ECFieldElement.F2m)b;
    for (int i=0; i < m - 1; i++) {
      yp=yp.square();
    }
  }
 else {
    ECFieldElement beta=xp.add(a).add(b.multiply(xp.square().invert()));
    ECFieldElement z=solveQuadraticEquation(beta);
    if (z == null) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    if (z.testBitZero() != (yTilde == 1)) {
      z=z.addOne();
    }
    yp=xp.multiply(z);
switch (this.getCoordinateSystem()) {
case COORD_LAMBDA_AFFINE:
case COORD_LAMBDA_PROJECTIVE:
{
        yp=yp.divide(xp).add(xp);
        break;
      }
default :
{
      break;
    }
}
}
return new ECPoint.F2m(this,xp,yp,true);
}

Fixed version (ground truth):
/** 
 * Decompresses a compressed point P = (xp, yp) (X9.62 s 4.2.2).
 * @param yTilde ~yp, an indication bit for the decompression of yp.
 * @param X1 The field element xp.
 * @return the decompressed point.
 */
protected ECPoint decompressPoint(int yTilde,BigInteger X1){
  ECFieldElement xp=fromBigInteger(X1);
  ECFieldElement yp;
  if (xp.isZero()) {
    yp=b.sqrt();
  }
 else {
    ECFieldElement beta=xp.add(a).add(b.multiply(xp.square().invert()));
    ECFieldElement z=solveQuadraticEquation(beta);
    if (z == null) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    if (z.testBitZero() != (yTilde == 1)) {
      z=z.addOne();
    }
    yp=xp.multiply(z);
switch (this.getCoordinateSystem()) {
case COORD_LAMBDA_AFFINE:
case COORD_LAMBDA_PROJECTIVE:
{
        yp=yp.divide(xp).add(xp);
        break;
      }
default :
{
      break;
    }
}
}
return new ECPoint.F2m(this,xp,yp,true);
}
Program: 52568
Project: 52568
Buggy source:
protected ECFieldElement getRawYCoord(){
  return y;
}

Fixed version (ground truth):
protected final ECFieldElement getRawYCoord(){
  return y;
}
Program: 52569
Project: 52569
Buggy source:
public ECPoint threeTimes(){
  if (this.isInfinity() || this.y.isZero()) {
    return this;
  }
  ECCurve curve=this.getCurve();
  int coord=curve.getCoordinateSystem();
switch (coord) {
case ECCurve.COORD_AFFINE:
{
      ECFieldElement X1=this.x, Y1=this.y;
      ECFieldElement _2Y1=two(Y1);
      ECFieldElement X=_2Y1.square();
      ECFieldElement Z=three(X1.square()).add(this.getCurve().getA());
      ECFieldElement Y=Z.square();
      ECFieldElement d=three(X1).multiply(X).subtract(Y);
      if (d.isZero()) {
        return this.getCurve().getInfinity();
      }
      ECFieldElement D=d.multiply(_2Y1);
      ECFieldElement I=D.invert();
      ECFieldElement L1=d.multiply(I).multiply(Z);
      ECFieldElement L2=X.square().multiply(I).subtract(L1);
      ECFieldElement X4=(L2.subtract(L1)).multiply(L1.add(L2)).add(X1);
      ECFieldElement Y4=(X1.subtract(X4)).multiply(L2).subtract(Y1);
      return new ECPoint.Fp(curve,X4,Y4,this.withCompression);
    }
case ECCurve.COORD_JACOBIAN_MODIFIED:
{
    return twiceJacobianModified(false).add(this);
  }
default :
{
  return twice().add(this);
}
}
}

Fixed version (ground truth):
public ECPoint threeTimes(){
  if (this.isInfinity()) {
    return this;
  }
  ECFieldElement Y1=this.y;
  if (Y1.isZero()) {
    return this;
  }
  ECCurve curve=this.getCurve();
  int coord=curve.getCoordinateSystem();
switch (coord) {
case ECCurve.COORD_AFFINE:
{
      ECFieldElement X1=this.x;
      ECFieldElement _2Y1=two(Y1);
      ECFieldElement X=_2Y1.square();
      ECFieldElement Z=three(X1.square()).add(this.getCurve().getA());
      ECFieldElement Y=Z.square();
      ECFieldElement d=three(X1).multiply(X).subtract(Y);
      if (d.isZero()) {
        return this.getCurve().getInfinity();
      }
      ECFieldElement D=d.multiply(_2Y1);
      ECFieldElement I=D.invert();
      ECFieldElement L1=d.multiply(I).multiply(Z);
      ECFieldElement L2=X.square().multiply(I).subtract(L1);
      ECFieldElement X4=(L2.subtract(L1)).multiply(L1.add(L2)).add(X1);
      ECFieldElement Y4=(X1.subtract(X4)).multiply(L2).subtract(Y1);
      return new ECPoint.Fp(curve,X4,Y4,this.withCompression);
    }
case ECCurve.COORD_JACOBIAN_MODIFIED:
{
    return twiceJacobianModified(false).add(this);
  }
default :
{
  return twice().add(this);
}
}
}
Program: 52570
Project: 52570
Buggy source:
protected ECFieldElement getRawXCoord(){
  return x;
}

Fixed version (ground truth):
protected final ECFieldElement getRawXCoord(){
  return x;
}
Program: 52571
Project: 52571
Buggy source:
public ECPoint twicePlus(ECPoint b){
  if (this.isInfinity()) {
    return b;
  }
  if (b.isInfinity()) {
    return twice();
  }
  ECCurve curve=this.getCurve();
  ECFieldElement X1=this.x;
  if (X1.isZero()) {
    return b;
  }
  int coord=curve.getCoordinateSystem();
switch (coord) {
case ECCurve.COORD_LAMBDA_PROJECTIVE:
{
      ECFieldElement X2=b.x, Z2=b.zs[0];
      if (X2.isZero() || !Z2.isOne()) {
        return twice().add(b);
      }
      ECFieldElement L1=this.y, Z1=this.zs[0];
      ECFieldElement L2=b.y;
      ECFieldElement X1Sq=X1.square();
      ECFieldElement L1Sq=L1.square();
      ECFieldElement Z1Sq=Z1.square();
      ECFieldElement L1Z1=L1.multiply(Z1);
      ECFieldElement T=curve.getA().multiply(Z1Sq).add(L1Sq).add(L1Z1);
      ECFieldElement L2plus1=L2.addOne();
      ECFieldElement A=curve.getA().add(L2plus1).multiply(Z1Sq).add(L1Sq).multiply(T).add(X1Sq.multiply(Z1Sq));
      ECFieldElement X2Z1Sq=X2.multiply(Z1Sq);
      ECFieldElement B=X2Z1Sq.add(T).square();
      ECFieldElement X3=A.square().multiply(X2Z1Sq);
      ECFieldElement Z3=A.multiply(B).multiply(Z1Sq);
      ECFieldElement L3=A.add(B).square().multiply(T).add(L2plus1.multiply(Z3));
      return new ECPoint.F2m(curve,X3,L3,new ECFieldElement[]{Z3},this.withCompression);
    }
default :
{
    return twice().add(b);
  }
}
}

Fixed version (ground truth):
public ECPoint twicePlus(ECPoint b){
  if (this == b) {
    return threeTimes();
  }
  if (this.isInfinity()) {
    return b;
  }
  if (b.isInfinity()) {
    return twice();
  }
  ECFieldElement Y1=this.y;
  if (Y1.isZero()) {
    return b;
  }
  ECCurve curve=this.getCurve();
  int coord=curve.getCoordinateSystem();
switch (coord) {
case ECCurve.COORD_AFFINE:
{
      ECFieldElement X1=this.x;
      ECFieldElement X2=b.x, Y2=b.y;
      ECFieldElement dx=X2.subtract(X1), dy=Y2.subtract(Y1);
      if (dx.isZero()) {
        if (dy.isZero()) {
          return threeTimes();
        }
        return this;
      }
      ECFieldElement X=dx.square(), Y=dy.square();
      ECFieldElement d=X.multiply(two(X1).add(X2)).subtract(Y);
      if (d.isZero()) {
        return curve.getInfinity();
      }
      ECFieldElement D=d.multiply(dx);
      ECFieldElement I=D.invert();
      ECFieldElement L1=d.multiply(I).multiply(dy);
      ECFieldElement L2=two(Y1).multiply(X).multiply(dx).multiply(I).subtract(L1);
      ECFieldElement X4=(L2.subtract(L1)).multiply(L1.add(L2)).add(X2);
      ECFieldElement Y4=(X1.subtract(X4)).multiply(L2).subtract(Y1);
      return new ECPoint.Fp(curve,X4,Y4,this.withCompression);
    }
case ECCurve.COORD_JACOBIAN_MODIFIED:
{
    return twiceJacobianModified(false).add(b);
  }
default :
{
  return twice().add(b);
}
}
}
Program: 52574
Project: 52574
Buggy source:
public void testGenerateWithMetadata() throws Exception {
  cmsTimeStampedDataGenerator.setMetaData(true,fileInput,"String_Node_Str");
  BcDigestCalculatorProvider calculatorProvider=new BcDigestCalculatorProvider();
  String algOID="String_Node_Str";
  DigestCalculator hashCalculator=calculatorProvider.get(new AlgorithmIdentifier(algOID));
  cmsTimeStampedDataGenerator.initialiseMessageImprintDigestCalculator(hashCalculator);
  hashCalculator.getOutputStream().write(baseData);
  hashCalculator.getOutputStream().close();
  TimeStampToken timeStampToken=createTimeStampToken(hashCalculator.getDigest(),NISTObjectIdentifiers.id_sha256);
  CMSTimeStampedData cmsTimeStampedData=cmsTimeStampedDataGenerator.generate(timeStampToken,baseData);
  for (int i=0; i < 3; i++) {
    byte[] newRequestData=cmsTimeStampedData.calculateNextHash(hashCalculator);
    TimeStampToken newTimeStampToken=createTimeStampToken(newRequestData,NISTObjectIdentifiers.id_sha256);
    cmsTimeStampedData=cmsTimeStampedData.addTimeStamp(newTimeStampToken);
  }
  byte[] timeStampedData=cmsTimeStampedData.getEncoded();
  metadataCheck(timeStampedData);
  metadataParserCheck(timeStampedData);
}

Fixed version (ground truth):
public void testGenerateWithMetadata() throws Exception {
  cmsTimeStampedDataGenerator.setMetaData(true,fileInput,"String_Node_Str");
  BcDigestCalculatorProvider calculatorProvider=new BcDigestCalculatorProvider();
  String algOID="String_Node_Str";
  DigestCalculator hashCalculator=calculatorProvider.get(new AlgorithmIdentifier(algOID));
  cmsTimeStampedDataGenerator.initialiseMessageImprintDigestCalculator(hashCalculator);
  hashCalculator.getOutputStream().write(baseData);
  hashCalculator.getOutputStream().close();
  TimeStampToken timeStampToken=createTimeStampToken(hashCalculator.getDigest(),NISTObjectIdentifiers.id_sha256);
  CMSTimeStampedData cmsTimeStampedData=cmsTimeStampedDataGenerator.generate(timeStampToken,baseData);
  for (int i=0; i <= 3; i++) {
    byte[] newRequestData=cmsTimeStampedData.calculateNextHash(hashCalculator);
    TimeStampToken newTimeStampToken=createTimeStampToken(newRequestData,NISTObjectIdentifiers.id_sha256);
    cmsTimeStampedData=cmsTimeStampedData.addTimeStamp(newTimeStampToken);
  }
  byte[] timeStampedData=cmsTimeStampedData.getEncoded();
  metadataCheck(timeStampedData);
  metadataParserCheck(timeStampedData);
}
Program: 52575
Project: 52575
Buggy source:
private void metadataCheck(byte[] timeStampedData) throws Exception {
  CMSTimeStampedData cmsTspData=new CMSTimeStampedData(timeStampedData);
  DigestCalculatorProvider newCalculatorProvider=new BcDigestCalculatorProvider();
  DigestCalculator imprintCalculator=cmsTspData.getMessageImprintDigestCalculator(newCalculatorProvider);
  byte[] newContent=cmsTspData.getContent();
  assertEquals("String_Node_Str",true,Arrays.areEqual(newContent,baseData));
  imprintCalculator.getOutputStream().write(newContent);
  assertEquals(fileInput,cmsTspData.getFileName());
  assertEquals("String_Node_Str",cmsTspData.getMediaType());
  byte[] digest=imprintCalculator.getDigest();
  TimeStampToken[] tokens=cmsTspData.getTimeStampTokens();
  assertEquals("String_Node_Str",4,tokens.length);
  for (int i=0; i < tokens.length; i++) {
    cmsTspData.validate(newCalculatorProvider,digest,tokens[i]);
  }
}

Fixed version (ground truth):
private void metadataCheck(byte[] timeStampedData) throws Exception {
  CMSTimeStampedData cmsTspData=new CMSTimeStampedData(timeStampedData);
  DigestCalculatorProvider newCalculatorProvider=new BcDigestCalculatorProvider();
  DigestCalculator imprintCalculator=cmsTspData.getMessageImprintDigestCalculator(newCalculatorProvider);
  byte[] newContent=cmsTspData.getContent();
  assertEquals("String_Node_Str",true,Arrays.areEqual(newContent,baseData));
  imprintCalculator.getOutputStream().write(newContent);
  assertEquals(fileInput,cmsTspData.getFileName());
  assertEquals("String_Node_Str",cmsTspData.getMediaType());
  byte[] digest=imprintCalculator.getDigest();
  TimeStampToken[] tokens=cmsTspData.getTimeStampTokens();
  assertEquals("String_Node_Str",5,tokens.length);
  for (int i=0; i < tokens.length; i++) {
    cmsTspData.validate(newCalculatorProvider,digest,tokens[i]);
  }
}
Program: 52576
Project: 52576
Buggy source:
private void metadataParserCheck(byte[] timeStampedData) throws Exception {
  CMSTimeStampedDataParser cmsTspData=new CMSTimeStampedDataParser(timeStampedData);
  DigestCalculatorProvider newCalculatorProvider=new BcDigestCalculatorProvider();
  InputStream input=cmsTspData.getContent();
  ByteArrayOutputStream bOut=new ByteArrayOutputStream();
  Streams.pipeAll(input,bOut);
  assertEquals("String_Node_Str",true,Arrays.areEqual(bOut.toByteArray(),baseData));
  DigestCalculator imprintCalculator=cmsTspData.getMessageImprintDigestCalculator(newCalculatorProvider);
  Streams.pipeAll(new ByteArrayInputStream(bOut.toByteArray()),imprintCalculator.getOutputStream());
  assertEquals(fileInput,cmsTspData.getFileName());
  assertEquals("String_Node_Str",cmsTspData.getMediaType());
  byte[] digest=imprintCalculator.getDigest();
  TimeStampToken[] tokens=cmsTspData.getTimeStampTokens();
  assertEquals("String_Node_Str",4,tokens.length);
  for (int i=0; i < tokens.length; i++) {
    cmsTspData.validate(newCalculatorProvider,digest,tokens[i]);
  }
}

Fixed version (ground truth):
private void metadataParserCheck(byte[] timeStampedData) throws Exception {
  CMSTimeStampedDataParser cmsTspData=new CMSTimeStampedDataParser(timeStampedData);
  DigestCalculatorProvider newCalculatorProvider=new BcDigestCalculatorProvider();
  InputStream input=cmsTspData.getContent();
  ByteArrayOutputStream bOut=new ByteArrayOutputStream();
  Streams.pipeAll(input,bOut);
  assertEquals("String_Node_Str",true,Arrays.areEqual(bOut.toByteArray(),baseData));
  DigestCalculator imprintCalculator=cmsTspData.getMessageImprintDigestCalculator(newCalculatorProvider);
  Streams.pipeAll(new ByteArrayInputStream(bOut.toByteArray()),imprintCalculator.getOutputStream());
  assertEquals(fileInput,cmsTspData.getFileName());
  assertEquals("String_Node_Str",cmsTspData.getMediaType());
  byte[] digest=imprintCalculator.getDigest();
  TimeStampToken[] tokens=cmsTspData.getTimeStampTokens();
  assertEquals("String_Node_Str",5,tokens.length);
  for (int i=0; i < tokens.length; i++) {
    cmsTspData.validate(newCalculatorProvider,digest,tokens[i]);
  }
}
Program: 52577
Project: 52577
Buggy source:
/** 
 * Create a TimeStampRequest from the past in input stream.
 * @param in input stream containing the request.
 * @throws IOException if the request is malformed.
 */
public TimeStampRequest(InputStream in) throws IOException {
  try {
    this.req=TimeStampReq.getInstance(new ASN1InputStream(in).readObject());
  }
 catch (  ClassCastException e) {
    throw new IOException("String_Node_Str" + e);
  }
catch (  IllegalArgumentException e) {
    throw new IOException("String_Node_Str" + e);
  }
}

Fixed version (ground truth):
/** 
 * Create a TimeStampRequest from the past in input stream.
 * @param in input stream containing the request.
 * @throws IOException if the request is malformed.
 */
public TimeStampRequest(InputStream in) throws IOException {
  this(loadRequest(in));
}
Program: 52579
Project: 52579
Buggy source:
private byte[] bigIntToBytes(BigInteger r){
  byte[] tmp=r.toByteArray();
  if (tmp[0] == 0) {
    byte[] ntmp=new byte[tmp.length - 1];
    System.arraycopy(tmp,1,ntmp,0,ntmp.length);
    return ntmp;
  }
  return tmp;
}

Fixed version (ground truth):
private byte[] bigIntToBytes(BigInteger r){
  int expectedLength=(p.bitLength() + 7) / 8;
  byte[] tmp=r.toByteArray();
  if (tmp.length == expectedLength) {
    return tmp;
  }
  if (tmp[0] == 0 && tmp.length == expectedLength + 1) {
    byte[] rv=new byte[tmp.length - 1];
    System.arraycopy(tmp,1,rv,0,rv.length);
    return rv;
  }
  byte[] rv=new byte[expectedLength];
  System.arraycopy(tmp,0,rv,rv.length - tmp.length,tmp.length);
  return rv;
}
Program: 52580
Project: 52580
Buggy source:
private void testTwoParty(String algName,int size,int privateValueSize,KeyPairGenerator keyGen) throws Exception {
  KeyPair aKeyPair=keyGen.generateKeyPair();
  KeyAgreement aKeyAgree=KeyAgreement.getInstance(algName,"String_Node_Str");
  checkKeySize(privateValueSize,aKeyPair);
  aKeyAgree.init(aKeyPair.getPrivate());
  KeyPair bKeyPair=keyGen.generateKeyPair();
  KeyAgreement bKeyAgree=KeyAgreement.getInstance(algName,"String_Node_Str");
  checkKeySize(privateValueSize,bKeyPair);
  bKeyAgree.init(bKeyPair.getPrivate());
  aKeyAgree.doPhase(bKeyPair.getPublic(),true);
  bKeyAgree.doPhase(aKeyPair.getPublic(),true);
  BigInteger k1=new BigInteger(aKeyAgree.generateSecret());
  BigInteger k2=new BigInteger(bKeyAgree.generateSecret());
  if (!k1.equals(k2)) {
    fail(size + "String_Node_Str");
  }
}

Fixed version (ground truth):
private byte[] testTwoParty(String algName,int size,int privateValueSize,KeyPair aKeyPair,KeyPair bKeyPair) throws Exception {
  KeyAgreement aKeyAgree=KeyAgreement.getInstance(algName,"String_Node_Str");
  checkKeySize(privateValueSize,aKeyPair);
  aKeyAgree.init(aKeyPair.getPrivate());
  KeyAgreement bKeyAgree=KeyAgreement.getInstance(algName,"String_Node_Str");
  checkKeySize(privateValueSize,bKeyPair);
  bKeyAgree.init(bKeyPair.getPrivate());
  aKeyAgree.doPhase(bKeyPair.getPublic(),true);
  bKeyAgree.doPhase(aKeyPair.getPublic(),true);
  byte[] aSecret=aKeyAgree.generateSecret();
  byte[] bSecret=bKeyAgree.generateSecret();
  if (!Arrays.areEqual(aSecret,bSecret)) {
    fail(size + "String_Node_Str");
  }
  return aSecret;
}
Program: 52581
Project: 52581
Buggy source:
public void performTest() throws Exception {
  testDefault(64,g512,p512);
  testEnc();
  testGP("String_Node_Str",512,0,g512,p512);
  testGP("String_Node_Str",768,0,g768,p768);
  testGP("String_Node_Str",1024,0,g1024,p1024);
  testGP("String_Node_Str",512,64,g512,p512);
  testGP("String_Node_Str",768,128,g768,p768);
  testGP("String_Node_Str",1024,256,g1024,p1024);
  testExplicitWrapping(512,0,g512,p512);
  testRandom(256);
  testECDH("String_Node_Str");
  testECDH("String_Node_Str");
  testExceptions();
  testDESAndDESede(g768,p768);
  testInitialise();
  testConfig();
}

Fixed version (ground truth):
public void performTest() throws Exception {
  testDefault(64,g512,p512);
  testEnc();
  testGP("String_Node_Str",512,0,g512,p512);
  testGP("String_Node_Str",768,0,g768,p768);
  testGP("String_Node_Str",1024,0,g1024,p1024);
  testGP("String_Node_Str",512,64,g512,p512);
  testGP("String_Node_Str",768,128,g768,p768);
  testGP("String_Node_Str",1024,256,g1024,p1024);
  testExplicitWrapping(512,0,g512,p512);
  testRandom(256);
  testECDH("String_Node_Str");
  testECDH("String_Node_Str");
  testExceptions();
  testDESAndDESede(g768,p768);
  testInitialise();
  testSmallSecret();
  testConfig();
}
Program: 52582
Project: 52582
Buggy source:
private void appendValue(StringBuffer buf,Hashtable oidSymbols,ASN1ObjectIdentifier oid,String value){
  String sym=(String)oidSymbols.get(oid);
  if (sym != null) {
    buf.append(sym);
  }
 else {
    buf.append(oid.getId());
  }
  buf.append('=');
  int index=buf.length();
  int start=index;
  buf.append(value);
  int end=buf.length();
  if (value.length() >= 2 && value.charAt(0) == '\\' && value.charAt(1) == '#') {
    index+=2;
  }
  while (index != end) {
    if ((buf.charAt(index) == ',') || (buf.charAt(index) == '"') || (buf.charAt(index) == '\\')|| (buf.charAt(index) == '+')|| (buf.charAt(index) == '=')|| (buf.charAt(index) == '<')|| (buf.charAt(index) == '>')|| (buf.charAt(index) == ';')) {
      buf.insert(index,"String_Node_Str");
      index++;
      end++;
    }
    index++;
  }
  while (buf.charAt(start) == ' ') {
    buf.insert(start,"String_Node_Str");
    start+=2;
  }
  int endBuf=buf.length() - 1;
  while (endBuf >= 0 && buf.charAt(endBuf) == ' ') {
    buf.insert(endBuf,'\\');
    endBuf--;
  }
}

Fixed version (ground truth):
private void appendValue(StringBuffer buf,Hashtable oidSymbols,ASN1ObjectIdentifier oid,String value){
  String sym=(String)oidSymbols.get(oid);
  if (sym != null) {
    buf.append(sym);
  }
 else {
    buf.append(oid.getId());
  }
  buf.append('=');
  int index=buf.length();
  int start=index;
  buf.append(value);
  int end=buf.length();
  if (value.length() >= 2 && value.charAt(0) == '\\' && value.charAt(1) == '#') {
    index+=2;
  }
  while (index != end) {
    if ((buf.charAt(index) == ',') || (buf.charAt(index) == '"') || (buf.charAt(index) == '\\')|| (buf.charAt(index) == '+')|| (buf.charAt(index) == '=')|| (buf.charAt(index) == '<')|| (buf.charAt(index) == '>')|| (buf.charAt(index) == ';')) {
      buf.insert(index,"String_Node_Str");
      index++;
      end++;
    }
    index++;
  }
  while (start < buf.length() && buf.charAt(start) == ' ') {
    buf.insert(start,"String_Node_Str");
    start+=2;
  }
  int endBuf=buf.length() - 1;
  while (endBuf >= 0 && buf.charAt(endBuf) == ' ') {
    buf.insert(endBuf,'\\');
    endBuf--;
  }
}