Search in sources :

Example 1 with KDFDoublePipelineIterationParameters

use of com.github.zhenwei.core.crypto.params.KDFDoublePipelineIterationParameters in project LinLong-Java by zhenwei1108.

the class KDFDoublePipelineIterationBytesGenerator method init.

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;
}
Also used : KeyParameter(com.github.zhenwei.core.crypto.params.KeyParameter) BigInteger(java.math.BigInteger) KDFDoublePipelineIterationParameters(com.github.zhenwei.core.crypto.params.KDFDoublePipelineIterationParameters)

Aggregations

KDFDoublePipelineIterationParameters (com.github.zhenwei.core.crypto.params.KDFDoublePipelineIterationParameters)1 KeyParameter (com.github.zhenwei.core.crypto.params.KeyParameter)1 BigInteger (java.math.BigInteger)1