summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-08-09 14:26:50 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-08-09 14:26:50 +0700
commite4f9374cbc49e000340836488666995e5cc3f23d (patch)
treefdc1cde55584b4286e8f64847937613cbb14e177
parentEdDSA refactoring (diff)
downloadBouncyCastle.NET-ed25519-e4f9374cbc49e000340836488666995e5cc3f23d.tar.xz
Add IntValueExact and LongValueExact to BigInteger
-rw-r--r--crypto/src/math/BigInteger.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/crypto/src/math/BigInteger.cs b/crypto/src/math/BigInteger.cs
index 36f30d7c0..3badb6d2c 100644
--- a/crypto/src/math/BigInteger.cs
+++ b/crypto/src/math/BigInteger.cs
@@ -1332,6 +1332,17 @@ namespace Org.BouncyCastle.Math
             }
         }
 
+        public int IntValueExact
+        {
+            get
+            {
+                if (BitLength > 31)
+                    throw new ArithmeticException("BigInteger out of int range");
+
+                return IntValue;
+            }
+        }
+
         /**
          * return whether or not a BigInteger is probably prime with a
          * probability of 1 - (1/2)**certainty.
@@ -1588,6 +1599,17 @@ namespace Org.BouncyCastle.Math
             }
         }
 
+        public long LongValueExact
+        {
+            get
+            {
+                if (BitLength > 63)
+                    throw new ArithmeticException("BigInteger out of long range");
+
+                return LongValue;
+            }
+        }
+
         public BigInteger Max(
             BigInteger value)
         {