aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/ikev2/ikev2_crypto.c
diff options
context:
space:
mode:
authorStanislav Zaikin <stanislav.zaikin@46labs.com>2024-08-06 18:10:13 +0200
committerBeno�t Ganne <bganne@cisco.com>2024-08-07 10:12:22 +0000
commitfa7b7a41e7ca9400dda2266a10dd9179be40c128 (patch)
tree851e58edcba94c0741f769ac3435bdc3ee4d3a36 /src/plugins/ikev2/ikev2_crypto.c
parentcf9356d642ce131c6562fcd281c01e51af888ec3 (diff)
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 <stanislav.zaikin@46labs.com>
Diffstat (limited to 'src/plugins/ikev2/ikev2_crypto.c')
-rw-r--r--src/plugins/ikev2/ikev2_crypto.c5
1 files changed, 2 insertions, 3 deletions
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