Commit dee38e9c authored by Milan Broz's avatar Milan Broz

Rename buffer to key in hmac_init in crypto backend.

It is key and naming was confusing.
parent b4fc36ea
......@@ -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);
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment