diff options
author | vnugent <public@vaughnnugent.com> | 2024-07-26 23:37:15 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-07-26 23:37:15 -0400 |
commit | 07de078a3b5b7b0043d9f81bb5a9e750a3a0c7c1 (patch) | |
tree | bb67c67e4d98bda21c6b2613549a82ee13e59b53 /src/providers/bcrypt.c | |
parent | 54f520e4bfc0fe23e2719d44b09739aa8709451c (diff) |
refactor: Span invasion, checks and fix some evp api
Diffstat (limited to 'src/providers/bcrypt.c')
-rw-r--r-- | src/providers/bcrypt.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/providers/bcrypt.c b/src/providers/bcrypt.c index 10cf801..2b9ba52 100644 --- a/src/providers/bcrypt.c +++ b/src/providers/bcrypt.c @@ -79,8 +79,8 @@ _IMPLSTB NTSTATUS _bcCreateHmac(struct _bcrypt_ctx* ctx, cspan_t key) &ctx->hHash, NULL, 0, - (uint8_t*)key.data, - key.size, + (uint8_t*)ncSpanGetOffsetC(key, 0), + ncSpanGetSizeC(key), BCRYPT_HASH_REUSABLE_FLAG /* Enable reusable for expand function */ ); } @@ -102,7 +102,11 @@ _IMPLSTB NTSTATUS _bcHashDataRaw(const struct _bcrypt_ctx* ctx, const uint8_t* d _IMPLSTB NTSTATUS _bcHashData(const struct _bcrypt_ctx* ctx, cspan_t data) { - return _bcHashDataRaw(ctx, data.data, data.size); + return _bcHashDataRaw( + ctx, + ncSpanGetOffsetC(data, 0), + ncSpanGetSizeC(data) + ); } _IMPLSTB NTSTATUS _bcFinishHash(const struct _bcrypt_ctx* ctx, sha256_t digestOut32) @@ -118,8 +122,8 @@ _IMPLSTB void _bcDestroyCtx(struct _bcrypt_ctx* ctx) /* Close the algorithm provider */ if (ctx->hAlg) BCryptCloseAlgorithmProvider(ctx->hAlg, 0); - ctx->hAlg = NULL; ctx->hHash = NULL; + ctx->hAlg = NULL; } #ifndef _IMPL_SECURE_ZERO_MEMSET @@ -213,7 +217,7 @@ _IMPLSTB void _bcDestroyCtx(struct _bcrypt_ctx* ctx) #define _IMPL_CRYPTO_SHA256_HKDF_EXPAND _bcrypt_fallback_hkdf_expand - cstatus_t _bcrypt_hkdf_update(void* ctx, cspan_t data) + static cstatus_t _bcrypt_hkdf_update(void* ctx, cspan_t data) { DEBUG_ASSERT(ctx != NULL) @@ -221,7 +225,7 @@ _IMPLSTB void _bcDestroyCtx(struct _bcrypt_ctx* ctx) return CSTATUS_OK; } - cstatus_t _bcrypt_hkdf_finish(void* ctx, sha256_t hmacOut32) + static cstatus_t _bcrypt_hkdf_finish(void* ctx, sha256_t hmacOut32) { DEBUG_ASSERT(ctx != NULL); DEBUG_ASSERT(hmacOut32 != NULL); |