aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ipsec/ipsec_sa.c
diff options
context:
space:
mode:
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);