本文整理汇总了Java中org.bouncycastle.crypto.KeyGenerationParameters.getRandom方法的典型用法代码示例。如果您正苦于以下问题:Java KeyGenerationParameters.getRandom方法的具体用法?Java KeyGenerationParameters.getRandom怎么用?Java KeyGenerationParameters.getRandom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.KeyGenerationParameters
的用法示例。
在下文中一共展示了KeyGenerationParameters.getRandom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.bouncycastle.crypto.KeyGenerationParameters; //导入方法依赖的package包/类
/**
* initialise the key generator - if strength is set to zero
* the key generated will be 192 bits in size, otherwise
* strength can be 128 or 192 (or 112 or 168 if you don't count
* parity bits), depending on whether you wish to do 2-key or 3-key
* triple DES.
*
* @param param the parameters to be used for key generation
*/
public void init(
KeyGenerationParameters param)
{
this.random = param.getRandom();
this.strength = (param.getStrength() + 7) / 8;
if (strength == 0 || strength == (168 / 8))
{
strength = DESedeParameters.DES_EDE_KEY_LENGTH;
}
else if (strength == (112 / 8))
{
strength = 2 * DESedeParameters.DES_KEY_LENGTH;
}
else if (strength != DESedeParameters.DES_EDE_KEY_LENGTH
&& strength != (2 * DESedeParameters.DES_KEY_LENGTH))
{
throw new IllegalArgumentException("DESede key must be "
+ (DESedeParameters.DES_EDE_KEY_LENGTH * 8) + " or "
+ (2 * 8 * DESedeParameters.DES_KEY_LENGTH)
+ " bits long.");
}
}
示例2: init
import org.bouncycastle.crypto.KeyGenerationParameters; //导入方法依赖的package包/类
@Override
public void init(final KeyGenerationParameters params)
{
strength = 0;
random = null;
if (params != null) {
strength = params.getStrength();
random = params.getRandom();
}
if (strength < 1)
strength = 256;
if (random == null)
random = new SecureRandom();
strengthInBytes = (strength + 7) / 8;
}
示例3: init
import org.bouncycastle.crypto.KeyGenerationParameters; //导入方法依赖的package包/类
/**
* Initialises the key generator.<br>
* Poly1305 keys are always 256 bits, so the key length in the provided parameters is ignored.
*/
public void init(KeyGenerationParameters param)
{
// Poly1305 keys are always 256 bits
super.init(new KeyGenerationParameters(param.getRandom(), 256));
}