Esempio n. 1
0
        /// <see cref="System.Security.Cryptography.SymmetricAlgorithm.CreateDecryptor(byte[], byte[])"/>
        public override ICryptoTransform CreateDecryptor(byte[] key, byte[] iv)
        {
            BlowfishAlgorithm result = new BlowfishAlgorithm(
                key,
                iv,
                (CipherMode.CBC == ModeValue),
                false);

            CopyPadding(result);
            return(result);
        }
Esempio n. 2
0
        void CopyPadding(BlowfishAlgorithm ba)
        {
            switch (Padding)
            {
            case PaddingMode.ANSIX923:
            case PaddingMode.ISO10126:
            case PaddingMode.PKCS7:
            case PaddingMode.Zeros:
            {
                ba.Padding = Padding;
                break;
            }

            default:
            {
                throw new CryptographicException(String.Format(Resources.BFALGO_UNSUPPORTED_PADDINGMODE_1, Padding));
            }
            }
        }
Esempio n. 3
0
        void CopyPadding(BlowfishAlgorithm ba)
        {
            switch (Padding)
            {
            case PaddingMode.ANSIX923:
            case PaddingMode.ISO10126:
            case PaddingMode.PKCS7:
            case PaddingMode.Zeros:
            {
                ba.Padding = Padding;
                break;
            }

            default:
            {
                throw new CryptographicException(String.Format("Unsupported padding mode {0}.", Padding));
            }
            }
        }