org.testifyproject.bouncycastle.cms.bc.BcKEKRecipient Maven / Gradle / Ivy
The newest version!
package org.testifyproject.bouncycastle.cms.bc;
import org.testifyproject.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.testifyproject.bouncycastle.cms.CMSException;
import org.testifyproject.bouncycastle.cms.KEKRecipient;
import org.testifyproject.bouncycastle.crypto.CipherParameters;
import org.testifyproject.bouncycastle.operator.OperatorException;
import org.testifyproject.bouncycastle.operator.SymmetricKeyUnwrapper;
import org.testifyproject.bouncycastle.operator.bc.BcSymmetricKeyUnwrapper;
public abstract class BcKEKRecipient
implements KEKRecipient
{
private SymmetricKeyUnwrapper unwrapper;
public BcKEKRecipient(BcSymmetricKeyUnwrapper unwrapper)
{
this.unwrapper = unwrapper;
}
protected CipherParameters extractSecretKey(AlgorithmIdentifier keyEncryptionAlgorithm, AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey)
throws CMSException
{
try
{
return CMSUtils.getBcKey(unwrapper.generateUnwrappedKey(contentEncryptionAlgorithm, encryptedContentEncryptionKey));
}
catch (OperatorException e)
{
throw new CMSException("exception unwrapping key: " + e.getMessage(), e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy