コード例 #1
0
ファイル: CipherInfo.cs プロジェクト: jinhang2008/FxSsh
        public CipherInfo(SymmetricAlgorithm algorithm, int keySize, CipherModeEx mode)
        {
            Contract.Requires(algorithm != null);
            Contract.Requires(algorithm.LegalKeySizes.Any(x =>
                x.MinSize <= keySize && keySize <= x.MaxSize && keySize % x.SkipSize == 0));

            algorithm.KeySize = keySize;
            KeySize = algorithm.KeySize;
            BlockSize = algorithm.BlockSize;
            Cipher = (key, vi, isEncryption) => new EncryptionAlgorithm(algorithm, keySize, mode, key, vi, isEncryption);
        }
コード例 #2
0
        public CipherInfo(SymmetricAlgorithm algorithm, int keySize, CipherModeEx mode)
        {
            Contract.Requires(algorithm != null);
            Contract.Requires(algorithm.LegalKeySizes.Any(x =>
                                                          x.MinSize <= keySize && keySize <= x.MaxSize && keySize % x.SkipSize == 0));

            algorithm.KeySize = keySize;
            KeySize           = algorithm.KeySize;
            BlockSize         = algorithm.BlockSize;
            Cipher            = (key, vi, isEncryption) => new EncryptionAlgorithm(algorithm, keySize, mode, key, vi, isEncryption);
        }
コード例 #3
0
        public EncryptionAlgorithm(SymmetricAlgorithm algorithm, int keySize, CipherModeEx mode, byte[] key, byte[] iv, bool isEncryption)
        {
            Contract.Requires(algorithm != null);
            Contract.Requires(key != null);
            Contract.Requires(iv != null);
            Contract.Requires(keySize == key.Length << 3);

            algorithm.KeySize = keySize;
            algorithm.Key     = key;
            algorithm.IV      = iv;
            algorithm.Padding = PaddingMode.None;

            _algorithm = algorithm;
            _mode      = mode;

            _transform = CreateTransform(isEncryption);
        }
コード例 #4
0
        public EncryptionAlgorithm(SymmetricAlgorithm algorithm, int keySize, CipherModeEx mode, byte[] key, byte[] iv, bool isEncryption)
        {
            Contract.Requires(algorithm != null);
            Contract.Requires(key != null);
            Contract.Requires(iv != null);
            Contract.Requires(keySize == key.Length << 3);

            algorithm.KeySize = keySize;
            algorithm.Key = key;
            algorithm.IV = iv;
            algorithm.Padding = PaddingMode.None;

            _algorithm = algorithm;
            _mode = mode;

            _transform = CreateTransform(isEncryption);
        }