示例#1
0
        /**
         * initialise a RC5-64 cipher.
         *
         * @param forEncryption whether or not we are for encryption.
         * @param parameters the parameters required to set up the cipher.
         * @exception ArgumentException if the parameters argument is
         * inappropriate.
         */
        public virtual void Init(
            bool forEncryption,
            ICipherParameters parameters)
        {
            if (!(typeof(RC5Parameters).IsInstanceOfType(parameters)))
            {
                throw new ArgumentException("invalid parameter passed to RC564 init - " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(parameters));
            }

            RC5Parameters p = (RC5Parameters)parameters;

            this.forEncryption = forEncryption;

            _noRounds = p.Rounds;

            SetKey(p.GetKey());
        }
示例#2
0
        /**
         * initialise a RC5-64 cipher.
         *
         * @param forEncryption whether or not we are for encryption.
         * @param parameters the parameters required to set up the cipher.
         * @exception ArgumentException if the parameters argument is
         * inappropriate.
         */
        public void Init(
            bool forEncryption,
            ICipherParameters parameters)
        {
            if (!(typeof(RC5Parameters).IsInstanceOfType(parameters)))
            {
                throw new ArgumentException("invalid parameter passed to RC564 init - " + parameters.GetType().ToString());
            }

            RC5Parameters p = (RC5Parameters)parameters;

            this.forEncryption = forEncryption;

            _noRounds = p.Rounds;

            SetKey(p.GetKey());
        }
示例#3
0
        /**
         * initialise a RC5-64 cipher.
         *
         * @param forEncryption whether or not we are for encryption.
         * @param parameters the parameters required to set up the cipher.
         * @exception ArgumentException if the parameters argument is
         * inappropriate.
         */
        public void Init(
            bool forEncryption,
            ICipherParameters parameters)
        {
            if (parameters == null || !typeof(RC5Parameters).GetTypeInfo().IsAssignableFrom(parameters.GetType().GetTypeInfo()))
            {
                throw new ArgumentException("invalid parameter passed to RC564 init - " + parameters.GetType().ToString());
            }

            RC5Parameters p = (RC5Parameters)parameters;

            this.forEncryption = forEncryption;

            _noRounds = p.Rounds;

            SetKey(p.GetKey());
        }
示例#4
0
 public virtual void Init(bool forEncryption, ICipherParameters parameters)
 {
     if (typeof(RC5Parameters).IsInstanceOfType(parameters))
     {
         RC5Parameters parameters2 = (RC5Parameters)parameters;
         this._noRounds = parameters2.Rounds;
         this.SetKey(parameters2.GetKey());
     }
     else
     {
         if (!typeof(KeyParameter).IsInstanceOfType(parameters))
         {
             throw new ArgumentException("invalid parameter passed to RC532 init - " + Platform.GetTypeName(parameters));
         }
         this.SetKey(((KeyParameter)parameters).GetKey());
     }
     this.forEncryption = forEncryption;
 }
示例#5
0
 public virtual void Init(bool forEncryption, ICipherParameters parameters)
 {
     if (typeof(RC5Parameters).IsInstanceOfType(parameters))
     {
         RC5Parameters rC5Parameters = (RC5Parameters)parameters;
         _noRounds = rC5Parameters.Rounds;
         SetKey(rC5Parameters.GetKey());
     }
     else
     {
         if (!typeof(KeyParameter).IsInstanceOfType(parameters))
         {
             throw new ArgumentException("invalid parameter passed to RC532 init - " + parameters.GetType().ToString());
         }
         KeyParameter keyParameter = (KeyParameter)parameters;
         SetKey(keyParameter.GetKey());
     }
     this.forEncryption = forEncryption;
 }
示例#6
0
 public virtual void Init(bool forEncryption, ICipherParameters parameters)
 {
     //IL_006a: Unknown result type (might be due to invalid IL or missing references)
     if (typeof(RC5Parameters).IsInstanceOfType((object)parameters))
     {
         RC5Parameters rC5Parameters = (RC5Parameters)parameters;
         _noRounds = rC5Parameters.Rounds;
         SetKey(rC5Parameters.GetKey());
     }
     else
     {
         if (!typeof(KeyParameter).IsInstanceOfType((object)parameters))
         {
             throw new ArgumentException("invalid parameter passed to RC532 init - " + Platform.GetTypeName(parameters));
         }
         KeyParameter keyParameter = (KeyParameter)parameters;
         SetKey(keyParameter.GetKey());
     }
     this.forEncryption = forEncryption;
 }
示例#7
0
        /**
         * initialise a RC5-32 cipher.
         *
         * @param forEncryption whether or not we are for encryption.
         * @param parameters the parameters required to set up the cipher.
         * @exception ArgumentException if the parameters argument is
         * inappropriate.
         */
        public void Init(
            bool forEncryption,
            ICipherParameters parameters)
        {
            //TODO: SUSTITUIDO. CAMBIAMOS EL IsInstanceOfType POR UN BLOQUE try - catch
            //if (typeof(RC5Parameters).IsInstanceOfType(parameters))
            //{
            //    RC5Parameters p = (RC5Parameters)parameters;
            //    _noRounds = p.Rounds;
            //    SetKey(p.GetKey());
            //}
            //else if (typeof(KeyParameter).GetType().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;

            try{
                RC5Parameters p = (RC5Parameters)parameters;
                _noRounds = p.Rounds;
                SetKey(p.GetKey());
            }
            catch (Exception e) {
                try
                {
                    KeyParameter p = (KeyParameter)parameters;
                    SetKey(p.GetKey());
                }
                catch (Exception e2)
                {
                    throw new ArgumentException("invalid parameter passed to RC532 init - " + parameters.GetType().ToString() + " e:" + e + " : " + e2);
                }
            }

            this.forEncryption = forEncryption;
        }