本文整理匯總了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();
}