IPSEC: support GCM in ESP
[vpp.git] / src / vnet / ipsec / ipsec_sa.h
index 44f9642..f87e12e 100644 (file)
@@ -43,6 +43,11 @@ typedef enum
     IPSEC_CRYPTO_N_ALG,
 } ipsec_crypto_alg_t;
 
+#define IPSEC_CRYPTO_ALG_IS_GCM(_alg)                     \
+  (((_alg == IPSEC_CRYPTO_ALG_AES_GCM_128) ||             \
+    (_alg == IPSEC_CRYPTO_ALG_AES_GCM_192) ||             \
+    (_alg == IPSEC_CRYPTO_ALG_AES_GCM_256)))
+
 #define foreach_ipsec_integ_alg                                            \
   _ (0, NONE, "none")                                                      \
   _ (1, MD5_96, "md5-96")           /* RFC2403 */                          \
@@ -85,11 +90,14 @@ typedef struct ipsec_key_t_
  */
 #define foreach_ipsec_sa_flags                            \
   _ (0, NONE, "none")                                     \
-  _ (1, USE_EXTENDED_SEQ_NUM, "esn")                      \
+  _ (1, USE_ESN, "esn")                                   \
   _ (2, USE_ANTI_REPLAY, "anti-replay")                   \
   _ (4, IS_TUNNEL, "tunnel")                              \
   _ (8, IS_TUNNEL_V6, "tunnel-v6")                        \
   _ (16, UDP_ENCAP, "udp-encap")                          \
+  _ (32, IS_GRE, "GRE")                                   \
+  _ (64, IS_INBOUND, "inboud")                            \
+  _ (128, IS_AEAD, "aead")                                \
 
 typedef enum ipsec_sad_flags_t_
 {
@@ -109,7 +117,7 @@ typedef struct
 
   u8 crypto_iv_size;
   u8 crypto_block_size;
-  u8 integ_trunc_size;
+  u8 integ_icv_size;
   u32 spi;
   u32 seq;
   u32 seq_hi;
@@ -117,9 +125,9 @@ typedef struct
   u32 last_seq_hi;
   u64 replay_window;
 
-  vnet_crypto_op_type_t crypto_enc_op_type;
-  vnet_crypto_op_type_t crypto_dec_op_type;
-  vnet_crypto_op_type_t integ_op_type;
+  vnet_crypto_op_id_t crypto_enc_op_id;
+  vnet_crypto_op_id_t crypto_dec_op_id;
+  vnet_crypto_op_id_t integ_op_id;
 
   dpo_id_t dpo[IPSEC_N_PROTOCOLS];
 
@@ -190,6 +198,7 @@ extern int ipsec_sa_add (u32 id,
                         const ipsec_key_t * ik,
                         ipsec_sa_flags_t flags,
                         u32 tx_table_id,
+                        u32 salt,
                         const ip46_address_t * tunnel_src_addr,
                         const ip46_address_t * tunnel_dst_addr,
                         u32 * sa_index);
@@ -227,7 +236,7 @@ ipsec_sa_anti_replay_check (ipsec_sa_t * sa, u32 * seqp)
 
   seq = clib_net_to_host_u32 (*seqp);
 
-  if ((sa->flags & IPSEC_SA_FLAG_USE_EXTENDED_SEQ_NUM) == 0)
+  if ((sa->flags & IPSEC_SA_FLAG_USE_ESN) == 0)
     {
 
       if (PREDICT_TRUE (seq > sa->last_seq))
@@ -291,7 +300,7 @@ ipsec_sa_anti_replay_advance (ipsec_sa_t * sa, u32 * seqp)
     return;
 
   seq = clib_host_to_net_u32 (*seqp);
-  if (PREDICT_TRUE (sa->flags & IPSEC_SA_FLAG_USE_EXTENDED_SEQ_NUM))
+  if (PREDICT_TRUE (sa->flags & IPSEC_SA_FLAG_USE_ESN))
     {
       int wrap = sa->seq_hi - sa->last_seq_hi;