diff options
author | Damjan Marion <damarion@cisco.com> | 2019-03-20 16:30:54 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2019-03-20 17:24:31 +0000 |
commit | 8863123badb7fea96a8a4dfc39131ce40161eee6 (patch) | |
tree | a5602b7395f41a94fb41fe3691d324de0f19f7ac /src/plugins/crypto_openssl | |
parent | f2edfbd2122bbf746a8e91cb343331fb843ee5eb (diff) |
crypto: add hmac truncate option
This reverts commit 785368e559dbdf50676f74f43f13423c817abb52.
Change-Id: I782ac2be4e161790c73ccd4b08492e2188a6d79d
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/crypto_openssl')
-rw-r--r-- | src/plugins/crypto_openssl/main.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/plugins/crypto_openssl/main.c b/src/plugins/crypto_openssl/main.c index 09d726749e1..7b645f4be88 100644 --- a/src/plugins/crypto_openssl/main.c +++ b/src/plugins/crypto_openssl/main.c @@ -102,6 +102,7 @@ static_always_inline u32 openssl_ops_hmac (vlib_main_t * vm, vnet_crypto_op_t * ops[], u32 n_ops, const EVP_MD * md) { + u8 buffer[64]; openssl_per_thread_data_t *ptd = vec_elt_at_index (per_thread_data, vm->thread_index); HMAC_CTX *ctx = ptd->hmac_ctx; @@ -113,7 +114,13 @@ openssl_ops_hmac (vlib_main_t * vm, vnet_crypto_op_t * ops[], u32 n_ops, HMAC_Init_ex (ctx, op->key, op->key_len, md, NULL); HMAC_Update (ctx, op->src, op->len); - HMAC_Final (ctx, op->dst, &out_len); + if (op->hmac_trunc_len) + { + HMAC_Final (ctx, buffer, &out_len); + clib_memcpy_fast (op->dst, buffer, op->hmac_trunc_len); + } + else + HMAC_Final (ctx, op->dst, &out_len); op->status = VNET_CRYPTO_OP_STATUS_COMPLETED; } return n_ops; |