Program: 52441
Project: 52441
Buggy source:
public void testAES256CCM() throws Exception {
  Security.addProvider(new BouncyCastleProvider());
  byte[] data="String_Node_Str".getBytes();
  ASN1ObjectIdentifier macAlg=CMSAlgorithm.AES256_CCM;
  AlgorithmParameters algParams=AlgorithmParameters.getInstance("String_Node_Str",BC);
  algParams.init(new CCMParameters(Hex.decode("String_Node_Str"),16).getEncoded());
  CMSAuthenticatedDataGenerator adGen=new CMSAuthenticatedDataGenerator();
  X509CertificateHolder origCert=new X509CertificateHolder(_origCert.getEncoded());
  adGen.setOriginatorInfo(new OriginatorInfoGenerator(origCert).generate());
  adGen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert).setProvider(BC));
  CMSAuthenticatedData ad=adGen.generate(new CMSProcessableByteArray(data),new JceCMSMacCalculatorBuilder(macAlg).setAlgorithmParameters(algParams).setProvider(BC).build());
  assertTrue(ad.getOriginatorInfo().getCertificates().getMatches(null).contains(origCert));
  RecipientInformationStore recipients=ad.getRecipientInfos();
  assertEquals(ad.getMacAlgOID(),macAlg.getId());
  Collection c=recipients.getRecipients();
  assertEquals(1,c.size());
  Iterator it=c.iterator();
  while (it.hasNext()) {
    RecipientInformation recipient=(RecipientInformation)it.next();
    assertEquals(recipient.getKeyEncryptionAlgOID(),PKCSObjectIdentifiers.rsaEncryption.getId());
    byte[] recData=recipient.getContent(new JceKeyTransAuthenticatedRecipient(_reciKP.getPrivate()).setProvider(BC));
    assertTrue(Arrays.equals(data,recData));
    assertEquals(16,ad.getMac().length);
    assertTrue(Arrays.equals(ad.getMac(),recipient.getMac()));
  }
}

Fixed version (ground truth):
public void testAES256CCM() throws Exception {
  byte[] data="String_Node_Str".getBytes();
  ASN1ObjectIdentifier macAlg=CMSAlgorithm.AES256_CCM;
  AlgorithmParameters algParams=AlgorithmParameters.getInstance("String_Node_Str",BC);
  algParams.init(new CCMParameters(Hex.decode("String_Node_Str"),16).getEncoded());
  CMSAuthenticatedDataGenerator adGen=new CMSAuthenticatedDataGenerator();
  X509CertificateHolder origCert=new X509CertificateHolder(_origCert.getEncoded());
  adGen.setOriginatorInfo(new OriginatorInfoGenerator(origCert).generate());
  adGen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert).setProvider(BC));
  CMSAuthenticatedData ad=adGen.generate(new CMSProcessableByteArray(data),new JceCMSMacCalculatorBuilder(macAlg).setAlgorithmParameters(algParams).setProvider(BC).build());
  assertTrue(ad.getOriginatorInfo().getCertificates().getMatches(null).contains(origCert));
  RecipientInformationStore recipients=ad.getRecipientInfos();
  assertEquals(ad.getMacAlgOID(),macAlg.getId());
  Collection c=recipients.getRecipients();
  assertEquals(1,c.size());
  Iterator it=c.iterator();
  while (it.hasNext()) {
    RecipientInformation recipient=(RecipientInformation)it.next();
    assertEquals(recipient.getKeyEncryptionAlgOID(),PKCSObjectIdentifiers.rsaEncryption.getId());
    byte[] recData=recipient.getContent(new JceKeyTransAuthenticatedRecipient(_reciKP.getPrivate()).setProvider(BC));
    assertTrue(Arrays.equals(data,recData));
    assertEquals(16,ad.getMac().length);
    assertTrue(Arrays.equals(ad.getMac(),recipient.getMac()));
  }
}