com.fitbur.bouncycastle.pkcs.bc.BcPKCS12MacCalculatorBuilderProvider Maven / Gradle / Ivy
package com.fitbur.bouncycastle.pkcs.bc;
import com.fitbur.bouncycastle.asn1.DERNull;
import com.fitbur.bouncycastle.asn1.pkcs.PKCS12PBEParams;
import com.fitbur.bouncycastle.asn1.x509.AlgorithmIdentifier;
import com.fitbur.bouncycastle.operator.MacCalculator;
import com.fitbur.bouncycastle.operator.OperatorCreationException;
import com.fitbur.bouncycastle.operator.bc.BcDigestProvider;
import com.fitbur.bouncycastle.pkcs.PKCS12MacCalculatorBuilder;
import com.fitbur.bouncycastle.pkcs.PKCS12MacCalculatorBuilderProvider;
public class BcPKCS12MacCalculatorBuilderProvider
implements PKCS12MacCalculatorBuilderProvider
{
private BcDigestProvider digestProvider;
public BcPKCS12MacCalculatorBuilderProvider(BcDigestProvider digestProvider)
{
this.digestProvider = digestProvider;
}
public PKCS12MacCalculatorBuilder get(final AlgorithmIdentifier algorithmIdentifier)
{
return new PKCS12MacCalculatorBuilder()
{
public MacCalculator build(final char[] password)
throws OperatorCreationException
{
PKCS12PBEParams pbeParams = PKCS12PBEParams.getInstance(algorithmIdentifier.getParameters());
return PKCS12PBEUtils.createMacCalculator(algorithmIdentifier.getAlgorithm(), digestProvider.get(algorithmIdentifier), pbeParams, password);
}
public AlgorithmIdentifier getDigestAlgorithmIdentifier()
{
return new AlgorithmIdentifier(algorithmIdentifier.getAlgorithm(), DERNull.INSTANCE);
}
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy