public static void OperationWithWrongKey(StreamCipherAlgorithm a)
 {
     using (var k = new Key(SignatureAlgorithm.Ed25519))
     {
         Assert.Throws <ArgumentException>("key", () => a.GeneratePseudoRandomStream(k, default(Nonce), 1));
         Assert.Throws <ArgumentException>("key", () => a.XOr(k, default(Nonce), ReadOnlySpan <byte> .Empty));
         Assert.Throws <ArgumentException>("key", () => a.XOrIC(k, default(Nonce), ReadOnlySpan <byte> .Empty, 1));
     }
 }
 public static void OperationWithNonceTooSmall(StreamCipherAlgorithm a)
 {
     using (var k = new Key(a))
     {
         Assert.Throws <ArgumentException>("nonce", () => a.GeneratePseudoRandomStream(k, new Nonce(0, a.NonceSize - 1), 1));
         Assert.Throws <ArgumentException>("nonce", () => a.XOr(k, new Nonce(0, a.NonceSize - 1), ReadOnlySpan <byte> .Empty));
         Assert.Throws <ArgumentException>("nonce", () => a.XOrIC(k, new Nonce(0, a.NonceSize - 1), ReadOnlySpan <byte> .Empty, 1));
     }
 }
        public static void OperationWithDisposedKey(StreamCipherAlgorithm a)
        {
            var k = new Key(a);

            k.Dispose();
            Assert.Throws <ObjectDisposedException>(() => a.GeneratePseudoRandomStream(k, new Nonce(0, a.NonceSize), 1));
            Assert.Throws <ObjectDisposedException>(() => a.XOr(k, new Nonce(0, a.NonceSize), ReadOnlySpan <byte> .Empty));
            Assert.Throws <ObjectDisposedException>(() => a.XOrIC(k, new Nonce(0, a.NonceSize), ReadOnlySpan <byte> .Empty, 1));
        }
 public static void OperationWithSpanWithNullKey(StreamCipherAlgorithm a)
 {
     Assert.Throws <ArgumentNullException>("key", () => a.GeneratePseudoRandomStream(null, default(Nonce), Span <byte> .Empty));
     Assert.Throws <ArgumentNullException>("key", () => a.XOr(null, default(Nonce), ReadOnlySpan <byte> .Empty, Span <byte> .Empty));
     Assert.Throws <ArgumentNullException>("key", () => a.XOrIC(null, default(Nonce), ReadOnlySpan <byte> .Empty, Span <byte> .Empty, 1));
 }