org.bouncycastle.operator.bc.BcRSAContentVerifierProviderBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcmail Show documentation
Show all versions of bcmail Show documentation
A patched bouncycastle-mail
The newest version!
package org.bouncycastle.operator.bc;
import java.io.IOException;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.Signer;
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
import org.bouncycastle.crypto.signers.RSADigestSigner;
import org.bouncycastle.crypto.util.PublicKeyFactory;
import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder;
import org.bouncycastle.operator.OperatorCreationException;
public class BcRSAContentVerifierProviderBuilder
extends BcContentVerifierProviderBuilder
{
private DigestAlgorithmIdentifierFinder digestAlgorithmFinder;
public BcRSAContentVerifierProviderBuilder(DigestAlgorithmIdentifierFinder digestAlgorithmFinder)
{
this.digestAlgorithmFinder = digestAlgorithmFinder;
}
protected Signer createSigner(AlgorithmIdentifier sigAlgId)
throws OperatorCreationException
{
AlgorithmIdentifier digAlg = digestAlgorithmFinder.find(sigAlgId);
Digest dig = BcUtil.createDigest(digAlg);
return new RSADigestSigner(dig);
}
protected AsymmetricKeyParameter extractKeyParameters(SubjectPublicKeyInfo publicKeyInfo)
throws IOException
{
return PublicKeyFactory.createKey(publicKeyInfo);
}
}