Beispiel #1
0
        /**
         * initialise the RSA engine.
         *
         * @param forEncryption true if we are encrypting, false otherwise.
         * @param param the necessary RSA key parameters.
         */
        public virtual void Init(
            bool forEncryption,
            ICipherParameters parameters)
        {
            if (core == null)
            {
                core = new RsaCoreEngine();
            }

            core.Init(forEncryption, parameters);
        }
Beispiel #2
0
        /**
         * initialise the RSA engine.
         *
         * @param forEncryption true if we are encrypting, false otherwise.
         * @param param the necessary RSA key parameters.
         */
        public virtual void Init(
            bool forEncryption,
            ICipherParameters param)
        {
            core.Init(forEncryption, param);

            if (param is ParametersWithRandom)
            {
                ParametersWithRandom rParam = (ParametersWithRandom)param;

                key    = (RsaKeyParameters)rParam.Parameters;
                random = rParam.Random;
            }
            else
            {
                key    = (RsaKeyParameters)param;
                random = new SecureRandom();
            }
        }
Beispiel #3
0
        /**
         * Initialise the blinding engine.
         *
         * @param forEncryption true if we are encrypting (blinding), false otherwise.
         * @param param         the necessary RSA key parameters.
         */
        public virtual void Init(
            bool forEncryption,
            ICipherParameters param)
        {
            RsaBlindingParameters p;

            if (param is ParametersWithRandom)
            {
                ParametersWithRandom rParam = (ParametersWithRandom)param;

                p = (RsaBlindingParameters)rParam.Parameters;
            }
            else
            {
                p = (RsaBlindingParameters)param;
            }

            core.Init(forEncryption, p.PublicKey);

            this.forEncryption  = forEncryption;
            this.key            = p.PublicKey;
            this.blindingFactor = p.BlindingFactor;
        }