Example #1
0
        public void TestCounter0(string keyHex, string ivHex, string hex, string hex2)
        {
            var key = keyHex.FromHex();
            var iv  = ivHex.FromHex();

            TestCounter0(new BcXChaCha20Crypto(key, iv), hex, hex2);
            TestCounter0(new XChaCha20CryptoSF(key, iv), hex, hex2);
            TestCounter0(new XChaCha20CryptoX86(key, iv), hex, hex2);
            TestCounter0(StreamCryptoCreate.XChaCha20(key, iv), hex, hex2);
        }
Example #2
0
    public XChaCha20Poly1305Crypto(ReadOnlySpan <byte> key)
    {
        if (key.Length < KeySize)
        {
            throw new ArgumentException(@"Key length must be 32 bytes.", nameof(key));
        }

        _chacha20 = StreamCryptoCreate.XChaCha20(key);

        _buffer = ArrayPool <byte> .Shared.Rent(32);
    }
Example #3
0
 protected override IStreamCrypto CreateCrypto(bool isEncrypt, ReadOnlySpan <byte> key, ReadOnlySpan <byte> iv)
 {
     return(StreamCryptoCreate.XChaCha20(key, iv));
 }