示例#1
0
        /// <summary>
        /// constructor
        /// </summary>
        public BlowfishAlgorithm() : base()
        {
            m_bf  = null;
            m_bfc = null;

            // FIXME: are we supposed to create a default key and IV?
            IVValue      = null;
            KeyValue     = null;
            KeySizeValue = Blowfish.MAXKEYLENGTH * 8;

            LegalBlockSizesValue    = new KeySizes[1];
            LegalBlockSizesValue[0] = new KeySizes(BlockSize, BlockSize, 8);

            LegalKeySizesValue    = new KeySizes[1];
            LegalKeySizesValue[0] = new KeySizes(0, Blowfish.MAXKEYLENGTH * 8, 8);

            ModeValue = CipherMode.ECB;

            m_rng = null;
        }
示例#2
0
        BlowfishAlgorithm
        (
            byte[] key,
            byte[] iv,
            bool blCBC,
            bool blIsEncryptor
        )
        {
            if (null == key)
            {
                GenerateKey();
            }
            else
            {
                Key = key;
            }

            if (blCBC)
            {
                if (null == iv)
                {
                    GenerateIV();
                }
                else
                {
                    IV = iv;
                }

                m_bf  = null;
                m_bfc = new BlowfishCBC(KeyValue, IVValue);
            }
            else
            {
                m_bf  = new Blowfish(KeyValue);
                m_bfc = null;
            }

            m_blIsEncryptor = blIsEncryptor;
        }