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