mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 07:03:09 -04:00
qcacmn: Correct shash APIs calling
Add changes to correct shash APIs calling. Change-Id: Ic1756311c3869c0b4881e1ac07a8d32be6e1e481 CRs-Fixed: 2089258
This commit is contained in:
parent
e22618a790
commit
b9abb628db
1 changed files with 12 additions and 47 deletions
|
|
@ -30,6 +30,7 @@
|
|||
#include <crypto/skcipher.h>
|
||||
|
||||
/* Function Definitions and Documentation */
|
||||
#define MAX_HMAC_ELEMENT_CNT 10
|
||||
|
||||
/*
|
||||
* xor: API to calculate xor
|
||||
|
|
@ -49,31 +50,8 @@ int qdf_get_hash(uint8_t *type,
|
|||
uint8_t element_cnt, uint8_t *addr[], uint32_t *addr_len,
|
||||
int8_t *hash)
|
||||
{
|
||||
int i, ret;
|
||||
struct hash_desc desc;
|
||||
struct scatterlist sg;
|
||||
|
||||
/* allocate crypto hash type */
|
||||
desc.tfm = crypto_alloc_hash(type, 0, CRYPTO_ALG_ASYNC);
|
||||
|
||||
if (IS_ERR(desc.tfm)) {
|
||||
ret = PTR_ERR(desc.tfm);
|
||||
return -EINVAL;
|
||||
}
|
||||
desc.flags = 0;
|
||||
ret = crypto_hash_init(&desc);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < element_cnt ; i++) {
|
||||
sg_init_one(&sg, addr[i], addr_len[i]);
|
||||
crypto_hash_update(&desc, &sg, addr_len[i]);
|
||||
}
|
||||
|
||||
crypto_hash_final(&desc, hash);
|
||||
crypto_free_hash(desc.tfm);
|
||||
return 0;
|
||||
return qdf_get_hmac_hash(type, NULL, 0, element_cnt,
|
||||
addr, addr_len, hash);
|
||||
}
|
||||
|
||||
int qdf_get_hmac_hash(uint8_t *type, uint8_t *key,
|
||||
|
|
@ -81,33 +59,20 @@ int qdf_get_hmac_hash(uint8_t *type, uint8_t *key,
|
|||
uint8_t element_cnt, uint8_t *addr[], uint32_t *addr_len,
|
||||
int8_t *hash)
|
||||
{
|
||||
int i, ret;
|
||||
struct hash_desc desc;
|
||||
struct scatterlist sg;
|
||||
int i;
|
||||
size_t src_len[MAX_HMAC_ELEMENT_CNT];
|
||||
|
||||
/* allocate crypto hash type */
|
||||
desc.tfm = crypto_alloc_hash(type, 0, CRYPTO_ALG_ASYNC);
|
||||
|
||||
if (IS_ERR(desc.tfm)) {
|
||||
ret = PTR_ERR(desc.tfm);
|
||||
if (element_cnt > MAX_HMAC_ELEMENT_CNT) {
|
||||
QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
||||
FL("Invalid element count %d"), element_cnt);
|
||||
return -EINVAL;
|
||||
}
|
||||
desc.flags = 0;
|
||||
ret = crypto_hash_setkey(desc.tfm, key, keylen);
|
||||
|
||||
crypto_hash_init(&desc);
|
||||
for (i = 0; i < element_cnt; i++)
|
||||
src_len[i] = addr_len[i];
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < element_cnt ; i++) {
|
||||
sg_init_one(&sg, addr[i], addr_len[i]);
|
||||
crypto_hash_update(&desc, &sg, addr_len[i]);
|
||||
}
|
||||
|
||||
crypto_hash_final(&desc, hash);
|
||||
crypto_free_hash(desc.tfm);
|
||||
return 0;
|
||||
return qdf_get_keyed_hash(type, key, keylen, (const uint8_t **)addr,
|
||||
src_len, element_cnt, hash);
|
||||
}
|
||||
|
||||
/* qdf_update_dbl from RFC 5297. Length of d is AES_BLOCK_SIZE (128 bits) */
|
||||
|
|
|
|||
Loading…
Reference in a new issue