From f2afcfd0e3dbad9be770c3f29485815c7dba834f Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Sun, 17 Mar 2024 18:44:33 -0400 Subject: Fixed error on first pull. --- src/lpm.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/lpm.c') diff --git a/src/lpm.c b/src/lpm.c index fef74cc..e63ff78 100644 --- a/src/lpm.c +++ b/src/lpm.c @@ -35,7 +35,11 @@ #include #include #include -#include +#if MBEDTLS_VERSION_MAJOR < 3 + #include +#else + #include +#endif #ifdef MBEDTLS_DEBUG_C #include #endif @@ -133,7 +137,7 @@ static int lpm_hash(lua_State* L) { unsigned char buffer[digest_length]; mbedtls_sha256_context hash_ctx; mbedtls_sha256_init(&hash_ctx); - mbedtls_sha256_starts_ret(&hash_ctx, 0); + mbedtls_sha256_starts(&hash_ctx, 0); if (strcmp(type, "file") == 0) { FILE* file = lua_fopen(L, data, "rb"); if (!file) { @@ -143,15 +147,15 @@ static int lpm_hash(lua_State* L) { while (1) { unsigned char chunk[4096]; size_t bytes = fread(chunk, 1, sizeof(chunk), file); - mbedtls_sha256_update_ret(&hash_ctx, chunk, bytes); + mbedtls_sha256_update(&hash_ctx, chunk, bytes); if (bytes < sizeof(chunk)) break; } fclose(file); } else { - mbedtls_sha256_update_ret(&hash_ctx, data, len); + mbedtls_sha256_update(&hash_ctx, data, len); } - mbedtls_sha256_finish_ret(&hash_ctx, buffer); + mbedtls_sha256_finish(&hash_ctx, buffer); mbedtls_sha256_free(&hash_ctx); lua_pushhexstring(L, buffer, digest_length); return 1; -- cgit v1.2.3