From 6f8252e83c17efa859cf937683b1caf723c439f2 Mon Sep 17 00:00:00 2001 From: Lijian Zhang Date: Wed, 8 Nov 2023 09:09:10 +0000 Subject: wireguard: notify key changes to crypto engine This is a prerequisite patch for the following openssl API optimization patch, which tries to offload openssl ctx init and key expansion work to the initialization stage. Wireguard adds crypto keys via vnet_crypto_key_add (), and whenever it modifies the keys, the underneath openssl crypto engine shoud be informed of the changes to update the openssl ctx. Type: feature Signed-off-by: Lijian Zhang Change-Id: I3e8f033f3f77eebcecfbd06e8e3bbbfdc95a50e2 --- src/vnet/crypto/crypto.c | 11 +++++++++++ src/vnet/crypto/crypto.h | 1 + 2 files changed, 12 insertions(+) (limited to 'src/vnet') diff --git a/src/vnet/crypto/crypto.c b/src/vnet/crypto/crypto.c index 3cada7591b1..25918f022cb 100644 --- a/src/vnet/crypto/crypto.c +++ b/src/vnet/crypto/crypto.c @@ -483,6 +483,17 @@ vnet_crypto_key_del (vlib_main_t * vm, vnet_crypto_key_index_t index) pool_put (cm->keys, key); } +void +vnet_crypto_key_update (vlib_main_t *vm, vnet_crypto_key_index_t index) +{ + vnet_crypto_main_t *cm = &crypto_main; + vnet_crypto_engine_t *engine; + + vec_foreach (engine, cm->engines) + if (engine->key_op_handler) + engine->key_op_handler (vm, VNET_CRYPTO_KEY_OP_MODIFY, index); +} + vnet_crypto_async_alg_t vnet_crypto_link_algs (vnet_crypto_alg_t crypto_alg, vnet_crypto_alg_t integ_alg) diff --git a/src/vnet/crypto/crypto.h b/src/vnet/crypto/crypto.h index 877eb183ea6..8200bad7eeb 100644 --- a/src/vnet/crypto/crypto.h +++ b/src/vnet/crypto/crypto.h @@ -496,6 +496,7 @@ int vnet_crypto_is_set_handler (vnet_crypto_alg_t alg); u32 vnet_crypto_key_add (vlib_main_t * vm, vnet_crypto_alg_t alg, u8 * data, u16 length); void vnet_crypto_key_del (vlib_main_t * vm, vnet_crypto_key_index_t index); +void vnet_crypto_key_update (vlib_main_t *vm, vnet_crypto_key_index_t index); /** * Use 2 created keys to generate new key for linked algs (cipher + integ) -- cgit 1.2.3-korg