本文整理汇总了Java中org.bouncycastle.crypto.params.DESedeParameters.setOddParity方法的典型用法代码示例。如果您正苦于以下问题:Java DESedeParameters.setOddParity方法的具体用法?Java DESedeParameters.setOddParity怎么用?Java DESedeParameters.setOddParity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.params.DESedeParameters
的用法示例。
在下文中一共展示了DESedeParameters.setOddParity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCipherParameters
import org.bouncycastle.crypto.params.DESedeParameters; //导入方法依赖的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;
}
示例2: generateKey
import org.bouncycastle.crypto.params.DESedeParameters; //导入方法依赖的package包/类
public byte[] generateKey()
{
byte[] newKey = new byte[strength];
int count = 0;
do
{
random.nextBytes(newKey);
DESedeParameters.setOddParity(newKey);
}
while (++count < MAX_IT && (DESedeParameters.isWeakKey(newKey, 0, newKey.length) || !DESedeParameters.isRealEDEKey(newKey, 0)));
if (DESedeParameters.isWeakKey(newKey, 0, newKey.length) || !DESedeParameters.isRealEDEKey(newKey, 0))
{
throw new IllegalStateException("Unable to generate DES-EDE key");
}
return newKey;
}
示例3: generateKey
import org.bouncycastle.crypto.params.DESedeParameters; //导入方法依赖的package包/类
public byte[] generateKey()
{
byte[] newKey = new byte[strength];
do
{
random.nextBytes(newKey);
DESedeParameters.setOddParity(newKey);
}
while (DESedeParameters.isWeakKey(newKey, 0, newKey.length));
return newKey;
}
示例4: init
import org.bouncycastle.crypto.params.DESedeParameters; //导入方法依赖的package包/类
public void init(boolean forEncryption, CipherParameters params)
throws IllegalArgumentException
{
byte[] k = Arrays.clone(((KeyParameter)params).getKey());
DESedeParameters.setOddParity(k);
if (!Arrays.areEqual(((KeyParameter)params).getKey(), k))
{
fail("key not odd parity");
}
cipher.init(forEncryption, params);
}