本文整理汇总了Java中org.bouncycastle.crypto.params.KeyParameter.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java KeyParameter.getKey方法的具体用法?Java KeyParameter.getKey怎么用?Java KeyParameter.getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.params.KeyParameter
的用法示例。
在下文中一共展示了KeyParameter.getKey方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: determineKeyEncAlg
import org.bouncycastle.crypto.params.KeyParameter; //导入方法依赖的package包/类
static AlgorithmIdentifier determineKeyEncAlg(KeyParameter key)
{
int length = key.getKey().length * 8;
ASN1ObjectIdentifier wrapOid;
if (length == 128)
{
wrapOid = NISTObjectIdentifiers.id_aes128_wrap;
}
else if (length == 192)
{
wrapOid = NISTObjectIdentifiers.id_aes192_wrap;
}
else if (length == 256)
{
wrapOid = NISTObjectIdentifiers.id_aes256_wrap;
}
else
{
throw new IllegalArgumentException("illegal keysize in AES");
}
return new AlgorithmIdentifier(wrapOid); // parameters absent
}
示例2: determineKeyEncAlg
import org.bouncycastle.crypto.params.KeyParameter; //导入方法依赖的package包/类
static AlgorithmIdentifier determineKeyEncAlg(KeyParameter key)
{
int length = key.getKey().length * 8;
ASN1ObjectIdentifier wrapOid;
if (length == 128)
{
wrapOid = NTTObjectIdentifiers.id_camellia128_wrap;
}
else if (length == 192)
{
wrapOid = NTTObjectIdentifiers.id_camellia192_wrap;
}
else if (length == 256)
{
wrapOid = NTTObjectIdentifiers.id_camellia256_wrap;
}
else
{
throw new IllegalArgumentException(
"illegal keysize in Camellia");
}
return new AlgorithmIdentifier(wrapOid); // parameters must be
// absent
}
示例3: init
import org.bouncycastle.crypto.params.KeyParameter; //导入方法依赖的package包/类
public void init(CipherParameters params)
throws IllegalArgumentException
{
if (!(params instanceof KeyParameter))
{
throw new IllegalArgumentException("'params' must be an instance of KeyParameter");
}
KeyParameter keyParameter = (KeyParameter)params;
byte[] key = keyParameter.getKey();
if (key.length != 16)
{
throw new IllegalArgumentException("'params' must be a 128-bit key");
}
this.k0 = Pack.littleEndianToLong(key, 0);
this.k1 = Pack.littleEndianToLong(key, 8);
reset();
}
示例4: init
import org.bouncycastle.crypto.params.KeyParameter; //导入方法依赖的package包/类
/**
* initialise a Salsa20 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)
{
/*
* Salsa20 encryption and decryption is completely
* symmetrical, so the 'forEncryption' is
* irrelevant. (Like 90% of stream ciphers)
*/
if (!(params instanceof ParametersWithIV))
{
throw new IllegalArgumentException("Salsa20 Init parameters must include an IV");
}
ParametersWithIV ivParams = (ParametersWithIV) params;
byte[] iv = ivParams.getIV();
if (iv == null || iv.length != 8)
{
throw new IllegalArgumentException("Salsa20 requires exactly 8 bytes of IV");
}
if (!(ivParams.getParameters() instanceof KeyParameter))
{
throw new IllegalArgumentException("Salsa20 Init parameters must include a key");
}
KeyParameter key = (KeyParameter) ivParams.getParameters();
workingKey = key.getKey();
workingIV = iv;
setKey(workingKey, workingIV);
}
示例5: init
import org.bouncycastle.crypto.params.KeyParameter; //导入方法依赖的package包/类
/**
* initialise a VMPC 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 ParametersWithIV))
{
throw new IllegalArgumentException(
"VMPC init parameters must include an IV");
}
ParametersWithIV ivParams = (ParametersWithIV) params;
KeyParameter key = (KeyParameter) ivParams.getParameters();
if (!(ivParams.getParameters() instanceof KeyParameter))
{
throw new IllegalArgumentException(
"VMPC init parameters must include a key");
}
this.workingIV = ivParams.getIV();
if (workingIV == null || workingIV.length < 1 || workingIV.length > 768)
{
throw new IllegalArgumentException("VMPC requires 1 to 768 bytes of IV");
}
this.workingKey = key.getKey();
initKey(this.workingKey, this.workingIV);
}
示例6: init
import org.bouncycastle.crypto.params.KeyParameter; //导入方法依赖的package包/类
public void init(CipherParameters params) throws IllegalArgumentException
{
if (!(params instanceof ParametersWithIV))
{
throw new IllegalArgumentException(
"VMPC-MAC Init parameters must include an IV");
}
ParametersWithIV ivParams = (ParametersWithIV) params;
KeyParameter key = (KeyParameter) ivParams.getParameters();
if (!(ivParams.getParameters() instanceof KeyParameter))
{
throw new IllegalArgumentException(
"VMPC-MAC Init parameters must include a key");
}
this.workingIV = ivParams.getIV();
if (workingIV == null || workingIV.length < 1 || workingIV.length > 768)
{
throw new IllegalArgumentException(
"VMPC-MAC requires 1 to 768 bytes of IV");
}
this.workingKey = key.getKey();
reset();
}
示例7: SingleIterationPBKDF2
import org.bouncycastle.crypto.params.KeyParameter; //导入方法依赖的package包/类
private static byte[] SingleIterationPBKDF2(byte[] P, byte[] S, int dkLen)
{
PBEParametersGenerator pGen = new PKCS5S2ParametersGenerator(new SHA256Digest());
pGen.init(P, S, 1);
KeyParameter key = (KeyParameter) pGen.generateDerivedMacParameters(dkLen * 8);
return key.getKey();
}
示例8: init
import org.bouncycastle.crypto.params.KeyParameter; //导入方法依赖的package包/类
/**
* Initialize a Grain-128 cipher.
*
* @param forEncryption Whether or not we are for encryption.
* @param params The parameters required to set up the cipher.
* @throws IllegalArgumentException If the params argument is inappropriate.
*/
public void init(boolean forEncryption, CipherParameters params)
throws IllegalArgumentException
{
/**
* Grain encryption and decryption is completely symmetrical, so the
* 'forEncryption' is irrelevant.
*/
if (!(params instanceof ParametersWithIV))
{
throw new IllegalArgumentException(
"Grain-128 Init parameters must include an IV");
}
ParametersWithIV ivParams = (ParametersWithIV)params;
byte[] iv = ivParams.getIV();
if (iv == null || iv.length != 12)
{
throw new IllegalArgumentException(
"Grain-128 requires exactly 12 bytes of IV");
}
if (!(ivParams.getParameters() instanceof KeyParameter))
{
throw new IllegalArgumentException(
"Grain-128 Init parameters must include a key");
}
KeyParameter key = (KeyParameter)ivParams.getParameters();
/**
* Initialize variables.
*/
workingIV = new byte[key.getKey().length];
workingKey = new byte[key.getKey().length];
lfsr = new int[STATE_SIZE];
nfsr = new int[STATE_SIZE];
out = new byte[4];
System.arraycopy(iv, 0, workingIV, 0, iv.length);
System.arraycopy(key.getKey(), 0, workingKey, 0, key.getKey().length);
setKey(workingKey, workingIV);
initGrain();
}
示例9: init
import org.bouncycastle.crypto.params.KeyParameter; //导入方法依赖的package包/类
/**
* Initialize a Grain v1 cipher.
*
* @param forEncryption Whether or not we are for encryption.
* @param params The parameters required to set up the cipher.
* @throws IllegalArgumentException If the params argument is inappropriate.
*/
public void init(boolean forEncryption, CipherParameters params)
throws IllegalArgumentException
{
/**
* Grain encryption and decryption is completely symmetrical, so the
* 'forEncryption' is irrelevant.
*/
if (!(params instanceof ParametersWithIV))
{
throw new IllegalArgumentException(
"Grain v1 Init parameters must include an IV");
}
ParametersWithIV ivParams = (ParametersWithIV)params;
byte[] iv = ivParams.getIV();
if (iv == null || iv.length != 8)
{
throw new IllegalArgumentException(
"Grain v1 requires exactly 8 bytes of IV");
}
if (!(ivParams.getParameters() instanceof KeyParameter))
{
throw new IllegalArgumentException(
"Grain v1 Init parameters must include a key");
}
KeyParameter key = (KeyParameter)ivParams.getParameters();
/**
* Initialize variables.
*/
workingIV = new byte[key.getKey().length];
workingKey = new byte[key.getKey().length];
lfsr = new int[STATE_SIZE];
nfsr = new int[STATE_SIZE];
out = new byte[2];
System.arraycopy(iv, 0, workingIV, 0, iv.length);
System.arraycopy(key.getKey(), 0, workingKey, 0, key.getKey().length);
setKey(workingKey, workingIV);
initGrain();
}