aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ipsec/ipsec_sa.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-03-20 16:07:09 +0100
committerNeale Ranns <nranns@cisco.com>2019-03-20 17:23:04 +0000
commitb966e8bfdd3c63e2436ab6e5d250c8b1bf4dd102 (patch)
tree7f3faba13dd462adc577bdc9798da99c209bee9c /src/vnet/ipsec/ipsec_sa.c
parentc372dc2190f2376f9b816f71120354fd53732fa7 (diff)
ipsec: keep crypto data inside SA
Change-Id: Ie8986bd3652d25c4befe681cea77df95aba37ebc Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/ipsec/ipsec_sa.c')
-rw-r--r--src/vnet/ipsec/ipsec_sa.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/vnet/ipsec/ipsec_sa.c b/src/vnet/ipsec/ipsec_sa.c
index fc8520d5ebb..337ca34eae9 100644
--- a/src/vnet/ipsec/ipsec_sa.c
+++ b/src/vnet/ipsec/ipsec_sa.c
@@ -88,6 +88,26 @@ ipsec_sa_stack (ipsec_sa_t * sa)
dpo_reset (&tmp);
}
+void
+ipsec_sa_set_crypto_alg (ipsec_sa_t * sa, ipsec_crypto_alg_t crypto_alg)
+{
+ ipsec_main_t *im = &ipsec_main;
+ sa->crypto_alg = crypto_alg;
+ sa->crypto_iv_size = im->crypto_algs[crypto_alg].iv_size;
+ sa->crypto_block_size = im->crypto_algs[crypto_alg].block_size;
+ sa->crypto_enc_op_type = im->crypto_algs[crypto_alg].enc_op_type;
+ sa->crypto_dec_op_type = im->crypto_algs[crypto_alg].dec_op_type;
+}
+
+void
+ipsec_sa_set_integ_alg (ipsec_sa_t * sa, ipsec_integ_alg_t integ_alg)
+{
+ ipsec_main_t *im = &ipsec_main;
+ sa->integ_alg = integ_alg;
+ sa->integ_trunc_size = im->integ_algs[integ_alg].trunc_size;
+ sa->integ_op_type = im->integ_algs[integ_alg].op_type;
+}
+
int
ipsec_sa_add (u32 id,
u32 spi,
@@ -123,9 +143,9 @@ ipsec_sa_add (u32 id,
sa->spi = spi;
sa->stat_index = sa_index;
sa->protocol = proto;
- sa->crypto_alg = crypto_alg;
+ ipsec_sa_set_crypto_alg (sa, crypto_alg);
clib_memcpy (&sa->crypto_key, ck, sizeof (sa->crypto_key));
- sa->integ_alg = integ_alg;
+ ipsec_sa_set_integ_alg (sa, integ_alg);
clib_memcpy (&sa->integ_key, ik, sizeof (sa->integ_key));
ip46_address_copy (&sa->tunnel_src_addr, tun_src);
ip46_address_copy (&sa->tunnel_dst_addr, tun_dst);