Search in sources :

Example 1 with KDFCounterParameters

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

the class KDFCounterBytesGenerator method init.

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

Aggregations

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