Skip to content

Commit c7981ac

Browse files
committed
src: Fix tag parameter validation.
1 parent 0665643 commit c7981ac

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/MultiMAC/MultiMac.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static byte[] Compute(byte[] key1, byte[] key2, TagLength tagLength, para
4343

4444
public static bool Verify(byte[] tag, byte[] key1, byte[] key2, params byte[][] inputs)
4545
{
46-
ParameterValidation.Tag(tag, tag?.Length ?? 0);
46+
ParameterValidation.Tag(tag);
4747
byte[] computedTag = Compute(key1, key2, (TagLength)tag.Length, inputs);
4848
return Utilities.Compare(tag, computedTag);
4949
}

src/MultiMAC/ParameterValidation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ internal static void Inputs(params byte[][] inputs)
4040
}
4141
}
4242

43-
internal static void Tag(byte[] tag, int validTagLength)
43+
internal static void Tag(byte[] tag)
4444
{
4545
if (tag == null) { throw new ArgumentNullException(nameof(tag), "The tag cannot be null."); }
46-
if (tag.Length != validTagLength) { throw new ArgumentOutOfRangeException(nameof(tag), tag.Length, $"The tag must be {validTagLength} bytes in length."); }
46+
if (tag.Length != (int)TagLength.BLAKE2b256 & tag.Length != (int)TagLength.BLAKE2b384 & tag.Length != (int)TagLength.BLAKE2b512) { throw new ArgumentOutOfRangeException(nameof(tag), tag.Length, $"The tag must be {(int)TagLength.BLAKE2b256}, {(int)TagLength.BLAKE2b384}, or {(int)TagLength.BLAKE2b512} bytes in length."); }
4747
}
4848
}

0 commit comments

Comments
 (0)