21 #include <picotls/openssl.h> 25 const void *, size_t);
49 if (!strcmp (ctx->
super.algo->name,
"AES128-CTR"))
51 id = VNET_CRYPTO_OP_AES_128_CTR_ENC;
53 else if (!strcmp (ctx->
super.algo->name,
"AES256-CTR"))
55 id = VNET_CRYPTO_OP_AES_256_CTR_ENC;
59 QUIC_DBG (1,
"%s, Invalid crypto cipher : ", __FUNCTION__,
77 const void *input,
size_t _len)
91 const void *
key,
const EVP_CIPHER * cipher,
98 ctx->
super.do_transform = do_transform;
102 if (!strcmp (ctx->
super.algo->name,
"AES128-CTR"))
104 algo = VNET_CRYPTO_ALG_AES_128_CTR;
106 else if (!strcmp (ctx->
super.algo->name,
"AES256-CTR"))
108 algo = VNET_CRYPTO_ALG_AES_256_CTR;
112 QUIC_DBG (1,
"%s, Invalid crypto cipher : ", __FUNCTION__,
118 (
u8 *) key, _ctx->algo->key_size);
141 const void *input,
size_t inlen, uint64_t seq,
142 const void *
iv,
const void *aad,
size_t aadlen)
144 QUIC_DBG (1,
"[quic] %s", __FUNCTION__);
150 if (!strcmp (ctx->
super.algo->name,
"AES128-GCM"))
152 id = VNET_CRYPTO_OP_AES_128_GCM_ENC;
154 else if (!strcmp (ctx->
super.algo->name,
"AES256-GCM"))
156 id = VNET_CRYPTO_OP_AES_256_GCM_ENC;
169 ctx->
op.
dst = output;
183 const void *input,
size_t inlen,
const void *
iv,
184 const void *aad,
size_t aadlen)
186 QUIC_DBG (1,
"[quic] %s", __FUNCTION__);
192 if (!strcmp (ctx->
super.algo->name,
"AES128-GCM"))
194 id = VNET_CRYPTO_OP_AES_128_GCM_DEC;
196 else if (!strcmp (ctx->
super.algo->name,
"AES256-GCM"))
198 id = VNET_CRYPTO_OP_AES_256_GCM_DEC;
211 ctx->
op.
dst = _output;
213 ctx->
op.
len = inlen - ctx->
super.algo->tag_size;
226 QUIC_DBG (1,
"[quic] %s", __FUNCTION__);
231 const void *
key,
const EVP_CIPHER * cipher)
233 QUIC_DBG (1,
"%s, algo : ", __FUNCTION__, _ctx->algo->name);
239 if (!strcmp (ctx->
super.algo->name,
"AES128-GCM"))
241 algo = VNET_CRYPTO_ALG_AES_128_GCM;
243 else if (!strcmp (ctx->
super.algo->name,
"AES256-GCM"))
245 algo = VNET_CRYPTO_ALG_AES_256_GCM;
249 QUIC_DBG (1,
"%s, algo : ", __FUNCTION__, _ctx->algo->name);
258 (
u8 *) key, _ctx->algo->key_size);
278 PTLS_AES128_KEY_SIZE,
281 aes128ctr_setup_crypto
284 ptls_cipher_algorithm_t vpp_crypto_aes256ctr = {
"AES256-CTR",
285 PTLS_AES256_KEY_SIZE,
289 aes256ctr_setup_crypto
292 ptls_aead_algorithm_t vpp_crypto_aes128gcm = {
"AES128-GCM",
295 PTLS_AES128_KEY_SIZE,
297 PTLS_AESGCM_TAG_SIZE,
299 vpp_crypto_aead_aes128gcm_setup_crypto
302 ptls_aead_algorithm_t vpp_crypto_aes256gcm = {
"AES256-GCM",
305 PTLS_AES256_KEY_SIZE,
307 PTLS_AESGCM_TAG_SIZE,
309 vpp_crypto_aead_aes256gcm_setup_crypto
312 ptls_cipher_suite_t vpp_crypto_aes128gcmsha256 =
313 { PTLS_CIPHER_SUITE_AES_128_GCM_SHA256,
318 ptls_cipher_suite_t vpp_crypto_aes256gcmsha384 =
319 { PTLS_CIPHER_SUITE_AES_256_GCM_SHA384,
324 ptls_cipher_suite_t *vpp_crypto_cipher_suites[] =
u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
static int vpp_crypto_aead_aes256gcm_setup_crypto(ptls_aead_context_t *ctx, int is_enc, const void *key)
ptls_cipher_context_t super
static int aes256ctr_setup_crypto(ptls_cipher_context_t *ctx, int is_enc, const void *key)
static int vpp_crypto_aead_aes128gcm_setup_crypto(ptls_aead_context_t *ctx, int is_enc, const void *key)
static int vpp_crypto_aead_setup_crypto(ptls_aead_context_t *_ctx, int is_enc, const void *key, const EVP_CIPHER *cipher)
size_t vpp_crypto_aead_encrypt(ptls_aead_context_t *_ctx, void *output, const void *input, size_t inlen, uint64_t seq, const void *iv, const void *aad, size_t aadlen)
static void vpp_crypto_cipher_encrypt(ptls_cipher_context_t *_ctx, void *output, const void *input, size_t _len)
ptls_cipher_algorithm_t vpp_crypto_aes128ctr
#define QUIC_DBG(_lvl, _fmt, _args...)
static void vpp_crypto_aead_dispose_crypto(ptls_aead_context_t *_ctx)
static_always_inline void vnet_crypto_op_init(vnet_crypto_op_t *op, vnet_crypto_op_id_t type)
u32 vnet_crypto_key_add(vlib_main_t *vm, vnet_crypto_alg_t alg, u8 *data, u16 length)
static void vpp_crypto_cipher_dispose(ptls_cipher_context_t *_ctx)
static void vpp_crypto_cipher_do_init(ptls_cipher_context_t *_ctx, const void *iv)
ptls_cipher_algorithm_t vpp_crypto_aes256ctr
static int vpp_crypto_cipher_setup_crypto(ptls_cipher_context_t *_ctx, int is_enc, const void *key, const EVP_CIPHER *cipher, quicly_do_transform_fn do_transform)
void(* quicly_do_transform_fn)(ptls_cipher_context_t *, void *, const void *, size_t)
ptls_cipher_suite_t vpp_crypto_aes256gcmsha384
ptls_cipher_suite_t vpp_crypto_aes128gcmsha256
static vlib_main_t * vlib_get_main(void)
ptls_aead_algorithm_t vpp_crypto_aes256gcm
size_t vpp_crypto_aead_decrypt(ptls_aead_context_t *_ctx, void *_output, const void *input, size_t inlen, const void *iv, const void *aad, size_t aadlen)
ptls_aead_context_t super
vnet_crypto_main_t crypto_main
static int aes128ctr_setup_crypto(ptls_cipher_context_t *ctx, int is_enc, const void *key)
ptls_aead_algorithm_t vpp_crypto_aes128gcm