diff --git a/lib/crypto_backend/crypto_backend.h b/lib/crypto_backend/crypto_backend.h index e65e9e27..84839e3a 100644 --- a/lib/crypto_backend/crypto_backend.h +++ b/lib/crypto_backend/crypto_backend.h @@ -48,7 +48,7 @@ void crypt_hash_destroy(struct crypt_hash *ctx); /* HMAC */ int crypt_hmac_size(const char *name); int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, - const void *buffer, size_t length); + const void *key, size_t key_length); int crypt_hmac_write(struct crypt_hmac *ctx, const char *buffer, size_t length); int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length); void crypt_hmac_destroy(struct crypt_hmac *ctx); diff --git a/lib/crypto_backend/crypto_gcrypt.c b/lib/crypto_backend/crypto_gcrypt.c index 7d237866..a1ed7f63 100644 --- a/lib/crypto_backend/crypto_gcrypt.c +++ b/lib/crypto_backend/crypto_gcrypt.c @@ -239,7 +239,7 @@ int crypt_hmac_size(const char *name) } int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, - const void *buffer, size_t length) + const void *key, size_t key_length) { struct crypt_hmac *h; unsigned int flags = GCRY_MD_FLAG_HMAC; @@ -261,7 +261,7 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, return -EINVAL; } - if (gcry_md_setkey(h->hd, buffer, length)) { + if (gcry_md_setkey(h->hd, key, key_length)) { gcry_md_close(h->hd); free(h); return -EINVAL; diff --git a/lib/crypto_backend/crypto_kernel.c b/lib/crypto_backend/crypto_kernel.c index 99bfad28..777f8da2 100644 --- a/lib/crypto_backend/crypto_kernel.c +++ b/lib/crypto_backend/crypto_kernel.c @@ -234,7 +234,7 @@ int crypt_hmac_size(const char *name) } int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, - const void *buffer, size_t length) + const void *key, size_t key_length) { struct crypt_hmac *h; struct hash_alg *ha; @@ -257,7 +257,7 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, snprintf((char *)sa.salg_name, sizeof(sa.salg_name), "hmac(%s)", ha->kernel_name); - if (crypt_kernel_socket_init(&sa, &h->tfmfd, &h->opfd, buffer, length) < 0) { + if (crypt_kernel_socket_init(&sa, &h->tfmfd, &h->opfd, key, key_length) < 0) { free(h); return -EINVAL; } diff --git a/lib/crypto_backend/crypto_nettle.c b/lib/crypto_backend/crypto_nettle.c index 5d133d6c..9a7406a4 100644 --- a/lib/crypto_backend/crypto_nettle.c +++ b/lib/crypto_backend/crypto_nettle.c @@ -215,7 +215,7 @@ int crypt_hmac_size(const char *name) } int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, - const void *buffer, size_t length) + const void *key, size_t key_length) { struct crypt_hmac *h; @@ -229,12 +229,12 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, if (!h->hash) goto bad; - h->key = malloc(length); + h->key = malloc(key_length); if (!h->key) goto bad; - memcpy(h->key, buffer, length); - h->key_length = length; + memcpy(h->key, key, key_length); + h->key_length = key_length; h->hash->init(&h->nettle_ctx); h->hash->hmac_set_key(&h->nettle_ctx, h->key_length, h->key); diff --git a/lib/crypto_backend/crypto_nss.c b/lib/crypto_backend/crypto_nss.c index 5287d3a7..9caf241b 100644 --- a/lib/crypto_backend/crypto_nss.c +++ b/lib/crypto_backend/crypto_nss.c @@ -194,15 +194,15 @@ int crypt_hmac_size(const char *name) } int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, - const void *buffer, size_t length) + const void *key, size_t key_length) { struct crypt_hmac *h; SECItem keyItem; SECItem noParams; keyItem.type = siBuffer; - keyItem.data = CONST_CAST(unsigned char *)buffer; - keyItem.len = (int)length; + keyItem.data = CONST_CAST(unsigned char *)key; + keyItem.len = (int)key_length; noParams.type = siBuffer; noParams.data = 0; diff --git a/lib/crypto_backend/crypto_openssl.c b/lib/crypto_backend/crypto_openssl.c index 147db028..4929f828 100644 --- a/lib/crypto_backend/crypto_openssl.c +++ b/lib/crypto_backend/crypto_openssl.c @@ -227,7 +227,7 @@ int crypt_hmac_size(const char *name) } int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, - const void *buffer, size_t length) + const void *key, size_t key_length) { struct crypt_hmac *h; @@ -248,7 +248,7 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, return -EINVAL; } - HMAC_Init_ex(h->md, buffer, length, h->hash_id, NULL); + HMAC_Init_ex(h->md, key, key_length, h->hash_id, NULL); h->hash_len = EVP_MD_size(h->hash_id); *ctx = h;