git.iko.soy/typeable/entropy
on main help sign in
Code clean for, one last windows build-test prior to push.
9932e9aThomas M. DuBuisson
Setup.hs+1−1
@@ -29,7 +29,7 @@ cArgs :: [String]
29cArgs = ["-DHAVE_RDRAND"]
29cArgs = ["-DHAVE_RDRAND"]
30
30
31cArgsHC :: [String]
31cArgsHC :: [String]
32−cArgsHC = map ("-optc" ++) cArgs
32+cArgsHC = cArgs ++ map ("-optc" ++) cArgs
33
33
34canUseRDRAND :: FilePath -> IO Bool
34canUseRDRAND :: FilePath -> IO Bool
35canUseRDRAND cc = do
35canUseRDRAND cc = do
System/EntropyWindows.hs+5−4
@@ -66,7 +66,7 @@ data CryptHandle
66msDefProv :: String
66msDefProv :: String
67msDefProv = "Microsoft Base Cryptographic Provider v1.0"
67msDefProv = "Microsoft Base Cryptographic Provider v1.0"
68provRSAFull :: Word32
68provRSAFull :: Word32
69−provRSAFull = fromIntegral 1
69+provRSAFull = 1
70cryptVerifyContext :: Word32
70cryptVerifyContext :: Word32
71cryptVerifyContext = fromIntegral 0xF0000000
71cryptVerifyContext = fromIntegral 0xF0000000
72
72
@@ -79,10 +79,10 @@ foreign import stdcall unsafe "CryptReleaseContext"
79 c_cryptReleaseCtx :: Word32 -> Word32 -> IO Int32
79 c_cryptReleaseCtx :: Word32 -> Word32 -> IO Int32
80
80
81cryptAcquireCtx :: IO Word32
81cryptAcquireCtx :: IO Word32
82−cryptAcquireCtx =
82+cryptAcquireCtx =
83 alloca $ \handlePtr ->
83 alloca $ \handlePtr ->
84 withCString msDefProv $ \provName -> do
84 withCString msDefProv $ \provName -> do
85− stat <- c_cryptAcquireCtx handlePtr nullPtr provName (fromIntegral 1) (fromIntegral cryptVerifyContext)
85+ stat <- c_cryptAcquireCtx handlePtr nullPtr provName provRSAFull cryptVerifyContext
86 if (toBool stat)
86 if (toBool stat)
87 then peek handlePtr
87 then peek handlePtr
88 else fail "c_cryptAcquireCtx"
88 else fail "c_cryptAcquireCtx"
@@ -90,7 +90,7 @@ cryptAcquireCtx =
90cryptGenRandom :: Word32 -> Int -> IO B.ByteString
90cryptGenRandom :: Word32 -> Int -> IO B.ByteString
91cryptGenRandom h i =
91cryptGenRandom h i =
92 BI.create i $ \c_buffer -> do
92 BI.create i $ \c_buffer -> do
93− stat <- c_cryptGenRandom (fromIntegral h) (fromIntegral i) c_buffer
93+ stat <- c_cryptGenRandom h (fromIntegral i) c_buffer
94 if (toBool stat)
94 if (toBool stat)
95 then return ()
95 then return ()
96 else fail "c_cryptGenRandom"
96 else fail "c_cryptGenRandom"
@@ -113,6 +113,7 @@ openHandle = do
113 liftM CH cryptAcquireCtx
113 liftM CH cryptAcquireCtx
114
114
115-- |Close the `CryptHandle`
115-- |Close the `CryptHandle`
116+closeHandle :: CryptHandle -> IO ()
116closeHandle (CH h) = cryptReleaseCtx h
117closeHandle (CH h) = cryptReleaseCtx h
117
118
118-- |Read from `CryptHandle`
119-- |Read from `CryptHandle`
entropy.cabal+1−1
@@ -30,7 +30,7 @@ flag halvm
30 description: Build for the HaLVM
30 description: Build for the HaLVM
31 default: False
31 default: False
32library
32library
33− ghc-options: -Wall -O2
33+ ghc-options: -O2
34 exposed-modules: System.Entropy
34 exposed-modules: System.Entropy
35 if os(windows)
35 if os(windows)
36 other-modules: System.EntropyWindows
36 other-modules: System.EntropyWindows