Пример #1
0
  /**
   * initialise a Rijndael cipher.
   *
   * @param forEncryption 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 forEncryption, CipherParameters params) {
    if (params instanceof KeyParameter) {
      workingKey = generateWorkingKey(((KeyParameter) params).getKey());
      this.forEncryption = forEncryption;
      return;
    }

    throw new IllegalArgumentException(
        "invalid parameter passed to Rijndael init - " + params.getClass().getName());
  }
Пример #2
0
  /**
   * initialise a CAST 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) {
    if (params instanceof KeyParameter) {
      _encrypting = encrypting;
      _workingKey = ((KeyParameter) params).getKey();

      setKey(_workingKey);

      return;
    }

    throw new IllegalArgumentException(
        "Invalid parameter passed to "
            + getAlgorithmName()
            + " init - "
            + params.getClass().getName());
  }