Search in sources :

Example 1 with KDFFeedbackParameters

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

the class KDFFeedbackBytesGenerator method init.

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

Aggregations

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