Search in sources :

Example 1 with RC2Parameters

use of org.bouncycastle.crypto.params.RC2Parameters in project robovm by robovm.

the class RC2Engine method init.

/**
     * initialise a RC2 cipher.
     *
     * @param encrypting whether or not we are for encryption.
     * @param params the parameters required to set up the cipher.
     * @exception IllegalArgumentException if the params argument is
     * inappropriate.
     */
public void init(boolean encrypting, CipherParameters params) {
    this.encrypting = encrypting;
    if (params instanceof RC2Parameters) {
        RC2Parameters param = (RC2Parameters) params;
        workingKey = generateWorkingKey(param.getKey(), param.getEffectiveKeyBits());
    } else if (params instanceof KeyParameter) {
        byte[] key = ((KeyParameter) params).getKey();
        workingKey = generateWorkingKey(key, key.length * 8);
    } else {
        throw new IllegalArgumentException("invalid parameter passed to RC2 init - " + params.getClass().getName());
    }
}
Also used : RC2Parameters(org.bouncycastle.crypto.params.RC2Parameters) KeyParameter(org.bouncycastle.crypto.params.KeyParameter)

Example 2 with RC2Parameters

use of org.bouncycastle.crypto.params.RC2Parameters in project XobotOS by xamarin.

the class RC2Engine method init.

/**
     * initialise a RC2 cipher.
     *
     * @param encrypting whether or not we are for encryption.
     * @param params the parameters required to set up the cipher.
     * @exception IllegalArgumentException if the params argument is
     * inappropriate.
     */
public void init(boolean encrypting, CipherParameters params) {
    this.encrypting = encrypting;
    if (params instanceof RC2Parameters) {
        RC2Parameters param = (RC2Parameters) params;
        workingKey = generateWorkingKey(param.getKey(), param.getEffectiveKeyBits());
    } else if (params instanceof KeyParameter) {
        byte[] key = ((KeyParameter) params).getKey();
        workingKey = generateWorkingKey(key, key.length * 8);
    } else {
        throw new IllegalArgumentException("invalid parameter passed to RC2 init - " + params.getClass().getName());
    }
}
Also used : RC2Parameters(org.bouncycastle.crypto.params.RC2Parameters) KeyParameter(org.bouncycastle.crypto.params.KeyParameter)

Aggregations

KeyParameter (org.bouncycastle.crypto.params.KeyParameter)2 RC2Parameters (org.bouncycastle.crypto.params.RC2Parameters)2