Java 类org.bouncycastle.crypto.DerivationParameters 实例源码

项目:ipack    文件:HKDFBytesGenerator.java   
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];
}
项目:gwt-crypto    文件:HKDFBytesGenerator.java   
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];
}
项目:gwt-crypto    文件:DHKEKGeneratorTest.java   
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);
    }
}
项目:gwt-crypto    文件:ECDHKEKGeneratorTest.java   
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);
    }
}
项目:Aki-SSL    文件:HKDFBytesGenerator.java   
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];
}
项目:TinyTravelTracker    文件:HKDFBytesGenerator.java   
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];
}
项目:CryptMeme    文件:HKDFBytesGenerator.java   
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];
}
项目:irma_future_id    文件:HKDFBytesGenerator.java   
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];
}
项目:irma_future_id    文件:DHKEKGeneratorTest.java   
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);
    }
}
项目:irma_future_id    文件:ECDHKEKGeneratorTest.java   
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);
    }
}
项目:bc-java    文件:HKDFBytesGenerator.java   
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];
}
项目:bc-java    文件:DHKEKGeneratorTest.java   
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);
    }
}
项目:bc-java    文件:ECDHKEKGeneratorTest.java   
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);
    }
}
项目:ipack    文件:BrokenKDF2BytesGenerator.java   
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();
}
项目:ipack    文件:DHKEKGenerator.java   
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();
}
项目:ipack    文件:ECDHKEKGenerator.java   
public void init(DerivationParameters param)
{
    DHKDFParameters params = (DHKDFParameters)param;

    this.algorithm = params.getAlgorithm();
    this.keySize = params.getKeySize();
    this.z = params.getZ();
}
项目:ipack    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:Direct-File-Downloader    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:gwt-crypto    文件:DHKEKGenerator.java   
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();
}
项目:gwt-crypto    文件:ECDHKEKGenerator.java   
public void init(DerivationParameters param)
{
    DHKDFParameters params = (DHKDFParameters)param;

    this.algorithm = params.getAlgorithm();
    this.keySize = params.getKeySize();
    this.z = params.getZ();
}
项目:gwt-crypto    文件:ConcatenationKDFGenerator.java   
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");
    }
}
项目:gwt-crypto    文件:KDFCounterBytesGenerator.java   
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;
}
项目:gwt-crypto    文件:KDFDoublePipelineIterationBytesGenerator.java   
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;
}
项目:gwt-crypto    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:gwt-crypto    文件:KDFFeedbackBytesGenerator.java   
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;
}
项目:Aki-SSL    文件:BrokenKDF2BytesGenerator.java   
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();
}
项目:Aki-SSL    文件:DHKEKGenerator.java   
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();
}
项目:Aki-SSL    文件:ECDHKEKGenerator.java   
public void init(DerivationParameters param)
{
    DHKDFParameters params = (DHKDFParameters)param;

    this.algorithm = params.getAlgorithm();
    this.keySize = params.getKeySize();
    this.z = params.getZ();
}
项目:Aki-SSL    文件:ConcatenationKDFGenerator.java   
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");
    }
}
项目:Aki-SSL    文件:KDFCounterBytesGenerator.java   
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;
}
项目:Aki-SSL    文件:KDFDoublePipelineIterationBytesGenerator.java   
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;
}
项目:Aki-SSL    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:Aki-SSL    文件:KDFFeedbackBytesGenerator.java   
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;
}
项目:jcifs-ng    文件:Smb3KeyDerivation.java   
/**
 * @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;
}
项目:TinyTravelTracker    文件:DHKEKGenerator.java   
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();
}
项目:TinyTravelTracker    文件:ECDHKEKGenerator.java   
public void init(DerivationParameters param)
{
    DHKDFParameters params = (DHKDFParameters)param;

    this.algorithm = params.getAlgorithm();
    this.keySize = params.getKeySize();
    this.z = params.getZ();
}
项目:TinyTravelTracker    文件:KDFCounterBytesGenerator.java   
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;
}
项目:TinyTravelTracker    文件:KDFDoublePipelineIterationBytesGenerator.java   
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;
}
项目:TinyTravelTracker    文件:MGF1BytesGenerator.java   
public void init(
    DerivationParameters    param)
{
    if (!(param instanceof MGFParameters))
    {
        throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
    }

    MGFParameters   p = (MGFParameters)param;

    seed = p.getSeed();
}
项目:TinyTravelTracker    文件:KDFFeedbackBytesGenerator.java   
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;
}