@@ -15,20 +15,21 @@ Ciphers](https://botan.randombit.net/handbook/api_ref/block_cipher.html) section
1515of the C++ API reference.
1616-}
1717
18- {-# LANGUAGE CApiFFI #-}
18+ {-# LANGUAGE OverloadedStrings #-}
1919
2020module Botan.Bindings.BlockCipher (
21- BotanBlockCipherStruct
22- , BotanBlockCipher (.. )
23- , botan_block_cipher_destroy
24- , botan_block_cipher_init
25- , 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
2627 , botan_block_cipher_set_key
27- , botan_block_cipher_block_size
28+ , Safe. botan_block_cipher_block_size
2829 , botan_block_cipher_encrypt_blocks
2930 , botan_block_cipher_decrypt_blocks
30- , botan_block_cipher_name
31- , botan_block_cipher_get_keyspec
31+ , Safe. botan_block_cipher_name
32+ , Safe. botan_block_cipher_get_keyspec
3233 -- * Available ciphers
3334 -- $available-ciphers
3435 , pattern BOTAN_BLOCK_CIPHER_AES_128
@@ -57,89 +58,27 @@ module Botan.Bindings.BlockCipher (
5758 , pattern BOTAN_BLOCK_CIPHER_TWOFISH
5859 ) where
5960
60- import Botan.Bindings.Prelude
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 )
6169
62- {- ------------------------------------------------------------------------------
63- Block ciphers
64- -------------------------------------------------------------------------------}
6570
66- -- | Opaque BlockCipher struct
67- data {-# CTYPE "botan/ffi.h" "struct botan_block_cipher_struct" #-} BotanBlockCipherStruct
68-
69- -- | Botan BlockCipher object
70- newtype {-# CTYPE "botan/ffi.h" "botan_block_cipher_t" #-} BotanBlockCipher
71- = MkBotanBlockCipher { runBotanBlockCipher :: Ptr BotanBlockCipherStruct }
72- deriving newtype (Eq , Ord , Storable )
73-
74- -- | Destroy a block cipher object
75- --
76- -- NOTE: this a binding to the /address/ of the @botan_block_cipher_destroy@ C
77- -- function.
78- foreign import capi safe " botan/ffi.h &botan_block_cipher_destroy"
79- botan_block_cipher_destroy
80- :: FinalizerPtr BotanBlockCipherStruct
81-
82- -- | Initialize a block cipher object
83- foreign import capi safe " botan/ffi.h botan_block_cipher_init"
84- botan_block_cipher_init
85- :: Ptr BotanBlockCipher -- ^ __bc__
86- -> ConstPtr CChar -- ^ __cipher_name__
87- -> IO CInt
88-
89- -- | Reinitializes the block cipher
90- foreign import capi safe " botan/ffi.h botan_block_cipher_clear"
91- botan_block_cipher_clear
92- :: BotanBlockCipher -- ^ __bc__
93- -> IO CInt -- ^ 0 on success, a negative value on failure
94-
95- -- | Set the key for a block cipher instance
96- foreign import capi safe " botan/ffi.h botan_block_cipher_set_key"
97- botan_block_cipher_set_key
98- :: BotanBlockCipher -- ^ __bc__
99- -> ConstPtr Word8 -- ^ __key[]__
100- -> CSize -- ^ __len__
101- -> IO CInt
102-
103- -- | Return the positive block size of this block cipher, or negative to indicate an error
104- foreign import capi safe " botan/ffi.h botan_block_cipher_block_size"
105- botan_block_cipher_block_size
106- :: BotanBlockCipher -- ^ __bc__
107- -> IO CInt
108-
109- -- | Encrypt one or more blocks with the cipher
110- foreign import capi safe " botan/ffi.h botan_block_cipher_encrypt_blocks"
111- botan_block_cipher_encrypt_blocks
112- :: BotanBlockCipher -- ^ __bc__
113- -> ConstPtr Word8 -- ^ __in[]__
114- -> Ptr Word8 -- ^ __out[]__
115- -> CSize -- ^ __blocks__
116- -> IO CInt
117-
118- -- | Decrypt one or more blocks with the cipher
119- foreign import capi safe " botan/ffi.h botan_block_cipher_decrypt_blocks"
120- botan_block_cipher_decrypt_blocks
121- :: BotanBlockCipher -- ^ __bc__
122- -> ConstPtr Word8 -- ^ __in[]__
123- -> Ptr Word8 -- ^ __out[]__
124- -> CSize -- ^ __blocks__
125- -> IO CInt
126-
127- -- | Get the name of this block cipher
128- foreign import capi safe " botan/ffi.h botan_block_cipher_name"
129- botan_block_cipher_name
130- :: BotanBlockCipher -- ^ __cipher__: the object to read
131- -> Ptr CChar -- ^ __name__: output buffer
132- -> Ptr CSize -- ^ __name_len__: on input, the length of buffer, on success the number of bytes written
133- -> IO CInt
134-
135- -- | Get the key length limits of this block cipher
136- foreign import capi safe " botan/ffi.h botan_block_cipher_get_keyspec"
137- botan_block_cipher_get_keyspec
138- :: BotanBlockCipher -- ^ __cipher__: the object to read
139- -> Ptr CSize -- ^ __out_minimum_keylength__: if non-NULL, will be set to minimum keylength of cipher
140- -> Ptr CSize -- ^ __out_maximum_keylength__: if non-NULL, will be set to maximum keylength of cipher
141- -> Ptr CSize -- ^ __out_keylength_modulo__: if non-NULL will be set to byte multiple of valid keys
142- -> 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
14382
14483{- ------------------------------------------------------------------------------
14584 Available ciphers
0 commit comments