private void verifyParserAlgorithm(String algorithmOid, MimeBodyPart msg) throws Exception {
    SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();

    gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert).setProvider(BC));

    //
    // generate a MimeBodyPart object which encapsulates the content
    // we want encrypted.
    //

    MimeBodyPart mp =
        gen.generate(
            msg,
            new JceCMSContentEncryptorBuilder(new ASN1ObjectIdentifier(algorithmOid))
                .setProvider(BC)
                .build());
    SMIMEEnvelopedParser m = new SMIMEEnvelopedParser(mp);
    RecipientId recId = getRecipientId(_reciCert);

    RecipientInformationStore recipients = m.getRecipientInfos();
    RecipientInformation recipient = recipients.get(recId);

    MimeBodyPart res =
        SMIMEUtil.toMimeBodyPart(
            recipient.getContent(
                new JceKeyTransEnvelopedRecipient(_reciKP.getPrivate()).setProvider(BC)));

    verifyMessageBytes(msg, res);
  }
  public void testTwoRecipients() throws Exception {
    MimeBodyPart _msg = SMIMETestUtil.makeMimeBodyPart("WallaWallaWashington");

    SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();

    gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert).setProvider(BC));
    gen.addRecipientInfoGenerator(
        new JceKeyTransRecipientInfoGenerator(_reciCert2).setProvider(BC));

    //
    // generate a MimeBodyPart object which encapsulates the content
    // we want encrypted.
    //
    MimeBodyPart mp =
        gen.generate(
            _msg,
            new JceCMSContentEncryptorBuilder(CMSAlgorithm.RC2_CBC, 40).setProvider(BC).build());

    SMIMEEnvelopedParser m = new SMIMEEnvelopedParser(mp);

    RecipientId recId = getRecipientId(_reciCert2);

    RecipientInformationStore recipients = m.getRecipientInfos();
    RecipientInformation recipient = recipients.get(recId);

    FileBackedMimeBodyPart res =
        SMIMEUtil.toMimeBodyPart(
            recipient.getContentStream(
                new JceKeyTransEnvelopedRecipient(_reciKP2.getPrivate()).setProvider(BC)));

    verifyMessageBytes(_msg, res);

    m = new SMIMEEnvelopedParser(mp);

    res.dispose();

    recId = getRecipientId(_reciCert);

    recipients = m.getRecipientInfos();
    recipient = recipients.get(recId);

    res =
        SMIMEUtil.toMimeBodyPart(
            recipient.getContentStream(
                new JceKeyTransEnvelopedRecipient(_reciKP.getPrivate()).setProvider(BC)));

    verifyMessageBytes(_msg, res);

    res.dispose();
  }