本文整理汇总了Java中org.bouncycastle.asn1.cms.EncryptedContentInfo类的典型用法代码示例。如果您正苦于以下问题:Java EncryptedContentInfo类的具体用法?Java EncryptedContentInfo怎么用?Java EncryptedContentInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EncryptedContentInfo类属于org.bouncycastle.asn1.cms包,在下文中一共展示了EncryptedContentInfo类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContentStream
import org.bouncycastle.asn1.cms.EncryptedContentInfo; //导入依赖的package包/类
public CMSTypedStream getContentStream(InputDecryptorProvider inputDecryptorProvider)
throws CMSException
{
try
{
EncryptedContentInfo encContentInfo = encryptedData.getEncryptedContentInfo();
InputDecryptor decrytor = inputDecryptorProvider.get(encContentInfo.getContentEncryptionAlgorithm());
ByteArrayInputStream encIn = new ByteArrayInputStream(encContentInfo.getEncryptedContent().getOctets());
return new CMSTypedStream(encContentInfo.getContentType(), decrytor.getInputStream(encIn));
}
catch (Exception e)
{
throw new CMSException("unable to create stream: " + e.getMessage(), e);
}
}
示例2: createDERForRecipient
import org.bouncycastle.asn1.cms.EncryptedContentInfo; //导入依赖的package包/类
private ASN1Primitive createDERForRecipient(byte[] in, X509Certificate cert)
throws IOException,
GeneralSecurityException
{
String s = "1.2.840.113549.3.2";
AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance(s);
AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
ASN1Primitive derobject = asn1inputstream.readObject();
KeyGenerator keygenerator = KeyGenerator.getInstance(s);
keygenerator.init(128);
SecretKey secretkey = keygenerator.generateKey();
Cipher cipher = Cipher.getInstance(s);
cipher.init(1, secretkey, algorithmparameters);
byte[] abyte1 = cipher.doFinal(in);
DEROctetString deroctetstring = new DEROctetString(abyte1);
KeyTransRecipientInfo keytransrecipientinfo = computeRecipientInfo(cert, secretkey.getEncoded());
DERSet derset = new DERSet(new RecipientInfo(keytransrecipientinfo));
AlgorithmIdentifier algorithmidentifier = new AlgorithmIdentifier(new ASN1ObjectIdentifier(s), derobject);
EncryptedContentInfo encryptedcontentinfo =
new EncryptedContentInfo(PKCSObjectIdentifiers.data, algorithmidentifier, deroctetstring);
EnvelopedData env = new EnvelopedData(null, derset, encryptedcontentinfo, (org.bouncycastle.asn1.ASN1Set) null);
ContentInfo contentinfo =
new ContentInfo(PKCSObjectIdentifiers.envelopedData, env);
return contentinfo.toASN1Primitive();
}
示例3: CMSAuthEnvelopedData
import org.bouncycastle.asn1.cms.EncryptedContentInfo; //导入依赖的package包/类
public CMSAuthEnvelopedData(ContentInfo contentInfo) throws CMSException
{
this.contentInfo = contentInfo;
AuthEnvelopedData authEnvData = AuthEnvelopedData.getInstance(contentInfo.getContent());
this.originator = authEnvData.getOriginatorInfo();
//
// read the recipients
//
ASN1Set recipientInfos = authEnvData.getRecipientInfos();
//
// read the auth-encrypted content info
//
EncryptedContentInfo authEncInfo = authEnvData.getAuthEncryptedContentInfo();
this.authEncAlg = authEncInfo.getContentEncryptionAlgorithm();
// final CMSProcessable processable = new CMSProcessableByteArray(
// authEncInfo.getEncryptedContent().getOctets());
CMSSecureReadable secureReadable = new CMSSecureReadable()
{
public InputStream getInputStream()
throws IOException, CMSException
{
return null;
}
};
//
// build the RecipientInformationStore
//
this.recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore(
recipientInfos, this.authEncAlg, secureReadable);
// FIXME These need to be passed to the AEAD cipher as AAD (Additional Authenticated Data)
this.authAttrs = authEnvData.getAuthAttrs();
this.mac = authEnvData.getMac().getOctets();
this.unauthAttrs = authEnvData.getUnauthAttrs();
}