diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-07-24 10:14:36 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-07-24 10:14:36 +0400 |
commit | 4802f833909cb5a30439600ae370429bb89c27fe (patch) | |
tree | 82a2443652b19d4650b6f12f357ca9f9b3cafc71 | |
parent | 5eac201dfd4c0fcde84afacc4288ec0fbd9c5ba3 (diff) |
Add more variations of check/isValid
-rw-r--r-- | core/src/main/java/org/bouncycastle/crypto/tls/TlsUtils.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/core/src/main/java/org/bouncycastle/crypto/tls/TlsUtils.java b/core/src/main/java/org/bouncycastle/crypto/tls/TlsUtils.java index a1cf9d4b..552486b3 100644 --- a/core/src/main/java/org/bouncycastle/crypto/tls/TlsUtils.java +++ b/core/src/main/java/org/bouncycastle/crypto/tls/TlsUtils.java @@ -63,6 +63,14 @@ public class TlsUtils } } + public static void checkUint8(long i) throws IOException + { + if (!isValidUint8(i)) + { + throw new TlsFatalAlert(AlertDescription.internal_error); + } + } + public static void checkUint16(int i) throws IOException { if (!isValidUint16(i)) @@ -71,6 +79,14 @@ public class TlsUtils } } + public static void checkUint16(long i) throws IOException + { + if (!isValidUint16(i)) + { + throw new TlsFatalAlert(AlertDescription.internal_error); + } + } + public static void checkUint24(int i) throws IOException { if (!isValidUint24(i)) @@ -79,6 +95,14 @@ public class TlsUtils } } + public static void checkUint24(long i) throws IOException + { + if (!isValidUint24(i)) + { + throw new TlsFatalAlert(AlertDescription.internal_error); + } + } + public static void checkUint32(long i) throws IOException { if (!isValidUint32(i)) @@ -113,16 +137,31 @@ public class TlsUtils return (i & 0xFF) == i; } + public static boolean isValidUint8(long i) + { + return (i & 0xFFL) == i; + } + public static boolean isValidUint16(int i) { return (i & 0xFFFF) == i; } + public static boolean isValidUint16(long i) + { + return (i & 0xFFFFL) == i; + } + public static boolean isValidUint24(int i) { return (i & 0xFFFFFF) == i; } + public static boolean isValidUint24(long i) + { + return (i & 0xFFFFFFL) == i; + } + public static boolean isValidUint32(long i) { return (i & 0xFFFFFFFFL) == i; |