CJOSE
0.6.0
|
Utility functions and data structures for CJOSE. More...
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <openssl/rsa.h>
Go to the source code of this file.
Macros | |
#define | CJOSE_OPENSSL_11X OPENSSL_VERSION_NUMBER >= 0x10100005L && !defined(LIBRESSL_VERSION_NUMBER) |
#define | CJOSE_UNUSED_PARAM(x) (void)(x) |
Typedefs | |
typedef void *(* | cjose_alloc_fn_t) (size_t) |
typedef void *(* | cjose_alloc3_fn_t) (size_t, const char *, int) |
typedef void *(* | cjose_realloc_fn_t) (void *, size_t) |
typedef void *(* | cjose_realloc3_fn_t) (void *, size_t, const char *, int) |
typedef void(* | cjose_dealloc_fn_t) (void *) |
typedef void(* | cjose_dealloc3_fn_t) (void *, const char *, int) |
Functions | |
void | cjose_set_alloc_funcs (cjose_alloc_fn_t alloc, cjose_realloc_fn_t realloc, cjose_dealloc_fn_t dealloc) |
void | cjose_set_alloc_ex_funcs (cjose_alloc3_fn_t alloc3, cjose_realloc3_fn_t realloc3, cjose_dealloc3_fn_t dealloc3) |
cjose_alloc_fn_t | cjose_get_alloc () |
cjose_alloc3_fn_t | cjose_get_alloc3 () |
cjose_realloc_fn_t | cjose_get_realloc () |
cjose_realloc3_fn_t | cjose_get_realloc3 () |
cjose_dealloc_fn_t | cjose_get_dealloc () |
cjose_dealloc3_fn_t | cjose_get_dealloc3 () |
int | cjose_const_memcmp (const uint8_t *a, const uint8_t *b, const size_t size) |
Utility functions and data structures for CJOSE.
#define CJOSE_UNUSED_PARAM | ( | x | ) | (void)(x) |
Macro to explicitly mark a parameter unused, and usable across multiple compiler/platform environments.
typedef void*(* cjose_alloc3_fn_t) (size_t, const char *, int) |
Typedef for the enhanced memory allocator function.
typedef void*(* cjose_alloc_fn_t) (size_t) |
Typedef for the basic memory allocator function.
typedef void(* cjose_dealloc3_fn_t) (void *, const char *, int) |
Typedef for the enhanced memory deallocator function.
typedef void(* cjose_dealloc_fn_t) (void *) |
Typedef for the basic memory deallocator function.
typedef void*(* cjose_realloc3_fn_t) (void *, size_t, const char *, int) |
Typedef for the enhanced memory reallocator function.
typedef void*(* cjose_realloc_fn_t) (void *, size_t) |
Typedef for the basic memory reallocator function.
int cjose_const_memcmp | ( | const uint8_t * | a, |
const uint8_t * | b, | ||
const size_t | size | ||
) |
Compares the first n bytes of the memory areas s1 and s2 in constant time.
a | [in] The first octet string to compare |
b | [in] The second octet string to compare |
size | [in] The length to compare |
cjose_alloc_fn_t cjose_get_alloc | ( | ) |
Retrieves the configured allocator function. If an allocator function is not set, this function returns a pointer to malloc()
.
cjose_alloc3_fn_t cjose_get_alloc3 | ( | ) |
Retrieves the configured enhanced allocator function. If an enhanced allocator function is not set, this function returns a pointer to an internally defined variant that wraps the basic allocator returned by cjose_get_alloc()
.
cjose_dealloc_fn_t cjose_get_dealloc | ( | ) |
Retrieves the configured deallocator function. If a deallocator function is not set, this function returns a pointer to free()
.
cjose_dealloc3_fn_t cjose_get_dealloc3 | ( | ) |
Retrieves the configured enhanced deallocator function. If an enhanced deallocator function is not set, this function returns a pointer to an internally defined variant that wraps the basic allocator returned by cjose_get_dealloc()
.
cjose_realloc_fn_t cjose_get_realloc | ( | ) |
Retrieve the configured reallocator function. If a reallocator function is not set, this function retursn a pointer to realloc
.
cjose_realloc3_fn_t cjose_get_realloc3 | ( | ) |
Retrieves the configured enhanced reallocator function. If an enhanced reallocator function is not set, this function returns a pointer to an internally defined variant that wraps the basic allocator returned by cjose_get_realloc()
.
void cjose_set_alloc_ex_funcs | ( | cjose_alloc3_fn_t | alloc3, |
cjose_realloc3_fn_t | realloc3, | ||
cjose_dealloc3_fn_t | dealloc3 | ||
) |
Sets the enhanced allocator and deallocator functions. This function provides improved support for OpenSSL >= 1.1.x.
NOTE: This function is mutually exclusive from cjose_set_alloc_funcs()
. Both SHOULD NOT be called.
If alloc3
is NULL, any previously set allocator function is cleared and the the default allocator malloc()
is used.
If dealloc3
is NULL, the default dallocator free()
is used.
alloc3 | [in] The custom allocator function to use for OpenSSL >= 1.1.0, called with extra file/line params. |
realloc3 | [in] The custom reallocator function to use for OpenSSL >= 1.1.0, called with extra file/line params. |
dealloc3 | [in] The custom deallocator function to use for OpenSSL >= 1.1.0, called with extra file/line params. |
void cjose_set_alloc_funcs | ( | cjose_alloc_fn_t | alloc, |
cjose_realloc_fn_t | realloc, | ||
cjose_dealloc_fn_t | dealloc | ||
) |
Sets the allocator and deallocator functions.
NOTE: This function is mutually exclusive from cjose_set_alloc_ex_funcs()
. Both SHOULD NOT be called.
If alloc
is NULL, any previously set allocator function is cleared and the the default allocator malloc()
is used.
If dealloc
is NULL, the default dallocator free()
is used.
alloc | [in] The custom allocator function to use. |
realloc | [in] The custom reallocator function to use. |
dealloc | [in] The custom deallocator function to use. |