コード例 #1
0
ファイル: CsprngFactory.cs プロジェクト: viruswevh/ObscurCore
        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);
        }
コード例 #2
0
        public static StreamCipherCsprngConfiguration CreateRandomConfiguration(CsPseudorandomNumberGenerator csprng)
        {
            var cipherEnum = csprng.ToString().ToEnum <StreamCipher>();
            var config     = new StreamCipherCsprngConfiguration {
                CipherName = csprng.ToString(),
                Key        = new byte[Athena.Cryptography.StreamCiphers[cipherEnum].DefaultKeySizeBits / 8],
                Nonce      = new byte[Athena.Cryptography.StreamCiphers[cipherEnum].DefaultNonceSizeBits / 8]
            };

            StratCom.EntropySupplier.NextBytes(config.Key);
            StratCom.EntropySupplier.NextBytes(config.Nonce);
            return(config);
        }
コード例 #3
0
 public StreamCipherCsprngMuxEntropySource(StreamCipherCsprngConfiguration config)
 {
     EntropySource = CsPrngFactory.CreateCsprng(config);
 }