Search in sources :

Example 1 with RSABlindingParameters

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

the class PSSSigner method init.

public void init(boolean forSigning, CipherParameters param) {
    CipherParameters params;
    if (param instanceof ParametersWithRandom) {
        ParametersWithRandom p = (ParametersWithRandom) param;
        params = p.getParameters();
        random = p.getRandom();
    } else {
        params = param;
        if (forSigning) {
            random = CryptoServicesRegistrar.getSecureRandom();
        }
    }
    RSAKeyParameters kParam;
    if (params instanceof RSABlindingParameters) {
        kParam = ((RSABlindingParameters) params).getPublicKey();
        // pass on random
        cipher.init(forSigning, param);
    } else {
        kParam = (RSAKeyParameters) params;
        cipher.init(forSigning, params);
    }
    emBits = kParam.getModulus().bitLength() - 1;
    if (emBits < (8 * hLen + 8 * sLen + 9)) {
        throw new IllegalArgumentException("key too small for specified hash and salt lengths");
    }
    block = new byte[(emBits + 7) / 8];
    reset();
}
Also used : CipherParameters(com.github.zhenwei.core.crypto.CipherParameters) ParametersWithRandom(com.github.zhenwei.core.crypto.params.ParametersWithRandom) RSABlindingParameters(com.github.zhenwei.core.crypto.params.RSABlindingParameters) RSAKeyParameters(com.github.zhenwei.core.crypto.params.RSAKeyParameters)

Example 2 with RSABlindingParameters

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

the class RSABlindingEngine method init.

/**
 * Initialise the blinding engine.
 *
 * @param forEncryption true if we are encrypting (blinding), false otherwise.
 * @param param         the necessary RSA key parameters.
 */
public void init(boolean forEncryption, CipherParameters param) {
    RSABlindingParameters p;
    if (param instanceof ParametersWithRandom) {
        ParametersWithRandom rParam = (ParametersWithRandom) param;
        p = (RSABlindingParameters) rParam.getParameters();
    } else {
        p = (RSABlindingParameters) param;
    }
    core.init(forEncryption, p.getPublicKey());
    this.forEncryption = forEncryption;
    this.key = p.getPublicKey();
    this.blindingFactor = p.getBlindingFactor();
}
Also used : RSABlindingParameters(com.github.zhenwei.core.crypto.params.RSABlindingParameters) ParametersWithRandom(com.github.zhenwei.core.crypto.params.ParametersWithRandom)

Aggregations

ParametersWithRandom (com.github.zhenwei.core.crypto.params.ParametersWithRandom)2 RSABlindingParameters (com.github.zhenwei.core.crypto.params.RSABlindingParameters)2 CipherParameters (com.github.zhenwei.core.crypto.CipherParameters)1 RSAKeyParameters (com.github.zhenwei.core.crypto.params.RSAKeyParameters)1