|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
18 #include <picotls/openssl.h>
25 const void *, size_t);
32 ptls_cipher_context_t
super;
45 uint8_t
iv[PTLS_MAX_IV_SIZE];
55 if (!strcmp (
ctx->super.algo->name,
"AES128-CTR"))
57 id = VNET_CRYPTO_OP_AES_128_CTR_ENC;
59 else if (!strcmp (
ctx->super.algo->name,
"AES256-CTR"))
61 id = VNET_CRYPTO_OP_AES_256_CTR_ENC;
65 TLS_DBG (1,
"%s, Invalid crypto cipher : ", __FUNCTION__,
72 ctx->op.key_index =
ctx->key_index;
83 const void *input,
size_t _len)
88 ctx->op.src = (
u8 *) input;
98 const EVP_CIPHER * cipher,
105 ctx->super.do_transform = do_transform;
109 if (!strcmp (
ctx->super.algo->name,
"AES128-CTR"))
111 algo = VNET_CRYPTO_ALG_AES_128_CTR;
113 else if (!strcmp (
ctx->super.algo->name,
"AES256-CTR"))
115 algo = VNET_CRYPTO_ALG_AES_256_CTR;
119 TLS_DBG (1,
"%s, Invalid crypto cipher : ", __FUNCTION__,
126 (
u8 *)
key, _ctx->algo->key_size);
134 const void *input,
size_t inlen, uint64_t seq,
135 const void *aad,
size_t aadlen)
139 int tag_size =
ctx->super.algo->tag_size;
141 ctx->op.dst = _output;
142 ctx->op.src = (
void *) input;
143 ctx->op.len = inlen - tag_size;;
145 ptls_aead__build_iv (
ctx->super.algo,
ctx->op.iv,
ctx->static_iv, seq);
146 ctx->op.aad = (
void *) aad;
147 ctx->op.aad_len = aadlen;
148 ctx->op.tag = (
void *) input + inlen - tag_size;
149 ctx->op.tag_len = tag_size;
152 assert (
ctx->op.status == VNET_CRYPTO_OP_STATUS_COMPLETED);
154 return inlen - tag_size;
159 const void *aad,
size_t aadlen)
163 ptls_aead__build_iv (
ctx->super.algo,
ctx->op.iv,
ctx->static_iv, seq);
164 ctx->op.aad = (
void *) aad;
165 ctx->op.aad_len = aadlen;
166 ctx->op.n_chunks = 2;
167 ctx->op.chunk_index = 0;
174 const void *input,
size_t inlen)
177 ctx->chunks[
ctx->chunk_index].dst = output;
178 ctx->chunks[
ctx->chunk_index].src = (
void *) input;
179 ctx->chunks[
ctx->chunk_index].len = inlen;
181 ctx->chunk_index =
ctx->chunk_index == 0 ? 1 : 0;
192 ctx->op.tag = _output;
193 ctx->op.tag_len =
ctx->super.algo->tag_size;
196 assert (
ctx->op.status == VNET_CRYPTO_OP_STATUS_COMPLETED);
198 return ctx->super.algo->tag_size;
209 const void *
key,
const void *
iv,
218 if (
alg == VNET_CRYPTO_ALG_AES_128_GCM)
225 else if (
alg == VNET_CRYPTO_ALG_AES_256_GCM)
236 TLS_DBG (1,
"%s, invalied aead cipher %s", __FUNCTION__,
247 ctx->chunk_index = 0;
261 int is_enc,
const void *
key)
269 int is_enc,
const void *
key)
277 int is_enc,
const void *
key,
281 VNET_CRYPTO_ALG_AES_128_GCM);
286 int is_enc,
const void *
key,
290 VNET_CRYPTO_ALG_AES_256_GCM);
295 PTLS_AES128_KEY_SIZE,
304 PTLS_AES256_KEY_SIZE,
313 PTLS_AESGCM_CONFIDENTIALITY_LIMIT,
314 PTLS_AESGCM_INTEGRITY_LIMIT,
317 PTLS_AES128_KEY_SIZE,
319 PTLS_AESGCM_TAG_SIZE,
326 PTLS_AESGCM_CONFIDENTIALITY_LIMIT,
327 PTLS_AESGCM_INTEGRITY_LIMIT,
330 PTLS_AES256_KEY_SIZE,
332 PTLS_AESGCM_TAG_SIZE,
338 { PTLS_CIPHER_SUITE_AES_128_GCM_SHA256,
344 { PTLS_CIPHER_SUITE_AES_256_GCM_SHA384,
static_always_inline void vnet_crypto_op_init(vnet_crypto_op_t *op, vnet_crypto_op_id_t type)
static int ptls_vpp_crypto_aead_aes256gcm_setup_crypto(ptls_aead_context_t *ctx, int is_enc, const void *key, const void *iv)
ptls_aead_algorithm_t ptls_vpp_crypto_aes256gcm
#define clib_memcpy(d, s, n)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
picotls_main_t picotls_main
static size_t ptls_vpp_crypto_aead_encrypt_final(ptls_aead_context_t *_ctx, void *_output)
static void clib_rwlock_writer_unlock(clib_rwlock_t *p)
ptls_aead_algorithm_t ptls_vpp_crypto_aes128gcm
static void ptls_vpp_crypto_aead_encrypt_init(ptls_aead_context_t *_ctx, uint64_t seq, const void *aad, size_t aadlen)
ptls_cipher_suite_t * ptls_vpp_crypto_cipher_suites[]
vnet_crypto_op_chunk_t chunks[2]
static int ptls_vpp_crypto_aead_setup_crypto(ptls_aead_context_t *_ctx, int is_enc, const void *key, const void *iv, vnet_crypto_alg_t alg)
ptls_cipher_suite_t ptls_vpp_crypto_aes128gcmsha256
ptls_aead_context_t super
static void ptls_vpp_crypto_cipher_encrypt(ptls_cipher_context_t *_ctx, void *output, const void *input, size_t _len)
u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
#define TLS_DBG(_lvl, _fmt, _args...)
clib_rwlock_t crypto_keys_rw_lock
u32 vnet_crypto_process_chained_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], vnet_crypto_op_chunk_t *chunks, u32 n_ops)
static size_t ptls_vpp_crypto_aead_encrypt_update(ptls_aead_context_t *_ctx, void *output, const void *input, size_t inlen)
#define VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS
static int ptls_vpp_crypto_aes128ctr_setup_crypto(ptls_cipher_context_t *ctx, int is_enc, const void *key)
static void clib_rwlock_writer_lock(clib_rwlock_t *p)
static int ptls_vpp_crypto_aead_aes128gcm_setup_crypto(ptls_aead_context_t *ctx, int is_enc, const void *key, const void *iv)
uint8_t static_iv[PTLS_MAX_IV_SIZE]
static void ptls_vpp_crypto_cipher_dispose(ptls_cipher_context_t *_ctx)
ptls_cipher_context_t super
vnet_crypto_main_t crypto_main
u32 vnet_crypto_key_add(vlib_main_t *vm, vnet_crypto_alg_t alg, u8 *data, u16 length)
size_t ptls_vpp_crypto_aead_decrypt(ptls_aead_context_t *_ctx, void *_output, const void *input, size_t inlen, uint64_t seq, const void *aad, size_t aadlen)
static int ptls_vpp_crypto_cipher_setup_crypto(ptls_cipher_context_t *_ctx, int is_enc, const void *key, const EVP_CIPHER *cipher, ptls_vpp_do_transform_fn do_transform)
ptls_cipher_algorithm_t ptls_vpp_crypto_aes256ctr
ptls_cipher_suite_t ptls_vpp_crypto_aes256gcmsha384
static vlib_main_t * vlib_get_main(void)
void(* ptls_vpp_do_transform_fn)(ptls_cipher_context_t *, void *, const void *, size_t)
static int ptls_vpp_crypto_aes256ctr_setup_crypto(ptls_cipher_context_t *ctx, int is_enc, const void *key)
uint8_t iv[PTLS_MAX_IV_SIZE]
ptls_cipher_algorithm_t ptls_vpp_crypto_aes128ctr
static void ptls_vpp_crypto_cipher_do_init(ptls_cipher_context_t *_ctx, const void *iv)
static void ptls_vpp_crypto_aead_dispose_crypto(ptls_aead_context_t *_ctx)