FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
crypto.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef included_vnet_crypto_crypto_h
17 #define included_vnet_crypto_crypto_h
18 
19 #include <vlib/vlib.h>
20 
21 #define VNET_CRYPTO_FRAME_SIZE 64
22 #define VNET_CRYPTO_FRAME_POOL_SIZE 1024
23 
24 /* CRYPTO_ID, PRETTY_NAME, KEY_LENGTH_IN_BYTES */
25 #define foreach_crypto_cipher_alg \
26  _(DES_CBC, "des-cbc", 7) \
27  _(3DES_CBC, "3des-cbc", 24) \
28  _(AES_128_CBC, "aes-128-cbc", 16) \
29  _(AES_192_CBC, "aes-192-cbc", 24) \
30  _(AES_256_CBC, "aes-256-cbc", 32) \
31  _(AES_128_CTR, "aes-128-ctr", 16) \
32  _(AES_192_CTR, "aes-192-ctr", 24) \
33  _(AES_256_CTR, "aes-256-ctr", 32)
34 
35 /* CRYPTO_ID, PRETTY_NAME, KEY_LENGTH_IN_BYTES */
36 #define foreach_crypto_aead_alg \
37  _(AES_128_GCM, "aes-128-gcm", 16) \
38  _(AES_192_GCM, "aes-192-gcm", 24) \
39  _(AES_256_GCM, "aes-256-gcm", 32) \
40  _(CHACHA20_POLY1305, "chacha20-poly1305", 32)
41 
42 #define foreach_crypto_hash_alg \
43  _ (SHA1, "sha-1") \
44  _ (SHA224, "sha-224") \
45  _ (SHA256, "sha-256") \
46  _ (SHA384, "sha-384") \
47  _ (SHA512, "sha-512")
48 
49 #define foreach_crypto_hmac_alg \
50  _(MD5, "md5") \
51  _(SHA1, "sha-1") \
52  _(SHA224, "sha-224") \
53  _(SHA256, "sha-256") \
54  _(SHA384, "sha-384") \
55  _(SHA512, "sha-512")
56 
57 #define foreach_crypto_op_type \
58  _ (ENCRYPT, "encrypt") \
59  _ (DECRYPT, "decrypt") \
60  _ (AEAD_ENCRYPT, "aead-encrypt") \
61  _ (AEAD_DECRYPT, "aead-decrypt") \
62  _ (HMAC, "hmac") \
63  _ (HASH, "hash")
64 
65 typedef enum
66 {
67 #define _(n, s) VNET_CRYPTO_OP_TYPE_##n,
69 #undef _
72 
73 #define foreach_crypto_op_status \
74  _(IDLE, "idle") \
75  _(PENDING, "pending") \
76  _(WORK_IN_PROGRESS, "work-in-progress") \
77  _(COMPLETED, "completed") \
78  _(FAIL_NO_HANDLER, "no-handler") \
79  _(FAIL_BAD_HMAC, "bad-hmac") \
80  _(FAIL_ENGINE_ERR, "engine-error")
81 
82 /** async crypto **/
83 
84 /* CRYPTO_ID, PRETTY_NAME, KEY_LENGTH_IN_BYTES, TAG_LEN, AAD_LEN */
85 #define foreach_crypto_aead_async_alg \
86  _(AES_128_GCM, "aes-128-gcm-aad8", 16, 16, 8) \
87  _(AES_128_GCM, "aes-128-gcm-aad12", 16, 16, 12) \
88  _(AES_192_GCM, "aes-192-gcm-aad8", 24, 16, 8) \
89  _(AES_192_GCM, "aes-192-gcm-aad12", 24, 16, 12) \
90  _(AES_256_GCM, "aes-256-gcm-aad8", 32, 16, 8) \
91  _(AES_256_GCM, "aes-256-gcm-aad12", 32, 16, 12) \
92  _(CHACHA20_POLY1305, "chacha20-poly1305-aad8", 32, 16, 8) \
93  _(CHACHA20_POLY1305, "chacha20-poly1305-aad12", 32, 16, 12)
94 
95 /* CRYPTO_ID, INTEG_ID, PRETTY_NAME, KEY_LENGTH_IN_BYTES, DIGEST_LEN */
96 #define foreach_crypto_link_async_alg \
97  _ (3DES_CBC, MD5, "3des-cbc-hmac-md5", 24, 12) \
98  _ (AES_128_CBC, MD5, "aes-128-cbc-hmac-md5", 16, 12) \
99  _ (AES_192_CBC, MD5, "aes-192-cbc-hmac-md5", 24, 12) \
100  _ (AES_256_CBC, MD5, "aes-256-cbc-hmac-md5", 32, 12) \
101  _ (3DES_CBC, SHA1, "3des-cbc-hmac-sha-1", 24, 12) \
102  _ (AES_128_CBC, SHA1, "aes-128-cbc-hmac-sha-1", 16, 12) \
103  _ (AES_192_CBC, SHA1, "aes-192-cbc-hmac-sha-1", 24, 12) \
104  _ (AES_256_CBC, SHA1, "aes-256-cbc-hmac-sha-1", 32, 12) \
105  _ (3DES_CBC, SHA224, "3des-cbc-hmac-sha-224", 24, 14) \
106  _ (AES_128_CBC, SHA224, "aes-128-cbc-hmac-sha-224", 16, 14) \
107  _ (AES_192_CBC, SHA224, "aes-192-cbc-hmac-sha-224", 24, 14) \
108  _ (AES_256_CBC, SHA224, "aes-256-cbc-hmac-sha-224", 32, 14) \
109  _ (3DES_CBC, SHA256, "3des-cbc-hmac-sha-256", 24, 16) \
110  _ (AES_128_CBC, SHA256, "aes-128-cbc-hmac-sha-256", 16, 16) \
111  _ (AES_192_CBC, SHA256, "aes-192-cbc-hmac-sha-256", 24, 16) \
112  _ (AES_256_CBC, SHA256, "aes-256-cbc-hmac-sha-256", 32, 16) \
113  _ (3DES_CBC, SHA384, "3des-cbc-hmac-sha-384", 24, 24) \
114  _ (AES_128_CBC, SHA384, "aes-128-cbc-hmac-sha-384", 16, 24) \
115  _ (AES_192_CBC, SHA384, "aes-192-cbc-hmac-sha-384", 24, 24) \
116  _ (AES_256_CBC, SHA384, "aes-256-cbc-hmac-sha-384", 32, 24) \
117  _ (3DES_CBC, SHA512, "3des-cbc-hmac-sha-512", 24, 32) \
118  _ (AES_128_CBC, SHA512, "aes-128-cbc-hmac-sha-512", 16, 32) \
119  _ (AES_192_CBC, SHA512, "aes-192-cbc-hmac-sha-512", 24, 32) \
120  _ (AES_256_CBC, SHA512, "aes-256-cbc-hmac-sha-512", 32, 32) \
121  _ (AES_128_CTR, SHA1, "aes-128-ctr-hmac-sha-1", 16, 12) \
122  _ (AES_192_CTR, SHA1, "aes-192-ctr-hmac-sha-1", 24, 12) \
123  _ (AES_256_CTR, SHA1, "aes-256-ctr-hmac-sha-1", 32, 12)
124 
125 #define foreach_crypto_async_op_type \
126  _(ENCRYPT, "async-encrypt") \
127  _(DECRYPT, "async-decrypt")
128 
129 typedef enum
130 {
135 
136 typedef enum
137 {
138 #define _(n, s) VNET_CRYPTO_OP_STATUS_##n,
140 #undef _
143 
144 /* *INDENT-OFF* */
145 typedef enum
146 {
148 #define _(n, s, l) VNET_CRYPTO_ALG_##n,
150 #undef _
151 #define _(n, s) VNET_CRYPTO_ALG_HMAC_##n,
153 #undef _
154 #define _(n, s) VNET_CRYPTO_ALG_HASH_##n,
156 #undef _
159 
160 typedef enum
161 {
162 #define _(n, s) VNET_CRYPTO_ASYNC_OP_TYPE_##n,
164 #undef _
167 
168 typedef enum
169 {
171 #define _(n, s, k, t, a) \
172  VNET_CRYPTO_ALG_##n##_TAG##t##_AAD##a,
174 #undef _
175 #define _(c, h, s, k ,d) \
176  VNET_CRYPTO_ALG_##c##_##h##_TAG##d,
178 #undef _
181 
182 typedef enum
183 {
185 #define _(n, s, k, t, a) \
186  VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_ENC, \
187  VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_DEC,
189 #undef _
190 #define _(c, h, s, k ,d) \
191  VNET_CRYPTO_OP_##c##_##h##_TAG##d##_ENC, \
192  VNET_CRYPTO_OP_##c##_##h##_TAG##d##_DEC,
194 #undef _
197 
198 typedef struct
199 {
200  union
201  {
202  struct
203  {
206  };
207  struct
208  {
212  };
213  };
214 #define VNET_CRYPTO_KEY_TYPE_DATA 0
215 #define VNET_CRYPTO_KEY_TYPE_LINK 1
218 
219 typedef enum
220 {
222 #define _(n, s, l) VNET_CRYPTO_OP_##n##_ENC, VNET_CRYPTO_OP_##n##_DEC,
224 #undef _
225 #define _(n, s) VNET_CRYPTO_OP_##n##_HMAC,
227 #undef _
228 #define _(n, s) VNET_CRYPTO_OP_##n##_HASH,
230 #undef _
233 /* *INDENT-ON* */
234 
235 typedef enum
236 {
241 
242 typedef struct
243 {
244  char *name;
247 
248 typedef struct
249 {
250  u8 *src;
251  u8 *dst;
254 
255 typedef struct
256 {
257  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
262 #define VNET_CRYPTO_OP_FLAG_INIT_IV (1 << 0)
263 #define VNET_CRYPTO_OP_FLAG_HMAC_CHECK (1 << 1)
264 #define VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS (1 << 2)
265 
266  union
267  {
270  };
272 
273  union
274  {
275  struct
276  {
277  u8 *src;
278  u8 *dst;
279  };
280 
281  /* valid if VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS is set */
283  };
284 
285  union
286  {
288  /* valid if VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS is set */
290  };
291 
293  u8 *iv;
294  u8 *aad;
295 
296  union
297  {
298  u8 *tag;
300  };
302 
304 
305 typedef struct
306 {
312 
313 typedef struct
314 {
319 
320 typedef struct
321 {
322  char *name;
325 
326 typedef struct
327 {
328  u8 *iv;
329  union
330  {
332  u8 *tag;
333  };
334  u8 *aad;
337  i16 crypto_start_offset; /* first buffer offset */
339  /* adj total_length for integ, e.g.4 bytes for IPSec ESN */
342  u8 flags; /**< share same VNET_CRYPTO_OP_FLAG_* values */
344 
345 /* Assert the size so the compiler will warn us when it changes */
347 
349 {
351  /* frame waiting to be processed */
356 } __clib_packed vnet_crypto_async_frame_state_t;
357 
358 typedef struct
359 {
360  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
365  u32 buffer_indices[VNET_CRYPTO_FRAME_SIZE];
366  u16 next_node_index[VNET_CRYPTO_FRAME_SIZE];
369 
370 typedef struct
371 {
372  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
377 
379 
381  vnet_crypto_op_t * ops[],
383  chunks, u32 n_ops);
384 
386  vnet_crypto_op_t * ops[], u32 n_ops);
387 
391 
392 /** async crypto function handlers **/
393 typedef int
397  (vnet_crypto_frame_dequeue_t) (vlib_main_t * vm, u32 * nb_elts_processed,
398  u32 * enqueue_thread_idx);
399 
400 u32
401 vnet_crypto_register_engine (vlib_main_t * vm, char *name, int prio,
402  char *desc);
403 
404 void vnet_crypto_register_ops_handler (vlib_main_t * vm, u32 engine_index,
407 
409  u32 engine_index,
412  * oph);
413 
418  cfn);
419 
420 void vnet_crypto_register_key_handler (vlib_main_t * vm, u32 engine_index,
422 
423 /** async crypto register functions */
424 u32 vnet_crypto_register_post_node (vlib_main_t * vm, char *post_node_name);
426  u32 engine_index,
430  deq_fn);
431 
432 typedef struct
433 {
434  char *name;
435  char *desc;
436  int priority;
440  * chained_ops_handlers[VNET_CRYPTO_N_OP_IDS];
444 
445 typedef struct
446 {
450 
451 typedef struct
452 {
471 #define VNET_CRYPTO_ASYNC_DISPATCH_POLLING 0
472 #define VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT 1
475 
477 
479  vnet_crypto_op_chunk_t * chunks,
480  u32 n_ops);
482  u32 n_ops);
483 
484 
485 int vnet_crypto_set_handler2 (char *ops_handler_name, char *engine,
488 
490  u8 * data, u16 length);
492 
493 /**
494  * Use 2 created keys to generate new key for linked algs (cipher + integ)
495  * The returned key index is to be used for linked alg only.
496  **/
498  vnet_crypto_key_index_t index_crypto,
499  vnet_crypto_key_index_t index_integ);
500 
502 
503 int vnet_crypto_set_async_handler2 (char *alg_name, char *engine);
504 
506 
507 void vnet_crypto_request_async_mode (int is_enable);
508 
510 
513 
515 
522 
526 
529 {
530  if (CLIB_DEBUG > 0)
531  clib_memset (op, 0xfe, sizeof (*op));
532  op->op = type;
533  op->flags = 0;
534  op->key_index = ~0;
535  op->n_chunks = 0;
536 }
537 
540 {
543  vnet_crypto_op_data_t *od = cm->opt_data + id;
544  return od->type;
545 }
546 
549 {
551  return vec_elt_at_index (cm->keys, index);
552 }
553 
555 vnet_crypto_set_handler (char *alg_name, char *engine)
556 {
557  return vnet_crypto_set_handler2 (alg_name, engine, CRYPTO_OP_BOTH);
558 }
559 
560 /** async crypto inline functions **/
561 
564 {
566  vnet_crypto_thread_t *ct = cm->threads + vm->thread_index;
568 
570  if (CLIB_DEBUG > 0)
571  clib_memset (f, 0xfe, sizeof (*f));
573  f->op = opt;
574  f->n_elts = 0;
575 
576  return f;
577 }
578 
582 {
584  vnet_crypto_thread_t *ct = cm->threads + vm->thread_index;
585  pool_put (ct->frame_pool, frame);
586 }
587 
591 {
595  u32 i = vlib_num_workers () > 0;
596 
598  frame->enqueue_thread_index = vm->thread_index;
599 
600  int ret = (cm->enqueue_handlers[frame->op]) (vm, frame);
601 
602  clib_bitmap_set_no_check (cm->async_active_ids, opt, 1);
603  if (PREDICT_TRUE (ret == 0))
604  {
605  if (cm->dispatch_mode == VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT)
606  {
607  for (; i < tm->n_vlib_mains; i++)
609  cm->crypto_node_index);
610  }
611  }
612  else
613  {
615  }
616 
617  return ret;
618 }
619 
622  u32 key_index, u32 crypto_len,
623  i16 integ_len_adj, i16 crypto_start_offset,
624  u16 integ_start_offset, u32 buffer_index,
625  u16 next_node, u8 *iv, u8 *tag, u8 *aad,
626  u8 flags)
627 {
629  u16 index;
630 
631  ASSERT (f->n_elts < VNET_CRYPTO_FRAME_SIZE);
632 
633  index = f->n_elts;
634  fe = &f->elts[index];
635  f->n_elts++;
636  fe->key_index = key_index;
637  fe->crypto_total_length = crypto_len;
638  fe->crypto_start_offset = crypto_start_offset;
639  fe->integ_start_offset = integ_start_offset;
640  fe->integ_length_adj = integ_len_adj;
641  fe->iv = iv;
642  fe->tag = tag;
643  fe->aad = aad;
644  fe->flags = flags;
645  f->buffer_indices[index] = buffer_index;
646  f->next_node_index[index] = next_node;
647 }
648 
651 {
653  ASSERT (f != 0);
655  || f->state == VNET_CRYPTO_FRAME_STATE_ELT_ERROR));
656  opt = f->op;
657  if (CLIB_DEBUG > 0)
658  clib_memset (f, 0xfe, sizeof (*f));
660  f->op = opt;
661  f->n_elts = 0;
662 }
663 
666 {
667  return (f->n_elts == VNET_CRYPTO_FRAME_SIZE);
668 }
669 
670 #endif /* included_vnet_crypto_crypto_h */
671 
672 /*
673  * fd.io coding-style-patch-verification: ON
674  *
675  * Local Variables:
676  * eval: (c-set-style "gnu")
677  * End:
678  */
vnet_crypto_engine_t
Definition: crypto.h:432
vlib.h
vnet_crypto_frame_dequeue_t
vnet_crypto_async_frame_t *() vnet_crypto_frame_dequeue_t(vlib_main_t *vm, u32 *nb_elts_processed, u32 *enqueue_thread_idx)
Definition: crypto.h:397
VNET_CRYPTO_KEY_OP_DEL
@ VNET_CRYPTO_KEY_OP_DEL
Definition: crypto.h:132
vnet_crypto_op_t::digest
u8 * digest
Definition: crypto.h:299
vnet_crypto_async_free_frame
static_always_inline void vnet_crypto_async_free_frame(vlib_main_t *vm, vnet_crypto_async_frame_t *frame)
Definition: crypto.h:580
vnet_crypto_async_alg_data_t
Definition: crypto.h:320
vnet_crypto_op_init
static_always_inline void vnet_crypto_op_init(vnet_crypto_op_t *op, vnet_crypto_op_id_t type)
Definition: crypto.h:528
vnet_crypto_alg_data_t::name
char * name
Definition: crypto.h:244
vnet_crypto_op_t::digest_len
u8 digest_len
Definition: crypto.h:268
vlib_num_workers
static u32 vlib_num_workers()
Definition: threads.h:333
vnet_crypto_set_handler2
int vnet_crypto_set_handler2(char *ops_handler_name, char *engine, crypto_op_class_type_t oct)
Definition: crypto.c:156
unformat_vnet_crypto_alg
unformat_function_t unformat_vnet_crypto_alg
Definition: crypto.h:521
vnet_crypto_main_t::keys
vnet_crypto_key_t * keys
Definition: crypto.h:463
vnet_crypto_main_t::enqueue_handlers
vnet_crypto_frame_enqueue_t ** enqueue_handlers
Definition: crypto.h:457
vnet_crypto_thread_t::frame_pool
vnet_crypto_async_frame_t * frame_pool
Definition: crypto.h:373
crypto_op_class_type_t
crypto_op_class_type_t
Definition: crypto.h:235
format_vnet_crypto_async_op_type
format_function_t format_vnet_crypto_async_op_type
Definition: crypto.h:525
foreach_crypto_op_status
#define foreach_crypto_op_status
Definition: crypto.h:73
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
vnet_crypto_async_next_node_t
Definition: crypto.h:445
vnet_crypto_async_frame_elt_t::integ_length_adj
u16 integ_length_adj
Definition: crypto.h:340
vnet_crypto_op_t::tag
u8 * tag
Definition: crypto.h:298
VNET_CRYPTO_ASYNC_ALG_NONE
@ VNET_CRYPTO_ASYNC_ALG_NONE
Definition: crypto.h:170
vnet_crypto_async_frame_elt_t::crypto_total_length
u32 crypto_total_length
Definition: crypto.h:336
crypto_main
vnet_crypto_main_t crypto_main
Definition: crypto.c:20
foreach_crypto_aead_async_alg
#define foreach_crypto_aead_async_alg
async crypto
Definition: crypto.h:85
VNET_CRYPTO_KEY_OP_MODIFY
@ VNET_CRYPTO_KEY_OP_MODIFY
Definition: crypto.h:133
vnet_crypto_async_frame_state_t
enum vnet_crypto_async_frame_state_t_ vnet_crypto_async_frame_state_t
foreach_crypto_link_async_alg
#define foreach_crypto_link_async_alg
Definition: crypto.h:96
VNET_CRYPTO_ASYNC_OP_N_IDS
@ VNET_CRYPTO_ASYNC_OP_N_IDS
Definition: crypto.h:195
vnet_crypto_register_engine
u32 vnet_crypto_register_engine(vlib_main_t *vm, char *name, int prio, char *desc)
Definition: crypto.c:112
VNET_CRYPTO_ASYNC_OP_N_TYPES
@ VNET_CRYPTO_ASYNC_OP_N_TYPES
Definition: crypto.h:165
f
vlib_frame_t * f
Definition: interface_output.c:1098
vnet_crypto_set_async_handler2
int vnet_crypto_set_async_handler2(char *alg_name, char *engine)
Definition: crypto.c:509
CLIB_CACHE_LINE_ALIGN_MARK
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
name
string name[64]
Definition: fib.api:25
vnet_crypto_main_t
Definition: crypto.h:451
vnet_crypto_op_t::status
vnet_crypto_op_status_t status
Definition: crypto.h:260
foreach_crypto_hash_alg
#define foreach_crypto_hash_alg
Definition: crypto.h:42
vnet_crypto_key_add_linked
u32 vnet_crypto_key_add_linked(vlib_main_t *vm, vnet_crypto_key_index_t index_crypto, vnet_crypto_key_index_t index_integ)
Use 2 created keys to generate new key for linked algs (cipher + integ) The returned key index is to ...
Definition: crypto.c:425
pool_get_aligned
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:249
clib_bitmap_t
uword clib_bitmap_t
Definition: bitmap.h:50
VNET_CRYPTO_ALG_NONE
@ VNET_CRYPTO_ALG_NONE
Definition: crypto.h:147
vnet_crypto_async_alg_t
vnet_crypto_async_alg_t
Definition: crypto.h:168
vnet_crypto_main_t::algs
vnet_crypto_alg_data_t * algs
Definition: crypto.h:453
vnet_crypto_is_set_handler
int vnet_crypto_is_set_handler(vnet_crypto_alg_t alg)
Definition: crypto.c:189
VNET_CRYPTO_FRAME_SIZE
#define VNET_CRYPTO_FRAME_SIZE
Definition: crypto.h:21
VNET_CRYPTO_N_ASYNC_ALGS
@ VNET_CRYPTO_N_ASYNC_ALGS
Definition: crypto.h:179
vnet_crypto_key_handler_t
void() vnet_crypto_key_handler_t(vlib_main_t *vm, vnet_crypto_key_op_t kop, vnet_crypto_key_index_t idx)
Definition: crypto.h:388
vnet_crypto_op_t::src
u8 * src
Definition: crypto.h:277
vnet_crypto_main_t::async_alg_index_by_name
uword * async_alg_index_by_name
Definition: crypto.h:466
u16
unsigned short u16
Definition: types.h:57
vnet_crypto_op_t::dst
u8 * dst
Definition: crypto.h:278
vnet_crypto_key_index_t
u32 vnet_crypto_key_index_t
Definition: crypto.h:378
vnet_crypto_async_frame_t
Definition: crypto.h:358
foreach_crypto_hmac_alg
#define foreach_crypto_hmac_alg
Definition: crypto.h:49
vnet_crypto_main_t::threads
vnet_crypto_thread_t * threads
Definition: crypto.h:454
mode
vl_api_tunnel_mode_t mode
Definition: gre.api:48
VNET_CRYPTO_OP_N_TYPES
@ VNET_CRYPTO_OP_N_TYPES
Definition: crypto.h:70
vnet_crypto_main_t::alg_index_by_name
uword * alg_index_by_name
Definition: crypto.h:465
vnet_crypto_async_add_to_frame
static_always_inline void vnet_crypto_async_add_to_frame(vlib_main_t *vm, vnet_crypto_async_frame_t *f, u32 key_index, u32 crypto_len, i16 integ_len_adj, i16 crypto_start_offset, u16 integ_start_offset, u32 buffer_index, u16 next_node, u8 *iv, u8 *tag, u8 *aad, u8 flags)
Definition: crypto.h:621
foreach_crypto_async_op_type
#define foreach_crypto_async_op_type
Definition: crypto.h:125
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
vnet_crypto_op_t::user_data
uword user_data
Definition: crypto.h:258
vnet_crypto_main_t::async_algs
vnet_crypto_async_alg_data_t * async_algs
Definition: crypto.h:467
vnet_crypto_main_t::chained_ops_handlers
vnet_crypto_chained_ops_handler_t ** chained_ops_handlers
Definition: crypto.h:456
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vnet_crypto_async_frame_elt_t::crypto_start_offset
i16 crypto_start_offset
Definition: crypto.h:337
CRYPTO_OP_SIMPLE
@ CRYPTO_OP_SIMPLE
Definition: crypto.h:237
vnet_crypto_key_t::index_crypto
u32 index_crypto
Definition: crypto.h:209
vnet_crypto_async_frame_t::state
vnet_crypto_async_frame_state_t state
Definition: crypto.h:361
vnet_crypto_op_t::iv
u8 * iv
Definition: crypto.h:293
vnet_crypto_key_t::data
u8 * data
Definition: crypto.h:204
VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT
#define VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT
Definition: crypto.h:472
vnet_crypto_main_t::next_nodes
vnet_crypto_async_next_node_t * next_nodes
Definition: crypto.h:469
vnet_crypto_op_t::len
u32 len
Definition: crypto.h:287
vnet_crypto_async_submit_open_frame
static_always_inline int vnet_crypto_async_submit_open_frame(vlib_main_t *vm, vnet_crypto_async_frame_t *frame)
Definition: crypto.h:589
vnet_crypto_engine_t::desc
char * desc
Definition: crypto.h:435
VNET_CRYPTO_FRAME_STATE_ELT_ERROR
@ VNET_CRYPTO_FRAME_STATE_ELT_ERROR
Definition: crypto.h:355
vnet_crypto_op_t::aad_len
u16 aad_len
Definition: crypto.h:271
vnet_crypto_alg_data_t
Definition: crypto.h:242
vnet_crypto_op_t
Definition: crypto.h:255
vnet_crypto_op_t::flags
u8 flags
Definition: crypto.h:261
vnet_crypto_op_t::key_index
u32 key_index
Definition: crypto.h:292
vnet_crypto_op_t::chunk_index
u32 chunk_index
Definition: crypto.h:289
vnet_crypto_set_async_dispatch_mode
void vnet_crypto_set_async_dispatch_mode(u8 mode)
Definition: crypto.c:608
i16
signed short i16
Definition: types.h:46
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:262
vnet_crypto_register_ops_handlers
void vnet_crypto_register_ops_handlers(vlib_main_t *vm, u32 engine_index, vnet_crypto_op_id_t opt, vnet_crypto_ops_handler_t *fn, vnet_crypto_chained_ops_handler_t *cfn)
Definition: crypto.c:269
vnet_crypto_main_t::async_refcnt
u32 async_refcnt
Definition: crypto.h:468
vnet_crypto_async_frame_t::op
vnet_crypto_async_op_id_t op
Definition: crypto.h:362
vnet_crypto_async_frame_elt_t::status
vnet_crypto_op_status_t status
Definition: crypto.h:341
vnet_crypto_frame_enqueue_t
int() vnet_crypto_frame_enqueue_t(vlib_main_t *vm, vnet_crypto_async_frame_t *frame)
async crypto function handlers
Definition: crypto.h:394
vnet_crypto_async_op_data_t::type
vnet_crypto_async_op_type_t type
Definition: crypto.h:315
vnet_crypto_request_async_mode
void vnet_crypto_request_async_mode(int is_enable)
Definition: crypto.c:571
vnet_crypto_async_op_type_t
vnet_crypto_async_op_type_t
Definition: crypto.h:160
vnet_crypto_op_data_t
Definition: crypto.h:305
vnet_crypto_async_frame_elt_t::key_index
u32 key_index
Definition: crypto.h:335
VNET_CRYPTO_OP_NONE
@ VNET_CRYPTO_OP_NONE
Definition: crypto.h:221
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_crypto_op_data_t::alg
vnet_crypto_alg_t alg
Definition: crypto.h:308
vnet_crypto_main_t::crypto_node_index
u32 crypto_node_index
Definition: crypto.h:470
vnet_crypto_op_type_t
vnet_crypto_op_type_t
Definition: crypto.h:65
foreach_crypto_aead_alg
#define foreach_crypto_aead_alg
Definition: crypto.h:36
vnet_crypto_op_chunk_t::src
u8 * src
Definition: crypto.h:250
static_always_inline
#define static_always_inline
Definition: clib.h:112
vnet_crypto_op_t::op
vnet_crypto_op_id_t op
Definition: crypto.h:259
vnet_crypto_link_algs
vnet_crypto_async_alg_t vnet_crypto_link_algs(vnet_crypto_alg_t crypto_alg, vnet_crypto_alg_t integ_alg)
Definition: crypto.c:412
VNET_CRYPTO_N_ALGS
@ VNET_CRYPTO_N_ALGS
Definition: crypto.h:157
vnet_crypto_thread_t::nexts
u16 * nexts
Definition: crypto.h:375
uword
u64 uword
Definition: types.h:112
vnet_crypto_async_reset_frame
static_always_inline void vnet_crypto_async_reset_frame(vnet_crypto_async_frame_t *f)
Definition: crypto.h:650
vnet_crypto_op_data_t::active_engine_index_simple
u32 active_engine_index_simple
Definition: crypto.h:309
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:215
vnet_crypto_op_id_t
vnet_crypto_op_id_t
Definition: crypto.h:219
vnet_crypto_register_post_node
u32 vnet_crypto_register_post_node(vlib_main_t *vm, char *post_node_name)
async crypto register functions
Definition: crypto.c:541
cm
vnet_feature_config_main_t * cm
Definition: nat44_ei_hairpinning.c:594
vnet_crypto_chained_ops_handler_t
u32() vnet_crypto_chained_ops_handler_t(vlib_main_t *vm, vnet_crypto_op_t *ops[], vnet_crypto_op_chunk_t *chunks, u32 n_ops)
Definition: crypto.h:380
vnet_crypto_get_key
static_always_inline vnet_crypto_key_t * vnet_crypto_get_key(vnet_crypto_key_index_t index)
Definition: crypto.h:548
vnet_crypto_async_frame_elt_t::flags
u8 flags
share same VNET_CRYPTO_OP_FLAG_* values
Definition: crypto.h:342
vnet_crypto_op_chunk_t
Definition: crypto.h:248
vnet_crypto_async_frame_is_full
static_always_inline u8 vnet_crypto_async_frame_is_full(const vnet_crypto_async_frame_t *f)
Definition: crypto.h:665
STATIC_ASSERT_SIZEOF
STATIC_ASSERT_SIZEOF(vnet_crypto_op_t, CLIB_CACHE_LINE_BYTES)
vnet_crypto_main_t::dequeue_handlers
vnet_crypto_frame_dequeue_t ** dequeue_handlers
Definition: crypto.h:458
vnet_crypto_key_t::async_alg
vnet_crypto_async_alg_t async_alg
Definition: crypto.h:211
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
VNET_CRYPTO_OP_N_STATUS
@ VNET_CRYPTO_OP_N_STATUS
Definition: crypto.h:141
format_vnet_crypto_op
format_function_t format_vnet_crypto_op
Definition: crypto.h:518
vnet_crypto_engine_t::key_op_handler
vnet_crypto_key_handler_t * key_op_handler
Definition: crypto.h:437
vnet_crypto_register_key_handler
void vnet_crypto_register_key_handler(vlib_main_t *vm, u32 engine_index, vnet_crypto_key_handler_t *keyh)
Definition: crypto.c:316
vnet_crypto_op_t::n_chunks
u16 n_chunks
Definition: crypto.h:282
data
u8 data[128]
Definition: ipsec_types.api:95
id
u8 id[64]
Definition: dhcp.api:160
vnet_crypto_op_data_t::active_engine_index_chained
u32 active_engine_index_chained
Definition: crypto.h:310
format_function_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
foreach_crypto_op_type
#define foreach_crypto_op_type
Definition: crypto.h:57
vnet_crypto_main_t::engine_index_by_name
uword * engine_index_by_name
Definition: crypto.h:464
vnet_crypto_async_frame_t::n_elts
u16 n_elts
Definition: crypto.h:363
vnet_crypto_op_chunk_t::dst
u8 * dst
Definition: crypto.h:251
index
u32 index
Definition: flow_types.api:221
vnet_crypto_op_data_t::type
vnet_crypto_op_type_t type
Definition: crypto.h:307
vnet_crypto_key_add
u32 vnet_crypto_key_add(vlib_main_t *vm, vnet_crypto_alg_t alg, u8 *data, u16 length)
Definition: crypto.c:360
vnet_crypto_async_frame_elt_t::aad
u8 * aad
Definition: crypto.h:334
vnet_crypto_op_t::tag_len
u8 tag_len
Definition: crypto.h:269
vnet_crypto_async_op_data_t
Definition: crypto.h:313
u64
unsigned long u64
Definition: types.h:89
vnet_crypto_register_ops_handler
void vnet_crypto_register_ops_handler(vlib_main_t *vm, u32 engine_index, vnet_crypto_op_id_t opt, vnet_crypto_ops_handler_t *oph)
Definition: crypto.c:252
vnet_crypto_op_t::aad
u8 * aad
Definition: crypto.h:294
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vnet_crypto_key_t
Definition: crypto.h:198
vnet_crypto_async_frame_state_t_
vnet_crypto_async_frame_state_t_
Definition: crypto.h:348
u32
unsigned int u32
Definition: types.h:88
VNET_CRYPTO_FRAME_STATE_NOT_PROCESSED
@ VNET_CRYPTO_FRAME_STATE_NOT_PROCESSED
Definition: crypto.h:350
integ_alg
u8 integ_alg
Definition: ikev2_types.api:59
vnet_crypto_get_op_type
static_always_inline vnet_crypto_op_type_t vnet_crypto_get_op_type(vnet_crypto_op_id_t id)
Definition: crypto.h:539
vlib_thread_main_t
Definition: threads.h:243
vlib_node_set_interrupt_pending
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
Definition: node_funcs.h:249
VNET_CRYPTO_FRAME_STATE_SUCCESS
@ VNET_CRYPTO_FRAME_STATE_SUCCESS
Definition: crypto.h:354
vnet_crypto_async_next_node_t::node_idx
u32 node_idx
Definition: crypto.h:447
vnet_crypto_async_get_frame
static_always_inline vnet_crypto_async_frame_t * vnet_crypto_async_get_frame(vlib_main_t *vm, vnet_crypto_async_op_id_t opt)
async crypto inline functions
Definition: crypto.h:563
VNET_CRYPTO_N_OP_IDS
@ VNET_CRYPTO_N_OP_IDS
Definition: crypto.h:231
vlib_get_main_by_index
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
Definition: global_funcs.h:29
unformat_function_t
uword() unformat_function_t(unformat_input_t *input, va_list *args)
Definition: format.h:225
iv
static u8 iv[]
Definition: aes_cbc.c:24
vnet_crypto_set_handler
static_always_inline int vnet_crypto_set_handler(char *alg_name, char *engine)
Definition: crypto.h:555
format_vnet_crypto_async_alg
format_function_t format_vnet_crypto_async_alg
Definition: crypto.h:524
vnet_crypto_async_frame_elt_t::integ_start_offset
i16 integ_start_offset
Definition: crypto.h:338
vnet_crypto_key_op_t
vnet_crypto_key_op_t
Definition: crypto.h:129
vnet_crypto_process_ops
u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
Definition: crypto.c:99
vnet_crypto_is_set_async_handler
int vnet_crypto_is_set_async_handler(vnet_crypto_async_op_id_t opt)
Definition: crypto.c:639
VNET_CRYPTO_FRAME_STATE_PENDING
@ VNET_CRYPTO_FRAME_STATE_PENDING
Definition: crypto.h:352
vnet_crypto_async_alg_data_t::name
char * name
Definition: crypto.h:322
length
char const int length
Definition: cJSON.h:163
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
vnet_crypto_main_t::async_active_ids
clib_bitmap_t * async_active_ids
Definition: crypto.h:459
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vnet_crypto_engine_t::priority
int priority
Definition: crypto.h:436
vnet_crypto_async_op_id_t
vnet_crypto_async_op_id_t
Definition: crypto.h:182
vnet_crypto_async_frame_elt_t::tag
u8 * tag
Definition: crypto.h:332
format_vnet_crypto_engine
format_function_t format_vnet_crypto_engine
Definition: crypto.h:517
crypto_dispatch_enable_disable
clib_error_t * crypto_dispatch_enable_disable(int is_enable)
Definition: crypto.c:459
vnet_crypto_ops_handler_t
u32() vnet_crypto_ops_handler_t(vlib_main_t *vm, vnet_crypto_op_t *ops[], u32 n_ops)
Definition: crypto.h:385
i
int i
Definition: flowhash_template.h:376
vnet_crypto_async_frame_elt_t::iv
u8 * iv
Definition: crypto.h:328
vnet_crypto_key_t::type
u8 type
Definition: crypto.h:216
vnet_crypto_engine_t::name
char * name
Definition: crypto.h:434
vnet_crypto_register_chained_ops_handler
void vnet_crypto_register_chained_ops_handler(vlib_main_t *vm, u32 engine_index, vnet_crypto_op_id_t opt, vnet_crypto_chained_ops_handler_t *oph)
Definition: crypto.c:260
VNET_CRYPTO_KEY_OP_ADD
@ VNET_CRYPTO_KEY_OP_ADD
Definition: crypto.h:131
vnet_crypto_async_next_node_t::next_idx
u32 next_idx
Definition: crypto.h:448
foreach_crypto_cipher_alg
#define foreach_crypto_cipher_alg
Definition: crypto.h:25
VNET_CRYPTO_ASYNC_OP_NONE
@ VNET_CRYPTO_ASYNC_OP_NONE
Definition: crypto.h:184
vnet_crypto_main_t::ops_handlers
vnet_crypto_ops_handler_t ** ops_handlers
Definition: crypto.h:455
vnet_crypto_main_t::dispatch_mode
u8 dispatch_mode
Definition: crypto.h:473
vnet_crypto_key_t::alg
vnet_crypto_alg_t alg
Definition: crypto.h:205
vnet_crypto_main_t::engines
vnet_crypto_engine_t * engines
Definition: crypto.h:462
format_vnet_crypto_alg
format_function_t format_vnet_crypto_alg
Definition: crypto.h:516
vnet_crypto_async_frame_elt_t
Definition: crypto.h:326
vnet_crypto_async_op_data_t::active_engine_index_async
u32 active_engine_index_async
Definition: crypto.h:317
clib_bitmap_set_no_check
static uword clib_bitmap_set_no_check(uword *a, uword i, uword new_value)
Sets the ith bit of a bitmap to new_value.
Definition: bitmap.h:141
CRYPTO_OP_BOTH
@ CRYPTO_OP_BOTH
Definition: crypto.h:239
vnet_crypto_alg_t
vnet_crypto_alg_t
Definition: crypto.h:145
vnet_crypto_thread_t
Definition: crypto.h:370
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
vnet_crypto_op_chunk_t::len
u32 len
Definition: crypto.h:252
vnet_crypto_key_del
void vnet_crypto_key_del(vlib_main_t *vm, vnet_crypto_key_index_t index)
Definition: crypto.c:386
vnet_crypto_thread_t::buffer_indices
u32 * buffer_indices
Definition: crypto.h:374
format_vnet_crypto_async_op
format_function_t format_vnet_crypto_async_op
Definition: crypto.h:523
CRYPTO_OP_CHAINED
@ CRYPTO_OP_CHAINED
Definition: crypto.h:238
vnet_crypto_key_t::index_integ
u32 index_integ
Definition: crypto.h:210
vnet_crypto_register_async_handler
void vnet_crypto_register_async_handler(vlib_main_t *vm, u32 engine_index, vnet_crypto_async_op_id_t opt, vnet_crypto_frame_enqueue_t *enq_fn, vnet_crypto_frame_dequeue_t *deq_fn)
Definition: crypto.c:278
format_vnet_crypto_op_status
format_function_t format_vnet_crypto_op_status
Definition: crypto.h:520
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
vnet_crypto_process_chained_ops
u32 vnet_crypto_process_chained_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], vnet_crypto_op_chunk_t *chunks, u32 n_ops)
Definition: crypto.c:105
VNET_CRYPTO_FRAME_STATE_WORK_IN_PROGRESS
@ VNET_CRYPTO_FRAME_STATE_WORK_IN_PROGRESS
Definition: crypto.h:353
vnet_crypto_op_status_t
vnet_crypto_op_status_t
Definition: crypto.h:136
format_vnet_crypto_op_type
format_function_t format_vnet_crypto_op_type
Definition: crypto.h:519
vnet_crypto_async_frame_t::enqueue_thread_index
u32 enqueue_thread_index
Definition: crypto.h:367
vnet_crypto_async_frame_elt_t::digest
u8 * digest
Definition: crypto.h:331
vnet_crypto_async_op_data_t::alg
vnet_crypto_async_alg_t alg
Definition: crypto.h:316
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105