本文整理汇总了Java中org.bouncycastle.crypto.ExtendedDigest类的典型用法代码示例。如果您正苦于以下问题:Java ExtendedDigest类的具体用法?Java ExtendedDigest怎么用?Java ExtendedDigest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtendedDigest类属于org.bouncycastle.crypto包,在下文中一共展示了ExtendedDigest类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getByteLength
import org.bouncycastle.crypto.ExtendedDigest; //导入依赖的package包/类
private static int getByteLength(
Digest digest)
{
if (digest instanceof ExtendedDigest)
{
return ((ExtendedDigest)digest).getByteLength();
}
Integer b = (Integer)blockLengths.get(digest.getAlgorithmName());
if (b == null)
{
throw new IllegalArgumentException("unknown digest passed: " + digest.getAlgorithmName());
}
return b.intValue();
}
示例2: createCipherParameters
import org.bouncycastle.crypto.ExtendedDigest; //导入依赖的package包/类
static CipherParameters createCipherParameters(ASN1ObjectIdentifier algorithm, ExtendedDigest digest, int blockSize, PKCS12PBEParams pbeParams, char[] password)
{
PKCS12ParametersGenerator pGen = new PKCS12ParametersGenerator(digest);
pGen.init(PKCS12ParametersGenerator.PKCS12PasswordToBytes(password), pbeParams.getIV(), pbeParams.getIterations().intValue());
CipherParameters params;
if (PKCS12PBEUtils.hasNoIv(algorithm))
{
params = pGen.generateDerivedParameters(PKCS12PBEUtils.getKeySize(algorithm));
}
else
{
params = pGen.generateDerivedParameters(PKCS12PBEUtils.getKeySize(algorithm), blockSize * 8);
if (PKCS12PBEUtils.isDesAlg(algorithm))
{
DESedeParameters.setOddParity(((KeyParameter)((ParametersWithIV)params).getParameters()).getKey());
}
}
return params;
}
示例3: ShortenedDigest
import org.bouncycastle.crypto.ExtendedDigest; //导入依赖的package包/类
/**
* Base constructor.
*
* @param baseDigest underlying digest to use.
* @param length length in bytes of the output of doFinal.
* @exception IllegalArgumentException if baseDigest is null, or length is greater than baseDigest.getDigestSize().
*/
public ShortenedDigest(
ExtendedDigest baseDigest,
int length)
{
if (baseDigest == null)
{
throw new IllegalArgumentException("baseDigest must not be null");
}
if (length > baseDigest.getDigestSize())
{
throw new IllegalArgumentException("baseDigest output not large enough to support length");
}
this.baseDigest = baseDigest;
this.length = length;
}
示例4: PKCS12ParametersGenerator
import org.bouncycastle.crypto.ExtendedDigest; //导入依赖的package包/类
/**
* Construct a PKCS 12 Parameters generator. This constructor will
* accept any digest which also implements ExtendedDigest.
*
* @param digest the digest to be used as the source of derived keys.
* @exception IllegalArgumentException if an unknown digest is passed in.
*/
public PKCS12ParametersGenerator(
Digest digest)
{
this.digest = digest;
if (digest instanceof ExtendedDigest)
{
u = digest.getDigestSize();
v = ((ExtendedDigest)digest).getByteLength();
}
else
{
throw new IllegalArgumentException("Digest " + digest.getAlgorithmName() + " unsupported");
}
}
示例5: get
import org.bouncycastle.crypto.ExtendedDigest; //导入依赖的package包/类
public ExtendedDigest get(AlgorithmIdentifier digestAlgorithmIdentifier)
throws OperatorCreationException
{
BcDigestProvider extProv = (BcDigestProvider)lookup.get(digestAlgorithmIdentifier.getAlgorithm());
if (extProv == null)
{
throw new OperatorCreationException("cannot recognise digest");
}
return extProv.get(digestAlgorithmIdentifier);
}
示例6: createMacCalculator
import org.bouncycastle.crypto.ExtendedDigest; //导入依赖的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));
}
};
}
示例7: NonMemoableDigest
import org.bouncycastle.crypto.ExtendedDigest; //导入依赖的package包/类
/**
* Base constructor.
*
* @param baseDigest underlying digest to use.
* @exception IllegalArgumentException if baseDigest is null
*/
public NonMemoableDigest(
ExtendedDigest baseDigest)
{
if (baseDigest == null)
{
throw new IllegalArgumentException("baseDigest must not be null");
}
this.baseDigest = baseDigest;
}