if (cert != null)
{
ASN1InputStream aIn = new ASN1InputStream(cert.getTBSCertificate());
TBSCertificateStructure tbs = TBSCertificateStructure.getInstance(aIn.readObject());
IssuerAndSerialNumber encSid = new IssuerAndSerialNumber(tbs.getIssuer(), tbs.getSerialNumber().getValue());
return new RecipientInfo(new KeyTransRecipientInfo(
new RecipientIdentifier(encSid),
keyEncAlg,
encKey));
}
else
{
return new RecipientInfo(new KeyTransRecipientInfo(
new RecipientIdentifier(subKeyId),
keyEncAlg,
encKey));
}
}
else if (originator != null)
{
Cipher keyCipher = HELPER.createAsymmetricCipher(
DERObjectIdentifier.getInstance(ASN1Sequence.getInstance(keyEncAlg.getParameters()).getObjectAt(0)).getId(), prov);
keyCipher.init(Cipher.WRAP_MODE, secKey, random);
ASN1OctetString encKey = new DEROctetString(
keyCipher.wrap(key));
RecipientEncryptedKey rKey = new RecipientEncryptedKey(new KeyAgreeRecipientIdentifier(
new IssuerAndSerialNumber(PrincipalUtil.getIssuerX509Principal(cert), cert.getSerialNumber())),
encKey);
return new RecipientInfo(new KeyAgreeRecipientInfo(originator, ukm, keyEncAlg, new DERSequence(rKey)));
}
else if (derivationAlg != null)