public void XChaCha20BlockWhenLengthIsInvalidFails() { // Arrange var key = new byte[Snuffle.KEY_SIZE_IN_BYTES]; var cipher = new XChaCha20(key, 0); var nonce = new byte[cipher.NonceSizeInBytes() + TestHelpers.ReturnRandomPositiveNegative()]; var block = new byte[0]; // Act & Assert Assert.Throws <CryptographicException>(() => cipher.ProcessKeyStreamBlock(nonce, 0, block)); }
public void XChaCha20BlockWhenNonceLengthIsEmptyFails() { // Arrange var key = new byte[Snuffle.KEY_SIZE_IN_BYTES]; var cipher = new XChaCha20(key, 0); var nonce = new byte[0]; var block = new byte[Snuffle.BLOCK_SIZE_IN_BYTES]; // Act & Assert Assert.Throws <CryptographicException>(() => cipher.ProcessKeyStreamBlock(nonce, 0, block)); }
public void XChaCha20BlockWhenLengthIsInvalidFails() { // Arrange var key = new byte[Snuffle.KEY_SIZE_IN_BYTES]; var cipher = new XChaCha20(key, 0); var nonce = new byte[XChaCha20.NONCE_SIZE_IN_BYTES + TestHelpers.ReturnRandomPositiveNegative()]; var block = new byte[0]; // Act & Assert Action act = () => cipher.ProcessKeyStreamBlock(nonce, 0, block); act.Should().Throw <CryptographicException>(); }