diff options
author | vnugent <public@vaughnnugent.com> | 2024-11-13 22:25:32 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-11-13 22:25:32 -0500 |
commit | 5cf1addc4a7b70aafda5ad8953f114a206df93cc (patch) | |
tree | d478524ea1ed7676f530f2eb26af644024d6aeca /src/providers/mbedtls.c | |
parent | 0baa4afd4716ad4d6d2f37b9d4af4fc839d16d7c (diff) |
integrate mbedtls testing and remove mbedtls fetch
Diffstat (limited to 'src/providers/mbedtls.c')
-rw-r--r-- | src/providers/mbedtls.c | 52 |
1 files changed, 25 insertions, 27 deletions
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 <mbedtls/md.h> - #include <mbedtls/hkdf.h> - #include <mbedtls/hmac_drbg.h> - #include <mbedtls/sha256.h> - #include <mbedtls/chacha20.h> - #include <mbedtls/constant_time.h> + #include <mbedtls/mbedtls/md.h> + #include <mbedtls/mbedtls/hkdf.h> + #include <mbedtls/mbedtls/hmac_drbg.h> + #include <mbedtls/mbedtls/sha256.h> + #include <mbedtls/mbedtls/chacha20.h> + #include <mbedtls/mbedtls/constant_time.h> #undef inline #else - #include <mbedtls/md.h> - #include <mbedtls/hkdf.h> - #include <mbedtls/hmac_drbg.h> - #include <mbedtls/sha256.h> - #include <mbedtls/chacha20.h> - #include <mbedtls/constant_time.h> + #include <mbedtls/mbedtls/md.h> + #include <mbedtls/mbedtls/hkdf.h> + #include <mbedtls/mbedtls/hmac_drbg.h> + #include <mbedtls/mbedtls/sha256.h> + #include <mbedtls/mbedtls/chacha20.h> + #include <mbedtls/mbedtls/constant_time.h> #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; } |