diff --git a/Crypto/Number/Compat.hs b/Crypto/Number/Compat.hs index 33c879b..4a73493 100644 --- a/Crypto/Number/Compat.hs +++ b/Crypto/Number/Compat.hs @@ -20,6 +20,7 @@ module Crypto.Number.Compat , gmpNextPrime , gmpTestPrimeMillerRabin , gmpSizeInBytes + , gmpSizeInBits , gmpExportInteger , gmpImportInteger ) where @@ -123,6 +124,13 @@ gmpSizeInBytes n = GmpSupported (I# (word2Int# (sizeInBaseInteger n 256#))) gmpSizeInBytes _ = GmpUnsupported #endif +gmpSizeInBits :: Integer -> GmpSupported Int +#if MIN_VERSION_integer_gmp(0,5,1) +gmpSizeInBits n = GmpSupported (I# (word2Int# (sizeInBaseInteger n 2#))) +#else +gmpSizeInBits _ = GmpUnsupported +#endif + -- | Export an integer to a memory gmpExportInteger :: Integer -> Ptr Word8 -> GmpSupported (IO ()) #if MIN_VERSION_integer_gmp(1,0,0)