otp_ssl.c

Include dependency graph for otp_ssl.c:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "8" [label="stdbool.h" tooltip="stdbool.h"]
    "5" [label="atom.h" tooltip="atom.h"]
    "41" [label="trace.h" tooltip="trace.h"]
    "11" [label="assert.h" tooltip="assert.h"]
    "16" [label="synclist.h" tooltip="synclist.h"]
    "28" [label="defaultatoms.h" tooltip="defaultatoms.h"]
    "4" [label="stdint.h" tooltip="stdint.h"]
    "6" [label="stdlib.h" tooltip="stdlib.h"]
    "30" [label="inet.h" tooltip="inet.h"]
    "33" [label="exportedfunction.h" tooltip="exportedfunction.h"]
    "38" [label="mbedtls/ctr_drbg.h" tooltip="mbedtls/ctr_drbg.h"]
    "2" [label="context.h" tooltip="context.h"]
    "37" [label="port.h" tooltip="port.h"]
    "22" [label="utils.h" tooltip="utils.h"]
    "14" [label="ets.h" tooltip="ets.h"]
    "7" [label="atom_table.h" tooltip="atom_table.h"]
    "10" [label="term_typedef.h" tooltip="term_typedef.h"]
    "23" [label="stddef.h" tooltip="stddef.h"]
    "39" [label="mbedtls/entropy.h" tooltip="mbedtls/entropy.h"]
    "12" [label="limits.h" tooltip="limits.h"]
    "35" [label="otp_socket_platform.h" tooltip="otp_socket_platform.h"]
    "24" [label="refc_binary.h" tooltip="refc_binary.h"]
    "20" [label="string.h" tooltip="string.h"]
    "26" [label="mailbox.h" tooltip="mailbox.h"]
    "19" [label="term.h" tooltip="term.h"]
    "9" [label="erl_nif.h" tooltip="erl_nif.h"]
    "1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_ssl.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_ssl.c" fillcolor="#BFBFBF"]
    "31" [label="interop.h" tooltip="interop.h"]
    "36" [label="otp_ssl.h" tooltip="otp_ssl.h"]
    "40" [label="mbedtls/ssl.h" tooltip="mbedtls/ssl.h"]
    "25" [label="resources.h" tooltip="resources.h"]
    "18" [label="smp.h" tooltip="smp.h"]
    "29" [label="erl_nif_priv.h" tooltip="erl_nif_priv.h"]
    "32" [label="nifs.h" tooltip="nifs.h"]
    "3" [label="globalcontext.h" tooltip="globalcontext.h"]
    "21" [label="memory.h" tooltip="memory.h"]
    "34" [label="otp_socket.h" tooltip="otp_socket.h"]
    "17" [label="stdio.h" tooltip="stdio.h"]
    "27" [label="timer_list.h" tooltip="timer_list.h"]
    "15" [label="list.h" tooltip="list.h"]
    "13" [label="inttypes.h" tooltip="inttypes.h"]
    "5" -> "4" [dir=forward tooltip="include"]
    "5" -> "6" [dir=forward tooltip="include"]
    "16" -> "17" [dir=forward tooltip="include"]
    "16" -> "15" [dir=forward tooltip="include"]
    "16" -> "18" [dir=forward tooltip="include"]
    "28" -> "3" [dir=forward tooltip="include"]
    "30" -> "31" [dir=forward tooltip="include"]
    "30" -> "21" [dir=forward tooltip="include"]
    "33" -> "19" [dir=forward tooltip="include"]
    "2" -> "3" [dir=forward tooltip="include"]
    "2" -> "15" [dir=forward tooltip="include"]
    "2" -> "26" [dir=forward tooltip="include"]
    "2" -> "18" [dir=forward tooltip="include"]
    "2" -> "19" [dir=forward tooltip="include"]
    "2" -> "27" [dir=forward tooltip="include"]
    "37" -> "2" [dir=forward tooltip="include"]
    "37" -> "28" [dir=forward tooltip="include"]
    "37" -> "3" [dir=forward tooltip="include"]
    "37" -> "21" [dir=forward tooltip="include"]
    "37" -> "19" [dir=forward tooltip="include"]
    "22" -> "23" [dir=forward tooltip="include"]
    "22" -> "17" [dir=forward tooltip="include"]
    "22" -> "6" [dir=forward tooltip="include"]
    "14" -> "15" [dir=forward tooltip="include"]
    "14" -> "16" [dir=forward tooltip="include"]
    "14" -> "19" [dir=forward tooltip="include"]
    "7" -> "8" [dir=forward tooltip="include"]
    "7" -> "5" [dir=forward tooltip="include"]
    "10" -> "11" [dir=forward tooltip="include"]
    "10" -> "12" [dir=forward tooltip="include"]
    "10" -> "13" [dir=forward tooltip="include"]
    "10" -> "4" [dir=forward tooltip="include"]
    "24" -> "8" [dir=forward tooltip="include"]
    "24" -> "6" [dir=forward tooltip="include"]
    "24" -> "15" [dir=forward tooltip="include"]
    "24" -> "25" [dir=forward tooltip="include"]
    "26" -> "8" [dir=forward tooltip="include"]
    "26" -> "15" [dir=forward tooltip="include"]
    "26" -> "10" [dir=forward tooltip="include"]
    "26" -> "22" [dir=forward tooltip="include"]
    "19" -> "8" [dir=forward tooltip="include"]
    "19" -> "4" [dir=forward tooltip="include"]
    "19" -> "17" [dir=forward tooltip="include"]
    "19" -> "6" [dir=forward tooltip="include"]
    "19" -> "20" [dir=forward tooltip="include"]
    "19" -> "21" [dir=forward tooltip="include"]
    "19" -> "24" [dir=forward tooltip="include"]
    "19" -> "22" [dir=forward tooltip="include"]
    "19" -> "10" [dir=forward tooltip="include"]
    "9" -> "10" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "28" [dir=forward tooltip="include"]
    "1" -> "9" [dir=forward tooltip="include"]
    "1" -> "29" [dir=forward tooltip="include"]
    "1" -> "3" [dir=forward tooltip="include"]
    "1" -> "30" [dir=forward tooltip="include"]
    "1" -> "31" [dir=forward tooltip="include"]
    "1" -> "32" [dir=forward tooltip="include"]
    "1" -> "34" [dir=forward tooltip="include"]
    "1" -> "36" [dir=forward tooltip="include"]
    "1" -> "37" [dir=forward tooltip="include"]
    "1" -> "24" [dir=forward tooltip="include"]
    "1" -> "19" [dir=forward tooltip="include"]
    "1" -> "10" [dir=forward tooltip="include"]
    "1" -> "20" [dir=forward tooltip="include"]
    "1" -> "38" [dir=forward tooltip="include"]
    "1" -> "39" [dir=forward tooltip="include"]
    "1" -> "40" [dir=forward tooltip="include"]
    "1" -> "41" [dir=forward tooltip="include"]
    "31" -> "2" [dir=forward tooltip="include"]
    "31" -> "19" [dir=forward tooltip="include"]
    "36" -> "3" [dir=forward tooltip="include"]
    "36" -> "32" [dir=forward tooltip="include"]
    "25" -> "6" [dir=forward tooltip="include"]
    "25" -> "9" [dir=forward tooltip="include"]
    "25" -> "15" [dir=forward tooltip="include"]
    "25" -> "21" [dir=forward tooltip="include"]
    "18" -> "8" [dir=forward tooltip="include"]
    "29" -> "2" [dir=forward tooltip="include"]
    "29" -> "21" [dir=forward tooltip="include"]
    "32" -> "5" [dir=forward tooltip="include"]
    "32" -> "2" [dir=forward tooltip="include"]
    "32" -> "33" [dir=forward tooltip="include"]
    "3" -> "4" [dir=forward tooltip="include"]
    "3" -> "5" [dir=forward tooltip="include"]
    "3" -> "7" [dir=forward tooltip="include"]
    "3" -> "9" [dir=forward tooltip="include"]
    "3" -> "14" [dir=forward tooltip="include"]
    "3" -> "15" [dir=forward tooltip="include"]
    "3" -> "26" [dir=forward tooltip="include"]
    "3" -> "18" [dir=forward tooltip="include"]
    "3" -> "16" [dir=forward tooltip="include"]
    "3" -> "19" [dir=forward tooltip="include"]
    "3" -> "27" [dir=forward tooltip="include"]
    "21" -> "4" [dir=forward tooltip="include"]
    "21" -> "6" [dir=forward tooltip="include"]
    "21" -> "9" [dir=forward tooltip="include"]
    "21" -> "10" [dir=forward tooltip="include"]
    "21" -> "22" [dir=forward tooltip="include"]
    "34" -> "3" [dir=forward tooltip="include"]
    "34" -> "32" [dir=forward tooltip="include"]
    "34" -> "35" [dir=forward tooltip="include"]
    "27" -> "8" [dir=forward tooltip="include"]
    "27" -> "4" [dir=forward tooltip="include"]
    "27" -> "15" [dir=forward tooltip="include"]
    "15" -> "8" [dir=forward tooltip="include"]
}

Defines

TAG "otp_ssl"
MBEDTLS_PRIVATE(member) member
DEFAULT_READ_BUFFER_FALLBACK 512
UNKNOWN_TABLE_VALUE -1

Functions

static void entropycontext_dtor(ErlNifEnv *caller_env, void *obj)
static void ctrdrbg_dtor(ErlNifEnv *caller_env, void *obj)
static void sslcontext_dtor(ErlNifEnv *caller_env, void *obj)
static void sslconfig_dtor(ErlNifEnv *caller_env, void *obj)
int mbedtls_ssl_send_cb(void *ctx, const unsigned char *buf, size_t len)
int mbedtls_ssl_recv_cb(void *ctx, unsigned char *buf, size_t len)
static term nif_ssl_entropy_init(Context *ctx, int argc, term argv[])
static term nif_ssl_ctr_drbg_init(Context *ctx, int argc, term argv[])
static term nif_ssl_ctr_drbg_seed(Context *ctx, int argc, term argv[])
static term nif_ssl_init(Context *ctx, int argc, term argv[])
static term nif_ssl_set_bio(Context *ctx, int argc, term argv[])
static term nif_ssl_config_init(Context *ctx, int argc, term argv[])
static term nif_ssl_config_defaults(Context *ctx, int argc, term argv[])
static term nif_ssl_set_hostname(Context *ctx, int argc, term argv[])
static term nif_ssl_conf_authmode(Context *ctx, int argc, term argv[])
static term nif_ssl_conf_rng(Context *ctx, int argc, term argv[])
static term nif_ssl_setup(Context *ctx, int argc, term argv[])
static term make_err_result(int err, Context *ctx)
static term nif_ssl_handshake_step(Context *ctx, int argc, term argv[])
static term nif_ssl_close_notify(Context *ctx, int argc, term argv[])
static term nif_ssl_write(Context *ctx, int argc, term argv[])
static term nif_ssl_read(Context *ctx, int argc, term argv[])
const struct Nif *otp_ssl_nif_get_nif(const char *nifname)
void otp_ssl_init(GlobalContext *global)

Variables

static const ErlNifResourceTypeInit EntropyContextResourceTypeInit = {.members = 1, .dtor = entropycontext_dtor,}
static const ErlNifResourceTypeInit CtrDrbgResourceTypeInit = {.members = 1, .dtor = ctrdrbg_dtor,}
static const ErlNifResourceTypeInit SSLContextResourceTypeInit = {.members = 1, .dtor = sslcontext_dtor,}
static const ErlNifResourceTypeInit SSLConfigResourceTypeInit = {.members = 1, .dtor = sslconfig_dtor,}
static ErlNifResourceType *entropycontext_resource_type
static ErlNifResourceType *ctrdrbg_resource_type
static ErlNifResourceType *sslcontext_resource_type
static ErlNifResourceType *sslconfig_resource_type
static const AtomStringIntPair endpoint_table [] = {{ATOM_STR("\x6", "client"), MBEDTLS_SSL_IS_CLIENT },{ATOM_STR("\x6", "server"), MBEDTLS_SSL_IS_SERVER },}
static const AtomStringIntPair authmode_table [] = {{ATOM_STR("\x4", "none"), MBEDTLS_SSL_VERIFY_NONE },{ATOM_STR("\x8", "optional"), MBEDTLS_SSL_VERIFY_OPTIONAL },{ATOM_STR("\x8", "required"), MBEDTLS_SSL_VERIFY_REQUIRED },}
static const struct Nif ssl_entropy_init_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_entropy_init}
static const struct Nif ssl_ctr_drbg_init_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_ctr_drbg_init}
static const struct Nif ssl_ctr_drbg_seed_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_ctr_drbg_seed}
static const struct Nif ssl_init_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_init}
static const struct Nif ssl_set_bio_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_set_bio}
static const struct Nif ssl_config_init_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_config_init}
static const struct Nif ssl_config_defaults_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_config_defaults}
static const struct Nif ssl_conf_authmode_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_conf_authmode}
static const struct Nif ssl_conf_rng_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_conf_rng}
static const struct Nif ssl_set_hostname_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_set_hostname}
static const struct Nif ssl_setup_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_setup}
static const struct Nif ssl_handshake_step_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_handshake_step}
static const struct Nif ssl_close_notify_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_close_notify}
static const struct Nif ssl_write_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_write}
static const struct Nif ssl_read_nif = {.base.type = NIFFunctionType, .nif_ptr = nif_ssl_read}
struct EntropyContextResource

Public Members

mbedtls_entropy_context context
struct CtrDrbgResource

Public Members

mbedtls_ctr_drbg_context context
struct SSLContextResource

Public Members

mbedtls_ssl_context context
struct SSLConfigResource

Public Members

mbedtls_ssl_config config