import mcpplibs.mwrap.mbedtls; declares Mbed TLS 3.6.8's hash API as <mbedtls/sha256.h>,
<mbedtls/sha512.h>, <mbedtls/sha1.h>, <mbedtls/md5.h>, <mbedtls/sha3.h> and <mbedtls/md.h>
do. Types and functions are the upstream globals, the very same entities as the headers', so a
translation unit may include the header too — every #include before the first import. The
library is compat.mbedtls 3.6.8: the release's sources built once as a C library.
One module per header; the root re-exports all of them.
| Module | What it holds |
|---|---|
mcpplibs.mwrap.mbedtls |
every module below |
.sha256 |
mbedtls_sha256_context; mbedtls_sha256_init / _free / _clone / _starts(ctx, is224) / _update / _finish; mbedtls_sha256(input, ilen, out, is224) |
.sha512 |
the same names with sha512 and is384 |
.sha1, .md5 |
mbedtls_sha1(input, ilen, out), mbedtls_md5(input, ilen, out) and their contexts |
.sha3 |
mbedtls_sha3_id (MBEDTLS_SHA3_224 … MBEDTLS_SHA3_512), mbedtls_sha3_context, mbedtls_sha3(id, input, ilen, out, olen) |
.md |
mbedtls_md_type_t, mbedtls_md_info_t, mbedtls_md_context_t, mbedtls_md_info_from_type / _string / _ctx, mbedtls_md_get_name / _size / _type, mbedtls_md, mbedtls_md_file, mbedtls_md_hmac, mbedtls_md_hmac_starts / _update / _finish / _reset, mbedtls_md_list |
The source is src/<module>.cppm, written by tools/generate.py from the headers of the
compat.mbedtls package mcpp resolved; tools/generate.py --check audits the committed files.
import mcpplibs.mwrap.mbedtls;
mbedtls_sha256_context ctx;
mbedtls_sha256_init(&ctx);
mbedtls_sha256_starts(&ctx, 0); // 1 = SHA-224
mbedtls_sha256_update(&ctx, data, size);
unsigned char out[32];
mbedtls_sha256_finish(&ctx, out);
mbedtls_sha256_free(&ctx);const mbedtls_md_info_t* info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256);
unsigned char mac[32];
mbedtls_md_hmac(info, key, key_len, message, message_len, mac);mbedtls_internal_sha256_processand its siblings: the block step of each hash, upstream's own.- Nothing else: every other public declaration of the six headers is a
using ::namein the module, in the order the generator read it.
The *_self_test functions are exported; the library provides them only when built with
MBEDTLS_SELF_TEST_C (compat.mbedtls is not), so linking them is a link error — call them
under #if defined(MBEDTLS_SELF_TEST_C).