Example #1
0
 public static ICipher Cipher(byte[] iv, List <uint> subKeys, CipherTypes cipher, ISBlock sBlock)
 {
     return(cipher switch
     {
         CipherTypes.Substitution => new SubstitutionCipher(sBlock),
         CipherTypes.Cfb => new CbfCipher(iv, sBlock),
         CipherTypes.Xor => new XorCipher(iv, subKeys, sBlock),
         _ => throw new ArgumentException(nameof(cipher)),
     });
Example #2
0
        public GostManager(byte[] key, byte[] iv, byte[] message, CipherTypes cipherType = CipherTypes.Substitution, SBlockTypes sBlockType = SBlockTypes.GOST)
        {
            released = false;
            _subKeys = new List <uint>();

            Key     = key;
            IV      = iv;
            Message = message;

            GenerateSubKeys();

            _sBlock = SBlockFactory.SBlock(sBlockType);
            _cipher = CipherFactory.Cipher(_iv, _subKeys, cipherType, _sBlock);
        }