From fa7b7a41e7ca9400dda2266a10dd9179be40c128 Mon Sep 17 00:00:00 2001 From: Stanislav Zaikin Date: Tue, 6 Aug 2024 18:10:13 +0200 Subject: ikev2: fix BN_bn2bin re-allocation the former code was re-allocating the vector when padding takes place. it's not necessary since we have the correct size. also, it caused issues since upper layer doesn't know about re-allocation and it caused crash. with this patch many test-cases are enabled again. Type: fix Change-Id: Idf0b320101670ec64d62e9aac6399cc7c54c996f Signed-off-by: Stanislav Zaikin --- src/plugins/ikev2/ikev2_crypto.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/ikev2/ikev2_crypto.c b/src/plugins/ikev2/ikev2_crypto.c index 3d4ad0a28ed..58167e2322e 100644 --- a/src/plugins/ikev2/ikev2_crypto.c +++ b/src/plugins/ikev2/ikev2_crypto.c @@ -481,15 +481,14 @@ ikev2_encrypt_data (ikev2_main_per_thread_data_t * ptd, ikev2_sa_t * sa, int BN_bn2binpad (const BIGNUM * a, unsigned char *to, int tolen) { - int r = BN_bn2bin (a, to); + int r = BN_num_bytes (a); ASSERT (tolen >= r); int pad = tolen - r; if (pad) { - vec_insert (to, pad, 0); clib_memset (to, 0, pad); - vec_dec_len (to, pad); } + BN_bn2bin (a, to + pad); return tolen; } #endif -- cgit