crypto_openssl: call EVP_EncryptFinal_ex only if needed
Change-Id: I4dc6749a67c0726bae20b8204a5171676308b909 Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:

committed by
Neale Ranns

parent
c80cc9ab84
commit
f2edfbd212
@ -69,6 +69,7 @@ openssl_ops_enc_cbc (vlib_main_t * vm, vnet_crypto_op_t * ops[], u32 n_ops,
|
|||||||
|
|
||||||
EVP_EncryptInit_ex (ctx, cipher, NULL, op->key, op->iv);
|
EVP_EncryptInit_ex (ctx, cipher, NULL, op->key, op->iv);
|
||||||
EVP_EncryptUpdate (ctx, op->dst, &out_len, op->src, op->len);
|
EVP_EncryptUpdate (ctx, op->dst, &out_len, op->src, op->len);
|
||||||
|
if (out_len < op->len)
|
||||||
EVP_EncryptFinal_ex (ctx, op->dst + out_len, &out_len);
|
EVP_EncryptFinal_ex (ctx, op->dst + out_len, &out_len);
|
||||||
op->status = VNET_CRYPTO_OP_STATUS_COMPLETED;
|
op->status = VNET_CRYPTO_OP_STATUS_COMPLETED;
|
||||||
}
|
}
|
||||||
@ -90,6 +91,7 @@ openssl_ops_dec_cbc (vlib_main_t * vm, vnet_crypto_op_t * ops[], u32 n_ops,
|
|||||||
|
|
||||||
EVP_DecryptInit_ex (ctx, cipher, NULL, op->key, op->iv);
|
EVP_DecryptInit_ex (ctx, cipher, NULL, op->key, op->iv);
|
||||||
EVP_DecryptUpdate (ctx, op->dst, &out_len, op->src, op->len);
|
EVP_DecryptUpdate (ctx, op->dst, &out_len, op->src, op->len);
|
||||||
|
if (out_len < op->len)
|
||||||
EVP_DecryptFinal_ex (ctx, op->dst + out_len, &out_len);
|
EVP_DecryptFinal_ex (ctx, op->dst + out_len, &out_len);
|
||||||
op->status = VNET_CRYPTO_OP_STATUS_COMPLETED;
|
op->status = VNET_CRYPTO_OP_STATUS_COMPLETED;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user