本文整理汇总了Java中org.bouncycastle.crypto.generators.PKCS12ParametersGenerator.generateDerivedMacParameters方法的典型用法代码示例。如果您正苦于以下问题:Java PKCS12ParametersGenerator.generateDerivedMacParameters方法的具体用法?Java PKCS12ParametersGenerator.generateDerivedMacParameters怎么用?Java PKCS12ParametersGenerator.generateDerivedMacParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.generators.PKCS12ParametersGenerator
的用法示例。
在下文中一共展示了PKCS12ParametersGenerator.generateDerivedMacParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMacCalculator
import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator; //导入方法依赖的package包/类
static MacCalculator createMacCalculator(final ASN1ObjectIdentifier digestAlgorithm, ExtendedDigest digest, final PKCS12PBEParams pbeParams, final char[] password)
{
PKCS12ParametersGenerator pGen = new PKCS12ParametersGenerator(digest);
pGen.init(PKCS12ParametersGenerator.PKCS12PasswordToBytes(password), pbeParams.getIV(), pbeParams.getIterations().intValue());
final KeyParameter keyParam = (KeyParameter)pGen.generateDerivedMacParameters(digest.getDigestSize() * 8);
final HMac hMac = new HMac(digest);
hMac.init(keyParam);
return new MacCalculator()
{
public AlgorithmIdentifier getAlgorithmIdentifier()
{
return new AlgorithmIdentifier(digestAlgorithm, pbeParams);
}
public OutputStream getOutputStream()
{
return new MacOutputStream(hMac);
}
public byte[] getMac()
{
byte[] res = new byte[hMac.getMacSize()];
hMac.doFinal(res, 0);
return res;
}
public GenericKey getKey()
{
return new GenericKey(getAlgorithmIdentifier(), PKCS12ParametersGenerator.PKCS12PasswordToBytes(password));
}
};
}