diff options
Diffstat (limited to 'crypto/src/math/raw/Nat.cs')
-rw-r--r-- | crypto/src/math/raw/Nat.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/src/math/raw/Nat.cs b/crypto/src/math/raw/Nat.cs index f9e4e6714..5cf5fe218 100644 --- a/crypto/src/math/raw/Nat.cs +++ b/crypto/src/math/raw/Nat.cs @@ -384,6 +384,22 @@ namespace Org.BouncyCastle.Math.Raw return z; } + public static ulong[] FromBigInteger64(int bits, BigInteger x) + { + if (x.SignValue < 0 || x.BitLength > bits) + throw new ArgumentException(); + + int len = (bits + 63) >> 6; + ulong[] z = Create64(len); + int i = 0; + while (x.SignValue != 0) + { + z[i++] = (ulong)x.LongValue; + x = x.ShiftRight(64); + } + return z; + } + public static uint GetBit(uint[] x, int bit) { if (bit == 0) |