@@ -66,7 +66,7 @@ data CryptHandle
6666msDefProv :: String
6767msDefProv = "Microsoft Base Cryptographic Provider v1.0"
6868provRSAFull :: Word32
69−provRSAFull = fromIntegral 1
69+provRSAFull = 1
7070cryptVerifyContext :: Word32
7171cryptVerifyContext = fromIntegral 0xF0000000
7272
@@ -79,10 +79,10 @@ foreign import stdcall unsafe "CryptReleaseContext"
7979 c_cryptReleaseCtx :: Word32 -> Word32 -> IO Int32
8080
8181cryptAcquireCtx :: IO Word32
82−cryptAcquireCtx =
82+cryptAcquireCtx =
8383 alloca $ \handlePtr ->
8484 withCString msDefProv $ \provName -> do
85− stat <- c_cryptAcquireCtx handlePtr nullPtr provName (fromIntegral 1) (fromIntegral cryptVerifyContext)
85+ stat <- c_cryptAcquireCtx handlePtr nullPtr provName provRSAFull cryptVerifyContext
8686 if (toBool stat)
8787 then peek handlePtr
8888 else fail "c_cryptAcquireCtx"
@@ -90,7 +90,7 @@ cryptAcquireCtx =
9090cryptGenRandom :: Word32 -> Int -> IO B.ByteString
9191cryptGenRandom h i =
9292 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
9494 if (toBool stat)
9595 then return ()
9696 else fail "c_cryptGenRandom"
@@ -113,6 +113,7 @@ openHandle = do
113113 liftM CH cryptAcquireCtx
114114
115115-- |Close the `CryptHandle`
116+closeHandle :: CryptHandle -> IO ()
116117closeHandle (CH h) = cryptReleaseCtx h
117118
118119-- |Read from `CryptHandle`