FD.io VPP  v21.01.1
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 
23 /* CRYPTO_ID, PRETTY_NAME, KEY_LENGTH_IN_BYTES */
24 #define foreach_crypto_cipher_alg \
25  _(DES_CBC, "des-cbc", 7) \
26  _(3DES_CBC, "3des-cbc", 24) \
27  _(AES_128_CBC, "aes-128-cbc", 16) \
28  _(AES_192_CBC, "aes-192-cbc", 24) \
29  _(AES_256_CBC, "aes-256-cbc", 32) \
30  _(AES_128_CTR, "aes-128-ctr", 16) \
31  _(AES_192_CTR, "aes-192-ctr", 24) \
32  _(AES_256_CTR, "aes-256-ctr", 32)
33 
34 /* CRYPTO_ID, PRETTY_NAME, KEY_LENGTH_IN_BYTES */
35 #define foreach_crypto_aead_alg \
36  _(AES_128_GCM, "aes-128-gcm", 16) \
37  _(AES_192_GCM, "aes-192-gcm", 24) \
38  _(AES_256_GCM, "aes-256-gcm", 32) \
39  _(CHACHA20_POLY1305, "chacha20-poly1305", 32)
40 
41 #define foreach_crypto_hmac_alg \
42  _(MD5, "md5") \
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_op_type \
50  _(ENCRYPT, "encrypt") \
51  _(DECRYPT, "decrypt") \
52  _(AEAD_ENCRYPT, "aead-encrypt") \
53  _(AEAD_DECRYPT, "aead-decrypt") \
54  _(HMAC, "hmac")
55 
56 typedef enum
57 {
58 #define _(n, s) VNET_CRYPTO_OP_TYPE_##n,
60 #undef _
63 
64 #define foreach_crypto_op_status \
65  _(IDLE, "idle") \
66  _(PENDING, "pending") \
67  _(WORK_IN_PROGRESS, "work-in-progress") \
68  _(COMPLETED, "completed") \
69  _(FAIL_NO_HANDLER, "no-handler") \
70  _(FAIL_BAD_HMAC, "bad-hmac") \
71  _(FAIL_ENGINE_ERR, "engine-error")
72 
73 /** async crypto **/
74 
75 /* CRYPTO_ID, PRETTY_NAME, KEY_LENGTH_IN_BYTES, TAG_LEN, AAD_LEN */
76 #define foreach_crypto_aead_async_alg \
77  _(AES_128_GCM, "aes-128-gcm-aad8", 16, 16, 8) \
78  _(AES_128_GCM, "aes-128-gcm-aad12", 16, 16, 12) \
79  _(AES_192_GCM, "aes-192-gcm-aad8", 24, 16, 8) \
80  _(AES_192_GCM, "aes-192-gcm-aad12", 24, 16, 12) \
81  _(AES_256_GCM, "aes-256-gcm-aad8", 32, 16, 8) \
82  _(AES_256_GCM, "aes-256-gcm-aad12", 32, 16, 12) \
83  _(CHACHA20_POLY1305, "chacha20-poly1305-aad8", 32, 16, 8) \
84  _(CHACHA20_POLY1305, "chacha20-poly1305-aad12", 32, 16, 12)
85 
86 /* CRYPTO_ID, INTEG_ID, PRETTY_NAME, KEY_LENGTH_IN_BYTES, DIGEST_LEN */
87 #define foreach_crypto_link_async_alg \
88  _ (AES_128_CBC, SHA1, "aes-128-cbc-hmac-sha-1", 16, 12) \
89  _ (AES_192_CBC, SHA1, "aes-192-cbc-hmac-sha-1", 24, 12) \
90  _ (AES_256_CBC, SHA1, "aes-256-cbc-hmac-sha-1", 32, 12) \
91  _ (AES_128_CBC, SHA224, "aes-128-cbc-hmac-sha-224", 16, 14) \
92  _ (AES_192_CBC, SHA224, "aes-192-cbc-hmac-sha-224", 24, 14) \
93  _ (AES_256_CBC, SHA224, "aes-256-cbc-hmac-sha-224", 32, 14) \
94  _ (AES_128_CBC, SHA256, "aes-128-cbc-hmac-sha-256", 16, 16) \
95  _ (AES_192_CBC, SHA256, "aes-192-cbc-hmac-sha-256", 24, 16) \
96  _ (AES_256_CBC, SHA256, "aes-256-cbc-hmac-sha-256", 32, 16) \
97  _ (AES_128_CBC, SHA384, "aes-128-cbc-hmac-sha-384", 16, 24) \
98  _ (AES_192_CBC, SHA384, "aes-192-cbc-hmac-sha-384", 24, 24) \
99  _ (AES_256_CBC, SHA384, "aes-256-cbc-hmac-sha-384", 32, 24) \
100  _ (AES_128_CBC, SHA512, "aes-128-cbc-hmac-sha-512", 16, 32) \
101  _ (AES_192_CBC, SHA512, "aes-192-cbc-hmac-sha-512", 24, 32) \
102  _ (AES_256_CBC, SHA512, "aes-256-cbc-hmac-sha-512", 32, 32)
103 
104 #define foreach_crypto_async_op_type \
105  _(ENCRYPT, "async-encrypt") \
106  _(DECRYPT, "async-decrypt")
107 
108 typedef enum
109 {
114 
115 typedef enum
116 {
117 #define _(n, s) VNET_CRYPTO_OP_STATUS_##n,
119 #undef _
122 
123 /* *INDENT-OFF* */
124 typedef enum
125 {
127 #define _(n, s, l) VNET_CRYPTO_ALG_##n,
130 #undef _
131 #define _(n, s) VNET_CRYPTO_ALG_HMAC_##n,
133 #undef _
136 
137 typedef enum
138 {
139 #define _(n, s) VNET_CRYPTO_ASYNC_OP_TYPE_##n,
141 #undef _
144 
145 typedef enum
146 {
148 #define _(n, s, k, t, a) \
149  VNET_CRYPTO_ALG_##n##_TAG##t##_AAD##a,
151 #undef _
152 #define _(c, h, s, k ,d) \
153  VNET_CRYPTO_ALG_##c##_##h##_TAG##d,
155 #undef _
158 
159 typedef enum
160 {
162 #define _(n, s, k, t, a) \
163  VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_ENC, \
164  VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_DEC,
166 #undef _
167 #define _(c, h, s, k ,d) \
168  VNET_CRYPTO_OP_##c##_##h##_TAG##d##_ENC, \
169  VNET_CRYPTO_OP_##c##_##h##_TAG##d##_DEC,
171 #undef _
174 
175 typedef struct
176 {
177  union
178  {
179  struct
180  {
182  vnet_crypto_alg_t alg:8;
183  };
184  struct
185  {
188  vnet_crypto_async_alg_t async_alg:8;
189  };
190  };
191 #define VNET_CRYPTO_KEY_TYPE_DATA 0
192 #define VNET_CRYPTO_KEY_TYPE_LINK 1
195 
196 typedef enum
197 {
199 #define _(n, s, l) VNET_CRYPTO_OP_##n##_ENC, VNET_CRYPTO_OP_##n##_DEC,
202 #undef _
203 #define _(n, s) VNET_CRYPTO_OP_##n##_HMAC,
205 #undef _
208 /* *INDENT-ON* */
209 
210 typedef enum
211 {
216 
217 typedef struct
218 {
219  char *name;
220  vnet_crypto_op_id_t op_by_type[VNET_CRYPTO_OP_N_TYPES];
222 
223 typedef struct
224 {
225  u8 *src;
226  u8 *dst;
229 
230 typedef struct
231 {
232  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
234  vnet_crypto_op_id_t op:16;
235  vnet_crypto_op_status_t status:8;
237 #define VNET_CRYPTO_OP_FLAG_INIT_IV (1 << 0)
238 #define VNET_CRYPTO_OP_FLAG_HMAC_CHECK (1 << 1)
239 #define VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS (1 << 2)
240 
241  union
242  {
245  };
247 
248  union
249  {
250  struct
251  {
252  u8 *src;
253  u8 *dst;
254  };
255 
256  /* valid if VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS is set */
258  };
259 
260  union
261  {
263  /* valid if VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS is set */
265  };
266 
268  u8 *iv;
269  u8 *aad;
270 
271  union
272  {
273  u8 *tag;
275  };
277 
279 
280 typedef struct
281 {
282  vnet_crypto_op_type_t type;
283  vnet_crypto_alg_t alg;
287 
288 typedef struct
289 {
290  vnet_crypto_async_op_type_t type;
291  vnet_crypto_async_alg_t alg;
294 
295 typedef struct
296 {
297  char *name;
298  vnet_crypto_async_op_id_t op_by_type[VNET_CRYPTO_ASYNC_OP_N_TYPES];
300 
301 typedef struct
302 {
303  vnet_crypto_op_status_t status:8;
305  i16 crypto_start_offset; /* first buffer offset */
308  /* adj total_length for integ, e.g.4 bytes for IPSec ESN */
310  u8 *iv;
311  union
312  {
314  u8 *tag;
315  };
316  u8 *aad;
317  u8 flags; /**< share same VNET_CRYPTO_OP_FLAG_* values */
319 
320 typedef struct
321 {
322  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
323 #define VNET_CRYPTO_FRAME_STATE_NOT_PROCESSED 0
324 #define VNET_CRYPTO_FRAME_STATE_PENDING 1 /* frame waiting to be processed */
325 #define VNET_CRYPTO_FRAME_STATE_WORK_IN_PROGRESS 2
326 #define VNET_CRYPTO_FRAME_STATE_SUCCESS 3
327 #define VNET_CRYPTO_FRAME_STATE_ELT_ERROR 4
329  vnet_crypto_async_op_id_t op:8;
332  u32 buffer_indices[VNET_CRYPTO_FRAME_SIZE];
333  u16 next_node_index[VNET_CRYPTO_FRAME_SIZE];
336 
337 typedef struct
338 {
339  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
345 
347 
349  vnet_crypto_op_t * ops[],
351  chunks, u32 n_ops);
352 
354  vnet_crypto_op_t * ops[], u32 n_ops);
355 
357  vnet_crypto_key_op_t kop,
358  vnet_crypto_key_index_t idx);
359 
360 /** async crypto function handlers **/
361 typedef int
365  (vnet_crypto_frame_dequeue_t) (vlib_main_t * vm, u32 * nb_elts_processed,
366  u32 * enqueue_thread_idx);
367 
368 u32
369 vnet_crypto_register_engine (vlib_main_t * vm, char *name, int prio,
370  char *desc);
371 
372 void vnet_crypto_register_ops_handler (vlib_main_t * vm, u32 engine_index,
373  vnet_crypto_op_id_t opt,
375 
377  u32 engine_index,
378  vnet_crypto_op_id_t opt,
380  * oph);
381 
382 void vnet_crypto_register_ops_handlers (vlib_main_t * vm, u32 engine_index,
383  vnet_crypto_op_id_t opt,
386  cfn);
387 
388 void vnet_crypto_register_key_handler (vlib_main_t * vm, u32 engine_index,
390 
391 /** async crypto register functions */
392 u32 vnet_crypto_register_post_node (vlib_main_t * vm, char *post_node_name);
394  u32 engine_index,
395  vnet_crypto_async_op_id_t opt,
398  deq_fn);
399 
400 typedef struct
401 {
402  char *name;
403  char *desc;
404  int priority;
408  * chained_ops_handlers[VNET_CRYPTO_N_OP_IDS];
412 
413 typedef struct
414 {
418 
419 typedef struct
420 {
439 #define VNET_CRYPTO_ASYNC_DISPATCH_POLLING 0
440 #define VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT 1
443 
445 
447  vnet_crypto_op_chunk_t * chunks,
448  u32 n_ops);
450  u32 n_ops);
451 
452 
453 int vnet_crypto_set_handler2 (char *ops_handler_name, char *engine,
454  crypto_op_class_type_t oct);
455 int vnet_crypto_is_set_handler (vnet_crypto_alg_t alg);
456 
457 u32 vnet_crypto_key_add (vlib_main_t * vm, vnet_crypto_alg_t alg,
458  u8 * data, u16 length);
459 void vnet_crypto_key_del (vlib_main_t * vm, vnet_crypto_key_index_t index);
460 
461 /**
462  * Use 2 created keys to generate new key for linked algs (cipher + integ)
463  * The returned key index is to be used for linked alg only.
464  **/
466  vnet_crypto_key_index_t index_crypto,
467  vnet_crypto_key_index_t index_integ);
468 
470 
471 int vnet_crypto_set_async_handler2 (char *alg_name, char *engine);
472 
473 int vnet_crypto_is_set_async_handler (vnet_crypto_async_op_id_t opt);
474 
475 void vnet_crypto_request_async_mode (int is_enable);
476 
478 
479 vnet_crypto_async_alg_t vnet_crypto_link_algs (vnet_crypto_alg_t crypto_alg,
480  vnet_crypto_alg_t integ_alg);
481 
483 
490 
494 
496 vnet_crypto_op_init (vnet_crypto_op_t * op, vnet_crypto_op_id_t type)
497 {
498  if (CLIB_DEBUG > 0)
499  clib_memset (op, 0xfe, sizeof (*op));
500  op->op = type;
501  op->flags = 0;
502  op->key_index = ~0;
503  op->n_chunks = 0;
504 }
505 
506 static_always_inline vnet_crypto_op_type_t
507 vnet_crypto_get_op_type (vnet_crypto_op_id_t id)
508 {
511  vnet_crypto_op_data_t *od = cm->opt_data + id;
512  return od->type;
513 }
514 
516 vnet_crypto_get_key (vnet_crypto_key_index_t index)
517 {
519  return vec_elt_at_index (cm->keys, index);
520 }
521 
523 vnet_crypto_set_handler (char *alg_name, char *engine)
524 {
525  return vnet_crypto_set_handler2 (alg_name, engine, CRYPTO_OP_BOTH);
526 }
527 
528 /** async crypto inline functions **/
529 
531 vnet_crypto_async_get_frame (vlib_main_t * vm, vnet_crypto_async_op_id_t opt)
532 {
534  vnet_crypto_thread_t *ct = cm->threads + vm->thread_index;
535  vnet_crypto_async_frame_t *f = ct->frames[opt];
536 
537  if (!f)
538  {
540  if (CLIB_DEBUG > 0)
541  clib_memset (f, 0xfe, sizeof (*f));
543  f->op = opt;
544  f->n_elts = 0;
545  ct->frames[opt] = f;
546  }
547  return f;
548 }
549 
553 {
555  vnet_crypto_thread_t *ct = cm->threads + vm->thread_index;
556  pool_put (ct->frame_pool, frame);
557 }
558 
562 {
565  vnet_crypto_thread_t *ct = cm->threads + vm->thread_index;
566  vnet_crypto_async_op_id_t opt = frame->op;
567  u32 i = vlib_num_workers () > 0;
568 
570  frame->enqueue_thread_index = vm->thread_index;
571 
572  int ret = (cm->enqueue_handlers[frame->op]) (vm, frame);
573 
575  if (PREDICT_TRUE (ret == 0))
576  {
579  if (CLIB_DEBUG > 0)
580  clib_memset (nf, 0xfe, sizeof (*nf));
582  nf->op = opt;
583  nf->n_elts = 0;
584  ct->frames[opt] = nf;
585  }
586  else
587  {
589  }
590 
592  {
593  for (; i < tm->n_vlib_mains; i++)
594  {
596  cm->crypto_node_index);
597  }
598  }
599  return ret;
600 }
601 
605  u32 key_index,
606  u32 crypto_len, i16 integ_len_adj,
607  i16 crypto_start_offset,
608  u16 integ_start_offset,
609  u32 buffer_index,
610  u16 next_node,
611  u8 * iv, u8 * tag, u8 * aad, u8 flags)
612 {
615  u16 index;
616 
618  {
619  vnet_crypto_async_op_id_t opt = f->op;
620  int ret;
622  if (PREDICT_FALSE (ret < 0))
623  return -1;
624  f = vnet_crypto_async_get_frame (vm, opt);
625  *frame = f;
626  }
627 
628  index = f->n_elts;
629  fe = &f->elts[index];
630  f->n_elts++;
631  fe->key_index = key_index;
632  fe->crypto_total_length = crypto_len;
633  fe->crypto_start_offset = crypto_start_offset;
634  fe->integ_start_offset = integ_start_offset;
635  fe->integ_length_adj = integ_len_adj;
636  fe->iv = iv;
637  fe->tag = tag;
638  fe->aad = aad;
639  fe->flags = flags;
640  f->buffer_indices[index] = buffer_index;
641  f->next_node_index[index] = next_node;
642 
643  return 0;
644 }
645 
648 {
649  vnet_crypto_async_op_id_t opt;
650  ASSERT (f != 0);
653  opt = f->op;
654  if (CLIB_DEBUG > 0)
655  clib_memset (f, 0xfe, sizeof (*f));
657  f->op = opt;
658  f->n_elts = 0;
659 }
660 
661 #endif /* included_vnet_crypto_crypto_h */
662 
663 /*
664  * fd.io coding-style-patch-verification: ON
665  *
666  * Local Variables:
667  * eval: (c-set-style "gnu")
668  * End:
669  */
int() vnet_crypto_frame_enqueue_t(vlib_main_t *vm, vnet_crypto_async_frame_t *frame)
async crypto function handlers
Definition: crypto.h:362
#define foreach_crypto_op_status
Definition: crypto.h:64
format_function_t format_vnet_crypto_op_type
Definition: crypto.h:487
static_always_inline int vnet_crypto_async_add_to_frame(vlib_main_t *vm, vnet_crypto_async_frame_t **frame, 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:603
uword * async_alg_index_by_name
Definition: crypto.h:434
vnet_crypto_engine_t * engines
Definition: crypto.h:430
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
uword * alg_index_by_name
Definition: crypto.h:433
vnet_crypto_thread_t * threads
Definition: crypto.h:422
#define foreach_crypto_link_async_alg
Definition: crypto.h:87
static_always_inline void vnet_crypto_async_reset_frame(vnet_crypto_async_frame_t *f)
Definition: crypto.h:647
#define VNET_CRYPTO_FRAME_STATE_NOT_PROCESSED
Definition: crypto.h:323
static_always_inline int vnet_crypto_set_handler(char *alg_name, char *engine)
Definition: crypto.h:523
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105
vnet_crypto_op_data_t opt_data[VNET_CRYPTO_N_OP_IDS]
Definition: crypto.h:428
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:348
vnet_crypto_alg_data_t * algs
Definition: crypto.h:421
vnet_crypto_frame_enqueue_t ** enqueue_handlers
Definition: crypto.h:425
#define PREDICT_TRUE(x)
Definition: clib.h:122
format_function_t format_vnet_crypto_op
Definition: crypto.h:486
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
Definition: node_funcs.h:255
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vnet_crypto_async_alg_data_t * async_algs
Definition: crypto.h:435
format_function_t format_vnet_crypto_alg
Definition: crypto.h:484
#define VNET_CRYPTO_FRAME_STATE_PENDING
Definition: crypto.h:324
vnet_crypto_async_op_type_t type
Definition: crypto.h:290
u32 thread_index
Definition: main.h:250
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
int vnet_crypto_is_set_handler(vnet_crypto_alg_t alg)
Definition: crypto.c:189
void vnet_crypto_register_key_handler(vlib_main_t *vm, u32 engine_index, vnet_crypto_key_handler_t *keyh)
Definition: crypto.c:307
vlib_main_t * vm
Definition: in2out_ed.c:1580
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:243
#define foreach_crypto_async_op_type
Definition: crypto.h:104
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:260
vlib_main_t ** vlib_mains
Definition: buffer.c:332
unsigned char u8
Definition: types.h:56
void vnet_crypto_request_async_mode(int is_enable)
Definition: crypto.c:559
u8 data[128]
Definition: ipsec_types.api:90
format_function_t format_vnet_crypto_async_op
Definition: crypto.h:491
u8 id[64]
Definition: dhcp.api:160
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
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
vnet_crypto_op_type_t
Definition: crypto.h:56
u32 vnet_crypto_key_add(vlib_main_t *vm, vnet_crypto_alg_t alg, u8 *data, u16 length)
Definition: crypto.c:345
#define static_always_inline
Definition: clib.h:109
vnet_crypto_key_op_t
Definition: crypto.h:108
void vnet_crypto_key_del(vlib_main_t *vm, vnet_crypto_key_index_t index)
Definition: crypto.c:371
#define foreach_crypto_aead_alg
Definition: crypto.h:35
u32 active_engine_index_chained
Definition: crypto.h:285
int vnet_crypto_set_async_handler2(char *alg_name, char *engine)
Definition: crypto.c:497
vnet_crypto_alg_t alg
Definition: crypto.h:283
static_always_inline void vnet_crypto_op_init(vnet_crypto_op_t *op, vnet_crypto_op_id_t type)
Definition: crypto.h:496
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:251
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
Definition: crypto.c:99
int vnet_crypto_is_set_async_handler(vnet_crypto_async_op_id_t opt)
Definition: crypto.c:626
#define foreach_crypto_hmac_alg
Definition: crypto.h:41
unsigned int u32
Definition: types.h:88
vnet_crypto_async_frame_t * frames[VNET_CRYPTO_ASYNC_OP_N_IDS]
Definition: crypto.h:340
vnet_crypto_op_id_t op
Definition: crypto.h:234
vnet_crypto_alg_t
Definition: crypto.h:124
vnet_crypto_chained_ops_handler_t ** chained_ops_handlers
Definition: crypto.h:424
#define VNET_CRYPTO_FRAME_SIZE
Definition: crypto.h:21
vl_api_fib_path_type_t type
Definition: fib_types.api:123
vnet_crypto_async_alg_t vnet_crypto_link_algs(vnet_crypto_alg_t crypto_alg, vnet_crypto_alg_t integ_alg)
Definition: crypto.c:397
vnet_crypto_main_t * cm
Definition: quic_crypto.c:53
#define VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT
Definition: crypto.h:440
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:356
static u8 iv[]
Definition: aes_cbc.c:24
u8 integ_alg
Definition: ikev2_types.api:59
uword user_data
Definition: crypto.h:233
vnet_crypto_key_handler_t * key_op_handler
Definition: crypto.h:405
vnet_crypto_async_next_node_t * next_nodes
Definition: crypto.h:437
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:269
u16 next_node_index[VNET_CRYPTO_FRAME_SIZE]
Definition: crypto.h:333
unsigned short u16
Definition: types.h:57
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:301
u32 active_engine_index_simple
Definition: crypto.h:284
#define PREDICT_FALSE(x)
Definition: clib.h:121
static_always_inline void vnet_crypto_async_free_frame(vlib_main_t *vm, vnet_crypto_async_frame_t *frame)
Definition: crypto.h:551
uword() unformat_function_t(unformat_input_t *input, va_list *args)
Definition: format.h:232
vnet_crypto_alg_t alg
Definition: crypto.h:182
vnet_crypto_async_frame_t * frame_pool
Definition: crypto.h:341
vl_api_tunnel_mode_t mode
Definition: gre.api:48
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:531
vnet_crypto_async_alg_t async_alg
Definition: crypto.h:188
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:245
u32 buffer_indices[VNET_CRYPTO_FRAME_SIZE]
Definition: crypto.h:332
format_function_t format_vnet_crypto_async_op_type
Definition: crypto.h:493
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
u32 crypto_node_index
Definition: crypto.h:438
format_function_t format_vnet_crypto_async_alg
Definition: crypto.h:492
vnet_crypto_frame_dequeue_t ** dequeue_handlers
Definition: crypto.h:426
vnet_crypto_async_op_type_t
Definition: crypto.h:137
clib_error_t * crypto_dispatch_enable_disable(int is_enable)
Definition: crypto.c:447
unformat_function_t unformat_vnet_crypto_alg
Definition: crypto.h:489
u32() vnet_crypto_ops_handler_t(vlib_main_t *vm, vnet_crypto_op_t *ops[], u32 n_ops)
Definition: crypto.h:353
#define VNET_CRYPTO_FRAME_STATE_ELT_ERROR
Definition: crypto.h:327
string name[64]
Definition: ip.api:44
crypto_op_class_type_t
Definition: crypto.h:210
vnet_crypto_async_alg_t alg
Definition: crypto.h:291
vnet_crypto_op_status_t
Definition: crypto.h:115
#define ASSERT(truth)
format_function_t format_vnet_crypto_op_status
Definition: crypto.h:488
uword * engine_index_by_name
Definition: crypto.h:432
static_always_inline vnet_crypto_op_type_t vnet_crypto_get_op_type(vnet_crypto_op_id_t id)
Definition: crypto.h:507
clib_bitmap_t * async_active_ids
Definition: crypto.h:427
u8 flags
share same VNET_CRYPTO_OP_FLAG_* values
Definition: crypto.h:317
u32 vnet_crypto_key_index_t
Definition: crypto.h:346
#define foreach_crypto_aead_async_alg
async crypto
Definition: crypto.h:76
char const int length
Definition: cJSON.h:163
vnet_crypto_async_op_id_t
Definition: crypto.h:159
static_always_inline int vnet_crypto_async_submit_open_frame(vlib_main_t *vm, vnet_crypto_async_frame_t *frame)
Definition: crypto.h:560
vnet_crypto_async_op_id_t op
Definition: crypto.h:329
static_always_inline vnet_crypto_key_t * vnet_crypto_get_key(vnet_crypto_key_index_t index)
Definition: crypto.h:516
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:365
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: in2out_ed.c:1581
format_function_t format_vnet_crypto_engine
Definition: crypto.h:485
u64 uword
Definition: types.h:112
u32 vnet_crypto_register_engine(vlib_main_t *vm, char *name, int prio, char *desc)
Definition: crypto.c:112
#define foreach_crypto_op_type
Definition: crypto.h:49
vnet_crypto_op_type_t type
Definition: crypto.h:282
u32 index
Definition: flow_types.api:221
vnet_crypto_op_status_t status
Definition: crypto.h:235
vnet_crypto_op_id_t
Definition: crypto.h:196
vnet_crypto_key_t * keys
Definition: crypto.h:431
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
static u32 vlib_num_workers()
Definition: threads.h:377
uword clib_bitmap_t
Definition: bitmap.h:50
void vnet_crypto_set_async_dispatch_mode(u8 mode)
Definition: crypto.c:596
STATIC_ASSERT_SIZEOF(vnet_crypto_op_t, CLIB_CACHE_LINE_BYTES)
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:410
vnet_crypto_main_t crypto_main
Definition: crypto.c:20
int vnet_crypto_set_handler2(char *ops_handler_name, char *engine, crypto_op_class_type_t oct)
Definition: crypto.c:156
vnet_crypto_ops_handler_t ** ops_handlers
Definition: crypto.h:423
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
u32 vnet_crypto_register_post_node(vlib_main_t *vm, char *post_node_name)
async crypto register functions
Definition: crypto.c:529
vnet_crypto_async_alg_t
Definition: crypto.h:145
#define foreach_crypto_cipher_alg
Definition: crypto.h:24
vnet_crypto_op_status_t status
Definition: crypto.h:303
vnet_crypto_async_frame_elt_t elts[VNET_CRYPTO_FRAME_SIZE]
Definition: crypto.h:331
signed short i16
Definition: types.h:46