
org.testifyproject.bouncycastle.cms.jcajce.JcePasswordAuthenticatedRecipient Maven / Gradle / Ivy
package org.testifyproject.bouncycastle.cms.jcajce;
import java.org.testifyproject.testifyproject.OutputStream;
import java.security.Key;
import javax.crypto.Mac;
import org.testifyproject.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.testifyproject.bouncycastle.cms.CMSException;
import org.testifyproject.bouncycastle.cms.RecipientOperator;
import org.testifyproject.bouncycastle.jcajce.org.testifyproject.testifyproject.MacOutputStream;
import org.testifyproject.bouncycastle.operator.GenericKey;
import org.testifyproject.bouncycastle.operator.MacCalculator;
import org.testifyproject.bouncycastle.operator.jcajce.JceGenericKey;
public class JcePasswordAuthenticatedRecipient
extends JcePasswordRecipient
{
public JcePasswordAuthenticatedRecipient(char[] password)
{
super(password);
}
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentMacAlgorithm, byte[] org.testifyproject.testifyprojectrivedKey, byte[] encryptedContentEncryptionKey)
throws CMSException
{
final Key secretKey = extractSecretKey(keyEncryptionAlgorithm, contentMacAlgorithm, org.testifyproject.testifyprojectrivedKey, encryptedContentEncryptionKey);
final Mac dataMac = helper.createContentMac(secretKey, contentMacAlgorithm);
return new RecipientOperator(new MacCalculator()
{
public AlgorithmIdentifier getAlgorithmIdentifier()
{
return contentMacAlgorithm;
}
public GenericKey getKey()
{
return new JceGenericKey(contentMacAlgorithm, secretKey);
}
public OutputStream getOutputStream()
{
return new MacOutputStream(dataMac);
}
public byte[] getMac()
{
return dataMac.doFinal();
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy