From ea1bb6789e6be7a3b4d51e7c9b30c511947ec606 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sat, 1 Feb 2025 14:37:53 +0100 Subject: [PATCH] added length parameter to why2_sha256 --- include/chat/crypto.h | 2 +- src/chat/crypto.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/chat/crypto.h b/include/chat/crypto.h index 8f62225..bbbb8d1 100644 --- a/include/chat/crypto.h +++ b/include/chat/crypto.h @@ -46,7 +46,7 @@ why2_bool why2_chat_ecc_verify_signature(char *message, char *signature, EVP_PKE char *why2_chat_ecc_serialize_public_key(); //GET PUBLIC ECC KEY IN BASE64 EVP_PKEY* why2_chat_ecc_deserialize_public_key(char *pubkey); //GET EVP_PKEY FROM BASE64 PUBLIC ECC KEY -char *why2_sha256(char *input); //HASH input USING SHA256 AND RETURN IN STRING +char *why2_sha256(char *input, size_t length); //HASH input USING SHA256 AND RETURN IN STRING #ifdef __cplusplus } diff --git a/src/chat/crypto.c b/src/chat/crypto.c index 76a8734..dc85750 100644 --- a/src/chat/crypto.c +++ b/src/chat/crypto.c @@ -247,12 +247,12 @@ void why2_chat_deallocate_keys(void) EVP_PKEY_free(keypair); } -char *why2_sha256(char *input) +char *why2_sha256(char *input, size_t length) { unsigned char *output = why2_malloc(SHA256_DIGEST_LENGTH + 1); char *formatted_output = why2_malloc(SHA256_DIGEST_LENGTH * 2 + 2); - SHA256((unsigned char*) input, strlen(input), output); + SHA256((unsigned char*) input, length, output); //SAVE AS STRING IN HEX for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)