diff --git a/crypto/src/crypto/Check.cs b/crypto/src/crypto/Check.cs
index 36263dc24..035304db4 100644
--- a/crypto/src/crypto/Check.cs
+++ b/crypto/src/crypto/Check.cs
@@ -2,38 +2,47 @@
namespace Org.BouncyCastle.Crypto
{
- internal class Check
+ internal static class Check
{
- internal static void DataLength(bool condition, string msg)
+ internal static void DataLength(bool condition, string message)
{
if (condition)
- throw new DataLengthException(msg);
+ ThrowDataLengthException(message);
}
- internal static void DataLength(byte[] buf, int off, int len, string msg)
+ internal static void DataLength(byte[] buf, int off, int len, string message)
{
if (off > (buf.Length - len))
- throw new DataLengthException(msg);
+ ThrowDataLengthException(message);
}
- internal static void OutputLength(byte[] buf, int off, int len, string msg)
+ internal static void OutputLength(bool condition, string message)
+ {
+ if (condition)
+ ThrowOutputLengthException(message);
+ }
+
+ internal static void OutputLength(byte[] buf, int off, int len, string message)
{
if (off > (buf.Length - len))
- throw new OutputLengthException(msg);
+ ThrowOutputLengthException(message);
}
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
- internal static void DataLength(ReadOnlySpan<byte> input, int len, string msg)
+ internal static void DataLength<T>(ReadOnlySpan<T> input, int len, string message)
{
if (input.Length < len)
- throw new DataLengthException(msg);
+ ThrowDataLengthException(message);
}
- internal static void OutputLength(Span<byte> output, int len, string msg)
+ internal static void OutputLength<T>(Span<T> output, int len, string message)
{
if (output.Length < len)
- throw new OutputLengthException(msg);
+ ThrowOutputLengthException(message);
}
#endif
+
+ internal static void ThrowDataLengthException(string message) => throw new DataLengthException(message);
+ internal static void ThrowOutputLengthException(string message) => throw new OutputLengthException(message);
}
}
|