{
return new SimpleTestResult(false, getName() + ": CMS KeyTrans enveloped, wrong recipient type");
}
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
ASN1OutputStream aOut = new ASN1OutputStream(bOut);
envData = new EnvelopedData(envData.getOriginatorInfo(), s, envData.getEncryptedContentInfo(), envData.getUnprotectedAttrs());
info = new ContentInfo(CMSObjectIdentifiers.envelopedData, envData);
aOut.writeObject(info);
if (!isSameAs(bOut.toByteArray(), envDataKeyTrns))
{
return new SimpleTestResult(false, getName() + ": CMS KeyTrans enveloped failed to re-encode");
}
//
// KEK
//
aIn = new ASN1InputStream(new ByteArrayInputStream(envDataKEK));
info = ContentInfo.getInstance(aIn.readObject());
envData = EnvelopedData.getInstance(info.getContent());
s = envData.getRecipientInfos();
if (s.size() != 1)
{
return new SimpleTestResult(false, getName() + ": CMS KEK enveloped, wrong number of recipients");
}
recip = RecipientInfo.getInstance(s.getObjectAt(0));
if (recip.getInfo() instanceof KEKRecipientInfo)
{
KEKRecipientInfo inf = KEKRecipientInfo.getInstance(recip.getInfo());
inf = new KEKRecipientInfo(inf.getKekid(), inf.getKeyEncryptionAlgorithm(), inf.getEncryptedKey());
s = new DERSet(new RecipientInfo(inf));
}
else
{
return new SimpleTestResult(false, getName() + ": CMS KEK enveloped, wrong recipient type");
}
bOut = new ByteArrayOutputStream();
aOut = new ASN1OutputStream(bOut);
envData = new EnvelopedData(envData.getOriginatorInfo(), s, envData.getEncryptedContentInfo(), envData.getUnprotectedAttrs());
info = new ContentInfo(CMSObjectIdentifiers.envelopedData, envData);
aOut.writeObject(info);
if (!isSameAs(bOut.toByteArray(), envDataKEK))
{
return new SimpleTestResult(false, getName() + ": CMS KEK enveloped failed to re-encode");
}