1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-12 15:41:16 +03:00

Update HMAC function parameter type

New openssl API, libmbedtls, libgcrypt use size_t for
HMAC len pameter.

New helper functions were added in libcrypto.c to avoid
code duplication. (the header pki.h is needed for this
reason)

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Norbert Pocs
2022-06-23 15:33:05 +00:00
committed by Andreas Schneider
parent 51c940adc9
commit debd0ea4d3
8 changed files with 328 additions and 50 deletions

View File

@@ -268,14 +268,20 @@ HMACCTX hmac_init(const void *key, size_t len, enum ssh_hmac_e type) {
return c;
}
void hmac_update(HMACCTX c, const void *data, size_t len) {
int hmac_update(HMACCTX c, const void *data, size_t len) {
gcry_md_write(c, data, len);
return 1;
}
void hmac_final(HMACCTX c, unsigned char *hashmacbuf, unsigned int *len) {
*len = gcry_md_get_algo_dlen(gcry_md_get_algo(c));
int hmac_final(HMACCTX c, unsigned char *hashmacbuf, size_t *len) {
unsigned int tmp = gcry_md_get_algo_dlen(gcry_md_get_algo(c));
if (tmp > SIZE_MAX) {
return 0;
}
*len = (size_t)tmp;
memcpy(hashmacbuf, gcry_md_read(c, 0), *len);
gcry_md_close(c);
return 1;
}
#ifdef WITH_BLOWFISH_CIPHER