otp_crypto.c

Include dependency graph for otp_crypto.c:

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

Defines

MAX_MD_SIZE
DEFINE_HASH_FOLD(ALGORITHM, SUFFIX)
DEFINE_HASH_FOLD_NORET(ALGORITHM, SUFFIX)
DEFINE_DO_HASH(ALGORITHM, SUFFIX)
DEFINE_DO_HASH_IS_OTHER(ALGORITHM, SUFFIX, IS_OTHER)
DEFINE_DO_HASH_NORET(ALGORITHM, SUFFIX)
DEFINE_DO_HASH_NORET_IS_OTHER(ALGORITHM, SUFFIX, IS_OTHER)

Enums

enum crypto_algorithm

Values:

enumerator CryptoInvalidAlgorithm
enumerator CryptoMd5
enumerator CryptoSha1
enumerator CryptoSha224
enumerator CryptoSha256
enumerator CryptoSha384
enumerator CryptoSha512

Functions

static term nif_crypto_hash(Context *ctx, int argc, term argv[])
static term handle_iodata(term iodata, const void **data, size_t *len, void **allocated_ptr)
static bool bool_to_mbedtls_operation(term encrypt_flag, mbedtls_operation_t *operation)
static term make_crypto_error(const char *file, int line, const char *message, Context *ctx)
static term nif_crypto_crypto_one_time(Context *ctx, int argc, term argv[])
term nif_crypto_strong_rand_bytes(Context *ctx, int argc, term argv[])
const struct Nif *otp_crypto_nif_get_nif(const char *nifname)

Variables

static const AtomStringIntPair crypto_algorithm_table[] = {{ATOM_STR("\x3", "md5"), CryptoMd5}, {ATOM_STR("\x3", "sha"), CryptoSha1}, {ATOM_STR("\x6", "sha224"), CryptoSha224}, {ATOM_STR("\x6", "sha256"), CryptoSha256}, {ATOM_STR("\x6", "sha384"), CryptoSha384}, {ATOM_STR("\x6", "sha512"), CryptoSha512},}
static const AtomStringIntPair cipher_table[] = {{ATOM_STR("\xB", "aes_128_ecb"), MBEDTLS_CIPHER_AES_128_ECB}, {ATOM_STR("\xB", "aes_192_ecb"), MBEDTLS_CIPHER_AES_192_ECB}, {ATOM_STR("\xB", "aes_256_ecb"), MBEDTLS_CIPHER_AES_256_ECB}, {ATOM_STR("\xB", "aes_128_cbc"), MBEDTLS_CIPHER_AES_128_CBC}, {ATOM_STR("\xB", "aes_192_cbc"), MBEDTLS_CIPHER_AES_192_CBC}, {ATOM_STR("\xB", "aes_256_cbc"), MBEDTLS_CIPHER_AES_256_CBC}, {ATOM_STR("\xE", "aes_128_cfb128"), MBEDTLS_CIPHER_AES_128_CFB128}, {ATOM_STR("\xE", "aes_192_cfb128"), MBEDTLS_CIPHER_AES_192_CFB128}, {ATOM_STR("\xE", "aes_256_cfb128"), MBEDTLS_CIPHER_AES_256_CFB128}, {ATOM_STR("\xB", "aes_128_ctr"), MBEDTLS_CIPHER_AES_128_CTR}, {ATOM_STR("\xB", "aes_192_ctr"), MBEDTLS_CIPHER_AES_192_CTR}, {ATOM_STR("\xB", "aes_256_ctr"), MBEDTLS_CIPHER_AES_256_CTR},}
static const AtomStringIntPair padding_table[] = {{ATOM_STR("\x4", "none"), MBEDTLS_PADDING_NONE}, {ATOM_STR("\xC", "pkcs_padding"), MBEDTLS_PADDING_PKCS7},}
static const struct Nif crypto_hash_nif  = {.base.type =NIFFunctionType,.nif_ptr = nif_crypto_hash}
static const struct Nif crypto_crypto_one_time_nif  = {.base.type =NIFFunctionType,.nif_ptr = nif_crypto_crypto_one_time}
static const struct Nif crypto_strong_rand_bytes_nif  = {.base.type =NIFFunctionType,.nif_ptr =nif_crypto_strong_rand_bytes }