@@ -15,21 +15,21 @@ Ciphers](https://botan.randombit.net/handbook/api_ref/block_cipher.html) section
1515of the C++ API reference.
1616-}
1717
18- {-# LANGUAGE CApiFFI #-}
1918{-# LANGUAGE OverloadedStrings #-}
2019
2120module Botan.Bindings.BlockCipher (
22- BotanBlockCipherStruct
23- , BotanBlockCipher (.. )
24- , botan_block_cipher_destroy
25- , botan_block_cipher_init
26- , botan_block_cipher_clear
21+ Types. Botan_block_cipher_t (.. )
22+ , Types. Botan_block_cipher_struct
23+ , Safe. botan_block_cipher_destroy
24+ , botan_block_cipher_destroy_ptr
25+ , Safe. botan_block_cipher_init
26+ , Safe. botan_block_cipher_clear
2727 , botan_block_cipher_set_key
28- , botan_block_cipher_block_size
28+ , Safe. botan_block_cipher_block_size
2929 , botan_block_cipher_encrypt_blocks
3030 , botan_block_cipher_decrypt_blocks
31- , botan_block_cipher_name
32- , botan_block_cipher_get_keyspec
31+ , Safe. botan_block_cipher_name
32+ , Safe. botan_block_cipher_get_keyspec
3333 -- * Available ciphers
3434 -- $available-ciphers
3535 , pattern BOTAN_BLOCK_CIPHER_AES_128
@@ -58,95 +58,27 @@ module Botan.Bindings.BlockCipher (
5858 , pattern BOTAN_BLOCK_CIPHER_TWOFISH
5959 ) where
6060
61- import Botan.Bindings.ConstPtr
62- import Data.String
63- import Data.Word
64- import Foreign.C.Types
65- import Foreign.ForeignPtr
66- import Foreign.Ptr
67- import Foreign.Storable
61+ import qualified Botan.Bindings.Generated as Types
62+ import qualified Botan.Bindings.Generated.FunPtr as FunPtr
63+ import qualified Botan.Bindings.Generated.Safe as Safe
64+ import Data.String (IsString )
65+ import Data.Word (Word8 )
66+ import Foreign.C.Types (CInt , CSize )
67+ import Foreign.Ptr (FunPtr , Ptr )
68+ import HsBindgen.Runtime.ConstPtr (ConstPtr )
6869
69- {- ------------------------------------------------------------------------------
70- Block ciphers
71- -------------------------------------------------------------------------------}
7270
73- -- | Opaque BlockCipher struct
74- data {-# CTYPE "botan/ffi.h" "struct botan_block_cipher_struct" #-} BotanBlockCipherStruct
75-
76- -- | Botan BlockCipher object
77- newtype {-# CTYPE "botan/ffi.h" "botan_block_cipher_t" #-} BotanBlockCipher
78- = MkBotanBlockCipher { runBotanBlockCipher :: Ptr BotanBlockCipherStruct }
79- deriving newtype (Eq , Ord , Storable )
80-
81- -- | Destroy a block cipher object
82- --
83- -- NOTE: this a binding to the /address/ of the @botan_block_cipher_destroy@ C
84- -- function.
85- foreign import capi safe " botan/ffi.h &botan_block_cipher_destroy"
86- botan_block_cipher_destroy
87- :: FinalizerPtr BotanBlockCipherStruct
88-
89- -- | Initialize a block cipher object
90- foreign import capi safe " botan/ffi.h botan_block_cipher_init"
91- botan_block_cipher_init
92- :: Ptr BotanBlockCipher -- ^ __bc__
93- -> ConstPtr CChar -- ^ __cipher_name__
94- -> IO CInt
95-
96- -- | Reinitializes the block cipher
97- foreign import capi safe " botan/ffi.h botan_block_cipher_clear"
98- botan_block_cipher_clear
99- :: BotanBlockCipher -- ^ __bc__
100- -> IO CInt -- ^ 0 on success, a negative value on failure
101-
102- -- | Set the key for a block cipher instance
103- foreign import capi safe " botan/ffi.h botan_block_cipher_set_key"
104- botan_block_cipher_set_key
105- :: BotanBlockCipher -- ^ __bc__
106- -> ConstPtr Word8 -- ^ __key[]__
107- -> CSize -- ^ __len__
108- -> IO CInt
109-
110- -- | Return the positive block size of this block cipher, or negative to indicate an error
111- foreign import capi safe " botan/ffi.h botan_block_cipher_block_size"
112- botan_block_cipher_block_size
113- :: BotanBlockCipher -- ^ __bc__
114- -> IO CInt
115-
116- -- | Encrypt one or more blocks with the cipher
117- foreign import capi safe " botan/ffi.h botan_block_cipher_encrypt_blocks"
118- botan_block_cipher_encrypt_blocks
119- :: BotanBlockCipher -- ^ __bc__
120- -> ConstPtr Word8 -- ^ __in[]__
121- -> Ptr Word8 -- ^ __out[]__
122- -> CSize -- ^ __blocks__
123- -> IO CInt
124-
125- -- | Decrypt one or more blocks with the cipher
126- foreign import capi safe " botan/ffi.h botan_block_cipher_decrypt_blocks"
127- botan_block_cipher_decrypt_blocks
128- :: BotanBlockCipher -- ^ __bc__
129- -> ConstPtr Word8 -- ^ __in[]__
130- -> Ptr Word8 -- ^ __out[]__
131- -> CSize -- ^ __blocks__
132- -> IO CInt
133-
134- -- | Get the name of this block cipher
135- foreign import capi safe " botan/ffi.h botan_block_cipher_name"
136- botan_block_cipher_name
137- :: BotanBlockCipher -- ^ __cipher__: the object to read
138- -> Ptr CChar -- ^ __name__: output buffer
139- -> Ptr CSize -- ^ __name_len__: on input, the length of buffer, on success the number of bytes written
140- -> IO CInt
141-
142- -- | Get the key length limits of this block cipher
143- foreign import capi safe " botan/ffi.h botan_block_cipher_get_keyspec"
144- botan_block_cipher_get_keyspec
145- :: BotanBlockCipher -- ^ __cipher__: the object to read
146- -> Ptr CSize -- ^ __out_minimum_keylength__: if non-NULL, will be set to minimum keylength of cipher
147- -> Ptr CSize -- ^ __out_maximum_keylength__: if non-NULL, will be set to maximum keylength of cipher
148- -> Ptr CSize -- ^ __out_keylength_modulo__: if non-NULL will be set to byte multiple of valid keys
149- -> IO CInt
71+ botan_block_cipher_destroy_ptr :: FunPtr (Types. Botan_block_cipher_t -> IO CInt )
72+ botan_block_cipher_destroy_ptr = FunPtr. botan_block_cipher_destroy
73+
74+ botan_block_cipher_set_key :: Types. Botan_block_cipher_t -> ConstPtr Word8 -> CSize -> IO CInt
75+ botan_block_cipher_set_key = Safe. botan_block_cipher_set_key_wrapper
76+
77+ botan_block_cipher_encrypt_blocks :: Types. Botan_block_cipher_t -> ConstPtr Word8 -> Ptr Word8 -> CSize -> IO CInt
78+ botan_block_cipher_encrypt_blocks = Safe. botan_block_cipher_encrypt_blocks_wrapper
79+
80+ botan_block_cipher_decrypt_blocks :: Types. Botan_block_cipher_t -> ConstPtr Word8 -> Ptr Word8 -> CSize -> IO CInt
81+ botan_block_cipher_decrypt_blocks = Safe. botan_block_cipher_decrypt_blocks_wrapper
15082
15183{- ------------------------------------------------------------------------------
15284 Available ciphers
0 commit comments