From 5cf1addc4a7b70aafda5ad8953f114a206df93cc Mon Sep 17 00:00:00 2001 From: vnugent Date: Wed, 13 Nov 2024 22:25:32 -0500 Subject: integrate mbedtls testing and remove mbedtls fetch --- src/noscrypt.c | 2 +- src/providers/mbedtls.c | 52 ++++++++++++++++++++++------------------------ src/providers/monocypher.c | 2 +- 3 files changed, 27 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/noscrypt.c b/src/noscrypt.c index 1e19337..9fd6c9b 100644 --- a/src/noscrypt.c +++ b/src/noscrypt.c @@ -51,7 +51,7 @@ /* * Actual, private defintion of the NCContext structure -* to allow for future development and ABI backords +* to allow for future development and ABI backwards * compatability. */ struct nc_ctx_struct { diff --git a/src/providers/mbedtls.c b/src/providers/mbedtls.c index ead3279..cd9a2dc 100644 --- a/src/providers/mbedtls.c +++ b/src/providers/mbedtls.c @@ -31,20 +31,20 @@ /* Inline errors on linux in header files on linux */ #ifndef inline #define inline __inline - #include - #include - #include - #include - #include - #include + #include + #include + #include + #include + #include + #include #undef inline #else - #include - #include - #include - #include - #include - #include + #include + #include + #include + #include + #include + #include #endif _IMPLSTB const mbedtls_md_info_t* _mbed_sha256_alg(void) @@ -57,7 +57,7 @@ _IMPLSTB const mbedtls_md_info_t* _mbed_sha256_alg(void) } #if SIZE_MAX < UINT64_MAX - #define _ssize_guard_int(x) if(x > SIZE_MAX) return 1; + #define _ssize_guard_int(x) if(x > SIZE_MAX) return CSTATUS_FAIL; #else #define _ssize_guard_int(x) #endif @@ -100,8 +100,8 @@ _IMPLSTB const mbedtls_md_info_t* _mbed_sha256_alg(void) _overflow_check(data.size) return mbedtls_sha256( - data.data, - data.size, + ncSpanGetOffsetC(data, 0), + ncSpanGetSizeC(data), digestOut32, 0 /* Set 0 for sha256 mode */ ) == 0 ? CSTATUS_OK : CSTATUS_FAIL; @@ -118,15 +118,13 @@ _IMPLSTB const mbedtls_md_info_t* _mbed_sha256_alg(void) { _overflow_check(data.size) - /* Keys should never be large enough for this to matter, but sanity check. */ - DEBUG_ASSERT2(key.size < SIZE_MAX, "Expected key size to be less than SIZE_MAX") return mbedtls_md_hmac( _mbed_sha256_alg(), - key.data, - key.size, - data.data, - data.size, + ncSpanGetOffsetC(key, 0), + ncSpanGetSizeC(key), + ncSpanGetOffsetC(data, 0), + ncSpanGetSizeC(data), hmacOut32 ) == 0 ? CSTATUS_OK : CSTATUS_FAIL; } @@ -146,12 +144,12 @@ _IMPLSTB const mbedtls_md_info_t* _mbed_sha256_alg(void) return mbedtls_hkdf_expand( _mbed_sha256_alg(), - prk.data, - prk.size, - info.data, - info.size, - okm.data, - okm.size + ncSpanGetOffsetC(prk, 0), + ncSpanGetSizeC(prk), + ncSpanGetOffsetC(info, 0), + ncSpanGetSizeC(info), + ncSpanGetOffset(okm, 0), + ncSpanGetSize(okm) ) == 0 ? CSTATUS_OK : CSTATUS_FAIL; } diff --git a/src/providers/monocypher.c b/src/providers/monocypher.c index c35f63e..0344872 100644 --- a/src/providers/monocypher.c +++ b/src/providers/monocypher.c @@ -29,7 +29,7 @@ #ifdef NC_ENABLE_MONOCYPHER -#include +#include /* Export secure memse0 */ #ifndef _IMPL_SECURE_ZERO_MEMSET -- cgit