Exemplo n.º 1
0
        public static CsPrng CreateCsprng(StreamCipherCsprngConfiguration config)
        {
            var streamCipherEnum            = config.CipherName.ToEnum <StreamCipher>();
            StreamCipherEngine streamCipher = CipherFactory.CreateStreamCipher(streamCipherEnum);
            var csprng = new StreamCsPrng(streamCipher, config.Key, config.Nonce);

            return(csprng);
        }
Exemplo n.º 2
0
 public StreamCsPrng(StreamCipherEngine cipher, byte[] key, byte[] nonce)
     : base(cipher.StateSize)
 {
     _csPrng = cipher as ICsPrngCompatible;
     if (_csPrng == null)
     {
         throw new ArgumentException();
     }
     _stateBuf = new byte[StateSize];
     cipher.Init(true, key, nonce);
 }