diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/crypto/tls/TlsUtilities.cs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/crypto/src/crypto/tls/TlsUtilities.cs b/crypto/src/crypto/tls/TlsUtilities.cs index f07626852..08fb6f0a4 100644 --- a/crypto/src/crypto/tls/TlsUtilities.cs +++ b/crypto/src/crypto/tls/TlsUtilities.cs @@ -25,18 +25,36 @@ namespace Org.BouncyCastle.Crypto.Tls throw new TlsFatalAlert(AlertDescription.internal_error); } + public static void CheckUint8(long i) + { + if (!IsValidUint8(i)) + throw new TlsFatalAlert(AlertDescription.internal_error); + } + public static void CheckUint16(int i) { if (!IsValidUint16(i)) throw new TlsFatalAlert(AlertDescription.internal_error); } + public static void CheckUint16(long i) + { + if (!IsValidUint16(i)) + throw new TlsFatalAlert(AlertDescription.internal_error); + } + public static void CheckUint24(int i) { if (!IsValidUint24(i)) throw new TlsFatalAlert(AlertDescription.internal_error); } + public static void CheckUint24(long i) + { + if (!IsValidUint24(i)) + throw new TlsFatalAlert(AlertDescription.internal_error); + } + public static void CheckUint32(long i) { if (!IsValidUint32(i)) @@ -60,15 +78,31 @@ namespace Org.BouncyCastle.Crypto.Tls return (i & 0xFF) == i; } + public static bool IsValidUint8(long i) + { + return (i & 0xFFL) == i; + } + public static bool IsValidUint16(int i) { return (i & 0xFFFF) == i; } + public static bool IsValidUint16(long i) + { + return (i & 0xFFFFL) == i; + } + public static bool IsValidUint24(int i) { return (i & 0xFFFFFF) == i; } + + public static bool IsValidUint24(long i) + { + return (i & 0xFFFFFFL) == i; + } + public static bool IsValidUint32(long i) { return (i & 0xFFFFFFFFL) == i; |