本文整理汇总了Java中org.bouncycastle.crypto.DerivationParameters类的典型用法代码示例。如果您正苦于以下问题:Java DerivationParameters类的具体用法?Java DerivationParameters怎么用?Java DerivationParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DerivationParameters类属于org.bouncycastle.crypto包,在下文中一共展示了DerivationParameters类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
public void init(DerivationParameters param)
{
if (!(param instanceof HKDFParameters))
{
throw new IllegalArgumentException(
"HKDF parameters required for HKDFBytesGenerator");
}
HKDFParameters params = (HKDFParameters)param;
if (params.skipExtract())
{
// use IKM directly as PRK
hMacHash.init(new KeyParameter(params.getIKM()));
}
else
{
hMacHash.init(extract(params.getSalt(), params.getIKM()));
}
info = params.getInfo();
generatedBytes = 0;
currentT = new byte[hashLen];
}
示例2: checkMask
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
private void checkMask(
int count,
DerivationFunction kdf,
DerivationParameters params,
byte[] result)
{
byte[] data = new byte[result.length];
kdf.init(params);
kdf.generateBytes(data, 0, data.length);
if (!areEqual(result, data))
{
fail("DHKEKGenerator failed generator test " + count);
}
}
示例3: checkMask
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
private void checkMask(
int count,
DerivationFunction kdf,
DerivationParameters params,
byte[] result)
{
byte[] data = new byte[result.length];
kdf.init(params);
kdf.generateBytes(data, 0, data.length);
if (!areEqual(result, data))
{
fail("ECDHKEKGenerator failed generator test " + count);
}
}
示例4: init
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
public void init(
DerivationParameters param)
{
if (!(param instanceof KDFParameters))
{
throw new IllegalArgumentException("KDF parameters required for KDF2Generator");
}
KDFParameters p = (KDFParameters)param;
shared = p.getSharedSecret();
iv = p.getIV();
}
示例5: init
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
public void init(DerivationParameters param)
{
DHKDFParameters params = (DHKDFParameters)param;
this.algorithm = params.getAlgorithm();
this.keySize = params.getKeySize();
this.z = params.getZ();
this.partyAInfo = params.getExtraInfo();
}
示例6: init
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
public void init(DerivationParameters param)
{
DHKDFParameters params = (DHKDFParameters)param;
this.algorithm = params.getAlgorithm();
this.keySize = params.getKeySize();
this.z = params.getZ();
}
示例7: init
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
public void init(
DerivationParameters param)
{
if (!(param instanceof MGFParameters))
{
throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
}
MGFParameters p = (MGFParameters)param;
seed = p.getSeed();
}
示例8: init
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
public void init(
DerivationParameters param)
{
if (param instanceof KDFParameters)
{
KDFParameters p = (KDFParameters)param;
shared = p.getSharedSecret();
otherInfo = p.getIV();
}
else
{
throw new IllegalArgumentException("KDF parameters required for KDF2Generator");
}
}
示例9: init
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
public void init(DerivationParameters param)
{
if (!(param instanceof KDFCounterParameters))
{
throw new IllegalArgumentException("Wrong type of arguments given");
}
KDFCounterParameters kdfParams = (KDFCounterParameters)param;
// --- init mac based PRF ---
this.prf.init(new KeyParameter(kdfParams.getKI()));
// --- set arguments ---
this.fixedInputDataCtrPrefix = kdfParams.getFixedInputDataCounterPrefix();
this.fixedInputData_afterCtr = kdfParams.getFixedInputDataCounterSuffix();
int r = kdfParams.getR();
this.ios = new byte[r / 8];
BigInteger maxSize = TWO.pow(r).multiply(BigInteger.valueOf(h));
this.maxSizeExcl = maxSize.compareTo(INTEGER_MAX) == 1 ?
Integer.MAX_VALUE : maxSize.intValue();
// --- set operational state ---
generatedBytes = 0;
}
示例10: init
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
public void init(DerivationParameters params)
{
if (!(params instanceof KDFDoublePipelineIterationParameters))
{
throw new IllegalArgumentException("Wrong type of arguments given");
}
KDFDoublePipelineIterationParameters dpiParams = (KDFDoublePipelineIterationParameters)params;
// --- init mac based PRF ---
this.prf.init(new KeyParameter(dpiParams.getKI()));
// --- set arguments ---
this.fixedInputData = dpiParams.getFixedInputData();
int r = dpiParams.getR();
this.ios = new byte[r / 8];
if (dpiParams.useCounter())
{
// this is more conservative than the spec
BigInteger maxSize = TWO.pow(r).multiply(BigInteger.valueOf(h));
this.maxSizeExcl = maxSize.compareTo(INTEGER_MAX) == 1 ?
Integer.MAX_VALUE : maxSize.intValue();
}
else
{
this.maxSizeExcl = Integer.MAX_VALUE;
}
this.useCounter = dpiParams.useCounter();
// --- set operational state ---
generatedBytes = 0;
}
示例11: init
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
public void init(DerivationParameters params)
{
if (!(params instanceof KDFFeedbackParameters))
{
throw new IllegalArgumentException("Wrong type of arguments given");
}
KDFFeedbackParameters feedbackParams = (KDFFeedbackParameters)params;
// --- init mac based PRF ---
this.prf.init(new KeyParameter(feedbackParams.getKI()));
// --- set arguments ---
this.fixedInputData = feedbackParams.getFixedInputData();
int r = feedbackParams.getR();
this.ios = new byte[r / 8];
if (feedbackParams.useCounter())
{
// this is more conservative than the spec
BigInteger maxSize = TWO.pow(r).multiply(BigInteger.valueOf(h));
this.maxSizeExcl = maxSize.compareTo(INTEGER_MAX) == 1 ?
Integer.MAX_VALUE : maxSize.intValue();
}
else
{
this.maxSizeExcl = Integer.MAX_VALUE;
}
this.iv = feedbackParams.getIV();
this.useCounter = feedbackParams.useCounter();
// --- set operational state ---
generatedBytes = 0;
}
示例12: derive
import org.bouncycastle.crypto.DerivationParameters; //导入依赖的package包/类
/**
* @param sessionKey
* @param label
* @param context
*/
private static byte[] derive ( byte[] sessionKey, byte[] label, byte[] context ) {
KDFCounterBytesGenerator gen = new KDFCounterBytesGenerator(new HMac(new SHA256Digest()));
int r = 32;
byte[] suffix = new byte[label.length + context.length + 5];
// per bouncycastle
// <li>1: K(i) := PRF( KI, [i]_2 || Label || 0x00 || Context || [L]_2 ) with the counter at the very beginning
// of the fixedInputData (The default implementation has this format)</li>
// with the parameters
// <li>1. KDFCounterParameters(ki, null, "Label || 0x00 || Context || [L]_2]", 8);
// all fixed inputs go into the suffix:
// + label
System.arraycopy(label, 0, suffix, 0, label.length);
// + 1 byte 0x00
// + context
System.arraycopy(context, 0, suffix, label.length + 1, context.length);
// + 4 byte (== r bits) big endian encoding of L
suffix[ suffix.length - 1 ] = (byte) 128;
DerivationParameters param = new KDFCounterParameters(sessionKey, null /* prefix */, suffix /* suffix */, r /* r */);
gen.init(param);
byte[] derived = new byte[16];
gen.generateBytes(derived, 0, 16);
return derived;
}