summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-07-24 13:15:24 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-07-24 13:15:24 +0700
commit2d53cf14aeda106a550b15e8aa8c813fad2fffea (patch)
treec5253e8847c4b47bc3f2b37b51643d7de2db2a43 /crypto/src
parentApply low-hamming-weight NAF check for more generators (diff)
downloadBouncyCastle.NET-ed25519-2d53cf14aeda106a550b15e8aa8c813fad2fffea.tar.xz
Add more variations of Check/IsValid
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/crypto/tls/TlsUtilities.cs34
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;