aboutsummaryrefslogtreecommitdiff
path: root/core/tee/tee_cryp_hkdf.c
diff options
context:
space:
mode:
authorJens Wiklander <jens.wiklander@linaro.org>2017-11-09 23:20:25 +0100
committerJérôme Forissier <jerome.forissier@linaro.org>2017-11-14 13:48:32 +0100
commite9eaba5c0a3d27075b1e995294fd42de65c0b912 (patch)
tree74999649def54c18ee7b4fa22f4486178086dc4f /core/tee/tee_cryp_hkdf.c
parent82d91db11f0188df939ce52f6106a39f026de74c (diff)
Replace struct mac_ops with function interface
Adds mac_cipher_get_ctx_size(), mac_cipher_init(), mac_cipher_update() and mac_cipher_final() replacing struct mac_ops in crypto_ops. Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'core/tee/tee_cryp_hkdf.c')
-rw-r--r--core/tee/tee_cryp_hkdf.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/core/tee/tee_cryp_hkdf.c b/core/tee/tee_cryp_hkdf.c
index d5287d97..7c93f70d 100644
--- a/core/tee/tee_cryp_hkdf.c
+++ b/core/tee/tee_cryp_hkdf.c
@@ -44,12 +44,6 @@ static TEE_Result hkdf_extract(uint32_t hash_id, const uint8_t *ikm,
void *ctx = NULL;
uint32_t hash_algo = TEE_ALG_HASH_ALGO(hash_id);
uint32_t hmac_algo = (TEE_OPERATION_MAC << 28) | hash_id;
- const struct mac_ops *m = &crypto_ops.mac;
-
- if (!m->get_ctx_size || !m->init || !m->update) {
- res = TEE_ERROR_NOT_IMPLEMENTED;
- goto out;
- }
if (!salt || !salt_len) {
/*
@@ -63,7 +57,7 @@ static TEE_Result hkdf_extract(uint32_t hash_id, const uint8_t *ikm,
goto out;
}
- res = m->get_ctx_size(hmac_algo, &ctx_size);
+ res = crypto_mac_get_ctx_size(hmac_algo, &ctx_size);
if (res != TEE_SUCCESS)
goto out;
@@ -79,15 +73,15 @@ static TEE_Result hkdf_extract(uint32_t hash_id, const uint8_t *ikm,
* Therefore, salt is the HMAC key in the formula from section 2.2:
* "PRK = HMAC-Hash(salt, IKM)"
*/
- res = m->init(ctx, hmac_algo, salt, salt_len);
+ res = crypto_mac_init(ctx, hmac_algo, salt, salt_len);
if (res != TEE_SUCCESS)
goto out;
- res = m->update(ctx, hmac_algo, ikm, ikm_len);
+ res = crypto_mac_update(ctx, hmac_algo, ikm, ikm_len);
if (res != TEE_SUCCESS)
goto out;
- res = m->final(ctx, hmac_algo, prk, *prk_len);
+ res = crypto_mac_final(ctx, hmac_algo, prk, *prk_len);
if (res != TEE_SUCCESS)
goto out;
@@ -105,15 +99,9 @@ static TEE_Result hkdf_expand(uint32_t hash_id, const uint8_t *prk,
size_t tn_len, hash_len, i, n, where, ctx_size;
TEE_Result res = TEE_SUCCESS;
void *ctx = NULL;
- const struct mac_ops *m = &crypto_ops.mac;
uint32_t hash_algo = TEE_ALG_HASH_ALGO(hash_id);
uint32_t hmac_algo = TEE_ALG_HMAC_ALGO(hash_id);
- if (!m->get_ctx_size || !m->init || !m->update || !m->final) {
- res = TEE_ERROR_NOT_IMPLEMENTED;
- goto out;
- }
-
res = tee_hash_get_digest_size(hash_algo, &hash_len);
if (res != TEE_SUCCESS)
goto out;
@@ -126,7 +114,7 @@ static TEE_Result hkdf_expand(uint32_t hash_id, const uint8_t *prk,
if (!info)
info_len = 0;
- res = m->get_ctx_size(hmac_algo, &ctx_size);
+ res = crypto_mac_get_ctx_size(hmac_algo, &ctx_size);
if (res != TEE_SUCCESS)
goto out;
@@ -162,19 +150,19 @@ static TEE_Result hkdf_expand(uint32_t hash_id, const uint8_t *prk,
for (i = 1; i <= n; i++) {
uint8_t c = i;
- res = m->init(ctx, hmac_algo, prk, prk_len);
+ res = crypto_mac_init(ctx, hmac_algo, prk, prk_len);
if (res != TEE_SUCCESS)
goto out;
- res = m->update(ctx, hmac_algo, tn, tn_len);
+ res = crypto_mac_update(ctx, hmac_algo, tn, tn_len);
if (res != TEE_SUCCESS)
goto out;
- res = m->update(ctx, hmac_algo, info, info_len);
+ res = crypto_mac_update(ctx, hmac_algo, info, info_len);
if (res != TEE_SUCCESS)
goto out;
- res = m->update(ctx, hmac_algo, &c, 1);
+ res = crypto_mac_update(ctx, hmac_algo, &c, 1);
if (res != TEE_SUCCESS)
goto out;
- res = m->final(ctx, hmac_algo, tn, sizeof(tn));
+ res = crypto_mac_final(ctx, hmac_algo, tn, sizeof(tn));
if (res != TEE_SUCCESS)
goto out;