Skip to content

Commit

Permalink
Move DecryptFailClearsPlaintext test to the right section
Browse files Browse the repository at this point in the history
  • Loading branch information
ektrah committed Nov 14, 2020
1 parent fe6ed6f commit 75763a0
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions tests/Base/AeadAlgorithmTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,24 +285,6 @@ public static void DecryptWithCiphertextTooSmall(AeadAlgorithm a)
Assert.Null(a.Decrypt(k, Utilities.RandomBytes.Slice(0, a.NonceSize), ReadOnlySpan<byte>.Empty, new byte[a.TagSize - 1]));
}

[Theory]
[MemberData(nameof(AeadAlgorithms))]
public static void DecryptFailClearsPlaintext(AeadAlgorithm a)
{
using var k = new Key(a);

var pt = new byte[16];
for (var i = 0; i < pt.Length; i++)
{
pt[i] = 0xD6;
}

var ct = new byte[pt.Length + a.TagSize];

Assert.False(a.Decrypt(k, Utilities.RandomBytes.Slice(0, a.NonceSize), ReadOnlySpan<byte>.Empty, ct, pt));
Assert.Equal(new byte[pt.Length], pt);
}

[Theory]
[MemberData(nameof(AeadAlgorithms))]
public static void DecryptEmptySuccess(AeadAlgorithm a)
Expand Down Expand Up @@ -454,6 +436,24 @@ public static void DecryptWithSpanInPlace(AeadAlgorithm a)
Assert.Equal(expected, actual);
}

[Theory]
[MemberData(nameof(AeadAlgorithms))]
public static void DecryptFailClearsPlaintext(AeadAlgorithm a)
{
using var k = new Key(a);

var pt = new byte[16];
for (var i = 0; i < pt.Length; i++)
{
pt[i] = 0xD6;
}

var ct = new byte[pt.Length + a.TagSize];

Assert.False(a.Decrypt(k, Utilities.RandomBytes.Slice(0, a.NonceSize), ReadOnlySpan<byte>.Empty, ct, pt));
Assert.Equal(new byte[pt.Length], pt);
}

#endregion

#region CreateKey
Expand Down

0 comments on commit 75763a0

Please sign in to comment.