nus-yam/ex-repair huggingface dataset:
Program: 52438
Project: 52438
Buggy source:
/** 
 * Decode PKCS#1.5 encoding, and return a random value if the padding is not correct.
 * @param in    The encrypted block.
 * @param inOff Offset in the encrypted block.
 * @param inLen Length of the encrypted block.//@param pLen Length of the desired output.
 * @return The plaintext without padding, or a random value if the padding was incorrect.
 * @throws InvalidCipherTextException
 */
private byte[] decodeBlockOrRandom(byte[] in,int inOff,int inLen) throws InvalidCipherTextException {
  if (!forPrivateKey) {
    throw new InvalidCipherTextException("String_Node_Str");
  }
  byte[] block=engine.processBlock(in,inOff,inLen);
  byte[] random;
  if (this.fallback == null) {
    random=new byte[this.pLen];
    this.random.nextBytes(random);
  }
 else {
    random=fallback;
  }
  System.arraycopy(block,0,blockBuffer,blockBuffer.length - block.length,block.length);
  byte[] data=(useStrictLength) ? block : blockBuffer;
  int correct=PKCS1Encoding.checkPkcs1Encoding(data,this.pLen);
  byte[] result=new byte[this.pLen];
  for (int i=0; i < this.pLen; i++) {
    result[i]=(byte)((data[i + (data.length - pLen)] & (~correct)) | (random[i] & correct));
  }
  Arrays.fill(data,(byte)0);
  Arrays.fill(blockBuffer,(byte)0);
  return result;
}

Fixed version (ground truth):
/** 
 * Decode PKCS#1.5 encoding, and return a random value if the padding is not correct.
 * @param in    The encrypted block.
 * @param inOff Offset in the encrypted block.
 * @param inLen Length of the encrypted block.//@param pLen Length of the desired output.
 * @return The plaintext without padding, or a random value if the padding was incorrect.
 * @throws InvalidCipherTextException
 */
private byte[] decodeBlockOrRandom(byte[] in,int inOff,int inLen) throws InvalidCipherTextException {
  if (!forPrivateKey) {
    throw new InvalidCipherTextException("String_Node_Str");
  }
  byte[] block=engine.processBlock(in,inOff,inLen);
  byte[] random;
  if (this.fallback == null) {
    random=new byte[this.pLen];
    this.random.nextBytes(random);
  }
 else {
    random=fallback;
  }
  byte[] data=(useStrictLength & (block.length != engine.getOutputBlockSize())) ? blockBuffer : block;
  int correct=PKCS1Encoding.checkPkcs1Encoding(data,this.pLen);
  byte[] result=new byte[this.pLen];
  for (int i=0; i < this.pLen; i++) {
    result[i]=(byte)((data[i + (data.length - pLen)] & (~correct)) | (random[i] & correct));
  }
  Arrays.fill(data,(byte)0);
  return result;
}
Program: 52439
Project: 52439
Buggy source:
private void testStrictPKCS1Length(RSAKeyParameters pubParameters,RSAKeyParameters privParameters){
  AsymmetricBlockCipher eng=new RSAEngine();
  eng.init(true,privParameters);
  byte[] data=null;
  try {
    data=eng.processBlock(oversizedSig,0,oversizedSig.length);
  }
 catch (  Exception e) {
    fail("String_Node_Str" + e.toString(),e);
  }
  eng=new PKCS1Encoding(eng);
  eng.init(false,pubParameters);
  try {
    data=eng.processBlock(data,0,data.length);
    fail("String_Node_Str");
  }
 catch (  InvalidCipherTextException e) {
    if (!e.getMessage().equals("String_Node_Str")) {
      fail("String_Node_Str" + e.toString(),e);
    }
  }
  System.getProperties().put(PKCS1Encoding.STRICT_LENGTH_ENABLED_PROPERTY,"String_Node_Str");
  eng=new PKCS1Encoding(new RSAEngine());
  eng.init(false,pubParameters);
  try {
    data=eng.processBlock(data,0,data.length);
  }
 catch (  InvalidCipherTextException e) {
    fail("String_Node_Str" + e.toString(),e);
  }
  System.getProperties().remove(PKCS1Encoding.STRICT_LENGTH_ENABLED_PROPERTY);
}

Fixed version (ground truth):
private void testStrictPKCS1Length(RSAKeyParameters pubParameters,RSAKeyParameters privParameters){
  AsymmetricBlockCipher eng=new RSAEngine();
  eng.init(true,privParameters);
  byte[] data=null;
  byte[] overSized=null;
  try {
    overSized=data=eng.processBlock(oversizedSig,0,oversizedSig.length);
  }
 catch (  Exception e) {
    fail("String_Node_Str" + e.toString(),e);
  }
  eng=new PKCS1Encoding(eng);
  eng.init(false,pubParameters);
  try {
    data=eng.processBlock(overSized,0,overSized.length);
    fail("String_Node_Str");
  }
 catch (  InvalidCipherTextException e) {
    if (!e.getMessage().equals("String_Node_Str")) {
      fail("String_Node_Str" + e.toString(),e);
    }
  }
  eng=new PKCS1Encoding(new RSAEngine(),Hex.decode("String_Node_Str"));
  eng.init(false,new ParametersWithRandom(privParameters,new SecureRandom()));
  try {
    data=eng.processBlock(overSized,0,overSized.length);
    isTrue("String_Node_Str",Arrays.areEqual(Hex.decode("String_Node_Str"),data));
  }
 catch (  InvalidCipherTextException e) {
    fail("String_Node_Str" + e.toString(),e);
  }
  System.getProperties().put(PKCS1Encoding.NOT_STRICT_LENGTH_ENABLED_PROPERTY,"String_Node_Str");
  eng=new PKCS1Encoding(new RSAEngine());
  eng.init(false,pubParameters);
  try {
    data=eng.processBlock(overSized,0,overSized.length);
  }
 catch (  InvalidCipherTextException e) {
    fail("String_Node_Str" + e.toString(),e);
  }
  System.getProperties().remove(PKCS1Encoding.NOT_STRICT_LENGTH_ENABLED_PROPERTY);
}
Program: 52443
Project: 52443
Buggy source:
/** 
 * Reads a parameter set from an input stream.
 * @param is an input stream
 * @throws java.io.IOException
 */
public NTRUEncryptionKeyGenerationParameters(InputStream is) throws IOException {
  super(new SecureRandom(),-1);
  DataInputStream dis=new DataInputStream(is);
  N=dis.readInt();
  q=dis.readInt();
  df=dis.readInt();
  df1=dis.readInt();
  df2=dis.readInt();
  df3=dis.readInt();
  db=dis.readInt();
  dm0=dis.readInt();
  c=dis.readInt();
  minCallsR=dis.readInt();
  minCallsMask=dis.readInt();
  hashSeed=dis.readBoolean();
  oid=new byte[3];
  dis.read(oid);
  sparse=dis.readBoolean();
  fastFp=dis.readBoolean();
  polyType=dis.read();
  String alg=dis.readUTF();
  if ("String_Node_Str".equals(alg)) {
    hashAlg=new SHA512Digest();
  }
 else   if ("String_Node_Str".equals(alg)) {
    hashAlg=new SHA256Digest();
  }
  init();
}

Fixed version (ground truth):
/** 
 * Reads a parameter set from an input stream.
 * @param is an input stream
 * @throws java.io.IOException
 */
public NTRUEncryptionKeyGenerationParameters(InputStream is) throws IOException {
  super(new SecureRandom(),-1);
  DataInputStream dis=new DataInputStream(is);
  N=dis.readInt();
  q=dis.readInt();
  df=dis.readInt();
  df1=dis.readInt();
  df2=dis.readInt();
  df3=dis.readInt();
  db=dis.readInt();
  dm0=dis.readInt();
  c=dis.readInt();
  minCallsR=dis.readInt();
  minCallsMask=dis.readInt();
  hashSeed=dis.readBoolean();
  oid=new byte[3];
  dis.readFully(oid);
  sparse=dis.readBoolean();
  fastFp=dis.readBoolean();
  polyType=dis.read();
  String alg=dis.readUTF();
  if ("String_Node_Str".equals(alg)) {
    hashAlg=new SHA512Digest();
  }
 else   if ("String_Node_Str".equals(alg)) {
    hashAlg=new SHA256Digest();
  }
  init();
}
Program: 52444
Project: 52444
Buggy source:
private static final long mul32x32_64(int i1,int i2){
  return ((long)i1) * i2;
}

Fixed version (ground truth):
private static final long mul32x32_64(int i1,int i2){
  return (i1 & 0xFFFFFFFFL) * i2;
}
Program: 52446
Project: 52446
Buggy source:
public int doFinal(final byte[] out,final int outOff) throws DataLengthException, IllegalStateException {
  if (outOff + BLOCK_SIZE > out.length) {
    throw new DataLengthException("String_Node_Str");
  }
  if (currentBlockOffset > 0) {
    processBlock();
  }
  long f0, f1, f2, f3;
  int b=h0 >>> 26;
  h0=h0 & 0x3ffffff;
  h1+=b;
  b=h1 >>> 26;
  h1=h1 & 0x3ffffff;
  h2+=b;
  b=h2 >>> 26;
  h2=h2 & 0x3ffffff;
  h3+=b;
  b=h3 >>> 26;
  h3=h3 & 0x3ffffff;
  h4+=b;
  b=h4 >>> 26;
  h4=h4 & 0x3ffffff;
  h0+=b * 5;
  int g0, g1, g2, g3, g4;
  g0=h0 + 5;
  b=g0 >>> 26;
  g0&=0x3ffffff;
  g1=h1 + b;
  b=g1 >>> 26;
  g1&=0x3ffffff;
  g2=h2 + b;
  b=g2 >>> 26;
  g2&=0x3ffffff;
  g3=h3 + b;
  b=g3 >>> 26;
  g3&=0x3ffffff;
  g4=h4 + b - (1 << 26);
  b=(g4 >>> 31) - 1;
  int nb=~b;
  h0=(h0 & nb) | (g0 & b);
  h1=(h1 & nb) | (g1 & b);
  h2=(h2 & nb) | (g2 & b);
  h3=(h3 & nb) | (g3 & b);
  h4=(h4 & nb) | (g4 & b);
  f0=(((h0) | (h1 << 26)) & 0xffffffffl) + (0xffffffffL & k0);
  f1=(((h1 >>> 6) | (h2 << 20)) & 0xffffffffl) + (0xffffffffL & k1);
  f2=(((h2 >>> 12) | (h3 << 14)) & 0xffffffffl) + (0xffffffffL & k2);
  f3=(((h3 >>> 18) | (h4 << 8)) & 0xffffffffl) + (0xffffffffL & k3);
  Pack.intToLittleEndian((int)f0,out,outOff);
  f1+=(f0 >>> 32);
  Pack.intToLittleEndian((int)f1,out,outOff + 4);
  f2+=(f1 >>> 32);
  Pack.intToLittleEndian((int)f2,out,outOff + 8);
  f3+=(f2 >>> 32);
  Pack.intToLittleEndian((int)f3,out,outOff + 12);
  reset();
  return BLOCK_SIZE;
}

Fixed version (ground truth):
public int doFinal(final byte[] out,final int outOff) throws DataLengthException, IllegalStateException {
  if (outOff + BLOCK_SIZE > out.length) {
    throw new DataLengthException("String_Node_Str");
  }
  if (currentBlockOffset > 0) {
    processBlock();
  }
  h1+=(h0 >>> 26);
  h0&=0x3ffffff;
  h2+=(h1 >>> 26);
  h1&=0x3ffffff;
  h3+=(h2 >>> 26);
  h2&=0x3ffffff;
  h4+=(h3 >>> 26);
  h3&=0x3ffffff;
  h0+=(h4 >>> 26) * 5;
  h4&=0x3ffffff;
  h1+=(h0 >>> 26);
  h0&=0x3ffffff;
  int g0, g1, g2, g3, g4, b;
  g0=h0 + 5;
  b=g0 >>> 26;
  g0&=0x3ffffff;
  g1=h1 + b;
  b=g1 >>> 26;
  g1&=0x3ffffff;
  g2=h2 + b;
  b=g2 >>> 26;
  g2&=0x3ffffff;
  g3=h3 + b;
  b=g3 >>> 26;
  g3&=0x3ffffff;
  g4=h4 + b - (1 << 26);
  b=(g4 >>> 31) - 1;
  int nb=~b;
  h0=(h0 & nb) | (g0 & b);
  h1=(h1 & nb) | (g1 & b);
  h2=(h2 & nb) | (g2 & b);
  h3=(h3 & nb) | (g3 & b);
  h4=(h4 & nb) | (g4 & b);
  long f0, f1, f2, f3;
  f0=(((h0) | (h1 << 26)) & 0xffffffffl) + (0xffffffffL & k0);
  f1=(((h1 >>> 6) | (h2 << 20)) & 0xffffffffl) + (0xffffffffL & k1);
  f2=(((h2 >>> 12) | (h3 << 14)) & 0xffffffffl) + (0xffffffffL & k2);
  f3=(((h3 >>> 18) | (h4 << 8)) & 0xffffffffl) + (0xffffffffL & k3);
  Pack.intToLittleEndian((int)f0,out,outOff);
  f1+=(f0 >>> 32);
  Pack.intToLittleEndian((int)f1,out,outOff + 4);
  f2+=(f1 >>> 32);
  Pack.intToLittleEndian((int)f2,out,outOff + 8);
  f3+=(f2 >>> 32);
  Pack.intToLittleEndian((int)f3,out,outOff + 12);
  reset();
  return BLOCK_SIZE;
}
Program: 52447
Project: 52447
Buggy source:
public SMIMECompressedTest(String name) throws Exception {
  super(name);
  msg=SMIMETestUtil.makeMimeBodyPart("String_Node_Str");
  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);
}

Fixed version (ground truth):
public SMIMECompressedTest(String name) throws Exception {
  super(name);
}
Program: 52448
Project: 52448
Buggy source:
private void sealedObjectTest() throws Exception {
  KeyPairGenerator kpg=KeyPairGenerator.getInstance("String_Node_Str");
  kpg.initialize(new ECGenParameterSpec("String_Node_Str"));
  KeyPair keyPair=kpg.generateKeyPair();
  Cipher cipher=Cipher.getInstance("String_Node_Str");
  cipher.init(Cipher.ENCRYPT_MODE,keyPair.getPublic());
  String toEncrypt="String_Node_Str";
  cipher.doFinal(toEncrypt.getBytes());
  SealedObject sealedObject=new SealedObject(toEncrypt,cipher);
  cipher.init(Cipher.DECRYPT_MODE,keyPair.getPrivate());
  String result=(String)sealedObject.getObject(cipher);
  isTrue("String_Node_Str",result.equals(toEncrypt));
}

Fixed version (ground truth):
private void sealedObjectTest() throws Exception {
  KeyPairGenerator kpg=KeyPairGenerator.getInstance("String_Node_Str");
  kpg.initialize(new ECGenParameterSpec("String_Node_Str"));
  KeyPair keyPair=kpg.generateKeyPair();
  Cipher cipher=Cipher.getInstance("String_Node_Str");
  cipher.init(Cipher.ENCRYPT_MODE,keyPair.getPublic());
  String toEncrypt="String_Node_Str";
  cipher.doFinal(toEncrypt.getBytes());
  SealedObject sealedObject=new SealedObject(toEncrypt,cipher);
  cipher.init(Cipher.DECRYPT_MODE,keyPair.getPrivate());
  String result=(String)sealedObject.getObject(cipher);
  isTrue("String_Node_Str",result.equals(toEncrypt));
  result=(String)sealedObject.getObject(keyPair.getPrivate());
  isTrue("String_Node_Str",result.equals(toEncrypt));
}
Program: 52451
Project: 52451
Buggy source:
int hash_2n_n_mask(byte[] out,int outOff,byte[] in,int inOff,byte[] mask,int maskOff){
  byte[] buf=new byte[2 * Sphincs256Config.HASH_BYTES];
  int i;
  for (i=0; i < 2 * Sphincs256Config.HASH_BYTES; i++) {
    buf[i]=(byte)(in[inOff + i] ^ mask[maskOff + i]);
  }
  int rv=hash_2n_n(out,outOff,buf,0);
  return rv;
}

Fixed version (ground truth):
int hash_2n_n_mask(byte[] out,int outOff,byte[] in,int inOff,byte[] mask,int maskOff){
  byte[] buf=new byte[2 * SPHINCS256Config.HASH_BYTES];
  int i;
  for (i=0; i < 2 * SPHINCS256Config.HASH_BYTES; i++) {
    buf[i]=(byte)(in[inOff + i] ^ mask[maskOff + i]);
  }
  int rv=hash_2n_n(out,outOff,buf,0);
  return rv;
}
Program: 52452
Project: 52452
Buggy source:
int hash_n_n_mask(byte[] out,int outOff,byte[] in,int inOff,byte[] mask,int maskOff){
  byte[] buf=new byte[Sphincs256Config.HASH_BYTES];
  int i;
  for (i=0; i < Sphincs256Config.HASH_BYTES; i++) {
    buf[i]=(byte)(in[inOff + i] ^ mask[maskOff + i]);
  }
  return hash_n_n(out,outOff,buf,0);
}

Fixed version (ground truth):
int hash_n_n_mask(byte[] out,int outOff,byte[] in,int inOff,byte[] mask,int maskOff){
  byte[] buf=new byte[SPHINCS256Config.HASH_BYTES];
  int i;
  for (i=0; i < SPHINCS256Config.HASH_BYTES; i++) {
    buf[i]=(byte)(in[inOff + i] ^ mask[maskOff + i]);
  }
  return hash_n_n(out,outOff,buf,0);
}
Program: 52454
Project: 52454
Buggy source:
static int horst_sign(HashFunctions hs,byte[] sig,int sigOff,byte[] pk,long[] sigbytes,byte[] seed,byte[] masks,byte[] m_hash){
  byte[] sk=new byte[HORST_T * HORST_SKBYTES];
  int idx;
  int i, j, k;
  int sigpos=sigOff;
  byte[] tree=new byte[(2 * HORST_T - 1) * Sphincs256Config.HASH_BYTES];
  expand_seed(sk,seed);
  for (i=0; i < HORST_T; i++)   hs.hash_n_n(tree,(HORST_T - 1 + i) * Sphincs256Config.HASH_BYTES,sk,i * HORST_SKBYTES);
  long offset_in, offset_out;
  for (i=0; i < HORST_LOGT; i++) {
    offset_in=(1 << (HORST_LOGT - i)) - 1;
    offset_out=(1 << (HORST_LOGT - i - 1)) - 1;
    for (j=0; j < (1 << (HORST_LOGT - i - 1)); j++)     hs.hash_2n_n_mask(tree,(int)((offset_out + j) * Sphincs256Config.HASH_BYTES),tree,(int)((offset_in + 2 * j) * Sphincs256Config.HASH_BYTES),masks,2 * i * Sphincs256Config.HASH_BYTES);
  }
  for (j=63 * Sphincs256Config.HASH_BYTES; j < 127 * Sphincs256Config.HASH_BYTES; j++)   sig[sigpos++]=tree[j];
  for (i=0; i < HORST_K; i++) {
    idx=(m_hash[2 * i] & 0xff) + ((m_hash[2 * i + 1] & 0xff) << 8);
    for (k=0; k < HORST_SKBYTES; k++)     sig[sigpos++]=sk[idx * HORST_SKBYTES + k];
    idx+=(HORST_T - 1);
    for (j=0; j < HORST_LOGT - 6; j++) {
      idx=((idx & 1) != 0) ? idx + 1 : idx - 1;
      for (k=0; k < Sphincs256Config.HASH_BYTES; k++)       sig[sigpos++]=tree[idx * Sphincs256Config.HASH_BYTES + k];
      idx=(idx - 1) / 2;
    }
  }
  for (i=0; i < Sphincs256Config.HASH_BYTES; i++)   pk[i]=tree[i];
  sigbytes[0]=HORST_SIGBYTES;
  return 0;
}

Fixed version (ground truth):
static int horst_sign(HashFunctions hs,byte[] sig,int sigOff,byte[] pk,long[] sigbytes,byte[] seed,byte[] masks,byte[] m_hash){
  byte[] sk=new byte[HORST_T * HORST_SKBYTES];
  int idx;
  int i, j, k;
  int sigpos=sigOff;
  byte[] tree=new byte[(2 * HORST_T - 1) * SPHINCS256Config.HASH_BYTES];
  expand_seed(sk,seed);
  for (i=0; i < HORST_T; i++)   hs.hash_n_n(tree,(HORST_T - 1 + i) * SPHINCS256Config.HASH_BYTES,sk,i * HORST_SKBYTES);
  long offset_in, offset_out;
  for (i=0; i < HORST_LOGT; i++) {
    offset_in=(1 << (HORST_LOGT - i)) - 1;
    offset_out=(1 << (HORST_LOGT - i - 1)) - 1;
    for (j=0; j < (1 << (HORST_LOGT - i - 1)); j++)     hs.hash_2n_n_mask(tree,(int)((offset_out + j) * SPHINCS256Config.HASH_BYTES),tree,(int)((offset_in + 2 * j) * SPHINCS256Config.HASH_BYTES),masks,2 * i * SPHINCS256Config.HASH_BYTES);
  }
  for (j=63 * SPHINCS256Config.HASH_BYTES; j < 127 * SPHINCS256Config.HASH_BYTES; j++)   sig[sigpos++]=tree[j];
  for (i=0; i < HORST_K; i++) {
    idx=(m_hash[2 * i] & 0xff) + ((m_hash[2 * i + 1] & 0xff) << 8);
    for (k=0; k < HORST_SKBYTES; k++)     sig[sigpos++]=sk[idx * HORST_SKBYTES + k];
    idx+=(HORST_T - 1);
    for (j=0; j < HORST_LOGT - 6; j++) {
      idx=((idx & 1) != 0) ? idx + 1 : idx - 1;
      for (k=0; k < SPHINCS256Config.HASH_BYTES; k++)       sig[sigpos++]=tree[idx * SPHINCS256Config.HASH_BYTES + k];
      idx=(idx - 1) / 2;
    }
  }
  for (i=0; i < SPHINCS256Config.HASH_BYTES; i++)   pk[i]=tree[i];
  sigbytes[0]=HORST_SIGBYTES;
  return 0;
}
Program: 52456
Project: 52456
Buggy source:
/** 
 * Base constructor.
 * @param data the octets making up the bit string.
 * @param padBits the number of extra bits at the end of the string.
 */
public ASN1BitString(byte[] data,int padBits){
  this.data=Arrays.clone(data);
  this.padBits=padBits;
}

Fixed version (ground truth):
/** 
 * Base constructor.
 * @param data the octets making up the bit string.
 * @param padBits the number of extra bits at the end of the string.
 */
public ASN1BitString(byte[] data,int padBits){
  if (data.length == 0 && padBits != 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (padBits > 7) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.data=Arrays.clone(data);
  this.padBits=padBits;
}
Program: 52457
Project: 52457
Buggy source:
public void performTest() throws Exception {
  KeyUsage k=new KeyUsage(KeyUsage.digitalSignature);
  if ((k.getBytes()[0] != (byte)KeyUsage.digitalSignature) || (k.getPadBits() != 7)) {
    fail("String_Node_Str");
  }
  k=new KeyUsage(KeyUsage.nonRepudiation);
  if ((k.getBytes()[0] != (byte)KeyUsage.nonRepudiation) || (k.getPadBits() != 6)) {
    fail("String_Node_Str");
  }
  k=new KeyUsage(KeyUsage.keyEncipherment);
  if ((k.getBytes()[0] != (byte)KeyUsage.keyEncipherment) || (k.getPadBits() != 5)) {
    fail("String_Node_Str");
  }
  k=new KeyUsage(KeyUsage.cRLSign);
  if ((k.getBytes()[0] != (byte)KeyUsage.cRLSign) || (k.getPadBits() != 1)) {
    fail("String_Node_Str");
  }
  k=new KeyUsage(KeyUsage.decipherOnly);
  if ((k.getBytes()[1] != (byte)(KeyUsage.decipherOnly >> 8)) || (k.getPadBits() != 7)) {
    fail("String_Node_Str");
  }
  try {
    ASN1Primitive.fromByteArray(new DERBitString(new byte[0],0).getEncoded());
  }
 catch (  IOException e) {
    fail(e.toString());
  }
  testRandomPadBits();
}

Fixed version (ground truth):
public void performTest() throws Exception {
  KeyUsage k=new KeyUsage(KeyUsage.digitalSignature);
  if ((k.getBytes()[0] != (byte)KeyUsage.digitalSignature) || (k.getPadBits() != 7)) {
    fail("String_Node_Str");
  }
  k=new KeyUsage(KeyUsage.nonRepudiation);
  if ((k.getBytes()[0] != (byte)KeyUsage.nonRepudiation) || (k.getPadBits() != 6)) {
    fail("String_Node_Str");
  }
  k=new KeyUsage(KeyUsage.keyEncipherment);
  if ((k.getBytes()[0] != (byte)KeyUsage.keyEncipherment) || (k.getPadBits() != 5)) {
    fail("String_Node_Str");
  }
  k=new KeyUsage(KeyUsage.cRLSign);
  if ((k.getBytes()[0] != (byte)KeyUsage.cRLSign) || (k.getPadBits() != 1)) {
    fail("String_Node_Str");
  }
  k=new KeyUsage(KeyUsage.decipherOnly);
  if ((k.getBytes()[1] != (byte)(KeyUsage.decipherOnly >> 8)) || (k.getPadBits() != 7)) {
    fail("String_Node_Str");
  }
  try {
    ASN1Primitive.fromByteArray(new DERBitString(new byte[0],0).getEncoded());
  }
 catch (  IOException e) {
    fail(e.toString());
  }
  testRandomPadBits();
  testZeroLengthStrings();
}
Program: 52458
Project: 52458
Buggy source:
@Override public int read(byte[] b,int off,int len){
  int bytesToRead=Math.min(buffer.available(),len);
  buffer.removeData(b,off,bytesToRead,0);
  return bytesToRead;
}

Fixed version (ground truth):
public int read(byte[] b,int off,int len){
  int bytesToRead=Math.min(buffer.available(),len);
  buffer.removeData(b,off,bytesToRead,0);
  return bytesToRead;
}
Program: 52459
Project: 52459
Buggy source:
@Override public int available(){
  return buffer.available();
}

Fixed version (ground truth):
public int available(){
  return buffer.available();
}
Program: 52460
Project: 52460
Buggy source:
@Override public long skip(long n){
  int bytesToRemove=Math.min((int)n,buffer.available());
  buffer.removeData(bytesToRemove);
  return bytesToRemove;
}

Fixed version (ground truth):
public long skip(long n){
  int bytesToRemove=Math.min((int)n,buffer.available());
  buffer.removeData(bytesToRemove);
  return bytesToRemove;
}
Program: 52461
Project: 52461
Buggy source:
@Override public void close(){
}

Fixed version (ground truth):
public void close(){
}
Program: 52462
Project: 52462
Buggy source:
@Override public void write(byte[] b,int off,int len) throws IOException {
  buffer.addData(b,off,len);
}

Fixed version (ground truth):
public void write(byte[] b,int off,int len) throws IOException {
  buffer.addData(b,off,len);
}
Program: 52463
Project: 52463
Buggy source:
@Test public void testSkip(){
  ByteQueueInputStream in=new ByteQueueInputStream();
  assertEquals(0,in.skip(10));
  in.addBytes(new byte[2]);
  assertEquals(2,in.skip(2));
  assertEquals(0,in.available());
  in.addBytes(new byte[10]);
  assertEquals(5,in.skip(5));
  assertEquals(5,in.available());
  assertEquals(5,in.skip(20));
  assertEquals(0,in.available());
  in.close();
}

Fixed version (ground truth):
public void testSkip(){
  ByteQueueInputStream in=new ByteQueueInputStream();
  assertEquals(0,in.skip(10));
  in.addBytes(new byte[2]);
  assertEquals(2,in.skip(2));
  assertEquals(0,in.available());
  in.addBytes(new byte[10]);
  assertEquals(5,in.skip(5));
  assertEquals(5,in.available());
  assertEquals(5,in.skip(20));
  assertEquals(0,in.available());
  in.close();
}
Program: 52464
Project: 52464
Buggy source:
@Test public void testReadArray(){
  ByteQueueInputStream in=new ByteQueueInputStream();
  in.addBytes(new byte[]{0x01,0x02,0x03,0x04,0x05,0x06});
  byte[] buffer=new byte[5];
  assertEquals(1,in.read(buffer,2,1));
  assertArrayEquals(new byte[]{0x00,0x00,0x01,0x00,0x00},buffer);
  assertEquals(5,in.read(buffer));
  assertArrayEquals(new byte[]{0x02,0x03,0x04,0x05,0x06},buffer);
  in.addBytes(new byte[]{0x01,0x02,0x03});
  assertEquals(3,in.read(buffer));
  assertArrayEquals(new byte[]{0x01,0x02,0x03,0x05,0x06},buffer);
  in.close();
}

Fixed version (ground truth):
public void testReadArray(){
  ByteQueueInputStream in=new ByteQueueInputStream();
  in.addBytes(new byte[]{0x01,0x02,0x03,0x04,0x05,0x06});
  byte[] buffer=new byte[5];
  assertEquals(1,in.read(buffer,2,1));
  assertArrayEquals(new byte[]{0x00,0x00,0x01,0x00,0x00},buffer);
  assertEquals(5,in.read(buffer));
  assertArrayEquals(new byte[]{0x02,0x03,0x04,0x05,0x06},buffer);
  in.addBytes(new byte[]{0x01,0x02,0x03});
  assertEquals(3,in.read(buffer));
  assertArrayEquals(new byte[]{0x01,0x02,0x03,0x05,0x06},buffer);
  in.close();
}
Program: 52465
Project: 52465
Buggy source:
@Test public void testAvailable(){
  ByteQueueInputStream in=new ByteQueueInputStream();
  assertEquals(0,in.available());
  in.addBytes(new byte[10]);
  assertEquals(10,in.available());
  in.addBytes(new byte[5]);
  assertEquals(15,in.available());
  in.read();
  assertEquals(14,in.available());
  in.read(new byte[4]);
  assertEquals(10,in.available());
  in.close();
}

Fixed version (ground truth):
public void testAvailable(){
  ByteQueueInputStream in=new ByteQueueInputStream();
  assertEquals(0,in.available());
  in.addBytes(new byte[10]);
  assertEquals(10,in.available());
  in.addBytes(new byte[5]);
  assertEquals(15,in.available());
  in.read();
  assertEquals(14,in.available());
  in.read(new byte[4]);
  assertEquals(10,in.available());
  in.close();
}
Program: 52466
Project: 52466
Buggy source:
@Test public void testRead(){
  ByteQueueInputStream in=new ByteQueueInputStream();
  in.addBytes(new byte[]{0x01,0x02});
  in.addBytes(new byte[]{0x03});
  assertEquals(0x01,in.read());
  assertEquals(0x02,in.read());
  assertEquals(0x03,in.read());
  assertEquals(-1,in.read());
  in.close();
}

Fixed version (ground truth):
public void testRead(){
  ByteQueueInputStream in=new ByteQueueInputStream();
  in.addBytes(new byte[]{0x01,0x02});
  in.addBytes(new byte[]{0x03});
  assertEquals(0x01,in.read());
  assertEquals(0x02,in.read());
  assertEquals(0x03,in.read());
  assertEquals(-1,in.read());
  in.close();
}
Program: 52467
Project: 52467
Buggy source:
@Test public void testPeek(){
  ByteQueueInputStream in=new ByteQueueInputStream();
  byte[] buffer=new byte[5];
  assertEquals(0,in.peek(buffer));
  assertArrayEquals(new byte[]{0x00,0x00,0x00,0x00,0x00},buffer);
  in.addBytes(new byte[]{0x01,0x02,0x03,0x04,0x05,0x06});
  assertEquals(5,in.peek(buffer));
  assertArrayEquals(new byte[]{0x01,0x02,0x03,0x04,0x05},buffer);
  assertEquals(6,in.available());
  in.read();
  assertEquals(5,in.peek(buffer));
  assertArrayEquals(new byte[]{0x02,0x03,0x04,0x05,0x06},buffer);
  assertEquals(5,in.available());
  in.close();
}

Fixed version (ground truth):
public void testPeek(){
  ByteQueueInputStream in=new ByteQueueInputStream();
  byte[] buffer=new byte[5];
  assertEquals(0,in.peek(buffer));
  assertArrayEquals(new byte[]{0x00,0x00,0x00,0x00,0x00},buffer);
  in.addBytes(new byte[]{0x01,0x02,0x03,0x04,0x05,0x06});
  assertEquals(5,in.peek(buffer));
  assertArrayEquals(new byte[]{0x01,0x02,0x03,0x04,0x05},buffer);
  assertEquals(6,in.available());
  in.read();
  assertEquals(5,in.peek(buffer));
  assertArrayEquals(new byte[]{0x02,0x03,0x04,0x05,0x06},buffer);
  assertEquals(5,in.available());
  in.close();
}
Program: 52468
Project: 52468
Buggy source:
/** 
 * close the digest, producing the final digest value. The doFinal call leaves the digest reset. Key, salt and personal string remain. 
 * @param out the array the digest is to be copied into.
 * @param outOffset the offset into the out array the digest is to start at.
 */
public int doFinal(byte[] out,int outOffset){
  f0=0xFFFFFFFFFFFFFFFFL;
  t0+=bufferPos;
  if ((t0 < 0) && (bufferPos > -t0)) {
    t1++;
  }
  compress(buffer,0);
  Arrays.fill(buffer,(byte)0);
  Arrays.fill(internalState,0L);
  for (int i=outOffset; i < chainValue.length; i++) {
    System.arraycopy(long2bytes(chainValue[i]),0,out,i * 8,8);
  }
  Arrays.fill(chainValue,0L);
  reset();
  return digestLength;
}

Fixed version (ground truth):
/** 
 * close the digest, producing the final digest value. The doFinal call leaves the digest reset. Key, salt and personal string remain. 
 * @param out the array the digest is to be copied into.
 * @param outOffset the offset into the out array the digest is to start at.
 */
public int doFinal(byte[] out,int outOffset){
  f0=0xFFFFFFFFFFFFFFFFL;
  t0+=bufferPos;
  if ((t0 < 0) && (bufferPos > -t0)) {
    t1++;
  }
  compress(buffer,0);
  Arrays.fill(buffer,(byte)0);
  Arrays.fill(internalState,0L);
  for (int i=0; i < chainValue.length; i++) {
    System.arraycopy(long2bytes(chainValue[i]),0,out,outOffset + i * 8,8);
  }
  Arrays.fill(chainValue,0L);
  reset();
  return digestLength;
}
Program: 52469
Project: 52469
Buggy source:
public void performTest() throws Exception {
  Blake2bDigest blake2bkeyed=new Blake2bDigest(Hex.decode(keyedTestVectors[0][1]));
  for (int tv=0; tv < keyedTestVectors.length; tv++) {
    byte[] input=Hex.decode(keyedTestVectors[tv][0]);
    blake2bkeyed.reset();
    blake2bkeyed.update(input,0,input.length);
    byte[] keyedHash=new byte[64];
    blake2bkeyed.doFinal(keyedHash,0);
    if (!Arrays.areEqual(Hex.decode(keyedTestVectors[tv][2]),keyedHash)) {
      fail("String_Node_Str",keyedTestVectors[tv][2],new String(Hex.encode(keyedHash)));
    }
  }
  Blake2bDigest blake2bunkeyed=new Blake2bDigest();
  for (int i=0; i < unkeyedTestVectors.length; i++) {
    try {
      byte[] unkeyedInput=unkeyedTestVectors[i][1].getBytes("String_Node_Str");
      for (int j=0; j < unkeyedInput.length; j++) {
        blake2bunkeyed.update(unkeyedInput[j]);
      }
    }
 catch (    UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    byte[] unkeyedHash=new byte[64];
    blake2bunkeyed.doFinal(unkeyedHash,0);
    blake2bunkeyed.reset();
    if (!Arrays.areEqual(Hex.decode(unkeyedTestVectors[i][0]),unkeyedHash)) {
      fail("String_Node_Str",unkeyedTestVectors[i][0],new String(Hex.encode(unkeyedHash)));
    }
  }
}

Fixed version (ground truth):
public void performTest() throws Exception {
  Blake2bDigest blake2bkeyed=new Blake2bDigest(Hex.decode(keyedTestVectors[0][1]));
  for (int tv=0; tv < keyedTestVectors.length; tv++) {
    byte[] input=Hex.decode(keyedTestVectors[tv][0]);
    blake2bkeyed.reset();
    blake2bkeyed.update(input,0,input.length);
    byte[] keyedHash=new byte[64];
    blake2bkeyed.doFinal(keyedHash,0);
    if (!Arrays.areEqual(Hex.decode(keyedTestVectors[tv][2]),keyedHash)) {
      fail("String_Node_Str",keyedTestVectors[tv][2],new String(Hex.encode(keyedHash)));
    }
    offsetTest(blake2bkeyed,input,keyedHash);
  }
  Blake2bDigest blake2bunkeyed=new Blake2bDigest();
  for (int i=0; i < unkeyedTestVectors.length; i++) {
    try {
      byte[] unkeyedInput=unkeyedTestVectors[i][1].getBytes("String_Node_Str");
      for (int j=0; j < unkeyedInput.length; j++) {
        blake2bunkeyed.update(unkeyedInput[j]);
      }
    }
 catch (    UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    byte[] unkeyedHash=new byte[64];
    blake2bunkeyed.doFinal(unkeyedHash,0);
    blake2bunkeyed.reset();
    if (!Arrays.areEqual(Hex.decode(unkeyedTestVectors[i][0]),unkeyedHash)) {
      fail("String_Node_Str",unkeyedTestVectors[i][0],new String(Hex.encode(unkeyedHash)));
    }
  }
}
Program: 52470
Project: 52470
Buggy source:
public void performTest(){
  byte[] resBuf=new byte[digest.getDigestSize()];
  for (int i=0; i < input.length - 1; i++) {
    byte[] m=toByteArray(input[i]);
    vectorTest(digest,i,resBuf,m,Hex.decode(results[i]));
  }
  byte[] lastV=toByteArray(input[input.length - 1]);
  byte[] lastDigest=Hex.decode(results[input.length - 1]);
  vectorTest(digest,input.length - 1,resBuf,lastV,Hex.decode(results[input.length - 1]));
  testClone(resBuf,lastV,lastDigest);
  testMemo(resBuf,lastV,lastDigest);
  if (digest instanceof EncodableDigest) {
    testEncodedState(resBuf,lastV,lastDigest);
  }
}

Fixed version (ground truth):
public void performTest(){
  byte[] resBuf=new byte[digest.getDigestSize()];
  for (int i=0; i < input.length - 1; i++) {
    byte[] m=toByteArray(input[i]);
    vectorTest(digest,i,resBuf,m,Hex.decode(results[i]));
  }
  offsetTest(digest,0,toByteArray(input[0]),Hex.decode(results[0]));
  byte[] lastV=toByteArray(input[input.length - 1]);
  byte[] lastDigest=Hex.decode(results[input.length - 1]);
  vectorTest(digest,input.length - 1,resBuf,lastV,Hex.decode(results[input.length - 1]));
  testClone(resBuf,lastV,lastDigest);
  testMemo(resBuf,lastV,lastDigest);
  if (digest instanceof EncodableDigest) {
    testEncodedState(resBuf,lastV,lastDigest);
  }
}
Program: 52471
Project: 52471
Buggy source:
private static void init() throws Exception {
  if (!_initialised) {
    _initialised=true;
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _reciDN2="String_Node_Str";
    _reciKP2=CMSTestUtil.makeKeyPair();
    _reciCert2=CMSTestUtil.makeCertificate(_reciKP2,_reciDN2,_signKP,_signDN);
  }
}

Fixed version (ground truth):
private static void init() throws Exception {
  if (!_initialised) {
    if (Security.getProvider("String_Node_Str") == null) {
      Security.addProvider(new BouncyCastleProvider());
    }
    _initialised=true;
    _signDN="String_Node_Str";
    _signKP=CMSTestUtil.makeKeyPair();
    _reciDN="String_Node_Str";
    _reciKP=CMSTestUtil.makeKeyPair();
    _reciCert=CMSTestUtil.makeCertificate(_reciKP,_reciDN,_signKP,_signDN);
    _reciDN2="String_Node_Str";
    _reciKP2=CMSTestUtil.makeKeyPair();
    _reciCert2=CMSTestUtil.makeCertificate(_reciKP2,_reciDN2,_signKP,_signDN);
  }
}
Program: 52472
Project: 52472
Buggy source:
public void testSignAttachmentOnly() throws Exception {
  MimeMessage m=loadMessage("String_Node_Str");
  List certList=new ArrayList();
  certList.add(_signCert);
  certList.add(_origCert);
  Store certs=new JcaCertStore(certList);
  ASN1EncodableVector signedAttrs=generateSignedAttributes();
  SMIMESignedGenerator gen=new SMIMESignedGenerator("String_Node_Str");
  gen.addSignerInfoGenerator(new JcaSimpleSignerInfoGeneratorBuilder().setProvider(BC).setSignedAttributeGenerator(new AttributeTable(signedAttrs)).build("String_Node_Str",_signKP.getPrivate(),_signCert));
  gen.addCertificates(certs);
  MimeMultipart mm=gen.generate(m);
  SMIMESigned s=new SMIMESigned(mm);
  verifySigners(s.getCertificates(),s.getSignerInfos());
  SMIMESignedParser sp=new SMIMESignedParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(),mm);
  verifySigners(sp.getCertificates(),sp.getSignerInfos());
}

Fixed version (ground truth):
public void testSignAttachmentOnly() throws Exception {
  MimeMessage m=loadMessage("String_Node_Str");
  List certList=new ArrayList();
  certList.add(_signCert);
  certList.add(_origCert);
  Store certs=new JcaCertStore(certList);
  ASN1EncodableVector signedAttrs=generateSignedAttributes();
  SMIMESignedGenerator gen=new SMIMESignedGenerator("String_Node_Str");
  gen.addSignerInfoGenerator(new JcaSimpleSignerInfoGeneratorBuilder().setProvider(BC).setSignedAttributeGenerator(new AttributeTable(signedAttrs)).build("String_Node_Str",_signKP.getPrivate(),_signCert));
  gen.addCertificates(certs);
  m.writeTo(System.err);
  MimeMultipart mm=gen.generate(m);
  mm.writeTo(System.err);
  SMIMESigned s=new SMIMESigned(mm);
  verifySigners(s.getCertificates(),s.getSignerInfos());
  SMIMESignedParser sp=new SMIMESignedParser(new JcaDigestCalculatorProviderBuilder().setProvider(BC).build(),mm);
  verifySigners(sp.getCertificates(),sp.getSignerInfos());
}
Program: 52473
Project: 52473
Buggy source:
/** 
 * Write out the contents of the provided file as a literal data packet in partial packet format.
 * @param out the stream to write the literal data to.
 * @param fileType the {@link PGPLiteralData} type to use for the file data.
 * @param file the file to write the contents of.
 * @param buffer buffer to be used to chunk the file into partial packets.
 * @see {@link PGPLiteralDataGenerator#open(OutputStream,char,String,Date,byte[])}.
 * @throws IOException if an error occurs reading the file or writing to the output stream.
 */
public static void writeFileToLiteralData(OutputStream out,char fileType,File file,byte[] buffer) throws IOException {
  PGPLiteralDataGenerator lData=new PGPLiteralDataGenerator();
  OutputStream pOut=lData.open(out,fileType,file.getName(),new Date(file.lastModified()),buffer);
  pipeFileContents(file,pOut,buffer.length);
}

Fixed version (ground truth):
/** 
 * Write out the contents of the provided file as a literal data packet in partial packet format.
 * @param out the stream to write the literal data to.
 * @param fileType the {@link PGPLiteralData} type to use for the file data.
 * @param file the file to write the contents of.
 * @param buffer buffer to be used to chunk the file into partial packets.
 * @see PGPLiteralDataGenerator#open(OutputStream, char, String, Date, byte[]).
 * @throws IOException if an error occurs reading the file or writing to the output stream.
 */
public static void writeFileToLiteralData(OutputStream out,char fileType,File file,byte[] buffer) throws IOException {
  PGPLiteralDataGenerator lData=new PGPLiteralDataGenerator();
  OutputStream pOut=lData.open(out,fileType,file.getName(),new Date(file.lastModified()),buffer);
  pipeFileContents(file,pOut,buffer.length);
}
Program: 52474
Project: 52474
Buggy source:
/** 
 * Builds CCPD request.
 * @param messageImprint - the message imprint to include.
 * @return
 * @throws DVCSException
 */
public DVCSRequest build(MessageImprint messageImprint) throws DVCSException {
  Data data=new Data(messageImprint.toASN1Structure());
  return createDVCRequest(data);
}

Fixed version (ground truth):
/** 
 * Builds CCPD request.
 * @param messageImprint - the message imprint to include.
 * @return a new DVCSRequest based on the state of this builder.
 * @throws DVCSException if an issue occurs during construction.
 */
public DVCSRequest build(MessageImprint messageImprint) throws DVCSException {
  Data data=new Data(messageImprint.toASN1Structure());
  return createDVCRequest(data);
}
Program: 52475
Project: 52475
Buggy source:
/** 
 * Get MessageImprint value
 * @return
 */
public MessageImprint getMessageImprint(){
  return new MessageImprint(data.getMessageImprint());
}

Fixed version (ground truth):
/** 
 * Get MessageImprint value
 * @return the message imprint data as a MessageImprint object.
 */
public MessageImprint getMessageImprint(){
  return new MessageImprint(data.getMessageImprint());
}
Program: 52476
Project: 52476
Buggy source:
/** 
 * Get contained message (data to be certified).
 * @return
 */
public byte[] getMessage(){
  return data.getMessage().getOctets();
}

Fixed version (ground truth):
/** 
 * Get contained message (data to be certified).
 * @return the contained message.
 */
public byte[] getMessage(){
  return data.getMessage().getOctets();
}
Program: 52477
Project: 52477
Buggy source:
/** 
 * Add a given extension field.
 * @param oid the OID defining the extension type.
 * @param isCritical true if the extension is critical, false otherwise.
 * @param value the ASN.1 structure that forms the extension's value.
 * @return this builder object.
 * @throws DVCSException if there is an issue encoding the extension for adding.
 */
public void addExtension(ASN1ObjectIdentifier oid,boolean isCritical,ASN1Encodable value) throws DVCSException {
  try {
    extGenerator.addExtension(oid,isCritical,value);
  }
 catch (  IOException e) {
    throw new DVCSException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Add a given extension field.
 * @param oid the OID defining the extension type.
 * @param isCritical true if the extension is critical, false otherwise.
 * @param value the ASN.1 structure that forms the extension's value.
 * @throws DVCSException if there is an issue encoding the extension for adding.
 */
public void addExtension(ASN1ObjectIdentifier oid,boolean isCritical,ASN1Encodable value) throws DVCSException {
  try {
    extGenerator.addExtension(oid,isCritical,value);
  }
 catch (  IOException e) {
    throw new DVCSException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 52478
Project: 52478
Buggy source:
/** 
 * Get DVCS version of request.
 * @return
 */
public int getVersion(){
  return data.getVersion();
}

Fixed version (ground truth):
/** 
 * Get DVCS version of request.
 * @return the version number of the request.
 */
public int getVersion(){
  return data.getVersion();
}
Program: 52479
Project: 52479
Buggy source:
/** 
 * Converts to corresponding ASN.1 structure (DVCSRequestInformation).
 * @return
 */
public DVCSRequestInformation toASN1Structure(){
  return data;
}

Fixed version (ground truth):
/** 
 * Converts to corresponding ASN.1 structure (DVCSRequestInformation).
 * @return a DVCSRequestInformation object.
 */
public DVCSRequestInformation toASN1Structure(){
  return data;
}
Program: 52480
Project: 52480
Buggy source:
/** 
 * Constructs DVCRequestInfo from DVCSRequestInformation ASN.1 structure.
 * @param data
 */
public DVCSRequestInfo(DVCSRequestInformation data){
  this.data=data;
}

Fixed version (ground truth):
/** 
 * Constructs DVCRequestInfo from DVCSRequestInformation ASN.1 structure.
 * @param data a DVCSRequestInformation to populate this object with.
 */
public DVCSRequestInfo(DVCSRequestInformation data){
  this.data=data;
}
Program: 52481
Project: 52481
Buggy source:
/** 
 * Get data locations, where the copy of request Data can be obtained. Note: the exact meaning of field is up to applications. Note: this field can be set by DVCS.
 * @return
 */
public GeneralNames getDataLocations(){
  return data.getDataLocations();
}

Fixed version (ground truth):
/** 
 * Get data locations, where the copy of request Data can be obtained. Note: the exact meaning of field is up to applications. Note: this field can be set by DVCS.
 * @return the DVCS dataLocations object, or null if not set.
 */
public GeneralNames getDataLocations(){
  return data.getDataLocations();
}
Program: 52482
Project: 52482
Buggy source:
/** 
 * Get names of DVCS servers. Note: this field can be set by DVCS.
 * @return
 */
public GeneralNames getDVCSNames(){
  return data.getDVCS();
}

Fixed version (ground truth):
/** 
 * Get names of DVCS servers. Note: this field can be set by DVCS.
 * @return the DVCS names object, or null if not set.
 */
public GeneralNames getDVCSNames(){
  return data.getDVCS();
}
Program: 52483
Project: 52483
Buggy source:
/** 
 * Get names of requesting entity, if set.
 * @return
 */
public GeneralNames getRequester(){
  return data.getRequester();
}

Fixed version (ground truth):
/** 
 * Get names of requesting entity, if set.
 * @return the requesting entity, or null.
 */
public GeneralNames getRequester(){
  return data.getRequester();
}
Program: 52484
Project: 52484
Buggy source:
/** 
 * Build DVCS request to VPKC service.
 * @throws DVCSException
 */
public DVCSRequest build() throws DVCSException {
  Data data=new Data((TargetEtcChain[])chains.toArray(new TargetEtcChain[chains.size()]));
  return createDVCRequest(data);
}

Fixed version (ground truth):
/** 
 * Build DVCS request to VPKC service.
 * @return a new DVCSRequest based on the state of this builder.
 * @throws DVCSException if an issue occurs during construction.
 */
public DVCSRequest build() throws DVCSException {
  Data data=new Data((TargetEtcChain[])chains.toArray(new TargetEtcChain[chains.size()]));
  return createDVCRequest(data);
}
Program: 52485
Project: 52485
Buggy source:
/** 
 * Build VSD request from CMS SignedData object.
 * @param document
 * @return
 * @throws DVCSException
 */
public DVCSRequest build(CMSSignedData document) throws DVCSException {
  try {
    Data data=new Data(document.getEncoded());
    return createDVCRequest(data);
  }
 catch (  IOException e) {
    throw new DVCSException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Build VSD request from CMS SignedData object.
 * @param document the CMS SignedData to include in the request.
 * @return a new DVCSRequest based on the state of this builder.
 * @throws DVCSException if an issue occurs during construction.
 */
public DVCSRequest build(CMSSignedData document) throws DVCSException {
  try {
    Data data=new Data(document.getEncoded());
    return createDVCRequest(data);
  }
 catch (  IOException e) {
    throw new DVCSException("String_Node_Str",e);
  }
}
Program: 52486
Project: 52486
Buggy source:
/** 
 * Get the CMS SignedData object represented by the encoded message.
 * @return
 */
public CMSSignedData getParsedMessage(){
  return doc;
}

Fixed version (ground truth):
/** 
 * Get the CMS SignedData object represented by the encoded message.
 * @return the parsed contents of the contained message as a CMS SignedData object.
 */
public CMSSignedData getParsedMessage(){
  return doc;
}
Program: 52487
Project: 52487
Buggy source:
/** 
 * Get contained message (data to be certified).
 * @return
 */
public byte[] getMessage(){
  return data.getMessage().getOctets();
}

Fixed version (ground truth):
/** 
 * Get contained message (data to be certified).
 * @return the contained message.
 */
public byte[] getMessage(){
  return data.getMessage().getOctets();
}
Program: 52488
Project: 52488
Buggy source:
/** 
 * Return true if the passed in objectIdentifier has a "human friendly" name associated with it.
 * @param objectIdentifier the OID of interest.
 * @boolean true if a name lookup exists for the OID, false otherwise.
 */
boolean hasAlgorithmName(ASN1ObjectIdentifier objectIdentifier);

Fixed version (ground truth):
/** 
 * Return true if the passed in objectIdentifier has a "human friendly" name associated with it.
 * @param objectIdentifier the OID of interest.
 * @return true if a name lookup exists for the OID, false otherwise.
 */
boolean hasAlgorithmName(ASN1ObjectIdentifier objectIdentifier);
Program: 52489
Project: 52489
Buggy source:
/** 
 * @deprecated use toASN1Structure
 * @return
 */
public TSTInfo toTSTInfo(){
  return tstInfo;
}

Fixed version (ground truth):
/** 
 * @deprecated use toASN1Structure
 */
public TSTInfo toTSTInfo(){
  return tstInfo;
}
Program: 52490
Project: 52490
Buggy source:
/** 
 * Constructor used by the   {@link McElieceKeyFactory}.
 * @param n            the length of the code
 * @param k            the dimension of the code
 * @param encFieldPoly the encoded field polynomial defining the finite field<tt>GF(2<sup>m</sup>)</tt>
 * @param encGoppaPoly the encoded irreducible Goppa polynomial
 * @param encP         the encoded permutation
 * @param encH         the encoded canonical check matrix
 * @param encQInv      the encoded matrix used to compute square roots in<tt>(GF(2^m))^t</tt>
 */
public McElieceCCA2PrivateKeySpec(String oid,int n,int k,byte[] encFieldPoly,byte[] encGoppaPoly,byte[] encP,byte[] encH,byte[][] encQInv){
  this.oid=oid;
  this.n=n;
  this.k=k;
  field=new GF2mField(encFieldPoly);
  goppaPoly=new PolynomialGF2mSmallM(field,encGoppaPoly);
  p=new Permutation(encP);
  h=new GF2Matrix(encH);
  qInv=new PolynomialGF2mSmallM[encQInv.length];
  for (int i=0; i < encQInv.length; i++) {
    qInv[i]=new PolynomialGF2mSmallM(field,encQInv[i]);
  }
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param n            the length of the code
 * @param k            the dimension of the code
 * @param encFieldPoly the encoded field polynomial defining the finite field<tt>GF(2<sup>m</sup>)</tt>
 * @param encGoppaPoly the encoded irreducible Goppa polynomial
 * @param encP         the encoded permutation
 * @param encH         the encoded canonical check matrix
 * @param encQInv      the encoded matrix used to compute square roots in<tt>(GF(2^m))^t</tt>
 */
public McElieceCCA2PrivateKeySpec(String oid,int n,int k,byte[] encFieldPoly,byte[] encGoppaPoly,byte[] encP,byte[] encH,byte[][] encQInv){
  this.oid=oid;
  this.n=n;
  this.k=k;
  field=new GF2mField(encFieldPoly);
  goppaPoly=new PolynomialGF2mSmallM(field,encGoppaPoly);
  p=new Permutation(encP);
  h=new GF2Matrix(encH);
  qInv=new PolynomialGF2mSmallM[encQInv.length];
  for (int i=0; i < encQInv.length; i++) {
    qInv[i]=new PolynomialGF2mSmallM(field,encQInv[i]);
  }
}
Program: 52491
Project: 52491
Buggy source:
/** 
 * return true if the signature represents a ISO9796-2 signature for the passed in message.
 */
public boolean verifySignature(byte[] signature){
  try {
    block=cipher.processBlock(signature,0,signature.length);
  }
 catch (  Exception e) {
    return false;
  }
  BigInteger t=new BigInteger(block);
  BigInteger f;
  if ((t.intValue() & 15) == 12) {
    f=t;
  }
 else {
    t=kParam.getModulus().subtract(t);
    if ((t.intValue() & 15) == 12) {
      f=t;
    }
 else {
      return false;
    }
  }
  createSignatureBlock();
  byte[] fBlock=BigIntegers.asUnsignedByteArray(block.length,f);
  boolean rv=Arrays.constantTimeAreEqual(block,fBlock);
  clearBlock(block);
  clearBlock(fBlock);
  return rv;
}

Fixed version (ground truth):
/** 
 * return true if the signature represents a ISO9796-2 signature for the passed in message.
 */
public boolean verifySignature(byte[] signature){
  try {
    block=cipher.processBlock(signature,0,signature.length);
  }
 catch (  Exception e) {
    return false;
  }
  BigInteger t=new BigInteger(1,block);
  BigInteger f;
  if ((t.intValue() & 15) == 12) {
    f=t;
  }
 else {
    t=kParam.getModulus().subtract(t);
    if ((t.intValue() & 15) == 12) {
      f=t;
    }
 else {
      return false;
    }
  }
  createSignatureBlock();
  byte[] fBlock=BigIntegers.asUnsignedByteArray(block.length,f);
  boolean rv=Arrays.constantTimeAreEqual(block,fBlock);
  clearBlock(block);
  clearBlock(fBlock);
  return rv;
}