Beispiel #1
0
        public virtual void init(bool forEncryption, KeyParameter @params)
        {
            int num = (int)forEncryption;

            this.WorkingKey    = this.generateWorkingKey(@params.getKey(), (bool)num);
            this.forEncryption = (bool)num;
        }
Beispiel #2
0
        /**
         * initialise a RC5-32 cipher.
         *
         * @param forEncryption whether or not we are for encryption.
         * @param params the parameters required to set up the cipher.
         * @exception ArgumentException if the params argument is
         * inappropriate.
         */
        public void init(
            bool forEncryption,
            CipherParameters parameters)
        {
            if (typeof(RC5Parameters).IsInstanceOfType(parameters))
            {
                RC5Parameters p = (RC5Parameters)parameters;

                _noRounds = p.getRounds();

                setKey(p.getKey());
            }
            else if (typeof(KeyParameter).IsInstanceOfType(parameters))
            {
                KeyParameter p = (KeyParameter)parameters;

                setKey(p.getKey());
            }
            else
            {
                throw new ArgumentException("invalid parameter passed to RC532 init - " + parameters.GetType().ToString());
            }

            this.forEncryption = forEncryption;
        }
Beispiel #3
0
        /**
         * initialise a RC5-32 cipher.
         *
         * @param forEncryption whether or not we are for encryption.
         * @param params the parameters required to set up the cipher.
         * @exception ArgumentException if the params argument is
         * inappropriate.
         */
        public void init(
            bool forEncryption,
            CipherParameters parameters)
        {
            if (!(typeof(KeyParameter).IsInstanceOfType(parameters)))
            {
                throw new ArgumentException("invalid parameter passed to RC6 init - " + parameters.GetType().ToString());
            }

            KeyParameter p = (KeyParameter)parameters;

            this.forEncryption = forEncryption;
            setKey(p.getKey());
        }