Botan 3.6.1
Crypto and TLS for C&
|
#include <botan/ffi.h>
#include <botan/base64.h>
#include <botan/hex.h>
#include <botan/mem_ops.h>
#include <botan/version.h>
#include <botan/internal/ct_utils.h>
#include <botan/internal/ffi_util.h>
#include <botan/internal/os_utils.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) |
const char * | botan_error_last_exception_message () |
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::botan_view_bin_bounce_fn (botan_view_ctx vctx, const uint8_t *buf, size_t len) |
int | Botan_FFI::botan_view_str_bounce_fn (botan_view_ctx vctx, const char *str, size_t len) |
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, const std::function< int()> &thunk) |
Variables | |
thread_local std::string | Botan_FFI::g_last_exception_what |
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 335 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 328 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 298 of file ffi.cpp.
References Botan::CT::is_equal().
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 146 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_STRING_CONVERSION_ERROR, BOTAN_FFI_ERROR_SYSTEM_ERROR, BOTAN_FFI_ERROR_TLS_ERROR, BOTAN_FFI_ERROR_UNKNOWN_ERROR, BOTAN_FFI_INVALID_VERIFIER, and BOTAN_FFI_SUCCESS.
const char * botan_error_last_exception_message | ( | void | ) |
Return the message of the last exception caught in this thread.
This pointer can/will be reallocated or overwritten the next time this thread calls any other Botan FFI function and must be copied to persistent storage first.
Definition at line 142 of file ffi.cpp.
References Botan_FFI::g_last_exception_what.
uint32_t botan_ffi_api_version | ( | void | ) |
Return the version of the currently supported FFI API. This is expressed in the form YYYYMMDD of the release date of this version of the API.
Definition at line 219 of file ffi.cpp.
References BOTAN_HAS_FFI.
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 223 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 the output buffer on input, set to the number of bytes written |
Definition at line 321 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 313 of file ffi.cpp.
References BOTAN_FFI_HEX_LOWER_CASE, BOTAN_FFI_SUCCESS, Botan_FFI::ffi_guard_thunk(), 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 304 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 308 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 294 of file ffi.cpp.
References Botan::version_datestamp().
uint32_t botan_version_major | ( | void | ) |
Return the major version of the library
Definition at line 282 of file ffi.cpp.
References Botan::version_major().
uint32_t botan_version_minor | ( | void | ) |
Return the minor version of the library
Definition at line 286 of file ffi.cpp.
References Botan::version_minor().
uint32_t botan_version_patch | ( | void | ) |
Return the patch version of the library
Definition at line 290 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 278 of file ffi.cpp.
References Botan::version_cstr().