nus-yam/ex-repair huggingface dataset:
Program: 52492
Project: 52492
Buggy source:
/** 
 * fill len bytes of the output buffer with bytes generated from the derivation function.
 * @throws DataLengthException if the out buffer is too small.
 */
public int generateBytes(byte[] out,int outOff,int len) throws DataLengthException, IllegalArgumentException {
  if ((out.length - len) < outOff) {
    throw new DataLengthException("String_Node_Str");
  }
  byte[] hashBuf=new byte[hLen];
  byte[] C=new byte[4];
  int counter=1;
  digest.reset();
  if (len > hLen) {
    do {
      ItoOSP(counter++,C);
      digest.update(C,0,C.length);
      digest.update(shared,0,shared.length);
      digest.update(otherInfo,0,otherInfo.length);
      digest.doFinal(hashBuf,0);
      System.arraycopy(hashBuf,0,out,outOff + (counter - 1) * hLen,hLen);
    }
 while (counter < (len / hLen));
  }
  if (((counter - 1) * hLen) < len) {
    ItoOSP(counter,C);
    digest.update(C,0,C.length);
    digest.update(shared,0,shared.length);
    digest.update(otherInfo,0,otherInfo.length);
    digest.doFinal(hashBuf,0);
    System.arraycopy(hashBuf,0,out,outOff + (counter - 1) * hLen,len - ((counter - 1) * hLen));
  }
  return len;
}

Fixed version (ground truth):
/** 
 * fill len bytes of the output buffer with bytes generated from the derivation function.
 * @throws DataLengthException if the out buffer is too small.
 */
public int generateBytes(byte[] out,int outOff,int len) throws DataLengthException, IllegalArgumentException {
  if ((out.length - len) < outOff) {
    throw new DataLengthException("String_Node_Str");
  }
  byte[] hashBuf=new byte[hLen];
  byte[] C=new byte[4];
  int counter=1;
  int outputLen=0;
  digest.reset();
  if (len > hLen) {
    do {
      ItoOSP(counter,C);
      digest.update(C,0,C.length);
      digest.update(shared,0,shared.length);
      digest.update(otherInfo,0,otherInfo.length);
      digest.doFinal(hashBuf,0);
      System.arraycopy(hashBuf,0,out,outOff + outputLen,hLen);
      outputLen+=hLen;
    }
 while ((counter++) < (len / hLen));
  }
  if (outputLen < len) {
    ItoOSP(counter,C);
    digest.update(C,0,C.length);
    digest.update(shared,0,shared.length);
    digest.update(otherInfo,0,otherInfo.length);
    digest.doFinal(hashBuf,0);
    System.arraycopy(hashBuf,0,out,outOff + outputLen,len - outputLen);
  }
  return len;
}
Program: 52495
Project: 52495
Buggy source:
public void performTest() throws Exception {
  testKeyConversion();
  testAdaptiveKeyConversion();
  decodeTest();
  testECDSA239bitPrime();
  testECDSA239bitBinary();
  testGeneration();
  testKeyPairGenerationWithOIDs();
  testNamedCurveParameterPreservation();
  testNamedCurveSigning();
  testBSI();
}

Fixed version (ground truth):
public void performTest() throws Exception {
  testKeyConversion();
  testAdaptiveKeyConversion();
  decodeTest();
  testECDSA239bitPrime();
  testECDSA239bitBinary();
  testGeneration();
  testKeyPairGenerationWithOIDs();
  testNamedCurveParameterPreservation();
  testNamedCurveSigning();
  testBSI();
  testMQVwithHMACOnePass();
}
Program: 52496
Project: 52496
Buggy source:
private void testGOSTStore() throws Exception {
  byte[] data=Hex.decode("String_Node_Str");
  KeyStore pkcs12=KeyStore.getInstance("String_Node_Str","String_Node_Str");
  pkcs12.load(new ByteArrayInputStream(gostPfx),"String_Node_Str".toCharArray());
  PrivateKey pk=(PrivateKey)pkcs12.getKey("String_Node_Str",null);
  Certificate[] pubCerts=pkcs12.getCertificateChain("String_Node_Str");
  Signature sig=Signature.getInstance("String_Node_Str","String_Node_Str");
  sig.initSign(pk);
  sig.update(data);
  byte[] signature=sig.sign();
  sig=Signature.getInstance("String_Node_Str","String_Node_Str");
  sig.initVerify(pubCerts[0].getPublicKey());
  sig.update(data);
  if (!sig.verify(signature)) {
    fail("String_Node_Str");
  }
}

Fixed version (ground truth):
private void testGOSTStore() throws Exception {
  byte[] data=Hex.decode("String_Node_Str");
  KeyStore pkcs12=KeyStore.getInstance("String_Node_Str","String_Node_Str");
  pkcs12.load(new ByteArrayInputStream(gostPfx),"String_Node_Str".toCharArray());
  PrivateKey pk=(PrivateKey)pkcs12.getKey("String_Node_Str",null);
  Certificate[] pubCerts=pkcs12.getCertificateChain("String_Node_Str");
  Signature sig=Signature.getInstance("String_Node_Str","String_Node_Str");
  sig.initSign(pk);
  sig.update(data);
  byte[] signature=sig.sign();
  sig=Signature.getInstance("String_Node_Str","String_Node_Str");
  sig.initVerify(pubCerts[0].getPublicKey());
  sig.update(data);
  if (!sig.verify(signature)) {
    fail("String_Node_Str");
  }
  KeyStore ks=KeyStore.getInstance("String_Node_Str","String_Node_Str");
  ks.load(new ByteArrayInputStream(gostOpenSSLIntegerDPfx),"String_Node_Str".toCharArray());
  PrivateKey key=(PrivateKey)ks.getKey("String_Node_Str","String_Node_Str".toCharArray());
  X509Certificate cert=(X509Certificate)ks.getCertificate("String_Node_Str");
  sig.initSign(key);
  sig.update(data);
  signature=sig.sign();
  sig.initVerify(cert.getPublicKey());
  sig.update(data);
  if (!sig.verify(signature)) {
    fail("String_Node_Str");
  }
}
Program: 52497
Project: 52497
Buggy source:
public void verify(PublicKey key,Provider sigProvider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
  Signature sig;
  if (sigProvider != null) {
    sig=Signature.getInstance(getSigAlgName(),sigProvider);
  }
 else {
    sig=Signature.getInstance(getSigAlgName());
  }
  doVerify(key,sig);
}

Fixed version (ground truth):
public void verify(PublicKey key,Provider sigProvider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
  Signature sig;
  if (sigProvider != null) {
    sig=Signature.getInstance(getSigAlgName(),sigProvider);
  }
 else {
    sig=Signature.getInstance(getSigAlgName());
  }
  doVerify(key,sig);
}
Program: 52498
Project: 52498
Buggy source:
private void doVerify(PublicKey key,Signature sig) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
  if (!c.getSignatureAlgorithm().equals(c.getTBSCertList().getSignature())) {
    throw new CRLException("String_Node_Str");
  }
  sig.initVerify(key);
  sig.update(this.getTBSCertList());
  if (!sig.verify(this.getSignature())) {
    throw new SignatureException("String_Node_Str");
  }
}

Fixed version (ground truth):
private void doVerify(PublicKey key,Signature sig) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
  if (!c.getSignatureAlgorithm().equals(c.getTBSCertList().getSignature())) {
    throw new CRLException("String_Node_Str");
  }
  sig.initVerify(key);
  sig.update(this.getTBSCertList());
  if (!sig.verify(this.getSignature())) {
    throw new SignatureException("String_Node_Str");
  }
}
Program: 52499
Project: 52499
Buggy source:
public final void verify(PublicKey key,Provider sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
  String sigName=X509SignatureUtil.getSignatureName(c.getSignatureAlgorithm());
  Signature signature;
  if (sigProvider != null) {
    signature=Signature.getInstance(sigName,sigProvider);
  }
 else {
    signature=Signature.getInstance(sigName);
  }
  checkSignature(key,signature);
}

Fixed version (ground truth):
public final void verify(PublicKey key,Provider sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
  String sigName=X509SignatureUtil.getSignatureName(c.getSignatureAlgorithm());
  Signature signature;
  if (sigProvider != null) {
    signature=Signature.getInstance(sigName,sigProvider);
  }
 else {
    signature=Signature.getInstance(sigName);
  }
  checkSignature(key,signature);
}
Program: 52500
Project: 52500
Buggy source:
public void verify(PublicKey key,Provider sigProvider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
  Signature sig;
  if (sigProvider != null) {
    sig=Signature.getInstance(getSigAlgName(),sigProvider);
  }
 else {
    sig=Signature.getInstance(getSigAlgName());
  }
  doVerify(key,sig);
}

Fixed version (ground truth):
public void verify(PublicKey key,Provider sigProvider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
  Signature sig;
  if (sigProvider != null) {
    sig=Signature.getInstance(getSigAlgName(),sigProvider);
  }
 else {
    sig=Signature.getInstance(getSigAlgName());
  }
  doVerify(key,sig);
}
Program: 52501
Project: 52501
Buggy source:
private void doVerify(PublicKey key,Signature sig) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
  if (!c.getSignatureAlgorithm().equals(c.getTBSCertList().getSignature())) {
    throw new CRLException("String_Node_Str");
  }
  sig.initVerify(key);
  sig.update(this.getTBSCertList());
  if (!sig.verify(this.getSignature())) {
    throw new SignatureException("String_Node_Str");
  }
}

Fixed version (ground truth):
private void doVerify(PublicKey key,Signature sig) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
  if (!c.getSignatureAlgorithm().equals(c.getTBSCertList().getSignature())) {
    throw new CRLException("String_Node_Str");
  }
  sig.initVerify(key);
  sig.update(this.getTBSCertList());
  if (!sig.verify(this.getSignature())) {
    throw new SignatureException("String_Node_Str");
  }
}
Program: 52502
Project: 52502
Buggy source:
public final void verify(PublicKey key,Provider sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
  String sigName=X509SignatureUtil.getSignatureName(c.getSignatureAlgorithm());
  Signature signature;
  if (sigProvider != null) {
    signature=Signature.getInstance(sigName,sigProvider);
  }
 else {
    signature=Signature.getInstance(sigName);
  }
  checkSignature(key,signature);
}

Fixed version (ground truth):
public final void verify(PublicKey key,Provider sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
  String sigName=X509SignatureUtil.getSignatureName(c.getSignatureAlgorithm());
  Signature signature;
  if (sigProvider != null) {
    signature=Signature.getInstance(sigName,sigProvider);
  }
 else {
    signature=Signature.getInstance(sigName);
  }
  checkSignature(key,signature);
}
Program: 52503
Project: 52503
Buggy source:
public void write(OutputStream out) throws IOException, CMSException {
  try {
    SMIMEUtil.outputBodyPart(out,bodyPart,defaultContentTransferEncoding);
  }
 catch (  MessagingException e) {
    throw new CMSException("String_Node_Str" + e,e);
  }
}

Fixed version (ground truth):
public void write(OutputStream out) throws IOException, CMSException {
  try {
    SMIMEUtil.outputBodyPart(out,true,bodyPart,defaultContentTransferEncoding);
  }
 catch (  MessagingException e) {
    throw new CMSException("String_Node_Str" + e,e);
  }
}
Program: 52504
Project: 52504
Buggy source:
private static CMSTypedStream getSignedInputStream(BodyPart bodyPart,String defaultContentTransferEncoding,File backingFile) throws MessagingException {
  try {
    OutputStream out=new BufferedOutputStream(new FileOutputStream(backingFile));
    SMIMEUtil.outputBodyPart(out,bodyPart,defaultContentTransferEncoding);
    out.close();
    InputStream in=new TemporaryFileInputStream(backingFile);
    return new CMSTypedStream(in);
  }
 catch (  IOException e) {
    throw new MessagingException("String_Node_Str" + e);
  }
}

Fixed version (ground truth):
private static CMSTypedStream getSignedInputStream(BodyPart bodyPart,String defaultContentTransferEncoding,File backingFile) throws MessagingException {
  try {
    OutputStream out=new BufferedOutputStream(new FileOutputStream(backingFile));
    SMIMEUtil.outputBodyPart(out,true,bodyPart,defaultContentTransferEncoding);
    out.close();
    InputStream in=new TemporaryFileInputStream(backingFile);
    return new CMSTypedStream(in);
  }
 catch (  IOException e) {
    throw new MessagingException("String_Node_Str" + e);
  }
}
Program: 52505
Project: 52505
Buggy source:
/** 
 * Return a CMS IssuerAndSerialNumber structure for the passed in X.509 certificate.
 * @param cert the X.509 certificate to get the issuer and serial number for.
 * @return an IssuerAndSerialNumber structure representing the certificate.
 */
public static IssuerAndSerialNumber createIssuerAndSerialNumberFor(X509Certificate cert) throws CertificateParsingException {
  try {
    return new IssuerAndSerialNumber(PrincipalUtil.getIssuerX509Principal(cert),cert.getSerialNumber());
  }
 catch (  Exception e) {
    throw new CertificateParsingException("String_Node_Str" + e);
  }
}

Fixed version (ground truth):
/** 
 * Return a CMS IssuerAndSerialNumber structure for the passed in X.509 certificate.
 * @param cert the X.509 certificate to get the issuer and serial number for.
 * @return an IssuerAndSerialNumber structure representing the certificate.
 */
public static IssuerAndSerialNumber createIssuerAndSerialNumberFor(X509Certificate cert) throws CertificateParsingException {
  try {
    return new IssuerAndSerialNumber(new JcaX509CertificateHolder(cert).getIssuer(),cert.getSerialNumber());
  }
 catch (  Exception e) {
    throw new CertificateParsingException("String_Node_Str" + e);
  }
}
Program: 52507
Project: 52507
Buggy source:
public static ECField convertField(FiniteField field){
  if (ECAlgorithms.isFpField(field)) {
    return new ECFieldFp(field.getCharacteristic());
  }
 else {
    Polynomial poly=((PolynomialExtensionField)field).getMinimalPolynomial();
    int[] exponents=poly.getExponentsPresent();
    int[] ks=Arrays.reverse(Arrays.copyOfRange(exponents,1,exponents.length - 2));
    return new ECFieldF2m(poly.getDegree(),ks);
  }
}

Fixed version (ground truth):
public static ECField convertField(FiniteField field){
  if (ECAlgorithms.isFpField(field)) {
    return new ECFieldFp(field.getCharacteristic());
  }
 else {
    Polynomial poly=((PolynomialExtensionField)field).getMinimalPolynomial();
    int[] exponents=poly.getExponentsPresent();
    int[] ks=Arrays.reverse(Arrays.copyOfRange(exponents,1,exponents.length - 1));
    return new ECFieldF2m(poly.getDegree(),ks);
  }
}
Program: 52508
Project: 52508
Buggy source:
private static ECField convertField(FiniteField field){
  if (ECAlgorithms.isFpField(field)) {
    return new ECFieldFp(field.getCharacteristic());
  }
 else {
    Polynomial poly=((PolynomialExtensionField)field).getMinimalPolynomial();
    int[] exponents=poly.getExponentsPresent();
    int[] ks=Arrays.reverse(Arrays.copyOfRange(exponents,1,exponents.length - 2));
    return new ECFieldF2m(poly.getDegree(),ks);
  }
}

Fixed version (ground truth):
private static ECField convertField(FiniteField field){
  if (ECAlgorithms.isFpField(field)) {
    return new ECFieldFp(field.getCharacteristic());
  }
 else {
    Polynomial poly=((PolynomialExtensionField)field).getMinimalPolynomial();
    int[] exponents=poly.getExponentsPresent();
    int[] ks=Arrays.reverse(Arrays.copyOfRange(exponents,1,exponents.length - 1));
    return new ECFieldF2m(poly.getDegree(),ks);
  }
}
Program: 52509
Project: 52509
Buggy source:
protected int engineDoFinal(byte[] input,int inputOffset,int inputLen,byte[] output,int outputOffset) throws IllegalBlockSizeException, BadPaddingException, ShortBufferException {
  try {
    int len=0;
    if (inputLen != 0) {
      len=cipher.processBytes(input,inputOffset,inputLen,output,outputOffset);
    }
    return (len + cipher.doFinal(output,outputOffset + len));
  }
 catch (  OutputLengthException e) {
    throw new ShortBufferException(e.getMessage());
  }
catch (  DataLengthException e) {
    throw new IllegalBlockSizeException(e.getMessage());
  }
}

Fixed version (ground truth):
protected int engineDoFinal(byte[] input,int inputOffset,int inputLen,byte[] output,int outputOffset) throws IllegalBlockSizeException, BadPaddingException, ShortBufferException {
  int len=0;
  if (outputOffset + engineGetOutputSize(inputLen) > output.length) {
    throw new ShortBufferException("String_Node_Str");
  }
  try {
    if (inputLen != 0) {
      len=cipher.processBytes(input,inputOffset,inputLen,output,outputOffset);
    }
    return (len + cipher.doFinal(output,outputOffset + len));
  }
 catch (  OutputLengthException e) {
    throw new ShortBufferException(e.getMessage());
  }
catch (  DataLengthException e) {
    throw new IllegalBlockSizeException(e.getMessage());
  }
}
Program: 52510
Project: 52510
Buggy source:
protected int engineDoFinal(byte[] input,int inputOffset,int inputLen,byte[] output,int outputOffset){
  if (inputLen != 0) {
    cipher.processBytes(input,inputOffset,inputLen,output,outputOffset);
  }
  cipher.reset();
  return inputLen;
}

Fixed version (ground truth):
protected int engineDoFinal(byte[] input,int inputOffset,int inputLen,byte[] output,int outputOffset) throws ShortBufferException {
  if (outputOffset + inputLen > output.length) {
    throw new ShortBufferException("String_Node_Str");
  }
  if (inputLen != 0) {
    cipher.processBytes(input,inputOffset,inputLen,output,outputOffset);
  }
  cipher.reset();
  return inputLen;
}
Program: 52511
Project: 52511
Buggy source:
private void createSignatureBlock(){
  int digSize=digest.getDigestSize();
  int delta;
  if (trailer == TRAILER_IMPLICIT) {
    delta=block.length - digSize - 1;
    digest.doFinal(block,delta);
    block[block.length - 1]=(byte)TRAILER_IMPLICIT;
  }
 else {
    delta=block.length - digSize - 2;
    digest.doFinal(block,delta);
    block[block.length - 2]=(byte)(trailer >>> 8);
    block[block.length - 1]=(byte)trailer;
  }
  block[0]=0x06;
  for (int i=delta - 2; i != 0; i--) {
    block[i]=(byte)0xbb;
  }
  block[delta - 1]=(byte)0xba;
}

Fixed version (ground truth):
private void createSignatureBlock(){
  int digSize=digest.getDigestSize();
  int delta;
  if (trailer == TRAILER_IMPLICIT) {
    delta=block.length - digSize - 1;
    digest.doFinal(block,delta);
    block[block.length - 1]=(byte)TRAILER_IMPLICIT;
  }
 else {
    delta=block.length - digSize - 2;
    digest.doFinal(block,delta);
    block[block.length - 2]=(byte)(trailer >>> 8);
    block[block.length - 1]=(byte)trailer;
  }
  block[0]=0x6b;
  for (int i=delta - 2; i != 0; i--) {
    block[i]=(byte)0xbb;
  }
  block[delta - 1]=(byte)0xba;
}
Program: 52512
Project: 52512
Buggy source:
public void performTest() throws Exception {
  BigInteger rsaPubMod=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPubExp=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivMod=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivDP=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivDQ=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivExp=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivP=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivQ=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivQinv=new BigInteger(Base64.decode("String_Node_Str"));
  RSAKeyParameters rsaPublic=new RSAKeyParameters(false,rsaPubMod,rsaPubExp);
  RSAPrivateCrtKeyParameters rsaPrivate=new RSAPrivateCrtKeyParameters(rsaPrivMod,rsaPubExp,rsaPrivExp,rsaPrivP,rsaPrivQ,rsaPrivDP,rsaPrivDQ,rsaPrivQinv);
  byte[] msg=new byte[]{1,6,3,32,7,43,2,5,7,78,4,23};
  X931Signer signer=new X931Signer(new RSAEngine(),new SHA1Digest());
  signer.init(true,rsaPrivate);
  signer.update(msg,0,msg.length);
  byte[] sig=signer.generateSignature();
  signer=new X931Signer(new RSAEngine(),new SHA1Digest());
  signer.init(false,rsaPublic);
  signer.update(msg,0,msg.length);
  if (!signer.verifySignature(sig)) {
    fail("String_Node_Str");
  }
}

Fixed version (ground truth):
public void performTest() throws Exception {
  BigInteger rsaPubMod=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPubExp=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivMod=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivDP=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivDQ=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivExp=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivP=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivQ=new BigInteger(Base64.decode("String_Node_Str"));
  BigInteger rsaPrivQinv=new BigInteger(Base64.decode("String_Node_Str"));
  RSAKeyParameters rsaPublic=new RSAKeyParameters(false,rsaPubMod,rsaPubExp);
  RSAPrivateCrtKeyParameters rsaPrivate=new RSAPrivateCrtKeyParameters(rsaPrivMod,rsaPubExp,rsaPrivExp,rsaPrivP,rsaPrivQ,rsaPrivDP,rsaPrivDQ,rsaPrivQinv);
  byte[] msg=new byte[]{1,6,3,32,7,43,2,5,7,78,4,23};
  X931Signer signer=new X931Signer(new RSAEngine(),new SHA1Digest());
  signer.init(true,rsaPrivate);
  signer.update(msg,0,msg.length);
  byte[] sig=signer.generateSignature();
  signer=new X931Signer(new RSAEngine(),new SHA1Digest());
  signer.init(false,rsaPublic);
  signer.update(msg,0,msg.length);
  if (!signer.verifySignature(sig)) {
    fail("String_Node_Str");
  }
  shouldPassSignatureTest1();
  shouldPassSignatureTest2();
}
Program: 52513
Project: 52513
Buggy source:
public static String canonicalize(String s){
  String value=Strings.toLowerCase(s.trim());
  if (value.length() > 0 && value.charAt(0) == '#') {
    ASN1Primitive obj=decodeObject(value);
    if (obj instanceof ASN1String) {
      value=Strings.toLowerCase(((ASN1String)obj).getString().trim());
    }
  }
  value=stripInternalSpaces(value);
  return value;
}

Fixed version (ground truth):
public static String canonicalize(String s){
  String value=Strings.toLowerCase(s);
  if (value.length() > 0 && value.charAt(0) == '#') {
    ASN1Primitive obj=decodeObject(value);
    if (obj instanceof ASN1String) {
      value=Strings.toLowerCase(((ASN1String)obj).getString());
    }
  }
  if (value.length() > 1) {
    int start=0;
    while (start + 1 < value.length() && value.charAt(start) == '\\' && value.charAt(start + 1) == ' ') {
      start+=2;
    }
    int end=value.length() - 1;
    while (end - 1 > 0 && value.charAt(end - 1) == '\\' && value.charAt(end) == ' ') {
      end-=2;
    }
    if (start > 0 || end < value.length() - 1) {
      value=value.substring(start,end + 1);
    }
  }
  value=stripInternalSpaces(value);
  return value;
}
Program: 52515
Project: 52515
Buggy source:
public void testSimpleTests(){
  org.bouncycastle.util.test.Test[] tests=new org.bouncycastle.util.test.Test[]{new CertTest(),new DANETest(),new PKCS10Test(),new AttrCertSelectorTest(),new AttrCertTest(),new X509ExtensionUtilsTest()};
  for (int i=0; i != tests.length; i++) {
    SimpleTestResult result=(SimpleTestResult)tests[i].perform();
    if (!result.isSuccessful()) {
      if (result.getException() != null) {
        result.getException().printStackTrace();
      }
      fail(result.toString());
    }
  }
}

Fixed version (ground truth):
public void testSimpleTests(){
  org.bouncycastle.util.test.Test[] tests=new org.bouncycastle.util.test.Test[]{new CertTest(),new DANETest(),new PKCS10Test(),new AttrCertSelectorTest(),new AttrCertTest(),new X509ExtensionUtilsTest(),new CertPathLoopTest()};
  for (int i=0; i != tests.length; i++) {
    SimpleTestResult result=(SimpleTestResult)tests[i].perform();
    if (!result.isSuccessful()) {
      if (result.getException() != null) {
        result.getException().printStackTrace();
      }
      fail(result.toString());
    }
  }
}
Program: 52521
Project: 52521
Buggy source:
public void encode(OutputStream out) throws IOException {
  int bodyLen=data.length + 1;
  if (bodyLen < 192) {
    out.write((byte)bodyLen);
  }
 else   if (bodyLen <= 8383) {
    bodyLen-=192;
    out.write((byte)(((bodyLen >> 8) & 0xff) + 192));
    out.write((byte)bodyLen);
  }
 else {
    out.write(0xff);
    out.write((byte)(bodyLen >> 24));
    out.write((byte)(bodyLen >> 16));
    out.write((byte)(bodyLen >> 8));
    out.write((byte)bodyLen);
  }
  out.write(type);
  out.write(data);
}

Fixed version (ground truth):
public void encode(OutputStream out) throws IOException {
  int bodyLen=data.length + 1;
  if (bodyLen < 192 && !longLength) {
    out.write((byte)bodyLen);
  }
 else   if (bodyLen <= 8383 && !longLength) {
    bodyLen-=192;
    out.write((byte)(((bodyLen >> 8) & 0xff) + 192));
    out.write((byte)bodyLen);
  }
 else {
    out.write(0xff);
    out.write((byte)(bodyLen >> 24));
    out.write((byte)(bodyLen >> 16));
    out.write((byte)(bodyLen >> 8));
    out.write((byte)bodyLen);
  }
  out.write(type);
  out.write(data);
}
Program: 52522
Project: 52522
Buggy source:
protected UserAttributeSubpacket(int type,byte[] data){
  this.type=type;
  this.data=data;
}

Fixed version (ground truth):
protected UserAttributeSubpacket(int type,boolean forceLongLength,byte[] data){
  this.type=type;
  this.longLength=forceLongLength;
  this.data=data;
}
Program: 52523
Project: 52523
Buggy source:
public UserAttributeSubpacket readPacket() throws IOException {
  int l=this.read();
  int bodyLen=0;
  if (l < 0) {
    return null;
  }
  if (l < 192) {
    bodyLen=l;
  }
 else   if (l <= 223) {
    bodyLen=((l - 192) << 8) + (in.read()) + 192;
  }
 else   if (l == 255) {
    bodyLen=(in.read() << 24) | (in.read() << 16) | (in.read() << 8)| in.read();
  }
 else {
  }
  int tag=in.read();
  if (tag < 0) {
    throw new EOFException("String_Node_Str");
  }
  byte[] data=new byte[bodyLen - 1];
  this.readFully(data,0,data.length);
  int type=tag;
switch (type) {
case IMAGE_ATTRIBUTE:
    return new ImageAttribute(data);
}
return new UserAttributeSubpacket(type,data);
}

Fixed version (ground truth):
public UserAttributeSubpacket readPacket() throws IOException {
  int l=this.read();
  int bodyLen=0;
  boolean longLength=false;
  if (l < 0) {
    return null;
  }
  if (l < 192) {
    bodyLen=l;
  }
 else   if (l <= 223) {
    bodyLen=((l - 192) << 8) + (in.read()) + 192;
  }
 else   if (l == 255) {
    bodyLen=(in.read() << 24) | (in.read() << 16) | (in.read() << 8)| in.read();
    longLength=true;
  }
 else {
    throw new IOException("String_Node_Str");
  }
  int tag=in.read();
  if (tag < 0) {
    throw new EOFException("String_Node_Str");
  }
  byte[] data=new byte[bodyLen - 1];
  this.readFully(data,0,data.length);
  int type=tag;
switch (type) {
case IMAGE_ATTRIBUTE:
    return new ImageAttribute(longLength,data);
}
return new UserAttributeSubpacket(type,longLength,data);
}
Program: 52524
Project: 52524
Buggy source:
public static void reduce(int[] xx,int[] z){
  int xx07=xx[7];
  Nat.shiftUpBit(8,xx,8,xx07,z,0);
  int c=Nat256.mulByWordAddTo(PInv,xx,z) << 1;
  int z7=z[7];
  c+=(z7 >> 31) - (xx07 >> 31);
  z7&=P7;
  z7+=Nat.addWordTo(7,c * PInv,z);
  z[7]=z7;
  if (Nat256.gte(z,P)) {
    subPFrom(z);
  }
}

Fixed version (ground truth):
public static void reduce(int[] xx,int[] z){
  int xx07=xx[7];
  Nat.shiftUpBit(8,xx,8,xx07,z,0);
  int c=Nat256.mulByWordAddTo(PInv,xx,z) << 1;
  int z7=z[7];
  c+=(z7 >>> 31) - (xx07 >>> 31);
  z7&=P7;
  z7+=Nat.addWordTo(7,c * PInv,z);
  z[7]=z7;
  if (Nat256.gte(z,P)) {
    subPFrom(z);
  }
}
Program: 52525
Project: 52525
Buggy source:
public void performTest() throws IOException {
  SubjectPublicKeyInfo pubInfo=SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(pubKeyInfo));
  SubjectKeyIdentifier ski=SubjectKeyIdentifier.createSHA1KeyIdentifier(pubInfo);
  if (!Arrays.areEqual(shaID,ski.getKeyIdentifier())) {
    fail("String_Node_Str");
  }
  ski=SubjectKeyIdentifier.createTruncatedSHA1KeyIdentifier(pubInfo);
  if (!Arrays.areEqual(shaTruncID,ski.getKeyIdentifier())) {
    fail("String_Node_Str");
  }
}

Fixed version (ground truth):
public void performTest() throws IOException {
}
Program: 52526
Project: 52526
Buggy source:
private SubjectKeyIdentifier createSubjectKeyId(PublicKey pubKey){
  try {
    SubjectPublicKeyInfo info=new SubjectPublicKeyInfo((ASN1Sequence)ASN1Primitive.fromByteArray(pubKey.getEncoded()));
    return new SubjectKeyIdentifier(info);
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
private SubjectKeyIdentifier createSubjectKeyId(PublicKey pubKey){
  try {
    SubjectPublicKeyInfo info=new SubjectPublicKeyInfo((ASN1Sequence)ASN1Primitive.fromByteArray(pubKey.getEncoded()));
    return new SubjectKeyIdentifier(getDigest(info));
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str");
  }
}
Program: 52531
Project: 52531
Buggy source:
static SubjectKeyIdentifier createSubjectKeyId(PublicKey pub) throws IOException {
  ByteArrayInputStream bIn=new ByteArrayInputStream(pub.getEncoded());
  SubjectPublicKeyInfo info=new SubjectPublicKeyInfo((ASN1Sequence)new ASN1InputStream(bIn).readObject());
  return new SubjectKeyIdentifier(info);
}

Fixed version (ground truth):
static SubjectKeyIdentifier createSubjectKeyId(PublicKey pub) throws IOException {
  ByteArrayInputStream bIn=new ByteArrayInputStream(pub.getEncoded());
  SubjectPublicKeyInfo info=new SubjectPublicKeyInfo((ASN1Sequence)new ASN1InputStream(bIn).readObject());
  return new BcX509ExtensionUtils().createSubjectKeyIdentifier(info);
}
Program: 52533
Project: 52533
Buggy source:
private static SubjectKeyIdentifier createSubjectKeyId(PublicKey _pubKey) throws IOException {
  ByteArrayInputStream _bais=new ByteArrayInputStream(_pubKey.getEncoded());
  SubjectPublicKeyInfo _info=new SubjectPublicKeyInfo((ASN1Sequence)new ASN1InputStream(_bais).readObject());
  return new SubjectKeyIdentifier(_info);
}

Fixed version (ground truth):
private static SubjectKeyIdentifier createSubjectKeyId(PublicKey _pubKey) throws IOException {
  return new BcX509ExtensionUtils().createSubjectKeyIdentifier(SubjectPublicKeyInfo.getInstance(_pubKey.getEncoded()));
}
Program: 52534
Project: 52534
Buggy source:
private void nullPointerTest() throws Exception {
  KeyPairGenerator keyGen=KeyPairGenerator.getInstance("String_Node_Str","String_Node_Str");
  keyGen.initialize(1024,new SecureRandom());
  KeyPair pair=keyGen.generateKeyPair();
  Vector oids=new Vector();
  Vector values=new Vector();
  oids.add(X509Extensions.BasicConstraints);
  values.add(new X509Extension(true,new DEROctetString(new BasicConstraints(true))));
  oids.add(X509Extensions.KeyUsage);
  values.add(new X509Extension(true,new DEROctetString(new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign))));
  SubjectKeyIdentifier subjectKeyIdentifier=new SubjectKeyIdentifierStructure(pair.getPublic());
  X509Extension ski=new X509Extension(false,new DEROctetString(subjectKeyIdentifier));
  oids.add(X509Extensions.SubjectKeyIdentifier);
  values.add(ski);
  Attribute attribute=new Attribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest,new DERSet(new X509Extensions(oids,values)));
  PKCS10CertificationRequest p1=new PKCS10CertificationRequest("String_Node_Str",new X509Principal("String_Node_Str"),pair.getPublic(),new DERSet(attribute),pair.getPrivate(),"String_Node_Str");
  PKCS10CertificationRequest p2=new PKCS10CertificationRequest("String_Node_Str",new X509Principal("String_Node_Str"),pair.getPublic(),new DERSet(attribute),pair.getPrivate(),"String_Node_Str");
  if (!p1.equals(p2)) {
    fail("String_Node_Str");
  }
}

Fixed version (ground truth):
private void nullPointerTest() throws Exception {
  KeyPairGenerator keyGen=KeyPairGenerator.getInstance("String_Node_Str","String_Node_Str");
  keyGen.initialize(1024,new SecureRandom());
  KeyPair pair=keyGen.generateKeyPair();
  Vector oids=new Vector();
  Vector values=new Vector();
  oids.add(X509Extensions.BasicConstraints);
  values.add(new X509Extension(true,new DEROctetString(new BasicConstraints(true))));
  oids.add(X509Extensions.KeyUsage);
  values.add(new X509Extension(true,new DEROctetString(new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign))));
  SubjectKeyIdentifier subjectKeyIdentifier=new SubjectKeyIdentifierStructure(getDigest(SubjectPublicKeyInfo.getInstance(pair.getPublic().getEncoded())));
  X509Extension ski=new X509Extension(false,new DEROctetString(subjectKeyIdentifier));
  oids.add(X509Extensions.SubjectKeyIdentifier);
  values.add(ski);
  Attribute attribute=new Attribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest,new DERSet(new X509Extensions(oids,values)));
  PKCS10CertificationRequest p1=new PKCS10CertificationRequest("String_Node_Str",new X509Principal("String_Node_Str"),pair.getPublic(),new DERSet(attribute),pair.getPrivate(),"String_Node_Str");
  PKCS10CertificationRequest p2=new PKCS10CertificationRequest("String_Node_Str",new X509Principal("String_Node_Str"),pair.getPublic(),new DERSet(attribute),pair.getPrivate(),"String_Node_Str");
  if (!p1.equals(p2)) {
    fail("String_Node_Str");
  }
}
Program: 52535
Project: 52535
Buggy source:
public static X509Certificate generateIntermediateCert(PublicKey intKey,PrivateKey caKey,X509Certificate caCert) throws Exception {
  X509V3CertificateGenerator certGen=new X509V3CertificateGenerator();
  certGen.setSerialNumber(BigInteger.valueOf(1));
  certGen.setIssuerDN(PrincipalUtil.getSubjectX509Principal(caCert));
  certGen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
  certGen.setNotAfter(new Date(System.currentTimeMillis() + 50000));
  certGen.setSubjectDN(new X509Principal("String_Node_Str"));
  certGen.setPublicKey(intKey);
  certGen.setSignatureAlgorithm("String_Node_Str");
  certGen.addExtension(X509Extensions.AuthorityKeyIdentifier,false,new AuthorityKeyIdentifierStructure(caCert));
  certGen.addExtension(X509Extensions.SubjectKeyIdentifier,false,new SubjectKeyIdentifierStructure(intKey));
  certGen.addExtension(X509Extensions.BasicConstraints,true,new BasicConstraints(0));
  certGen.addExtension(X509Extensions.KeyUsage,true,new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyCertSign | KeyUsage.cRLSign));
  return certGen.generate(caKey,"String_Node_Str");
}

Fixed version (ground truth):
public static X509Certificate generateIntermediateCert(PublicKey intKey,PrivateKey caKey,X509Certificate caCert) throws Exception {
  X509V3CertificateGenerator certGen=new X509V3CertificateGenerator();
  certGen.setSerialNumber(BigInteger.valueOf(1));
  certGen.setIssuerDN(PrincipalUtil.getSubjectX509Principal(caCert));
  certGen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
  certGen.setNotAfter(new Date(System.currentTimeMillis() + 50000));
  certGen.setSubjectDN(new X509Principal("String_Node_Str"));
  certGen.setPublicKey(intKey);
  certGen.setSignatureAlgorithm("String_Node_Str");
  certGen.addExtension(X509Extensions.AuthorityKeyIdentifier,false,new AuthorityKeyIdentifierStructure(caCert));
  certGen.addExtension(X509Extensions.SubjectKeyIdentifier,false,new SubjectKeyIdentifierStructure(getDigest(SubjectPublicKeyInfo.getInstance(intKey.getEncoded()))));
  certGen.addExtension(X509Extensions.BasicConstraints,true,new BasicConstraints(0));
  certGen.addExtension(X509Extensions.KeyUsage,true,new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyCertSign | KeyUsage.cRLSign));
  return certGen.generate(caKey,"String_Node_Str");
}
Program: 52536
Project: 52536
Buggy source:
public static X509Certificate generateEndEntityCert(PublicKey entityKey,PrivateKey caKey,X509Certificate caCert) throws Exception {
  X509V3CertificateGenerator certGen=new X509V3CertificateGenerator();
  certGen.setSerialNumber(BigInteger.valueOf(1));
  certGen.setIssuerDN(PrincipalUtil.getSubjectX509Principal(caCert));
  certGen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
  certGen.setNotAfter(new Date(System.currentTimeMillis() + 50000));
  certGen.setSubjectDN(new X509Principal("String_Node_Str"));
  certGen.setPublicKey(entityKey);
  certGen.setSignatureAlgorithm("String_Node_Str");
  certGen.addExtension(X509Extensions.AuthorityKeyIdentifier,false,new AuthorityKeyIdentifierStructure(caCert));
  certGen.addExtension(X509Extensions.SubjectKeyIdentifier,false,new SubjectKeyIdentifierStructure(entityKey));
  certGen.addExtension(X509Extensions.BasicConstraints,true,new BasicConstraints(false));
  certGen.addExtension(X509Extensions.KeyUsage,true,new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyEncipherment));
  return certGen.generate(caKey,"String_Node_Str");
}

Fixed version (ground truth):
public static X509Certificate generateEndEntityCert(PublicKey entityKey,PrivateKey caKey,X509Certificate caCert) throws Exception {
  X509V3CertificateGenerator certGen=new X509V3CertificateGenerator();
  certGen.setSerialNumber(BigInteger.valueOf(1));
  certGen.setIssuerDN(PrincipalUtil.getSubjectX509Principal(caCert));
  certGen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
  certGen.setNotAfter(new Date(System.currentTimeMillis() + 50000));
  certGen.setSubjectDN(new X509Principal("String_Node_Str"));
  certGen.setPublicKey(entityKey);
  certGen.setSignatureAlgorithm("String_Node_Str");
  certGen.addExtension(X509Extensions.AuthorityKeyIdentifier,false,new AuthorityKeyIdentifierStructure(caCert));
  certGen.addExtension(X509Extensions.SubjectKeyIdentifier,false,new SubjectKeyIdentifierStructure(getDigest(SubjectPublicKeyInfo.getInstance(entityKey.getEncoded()))));
  certGen.addExtension(X509Extensions.BasicConstraints,true,new BasicConstraints(false));
  certGen.addExtension(X509Extensions.KeyUsage,true,new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyEncipherment));
  return certGen.generate(caKey,"String_Node_Str");
}
Program: 52537
Project: 52537
Buggy source:
private void finaliseCipher() throws IOException {
  try {
    finalized=true;
    if (bufferedBlockCipher != null) {
      maxBuf=bufferedBlockCipher.doFinal(buf,0);
    }
 else     if (aeadBlockCipher != null) {
      maxBuf=aeadBlockCipher.doFinal(buf,0);
    }
 else {
      maxBuf=0;
    }
  }
 catch (  final InvalidCipherTextException e) {
    throw new InvalidCipherTextIOException("String_Node_Str",e);
  }
catch (  Exception e) {
    throw new IOException("String_Node_Str" + e);
  }
}

Fixed version (ground truth):
private void finaliseCipher() throws IOException {
  try {
    finalized=true;
    ensureCapacity(0,true);
    if (bufferedBlockCipher != null) {
      maxBuf=bufferedBlockCipher.doFinal(buf,0);
    }
 else     if (aeadBlockCipher != null) {
      maxBuf=aeadBlockCipher.doFinal(buf,0);
    }
 else {
      maxBuf=0;
    }
  }
 catch (  final InvalidCipherTextException e) {
    throw new InvalidCipherTextIOException("String_Node_Str",e);
  }
catch (  Exception e) {
    throw new IOException("String_Node_Str" + e);
  }
}
Program: 52538
Project: 52538
Buggy source:
/** 
 * Constructs a CipherInputStream from an InputStream and an AEADBlockCipher.
 */
public CipherInputStream(InputStream is,AEADBlockCipher cipher){
  super(is);
  this.aeadBlockCipher=cipher;
  buf=new byte[cipher.getOutputSize(INPUT_BUF_SIZE)];
  inBuf=new byte[INPUT_BUF_SIZE];
}

Fixed version (ground truth):
/** 
 * Constructs a CipherInputStream from an InputStream and an AEADBlockCipher.
 */
public CipherInputStream(InputStream is,AEADBlockCipher cipher){
  super(is);
  this.aeadBlockCipher=cipher;
}
Program: 52539
Project: 52539
Buggy source:
/** 
 * Read data from underlying stream and process with cipher until end of stream or some data is available after cipher processing.
 * @return -1 to indicate end of stream, or the number of bytes (> 0) available.
 */
private int nextChunk() throws IOException {
  if (finalized) {
    return -1;
  }
  bufOff=0;
  maxBuf=0;
  while (maxBuf == 0) {
    int read=in.read(inBuf);
    if (read == -1) {
      finaliseCipher();
      if (maxBuf == 0) {
        return -1;
      }
      return maxBuf;
    }
    try {
      if (bufferedBlockCipher != null) {
        maxBuf=bufferedBlockCipher.processBytes(inBuf,0,read,buf,0);
      }
 else       if (aeadBlockCipher != null) {
        maxBuf=aeadBlockCipher.processBytes(inBuf,0,read,buf,0);
      }
 else {
        streamCipher.processBytes(inBuf,0,read,buf,0);
        maxBuf=read;
      }
    }
 catch (    Exception e) {
      throw new IOException("String_Node_Str" + e);
    }
  }
  return maxBuf;
}

Fixed version (ground truth):
/** 
 * Read data from underlying stream and process with cipher until end of stream or some data is available after cipher processing.
 * @return -1 to indicate end of stream, or the number of bytes (> 0) available.
 */
private int nextChunk() throws IOException {
  if (finalized) {
    return -1;
  }
  bufOff=0;
  maxBuf=0;
  while (maxBuf == 0) {
    int read=in.read(inBuf);
    if (read == -1) {
      finaliseCipher();
      if (maxBuf == 0) {
        return -1;
      }
      return maxBuf;
    }
    try {
      ensureCapacity(read,false);
      if (bufferedBlockCipher != null) {
        maxBuf=bufferedBlockCipher.processBytes(inBuf,0,read,buf,0);
      }
 else       if (aeadBlockCipher != null) {
        maxBuf=aeadBlockCipher.processBytes(inBuf,0,read,buf,0);
      }
 else {
        streamCipher.processBytes(inBuf,0,read,buf,0);
        maxBuf=read;
      }
    }
 catch (    Exception e) {
      throw new CipherIOException("String_Node_Str",e);
    }
  }
  return maxBuf;
}
Program: 52540
Project: 52540
Buggy source:
private void nullPointerTest() throws Exception {
  KeyPairGenerator keyGen=KeyPairGenerator.getInstance("String_Node_Str","String_Node_Str");
  keyGen.initialize(1024,new SecureRandom());
  KeyPair pair=keyGen.generateKeyPair();
  Vector oids=new Vector();
  Vector values=new Vector();
  oids.add(X509Extensions.BasicConstraints);
  values.add(new X509Extension(true,new DEROctetString(new BasicConstraints(true))));
  oids.add(X509Extensions.KeyUsage);
  values.add(new X509Extension(true,new DEROctetString(new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign))));
  SubjectKeyIdentifier subjectKeyIdentifier=new SubjectKeyIdentifierStructure(getDigest(SubjectPublicKeyInfo.getInstance(pair.getPublic().getEncoded())));
  X509Extension ski=new X509Extension(false,new DEROctetString(subjectKeyIdentifier));
  oids.add(X509Extensions.SubjectKeyIdentifier);
  values.add(ski);
  Attribute attribute=new Attribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest,new DERSet(new X509Extensions(oids,values)));
  PKCS10CertificationRequest p1=new PKCS10CertificationRequest("String_Node_Str",new X509Principal("String_Node_Str"),pair.getPublic(),new DERSet(attribute),pair.getPrivate(),"String_Node_Str");
  PKCS10CertificationRequest p2=new PKCS10CertificationRequest("String_Node_Str",new X509Principal("String_Node_Str"),pair.getPublic(),new DERSet(attribute),pair.getPrivate(),"String_Node_Str");
  if (!p1.equals(p2)) {
    fail("String_Node_Str");
  }
}

Fixed version (ground truth):
private void nullPointerTest() throws Exception {
  KeyPairGenerator keyGen=KeyPairGenerator.getInstance("String_Node_Str","String_Node_Str");
  keyGen.initialize(1024,new SecureRandom());
  KeyPair pair=keyGen.generateKeyPair();
  Vector oids=new Vector();
  Vector values=new Vector();
  oids.add(X509Extensions.BasicConstraints);
  values.add(new X509Extension(true,new DEROctetString(new BasicConstraints(true))));
  oids.add(X509Extensions.KeyUsage);
  values.add(new X509Extension(true,new DEROctetString(new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign))));
  SubjectKeyIdentifier subjectKeyIdentifier=new SubjectKeyIdentifier(getDigest(SubjectPublicKeyInfo.getInstance(pair.getPublic().getEncoded())));
  X509Extension ski=new X509Extension(false,new DEROctetString(subjectKeyIdentifier));
  oids.add(X509Extensions.SubjectKeyIdentifier);
  values.add(ski);
  Attribute attribute=new Attribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest,new DERSet(new X509Extensions(oids,values)));
  PKCS10CertificationRequest p1=new PKCS10CertificationRequest("String_Node_Str",new X509Principal("String_Node_Str"),pair.getPublic(),new DERSet(attribute),pair.getPrivate(),"String_Node_Str");
  PKCS10CertificationRequest p2=new PKCS10CertificationRequest("String_Node_Str",new X509Principal("String_Node_Str"),pair.getPublic(),new DERSet(attribute),pair.getPrivate(),"String_Node_Str");
  if (!p1.equals(p2)) {
    fail("String_Node_Str");
  }
}
Program: 52541
Project: 52541
Buggy source:
protected static long rotateLeft(long x,int n){
  return (x << n) | (x >>> (64 - n));
}

Fixed version (ground truth):
protected static long rotateLeft(long x,int n){
  return (x << n) | (x >>> -n);
}
Program: 52542
Project: 52542
Buggy source:
public void update(byte[] input,int offset,int length) throws DataLengthException, IllegalStateException {
  int i=0, fullWords=length & ~7;
  if (wordPos == 0) {
    for (; i < fullWords; i+=8) {
      m=Pack.littleEndianToLong(input,offset + i);
      processMessageWord();
    }
    for (; i < length; ++i) {
      m>>>=8;
      m|=(input[offset + i] & 0xffL) << 56;
    }
    wordPos=length - fullWords;
  }
 else {
    int bits=wordPos << 3;
    for (; i < fullWords; i+=8) {
      long n=Pack.littleEndianToLong(input,offset + i);
      m>>>=64 - bits;
      m|=n << bits;
      processMessageWord();
      m=n;
    }
    for (; i < length; ++i) {
      m>>>=8;
      m|=(input[offset + i] & 0xffL) << 56;
      if (++wordPos == 8) {
        processMessageWord();
        wordPos=0;
      }
    }
  }
}

Fixed version (ground truth):
public void update(byte[] input,int offset,int length) throws DataLengthException, IllegalStateException {
  int i=0, fullWords=length & ~7;
  if (wordPos == 0) {
    for (; i < fullWords; i+=8) {
      m=Pack.littleEndianToLong(input,offset + i);
      processMessageWord();
    }
    for (; i < length; ++i) {
      m>>>=8;
      m|=(input[offset + i] & 0xffL) << 56;
    }
    wordPos=length - fullWords;
  }
 else {
    int bits=wordPos << 3;
    for (; i < fullWords; i+=8) {
      long n=Pack.littleEndianToLong(input,offset + i);
      m=(n << bits) | (m >>> -bits);
      processMessageWord();
      m=n;
    }
    for (; i < length; ++i) {
      m>>>=8;
      m|=(input[offset + i] & 0xffL) << 56;
      if (++wordPos == 8) {
        processMessageWord();
        wordPos=0;
      }
    }
  }
}
Program: 52543
Project: 52543
Buggy source:
protected void applySipRounds(int n){
  for (int r=0; r < n; ++r) {
    v0+=v1;
    v2+=v3;
    v1=rotateLeft(v1,13);
    v3=rotateLeft(v3,16);
    v1^=v0;
    v3^=v2;
    v0=rotateLeft(v0,32);
    v2+=v1;
    v0+=v3;
    v1=rotateLeft(v1,17);
    v3=rotateLeft(v3,21);
    v1^=v2;
    v3^=v0;
    v2=rotateLeft(v2,32);
  }
}

Fixed version (ground truth):
protected void applySipRounds(int n){
  long r0=v0, r1=v1, r2=v2, r3=v3;
  for (int r=0; r < n; ++r) {
    r0+=r1;
    r2+=r3;
    r1=rotateLeft(r1,13);
    r3=rotateLeft(r3,16);
    r1^=r0;
    r3^=r2;
    r0=rotateLeft(r0,32);
    r2+=r1;
    r0+=r3;
    r1=rotateLeft(r1,17);
    r3=rotateLeft(r3,21);
    r1^=r2;
    r3^=r0;
    r2=rotateLeft(r2,32);
  }
  v0=r0;
  v1=r1;
  v2=r2;
  v3=r3;
}
Program: 52544
Project: 52544
Buggy source:
/** 
 * return a sqrt root - the routine verifies that the calculation returns the right value - if none exists it returns null.
 */
public ECFieldElement sqrt(){
  int[] c=this.x;
  if (Nat224.isZero(c) || Nat224.isOne(c)) {
    return this;
  }
  int[] nc=Nat224.create();
  SecP224R1Field.negate(c,nc);
  int[] r=Mod.random(SecP224R1Field.P);
  int[] t=Nat224.create();
  for (; ; ) {
    int[] d1=Nat224.create();
    Nat224.copy(r,d1);
    int[] e1=Nat224.create();
    e1[0]=1;
    int[] f1=Nat224.create();
    RP(nc,d1,e1,f1,t);
    int[] d0=Nat224.create();
    int[] e0=Nat224.create();
    for (int k=1; k < 96; ++k) {
      Nat224.copy(d1,d0);
      Nat224.copy(e1,e0);
      RS(d1,e1,f1,t);
      if (Nat224.isZero(d1)) {
        Mod.invert(SecP224R1Field.P,e0,f1);
        SecP224R1Field.multiply(f1,d0,f1);
        SecP224R1Field.square(f1,d1);
        return Nat224.eq(c,d1) ? new SecP224R1FieldElement(f1) : null;
      }
    }
    SecP224R1Field.addOne(r,r);
  }
}

Fixed version (ground truth):
/** 
 * return a sqrt root - the routine verifies that the calculation returns the right value - if none exists it returns null.
 */
public ECFieldElement sqrt(){
  int[] c=this.x;
  if (Nat224.isZero(c) || Nat224.isOne(c)) {
    return this;
  }
  int[] nc=Nat224.create();
  SecP224R1Field.negate(c,nc);
  int[] r=Mod.random(SecP224R1Field.P);
  int[] t=Nat224.create();
  if (!isSquare(c)) {
    return null;
  }
  while (!trySqrt(nc,r,t)) {
    SecP224R1Field.addOne(r,r);
  }
  SecP224R1Field.square(t,r);
  return Nat224.eq(c,r) ? new SecP224R1FieldElement(t) : null;
}