org.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipient Java Examples
The following examples show how to use
org.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnvelopedDataDecryptor.java From xipki with Apache License 2.0 | 5 votes |
public EnvelopedDataDecryptorInstance(X509Cert recipientCert, PrivateKey privKey) { Args.notNull(recipientCert, "recipientCert"); Args.notNull(privKey, "privKey"); this.recipientId = new KeyTransRecipientId( recipientCert.getIssuer(), recipientCert.getSerialNumber(), recipientCert.getSubjectKeyId()); this.recipient = new JceKeyTransEnvelopedRecipient(privKey); }
Example #2
Source File: BouncyCastleCrypto.java From tutorials with MIT License | 5 votes |
public static byte[] decryptData(final byte[] encryptedData, final PrivateKey decryptionKey) throws CMSException { byte[] decryptedData = null; if (null != encryptedData && null != decryptionKey) { CMSEnvelopedData envelopedData = new CMSEnvelopedData(encryptedData); Collection<RecipientInformation> recip = envelopedData.getRecipientInfos().getRecipients(); KeyTransRecipientInformation recipientInfo = (KeyTransRecipientInformation) recip.iterator().next(); JceKeyTransRecipient recipient = new JceKeyTransEnvelopedRecipient(decryptionKey); decryptedData = recipientInfo.getContent(recipient); } return decryptedData; }