本文整理汇总了Java中org.bouncycastle.crypto.params.ParametersWithSBox.getParameters方法的典型用法代码示例。如果您正苦于以下问题:Java ParametersWithSBox.getParameters方法的具体用法?Java ParametersWithSBox.getParameters怎么用?Java ParametersWithSBox.getParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.params.ParametersWithSBox
的用法示例。
在下文中一共展示了ParametersWithSBox.getParameters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.bouncycastle.crypto.params.ParametersWithSBox; //导入方法依赖的package包/类
/**
* initialise an GOST28147 cipher.
*
* @param forEncryption whether or not we are for encryption.
* @param params the parameters required to set up the cipher.
* @exception IllegalArgumentException if the params argument is
* inappropriate.
*/
public void init(
boolean forEncryption,
CipherParameters params)
{
if (params instanceof ParametersWithSBox)
{
ParametersWithSBox param = (ParametersWithSBox)params;
//
// Set the S-Box
//
byte[] sBox = param.getSBox();
if (sBox.length != Sbox_Default.length)
{
throw new IllegalArgumentException("invalid S-box passed to GOST28147 init");
}
this.S = Arrays.clone(sBox);
//
// set key if there is one
//
if (param.getParameters() != null)
{
workingKey = generateWorkingKey(forEncryption,
((KeyParameter)param.getParameters()).getKey());
}
}
else if (params instanceof KeyParameter)
{
workingKey = generateWorkingKey(forEncryption,
((KeyParameter)params).getKey());
}
else if (params != null)
{
throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
}
}
示例2: init
import org.bouncycastle.crypto.params.ParametersWithSBox; //导入方法依赖的package包/类
public void init(
CipherParameters params)
throws IllegalArgumentException
{
reset();
buf = new byte[blockSize];
if (params instanceof ParametersWithSBox)
{
ParametersWithSBox param = (ParametersWithSBox)params;
//
// Set the S-Box
//
System.arraycopy(param.getSBox(), 0, this.S, 0, param.getSBox().length);
//
// set key if there is one
//
if (param.getParameters() != null)
{
workingKey = generateWorkingKey(((KeyParameter)param.getParameters()).getKey());
}
}
else if (params instanceof KeyParameter)
{
workingKey = generateWorkingKey(((KeyParameter)params).getKey());
}
else
{
throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
}
}