Botan 2.19.2
Crypto and TLS for C&
|
#include <botan/ffi.h>
#include <botan/internal/ffi_util.h>
#include <botan/internal/os_utils.h>
#include <botan/version.h>
#include <botan/mem_ops.h>
#include <botan/hex.h>
#include <botan/base64.h>
#include <cstdio>
#include <cstdlib>
Go to the source code of this file.
Namespaces | |
namespace | Botan_FFI |
Functions | |
int | botan_base64_decode (const char *base64_str, size_t in_len, uint8_t *out, size_t *out_len) |
int | botan_base64_encode (const uint8_t *in, size_t len, char *out, size_t *out_len) |
int | botan_constant_time_compare (const uint8_t *x, const uint8_t *y, size_t len) |
const char * | botan_error_description (int err) |
uint32_t | botan_ffi_api_version () |
int | botan_ffi_supports_api (uint32_t api_version) |
int | botan_hex_decode (const char *hex_str, size_t in_len, uint8_t *out, size_t *out_len) |
int | botan_hex_encode (const uint8_t *in, size_t len, char *out, uint32_t flags) |
int | botan_same_mem (const uint8_t *x, const uint8_t *y, size_t len) |
int | botan_scrub_mem (void *mem, size_t bytes) |
uint32_t | botan_version_datestamp () |
uint32_t | botan_version_major () |
uint32_t | botan_version_minor () |
uint32_t | botan_version_patch () |
const char * | botan_version_string () |
int | Botan_FFI::ffi_error_exception_thrown (const char *func_name, const char *exn, int rc) |
int | Botan_FFI::ffi_guard_thunk (const char *func_name, std::function< int()> thunk) |
int botan_base64_decode | ( | const char * | base64_str, |
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len | ||
) |
Perform base64 decoding
Definition at line 282 of file ffi.cpp.
References Botan::base64_decode(), Botan::base64_decode_max_output(), BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE, BOTAN_FFI_SUCCESS, and Botan_FFI::ffi_guard_thunk().
int botan_base64_encode | ( | const uint8_t * | x, |
size_t | len, | ||
char * | out, | ||
size_t * | out_len | ||
) |
Perform base64 encoding
Definition at line 274 of file ffi.cpp.
References Botan::base64_encode(), Botan_FFI::ffi_guard_thunk(), and Botan_FFI::write_str_output().
int botan_constant_time_compare | ( | const uint8_t * | x, |
const uint8_t * | y, | ||
size_t | len | ||
) |
Returns 0 if x[0..len] == y[0..len], or otherwise -1
Definition at line 241 of file ffi.cpp.
References Botan::constant_time_compare().
Referenced by botan_same_mem().
const char * botan_error_description | ( | int | err | ) |
Convert an error code into a string. Returns "Unknown error" if the error code is not a known one.
Definition at line 125 of file ffi.cpp.
References BOTAN_FFI_ERROR_BAD_FLAG, BOTAN_FFI_ERROR_BAD_MAC, BOTAN_FFI_ERROR_BAD_PARAMETER, BOTAN_FFI_ERROR_EXCEPTION_THROWN, BOTAN_FFI_ERROR_HTTP_ERROR, BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE, BOTAN_FFI_ERROR_INTERNAL_ERROR, BOTAN_FFI_ERROR_INVALID_INPUT, BOTAN_FFI_ERROR_INVALID_KEY_LENGTH, BOTAN_FFI_ERROR_INVALID_OBJECT, BOTAN_FFI_ERROR_INVALID_OBJECT_STATE, BOTAN_FFI_ERROR_KEY_NOT_SET, BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_ERROR_OUT_OF_MEMORY, BOTAN_FFI_ERROR_SYSTEM_ERROR, BOTAN_FFI_ERROR_TLS_ERROR, BOTAN_FFI_ERROR_UNKNOWN_ERROR, BOTAN_FFI_INVALID_VERIFIER, and BOTAN_FFI_SUCCESS.
uint32_t botan_ffi_api_version | ( | void | ) |
int botan_ffi_supports_api | ( | uint32_t | api_version | ) |
Return 0 (ok) if the version given is one this library supports. botan_ffi_supports_api(botan_ffi_api_version()) will always return 0.
Definition at line 201 of file ffi.cpp.
References BOTAN_FFI_SUCCESS.
int botan_hex_decode | ( | const char * | hex_str, |
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len | ||
) |
Perform hex decoding
hex_str | a string of hex chars (whitespace is ignored) |
in_len | the length of hex_str |
out | the output buffer should be at least strlen(hex_str)/2 bytes |
out_len | the size of out |
Definition at line 266 of file ffi.cpp.
References Botan_FFI::ffi_guard_thunk(), Botan::hex_decode(), and Botan_FFI::write_vec_output().
int botan_hex_encode | ( | const uint8_t * | x, |
size_t | len, | ||
char * | out, | ||
uint32_t | flags | ||
) |
Perform hex encoding
x | is some binary data |
len | length of x in bytes |
out | an array of at least x*2 bytes |
flags | flags out be upper or lower case? |
Definition at line 257 of file ffi.cpp.
References BOTAN_FFI_HEX_LOWER_CASE, BOTAN_FFI_SUCCESS, Botan_FFI::ffi_guard_thunk(), Botan::PKCS11::flags(), and Botan::hex_encode().
int botan_same_mem | ( | const uint8_t * | x, |
const uint8_t * | y, | ||
size_t | len | ||
) |
Deprecated equivalent to botan_constant_time_compare
Definition at line 246 of file ffi.cpp.
References botan_constant_time_compare().
int botan_scrub_mem | ( | void * | mem, |
size_t | bytes | ||
) |
Clear out memory using a system specific approach to bypass elision by the compiler (currently using RtlSecureZeroMemory or tricks with volatile pointers).
Definition at line 251 of file ffi.cpp.
References BOTAN_FFI_SUCCESS, and Botan::secure_scrub_memory().
uint32_t botan_version_datestamp | ( | void | ) |
Return the date this version was released as an integer, or 0 if an unreleased version
Definition at line 239 of file ffi.cpp.
References Botan::version_datestamp().
uint32_t botan_version_major | ( | void | ) |
Return the major version of the library
Definition at line 236 of file ffi.cpp.
References Botan::version_major().
uint32_t botan_version_minor | ( | void | ) |
Return the minor version of the library
Definition at line 237 of file ffi.cpp.
References Botan::version_minor().
uint32_t botan_version_patch | ( | void | ) |
Return the patch version of the library
Definition at line 238 of file ffi.cpp.
References Botan::version_patch().
const char * botan_version_string | ( | void | ) |
Return a free-form version string, e.g., 2.0.0
Definition at line 231 of file ffi.cpp.
References Botan::version_cstr().