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"]
    "40" [label="trace.h" tooltip="trace.h"]
    "11" [label="assert.h" tooltip="assert.h"]
    "20" [label="synclist.h" tooltip="synclist.h"]
    "27" [label="defaultatoms.h" tooltip="defaultatoms.h"]
    "4" [label="stdint.h" tooltip="stdint.h"]
    "6" [label="stdlib.h" tooltip="stdlib.h"]
    "29" [label="inet.h" tooltip="inet.h"]
    "32" [label="exportedfunction.h" tooltip="exportedfunction.h"]
    "37" [label="mbedtls/ctr_drbg.h" tooltip="mbedtls/ctr_drbg.h"]
    "2" [label="context.h" tooltip="context.h"]
    "36" [label="port.h" tooltip="port.h"]
    "16" [label="utils.h" tooltip="utils.h"]
    "7" [label="atom_table.h" tooltip="atom_table.h"]
    "10" [label="term_typedef.h" tooltip="term_typedef.h"]
    "17" [label="stddef.h" tooltip="stddef.h"]
    "38" [label="mbedtls/entropy.h" tooltip="mbedtls/entropy.h"]
    "12" [label="limits.h" tooltip="limits.h"]
    "34" [label="otp_socket_platform.h" tooltip="otp_socket_platform.h"]
    "24" [label="refc_binary.h" tooltip="refc_binary.h"]
    "22" [label="string.h" tooltip="string.h"]
    "15" [label="mailbox.h" tooltip="mailbox.h"]
    "21" [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"]
    "30" [label="interop.h" tooltip="interop.h"]
    "35" [label="otp_ssl.h" tooltip="otp_ssl.h"]
    "39" [label="mbedtls/ssl.h" tooltip="mbedtls/ssl.h"]
    "25" [label="resources.h" tooltip="resources.h"]
    "19" [label="smp.h" tooltip="smp.h"]
    "28" [label="erl_nif_priv.h" tooltip="erl_nif_priv.h"]
    "31" [label="nifs.h" tooltip="nifs.h"]
    "3" [label="globalcontext.h" tooltip="globalcontext.h"]
    "23" [label="memory.h" tooltip="memory.h"]
    "33" [label="otp_socket.h" tooltip="otp_socket.h"]
    "18" [label="stdio.h" tooltip="stdio.h"]
    "26" [label="timer_list.h" tooltip="timer_list.h"]
    "14" [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"]
    "20" -> "18" [dir=forward tooltip="include"]
    "20" -> "14" [dir=forward tooltip="include"]
    "20" -> "19" [dir=forward tooltip="include"]
    "27" -> "3" [dir=forward tooltip="include"]
    "29" -> "30" [dir=forward tooltip="include"]
    "29" -> "23" [dir=forward tooltip="include"]
    "32" -> "21" [dir=forward tooltip="include"]
    "2" -> "3" [dir=forward tooltip="include"]
    "2" -> "14" [dir=forward tooltip="include"]
    "2" -> "15" [dir=forward tooltip="include"]
    "2" -> "19" [dir=forward tooltip="include"]
    "2" -> "21" [dir=forward tooltip="include"]
    "2" -> "26" [dir=forward tooltip="include"]
    "36" -> "2" [dir=forward tooltip="include"]
    "36" -> "27" [dir=forward tooltip="include"]
    "36" -> "3" [dir=forward tooltip="include"]
    "36" -> "23" [dir=forward tooltip="include"]
    "36" -> "21" [dir=forward tooltip="include"]
    "16" -> "17" [dir=forward tooltip="include"]
    "16" -> "18" [dir=forward tooltip="include"]
    "16" -> "6" [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" -> "14" [dir=forward tooltip="include"]
    "24" -> "25" [dir=forward tooltip="include"]
    "15" -> "8" [dir=forward tooltip="include"]
    "15" -> "14" [dir=forward tooltip="include"]
    "15" -> "10" [dir=forward tooltip="include"]
    "15" -> "16" [dir=forward tooltip="include"]
    "21" -> "8" [dir=forward tooltip="include"]
    "21" -> "4" [dir=forward tooltip="include"]
    "21" -> "18" [dir=forward tooltip="include"]
    "21" -> "6" [dir=forward tooltip="include"]
    "21" -> "22" [dir=forward tooltip="include"]
    "21" -> "23" [dir=forward tooltip="include"]
    "21" -> "24" [dir=forward tooltip="include"]
    "21" -> "16" [dir=forward tooltip="include"]
    "21" -> "10" [dir=forward tooltip="include"]
    "9" -> "10" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "27" [dir=forward tooltip="include"]
    "1" -> "9" [dir=forward tooltip="include"]
    "1" -> "28" [dir=forward tooltip="include"]
    "1" -> "3" [dir=forward tooltip="include"]
    "1" -> "29" [dir=forward tooltip="include"]
    "1" -> "30" [dir=forward tooltip="include"]
    "1" -> "31" [dir=forward tooltip="include"]
    "1" -> "33" [dir=forward tooltip="include"]
    "1" -> "35" [dir=forward tooltip="include"]
    "1" -> "36" [dir=forward tooltip="include"]
    "1" -> "24" [dir=forward tooltip="include"]
    "1" -> "21" [dir=forward tooltip="include"]
    "1" -> "10" [dir=forward tooltip="include"]
    "1" -> "22" [dir=forward tooltip="include"]
    "1" -> "37" [dir=forward tooltip="include"]
    "1" -> "38" [dir=forward tooltip="include"]
    "1" -> "39" [dir=forward tooltip="include"]
    "1" -> "40" [dir=forward tooltip="include"]
    "30" -> "2" [dir=forward tooltip="include"]
    "30" -> "21" [dir=forward tooltip="include"]
    "35" -> "3" [dir=forward tooltip="include"]
    "35" -> "31" [dir=forward tooltip="include"]
    "25" -> "6" [dir=forward tooltip="include"]
    "25" -> "9" [dir=forward tooltip="include"]
    "25" -> "14" [dir=forward tooltip="include"]
    "25" -> "23" [dir=forward tooltip="include"]
    "19" -> "8" [dir=forward tooltip="include"]
    "28" -> "2" [dir=forward tooltip="include"]
    "28" -> "23" [dir=forward tooltip="include"]
    "31" -> "5" [dir=forward tooltip="include"]
    "31" -> "2" [dir=forward tooltip="include"]
    "31" -> "32" [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" -> "19" [dir=forward tooltip="include"]
    "3" -> "20" [dir=forward tooltip="include"]
    "3" -> "21" [dir=forward tooltip="include"]
    "3" -> "26" [dir=forward tooltip="include"]
    "23" -> "4" [dir=forward tooltip="include"]
    "23" -> "6" [dir=forward tooltip="include"]
    "23" -> "9" [dir=forward tooltip="include"]
    "23" -> "10" [dir=forward tooltip="include"]
    "23" -> "16" [dir=forward tooltip="include"]
    "33" -> "3" [dir=forward tooltip="include"]
    "33" -> "31" [dir=forward tooltip="include"]
    "33" -> "34" [dir=forward tooltip="include"]
    "26" -> "8" [dir=forward tooltip="include"]
    "26" -> "4" [dir=forward tooltip="include"]
    "26" -> "14" [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