added length parameter to why2_sha256

This commit is contained in:
Václav Šmejkal 2025-02-01 14:37:53 +01:00
parent f404da5e2d
commit ea1bb6789e
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
2 changed files with 3 additions and 3 deletions

View File

@ -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
}

View File

@ -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++)