Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Commit

Permalink
Fix the foreign types of the cipher functions to use CInt, not Int
Browse files Browse the repository at this point in the history
darcs-hash:20080311020054-19166-9c1b0b793059ba28bd59d0e4515f2c8b4c142e94.gz
  • Loading branch information
agl committed Mar 11, 2008
1 parent ce07d07 commit cb3caf1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions OpenSSL/EVP/Cipher.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ data CryptoMode = Encrypt | Decrypt


foreign import ccall unsafe "EVP_CipherInit"
_CipherInit :: Ptr EVP_CIPHER_CTX -> Ptr EVP_CIPHER -> CString -> CString -> Int -> IO Int
_CipherInit :: Ptr EVP_CIPHER_CTX -> Ptr EVP_CIPHER -> CString -> CString -> CInt -> IO CInt

foreign import ccall unsafe "EVP_CipherUpdate"
_CipherUpdate :: Ptr EVP_CIPHER_CTX -> Ptr CChar -> Ptr Int -> Ptr CChar -> Int -> IO Int
_CipherUpdate :: Ptr EVP_CIPHER_CTX -> Ptr CChar -> Ptr CInt -> Ptr CChar -> CInt -> IO CInt

foreign import ccall unsafe "EVP_CipherFinal"
_CipherFinal :: Ptr EVP_CIPHER_CTX -> Ptr CChar -> Ptr Int -> IO Int
_CipherFinal :: Ptr EVP_CIPHER_CTX -> Ptr CChar -> Ptr CInt -> IO CInt


cryptoModeToInt :: CryptoMode -> Int
cryptoModeToInt :: CryptoMode -> CInt
cryptoModeToInt Encrypt = 1
cryptoModeToInt Decrypt = 0

Expand All @@ -152,9 +152,9 @@ cipherUpdateBS ctx inBS
unsafeUseAsCStringLen inBS $ \ (inBuf, inLen) ->
createAndTrim (inLen + _ctx_block_size ctxPtr - 1) $ \ outBuf ->
alloca $ \ outLenPtr ->
_CipherUpdate ctxPtr (castPtr outBuf) outLenPtr inBuf inLen
_CipherUpdate ctxPtr (castPtr outBuf) outLenPtr inBuf (fromIntegral inLen)
>>= failIf (/= 1)
>> peek outLenPtr
>> liftM fromIntegral (peek outLenPtr)


cipherFinalBS :: CipherCtx -> IO B8.ByteString
Expand All @@ -164,7 +164,7 @@ cipherFinalBS ctx
alloca $ \ outLenPtr ->
_CipherFinal ctxPtr (castPtr outBuf) outLenPtr
>>= failIf (/= 1)
>> peek outLenPtr
>> liftM fromIntegral (peek outLenPtr)

-- |@'cipher'@ lazilly encrypts or decrypts a stream of data. The
-- input string doesn't necessarily have to be finite.
Expand Down

0 comments on commit cb3caf1

Please sign in to comment.