Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 2 | * ipsec.c : IPSEC module functions |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <vnet/vnet.h> |
| 19 | #include <vnet/api_errno.h> |
| 20 | #include <vnet/ip/ip.h> |
| 21 | #include <vnet/interface.h> |
Klement Sekera | 4b089f2 | 2018-04-17 18:04:57 +0200 | [diff] [blame] | 22 | #include <vnet/udp/udp.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 23 | |
| 24 | #include <vnet/ipsec/ipsec.h> |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 25 | #include <vnet/ipsec/esp.h> |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 26 | #include <vnet/ipsec/ah.h> |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 27 | |
Dave Wallace | 71612d6 | 2017-10-24 01:32:41 -0400 | [diff] [blame] | 28 | ipsec_main_t ipsec_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 29 | |
| 30 | static clib_error_t * |
Klement Sekera | 4fd5a9d | 2019-01-30 11:11:23 +0100 | [diff] [blame] | 31 | ipsec_check_ah_support (ipsec_sa_t * sa) |
| 32 | { |
| 33 | if (sa->integ_alg == IPSEC_INTEG_ALG_NONE) |
| 34 | return clib_error_return (0, "unsupported none integ-alg"); |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | static clib_error_t * |
| 39 | ipsec_check_esp_support (ipsec_sa_t * sa) |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 40 | { |
| 41 | if (sa->crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128) |
| 42 | return clib_error_return (0, "unsupported aes-gcm-128 crypto-alg"); |
Klement Sekera | 4fd5a9d | 2019-01-30 11:11:23 +0100 | [diff] [blame] | 43 | if (sa->crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_192) |
| 44 | return clib_error_return (0, "unsupported aes-gcm-192 crypto-alg"); |
| 45 | if (sa->crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_256) |
| 46 | return clib_error_return (0, "unsupported aes-gcm-256 crypto-alg"); |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 51 | clib_error_t * |
| 52 | ipsec_add_del_sa_sess_cb (ipsec_main_t * im, u32 sa_index, u8 is_add) |
| 53 | { |
| 54 | ipsec_ah_backend_t *ah = |
| 55 | pool_elt_at_index (im->ah_backends, im->ah_current_backend); |
| 56 | if (ah->add_del_sa_sess_cb) |
| 57 | { |
| 58 | clib_error_t *err = ah->add_del_sa_sess_cb (sa_index, is_add); |
| 59 | if (err) |
| 60 | return err; |
| 61 | } |
| 62 | ipsec_esp_backend_t *esp = |
| 63 | pool_elt_at_index (im->esp_backends, im->esp_current_backend); |
| 64 | if (esp->add_del_sa_sess_cb) |
| 65 | { |
| 66 | clib_error_t *err = esp->add_del_sa_sess_cb (sa_index, is_add); |
| 67 | if (err) |
| 68 | return err; |
| 69 | } |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | clib_error_t * |
| 74 | ipsec_check_support_cb (ipsec_main_t * im, ipsec_sa_t * sa) |
| 75 | { |
| 76 | clib_error_t *error = 0; |
Matthew Smith | 461caa5 | 2018-12-21 11:53:16 -0600 | [diff] [blame] | 77 | |
| 78 | if (PREDICT_FALSE (sa->protocol == IPSEC_PROTOCOL_AH)) |
| 79 | { |
| 80 | ipsec_ah_backend_t *ah = |
| 81 | pool_elt_at_index (im->ah_backends, im->ah_current_backend); |
| 82 | ASSERT (ah->check_support_cb); |
| 83 | error = ah->check_support_cb (sa); |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | ipsec_esp_backend_t *esp = |
| 88 | pool_elt_at_index (im->esp_backends, im->esp_current_backend); |
| 89 | ASSERT (esp->check_support_cb); |
| 90 | error = esp->check_support_cb (sa); |
| 91 | } |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 92 | return error; |
| 93 | } |
| 94 | |
| 95 | |
| 96 | static void |
| 97 | ipsec_add_node (vlib_main_t * vm, const char *node_name, |
| 98 | const char *prev_node_name, u32 * out_node_index, |
| 99 | u32 * out_next_index) |
| 100 | { |
| 101 | vlib_node_t *prev_node, *node; |
| 102 | prev_node = vlib_get_node_by_name (vm, (u8 *) prev_node_name); |
| 103 | ASSERT (prev_node); |
| 104 | node = vlib_get_node_by_name (vm, (u8 *) node_name); |
| 105 | ASSERT (node); |
| 106 | *out_node_index = node->index; |
| 107 | *out_next_index = vlib_node_add_next (vm, prev_node->index, node->index); |
| 108 | } |
| 109 | |
| 110 | u32 |
| 111 | ipsec_register_ah_backend (vlib_main_t * vm, ipsec_main_t * im, |
| 112 | const char *name, |
| 113 | const char *ah4_encrypt_node_name, |
| 114 | const char *ah4_decrypt_node_name, |
| 115 | const char *ah6_encrypt_node_name, |
| 116 | const char *ah6_decrypt_node_name, |
| 117 | check_support_cb_t ah_check_support_cb, |
| 118 | add_del_sa_sess_cb_t ah_add_del_sa_sess_cb) |
| 119 | { |
| 120 | ipsec_ah_backend_t *b; |
| 121 | pool_get (im->ah_backends, b); |
Kingwel Xie | 561d1ca | 2019-03-05 22:56:17 -0500 | [diff] [blame] | 122 | b->name = format (0, "%s%c", name, 0); |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 123 | |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 124 | ipsec_add_node (vm, ah4_encrypt_node_name, "ipsec4-output-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 125 | &b->ah4_encrypt_node_index, &b->ah4_encrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 126 | ipsec_add_node (vm, ah4_decrypt_node_name, "ipsec4-input-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 127 | &b->ah4_decrypt_node_index, &b->ah4_decrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 128 | ipsec_add_node (vm, ah6_encrypt_node_name, "ipsec6-output-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 129 | &b->ah6_encrypt_node_index, &b->ah6_encrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 130 | ipsec_add_node (vm, ah6_decrypt_node_name, "ipsec6-input-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 131 | &b->ah6_decrypt_node_index, &b->ah6_decrypt_next_index); |
| 132 | |
| 133 | b->check_support_cb = ah_check_support_cb; |
| 134 | b->add_del_sa_sess_cb = ah_add_del_sa_sess_cb; |
| 135 | return b - im->ah_backends; |
| 136 | } |
| 137 | |
| 138 | u32 |
| 139 | ipsec_register_esp_backend (vlib_main_t * vm, ipsec_main_t * im, |
| 140 | const char *name, |
| 141 | const char *esp4_encrypt_node_name, |
| 142 | const char *esp4_decrypt_node_name, |
| 143 | const char *esp6_encrypt_node_name, |
| 144 | const char *esp6_decrypt_node_name, |
| 145 | check_support_cb_t esp_check_support_cb, |
| 146 | add_del_sa_sess_cb_t esp_add_del_sa_sess_cb) |
| 147 | { |
| 148 | ipsec_esp_backend_t *b; |
| 149 | pool_get (im->esp_backends, b); |
Kingwel Xie | 561d1ca | 2019-03-05 22:56:17 -0500 | [diff] [blame] | 150 | b->name = format (0, "%s%c", name, 0); |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 151 | |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 152 | ipsec_add_node (vm, esp4_encrypt_node_name, "ipsec4-output-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 153 | &b->esp4_encrypt_node_index, &b->esp4_encrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 154 | ipsec_add_node (vm, esp4_decrypt_node_name, "ipsec4-input-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 155 | &b->esp4_decrypt_node_index, &b->esp4_decrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 156 | ipsec_add_node (vm, esp6_encrypt_node_name, "ipsec6-output-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 157 | &b->esp6_encrypt_node_index, &b->esp6_encrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 158 | ipsec_add_node (vm, esp6_decrypt_node_name, "ipsec6-input-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 159 | &b->esp6_decrypt_node_index, &b->esp6_decrypt_next_index); |
| 160 | |
| 161 | b->check_support_cb = esp_check_support_cb; |
| 162 | b->add_del_sa_sess_cb = esp_add_del_sa_sess_cb; |
| 163 | return b - im->esp_backends; |
| 164 | } |
| 165 | |
Neale Ranns | b4cfd55 | 2019-02-13 02:08:06 -0800 | [diff] [blame] | 166 | static walk_rc_t |
| 167 | ipsec_sa_restack (ipsec_sa_t * sa, void *ctx) |
| 168 | { |
| 169 | ipsec_sa_stack (sa); |
| 170 | |
| 171 | return (WALK_CONTINUE); |
| 172 | } |
| 173 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 174 | int |
| 175 | ipsec_select_ah_backend (ipsec_main_t * im, u32 backend_idx) |
| 176 | { |
| 177 | if (pool_elts (im->sad) > 0 |
| 178 | || pool_is_free_index (im->ah_backends, backend_idx)) |
| 179 | { |
| 180 | return -1; |
| 181 | } |
| 182 | ipsec_ah_backend_t *b = pool_elt_at_index (im->ah_backends, backend_idx); |
| 183 | im->ah_current_backend = backend_idx; |
| 184 | im->ah4_encrypt_node_index = b->ah4_encrypt_node_index; |
| 185 | im->ah4_decrypt_node_index = b->ah4_decrypt_node_index; |
| 186 | im->ah4_encrypt_next_index = b->ah4_encrypt_next_index; |
| 187 | im->ah4_decrypt_next_index = b->ah4_decrypt_next_index; |
| 188 | im->ah6_encrypt_node_index = b->ah6_encrypt_node_index; |
| 189 | im->ah6_decrypt_node_index = b->ah6_decrypt_node_index; |
| 190 | im->ah6_encrypt_next_index = b->ah6_encrypt_next_index; |
| 191 | im->ah6_decrypt_next_index = b->ah6_decrypt_next_index; |
Neale Ranns | b4cfd55 | 2019-02-13 02:08:06 -0800 | [diff] [blame] | 192 | |
| 193 | ipsec_sa_walk (ipsec_sa_restack, NULL); |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | int |
| 198 | ipsec_select_esp_backend (ipsec_main_t * im, u32 backend_idx) |
| 199 | { |
| 200 | if (pool_elts (im->sad) > 0 |
| 201 | || pool_is_free_index (im->esp_backends, backend_idx)) |
| 202 | { |
| 203 | return -1; |
| 204 | } |
| 205 | ipsec_esp_backend_t *b = pool_elt_at_index (im->esp_backends, backend_idx); |
| 206 | im->esp_current_backend = backend_idx; |
| 207 | im->esp4_encrypt_node_index = b->esp4_encrypt_node_index; |
| 208 | im->esp4_decrypt_node_index = b->esp4_decrypt_node_index; |
| 209 | im->esp4_encrypt_next_index = b->esp4_encrypt_next_index; |
| 210 | im->esp4_decrypt_next_index = b->esp4_decrypt_next_index; |
| 211 | im->esp6_encrypt_node_index = b->esp6_encrypt_node_index; |
| 212 | im->esp6_decrypt_node_index = b->esp6_decrypt_node_index; |
| 213 | im->esp6_encrypt_next_index = b->esp6_encrypt_next_index; |
| 214 | im->esp6_decrypt_next_index = b->esp6_decrypt_next_index; |
Neale Ranns | b4cfd55 | 2019-02-13 02:08:06 -0800 | [diff] [blame] | 215 | |
| 216 | ipsec_sa_walk (ipsec_sa_restack, NULL); |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 217 | return 0; |
| 218 | } |
| 219 | |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 220 | static clib_error_t * |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 221 | ipsec_init (vlib_main_t * vm) |
| 222 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 223 | clib_error_t *error; |
| 224 | ipsec_main_t *im = &ipsec_main; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 225 | ipsec_main_crypto_alg_t *a; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 226 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 227 | im->vnet_main = vnet_get_main (); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 228 | im->vlib_main = vm; |
| 229 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 230 | im->spd_index_by_spd_id = hash_create (0, sizeof (uword)); |
| 231 | im->sa_index_by_sa_id = hash_create (0, sizeof (uword)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 232 | im->spd_index_by_sw_if_index = hash_create (0, sizeof (uword)); |
| 233 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 234 | vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "error-drop"); |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 235 | ASSERT (node); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 236 | im->error_drop_node_index = node->index; |
| 237 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 238 | u32 idx = ipsec_register_ah_backend (vm, im, "default openssl backend", |
| 239 | "ah4-encrypt", |
| 240 | "ah4-decrypt", |
| 241 | "ah6-encrypt", |
| 242 | "ah6-decrypt", |
Klement Sekera | 4fd5a9d | 2019-01-30 11:11:23 +0100 | [diff] [blame] | 243 | ipsec_check_ah_support, |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 244 | NULL); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 245 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 246 | im->ah_default_backend = idx; |
| 247 | int rv = ipsec_select_ah_backend (im, idx); |
| 248 | ASSERT (0 == rv); |
| 249 | (void) (rv); // avoid warning |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 250 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 251 | idx = ipsec_register_esp_backend (vm, im, "default openssl backend", |
| 252 | "esp4-encrypt", |
| 253 | "esp4-decrypt", |
| 254 | "esp6-encrypt", |
| 255 | "esp6-decrypt", |
Klement Sekera | 4fd5a9d | 2019-01-30 11:11:23 +0100 | [diff] [blame] | 256 | ipsec_check_esp_support, NULL); |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 257 | im->esp_default_backend = idx; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 258 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 259 | rv = ipsec_select_esp_backend (im, idx); |
| 260 | ASSERT (0 == rv); |
| 261 | (void) (rv); // avoid warning |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 262 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 263 | if ((error = vlib_call_init_function (vm, ipsec_cli_init))) |
| 264 | return error; |
| 265 | |
| 266 | if ((error = vlib_call_init_function (vm, ipsec_tunnel_if_init))) |
| 267 | return error; |
| 268 | |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 269 | vec_validate (im->crypto_algs, IPSEC_CRYPTO_N_ALG - 1); |
| 270 | |
| 271 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_DES_CBC; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 272 | a->enc_op_id = VNET_CRYPTO_OP_DES_CBC_ENC; |
| 273 | a->dec_op_id = VNET_CRYPTO_OP_DES_CBC_DEC; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 274 | a->iv_size = a->block_size = 8; |
| 275 | |
| 276 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_3DES_CBC; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 277 | a->enc_op_id = VNET_CRYPTO_OP_3DES_CBC_ENC; |
| 278 | a->dec_op_id = VNET_CRYPTO_OP_3DES_CBC_DEC; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 279 | a->iv_size = a->block_size = 8; |
| 280 | |
| 281 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_128; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 282 | a->enc_op_id = VNET_CRYPTO_OP_AES_128_CBC_ENC; |
| 283 | a->dec_op_id = VNET_CRYPTO_OP_AES_128_CBC_DEC; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 284 | a->iv_size = a->block_size = 16; |
| 285 | |
| 286 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_192; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 287 | a->enc_op_id = VNET_CRYPTO_OP_AES_192_CBC_ENC; |
| 288 | a->dec_op_id = VNET_CRYPTO_OP_AES_192_CBC_DEC; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 289 | a->iv_size = a->block_size = 16; |
| 290 | |
| 291 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_256; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 292 | a->enc_op_id = VNET_CRYPTO_OP_AES_256_CBC_ENC; |
| 293 | a->dec_op_id = VNET_CRYPTO_OP_AES_256_CBC_DEC; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 294 | a->iv_size = a->block_size = 16; |
| 295 | |
| 296 | vec_validate (im->integ_algs, IPSEC_INTEG_N_ALG - 1); |
| 297 | ipsec_main_integ_alg_t *i; |
| 298 | |
| 299 | i = &im->integ_algs[IPSEC_INTEG_ALG_SHA1_96]; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 300 | i->op_id = VNET_CRYPTO_OP_SHA1_HMAC; |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 301 | i->icv_size = 12; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 302 | |
| 303 | i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_256_96]; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 304 | i->op_id = VNET_CRYPTO_OP_SHA1_HMAC; |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 305 | i->icv_size = 12; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 306 | |
| 307 | i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_256_128]; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 308 | i->op_id = VNET_CRYPTO_OP_SHA256_HMAC; |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 309 | i->icv_size = 16; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 310 | |
| 311 | i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_384_192]; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 312 | i->op_id = VNET_CRYPTO_OP_SHA384_HMAC; |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 313 | i->icv_size = 24; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 314 | |
| 315 | i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_512_256]; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 316 | i->op_id = VNET_CRYPTO_OP_SHA512_HMAC; |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 317 | i->icv_size = 32; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 318 | |
Neale Ranns | 5ae793a | 2019-04-03 13:36:56 +0000 | [diff] [blame] | 319 | vec_validate_aligned (im->ptd, vlib_num_workers (), CLIB_CACHE_LINE_BYTES); |
Damjan Marion | c59b9a2 | 2019-03-19 15:38:40 +0100 | [diff] [blame] | 320 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | VLIB_INIT_FUNCTION (ipsec_init); |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 325 | |
| 326 | /* |
| 327 | * fd.io coding-style-patch-verification: ON |
| 328 | * |
| 329 | * Local Variables: |
| 330 | * eval: (c-set-style "gnu") |
| 331 | * End: |
| 332 | */ |