Esempio n. 1
0
 public FeistelCipher(int keySize, FeistelType feistelType, CipherMode cipherMode)
 {
     _feistelType = feistelType;
     _cipherMode  = cipherMode;
     _key         = GenerateKey(keySize);
     _blockSize   = _key.Length * ((feistelType == FeistelType.ClassicFeistel) ? 2 : 4);
     if (cipherMode == CipherMode.CBC)
     {
         _IVcbc = GenerateIV(_blockSize);
     }
     if (cipherMode == CipherMode.CFB)
     {
         _IVcfb = GenerateIV(_blockSize);
     }
 }
Esempio n. 2
0
 public FeistelCipher(byte[] key, FeistelType feistelType, CipherMode cipherMode) : this(key.Length, feistelType, cipherMode)
 {
     if (key.Length % 2 != 0)
     {
         throw new Exception("Key size must be multiple of 2 size!");
     }
     _key       = key;
     _blockSize = key.Length * ((feistelType == FeistelType.ClassicFeistel) ? 2 : 4);
     if (cipherMode == CipherMode.CBC)
     {
         _IVcbc = GenerateIV(_blockSize);
     }
     if (cipherMode == CipherMode.CFB)
     {
         _IVcfb = GenerateIV(_blockSize * 4);
     }
 }