ffi.cpp |
|
9527 |
ffi.h |
This header exports some of botan's functionality via a C89 interface. This API
is used by the Python, OCaml, Rust, Ruby, and Haskell bindings via those languages
respective ctypes/FFI libraries.
The API is intended to be as easy as possible to call from other
languages, which often have easy ways to call C, because C. But some C
code is easier to deal with than others, so to make things easy this
API follows a few simple rules:
- All interactions are via pointers to opaque structs. No need to worry about
structure padding issues and the like.
- All functions return an int error code (except the version calls, which are
assumed to always have something to say).
- Use simple types: size_t for lengths, const char* NULL terminated strings,
uint8_t for binary.
- No ownership of memory transfers across the API boundary. The API will consume
data from const pointers with specifed lengths. Outputs are either placed into
buffers provided by (and allocated by) the caller, or are returned via a
callback (what the FFI layer calls "view" functions).
When writing to an application-provided buffer, the function takes a pointer
to the output array and a read/write pointer to the length. The length field
is always set to the actual amount of data that would have been written. If
the input buffer's size was insufficient an error is returned.
In many situations the length of the output can be known in advance without
difficulty, in which case there will be a function which allows querying the
expected output length. For example `botan_hash_output_length` allows knowing
in advance the expected size for `botan_hash_final`. Some of these are exact,
while others such as `botan_pk_op_decrypt_output_length` can only provide an
upper bound for various technical reasons.
In some cases knowing the exact size is difficult or impossible. In these
situations view functions are used; see the handbook for further details.
TODO: Doxygen comments for all parameters
|
97270 |
ffi_block.cpp |
Destroy a block cipher object
|
3153 |
ffi_cert.cpp |
|
16974 |
ffi_cipher.cpp |
Select an update size so that the following constraints are satisfies:
- greater than or equal to the mode's update granularity
- greater than the mode's minimum final size
- the mode's ideal update granularity is a multiple of this size
- (optional) a power of 2
Note that this is necessary mostly for backward-compatibility with previous
versions of the FFI (prior to Botan 3.5.0). For Botan 4.0.0 we should just
directly return the update granularity of the cipher mode and instruct users
to switch to botan_cipher_get_ideal_update_granularity() instead. See also
the discussion in GitHub Issue #4090.
|
13204 |
ffi_ec.cpp |
|
6787 |
ffi_ec.h |
|
348 |
ffi_fpe.cpp |
|
2329 |
ffi_hash.cpp |
|
2420 |
ffi_hotp.cpp |
|
2214 |
ffi_kdf.cpp |
|
5825 |
ffi_keywrap.cpp |
|
3393 |
ffi_mac.cpp |
|
2512 |
ffi_mp.cpp |
|
8601 |
ffi_mp.h |
|
309 |
ffi_oid.cpp |
|
2477 |
ffi_oid.h |
|
345 |
ffi_pk_op.cpp |
Public Key Decryption
|
13080 |
ffi_pkey.cpp |
|
17014 |
ffi_pkey.h |
|
402 |
ffi_pkey_algs.cpp |
|
44876 |
ffi_rng.cpp |
|
6225 |
ffi_rng.h |
|
324 |
ffi_srp6.cpp |
|
6561 |
ffi_totp.cpp |
|
2123 |
ffi_tpm2.cpp |
|
8231 |
ffi_util.h |
|
7532 |
ffi_zfec.cpp |
|
1547 |
info.txt |
|
399 |