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)
148 if (!strcmp (ctx->
super.algo->name,
"AES128-GCM"))
150 id = VNET_CRYPTO_OP_AES_128_GCM_ENC;
152 else if (!strcmp (ctx->
super.algo->name,
"AES256-GCM"))
154 id = VNET_CRYPTO_OP_AES_256_GCM_ENC;
167 ctx->
op.
dst = output;
181 const void *input,
size_t inlen,
const void *
iv,
182 const void *aad,
size_t aadlen)
188 if (!strcmp (ctx->
super.algo->name,
"AES128-GCM"))
190 id = VNET_CRYPTO_OP_AES_128_GCM_DEC;
192 else if (!strcmp (ctx->
super.algo->name,
"AES256-GCM"))
194 id = VNET_CRYPTO_OP_AES_256_GCM_DEC;
207 ctx->
op.
dst = _output;
209 ctx->
op.
len = inlen - ctx->
super.algo->tag_size;
227 const void *
key,
const EVP_CIPHER * cipher)
233 if (!strcmp (ctx->
super.algo->name,
"AES128-GCM"))
235 algo = VNET_CRYPTO_ALG_AES_128_GCM;
237 else if (!strcmp (ctx->
super.algo->name,
"AES256-GCM"))
239 algo = VNET_CRYPTO_ALG_AES_256_GCM;
243 QUIC_DBG (1,
"%s, invalied aead cipher %s", __FUNCTION__,
253 (
u8 *) key, _ctx->algo->key_size);
260 int is_enc,
const void *
key)
267 int is_enc,
const void *
key)
273 PTLS_AES128_KEY_SIZE,
276 aes128ctr_setup_crypto
279 ptls_cipher_algorithm_t quic_crypto_aes256ctr = {
"AES256-CTR",
280 PTLS_AES256_KEY_SIZE,
284 aes256ctr_setup_crypto
287 ptls_aead_algorithm_t quic_crypto_aes128gcm = {
"AES128-GCM",
290 PTLS_AES128_KEY_SIZE,
292 PTLS_AESGCM_TAG_SIZE,
294 quic_crypto_aead_aes128gcm_setup_crypto
297 ptls_aead_algorithm_t quic_crypto_aes256gcm = {
"AES256-GCM",
300 PTLS_AES256_KEY_SIZE,
302 PTLS_AESGCM_TAG_SIZE,
304 quic_crypto_aead_aes256gcm_setup_crypto
307 ptls_cipher_suite_t quic_crypto_aes128gcmsha256 =
308 { PTLS_CIPHER_SUITE_AES_128_GCM_SHA256,
313 ptls_cipher_suite_t quic_crypto_aes256gcmsha384 =
314 { PTLS_CIPHER_SUITE_AES_256_GCM_SHA384,
319 ptls_cipher_suite_t *quic_crypto_cipher_suites[] =
u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
ptls_cipher_context_t super
static int aes256ctr_setup_crypto(ptls_cipher_context_t *ctx, int is_enc, const void *key)
size_t quic_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)
#define QUIC_DBG(_lvl, _fmt, _args...)
static_always_inline void vnet_crypto_op_init(vnet_crypto_op_t *op, vnet_crypto_op_id_t type)
ptls_cipher_algorithm_t quic_crypto_aes128ctr
static int quic_crypto_aead_setup_crypto(ptls_aead_context_t *_ctx, int is_enc, const void *key, const EVP_CIPHER *cipher)
static int quic_crypto_aead_aes256gcm_setup_crypto(ptls_aead_context_t *ctx, int is_enc, const void *key)
u32 vnet_crypto_key_add(vlib_main_t *vm, vnet_crypto_alg_t alg, u8 *data, u16 length)
ptls_cipher_suite_t quic_crypto_aes256gcmsha384
static int quic_crypto_aead_aes128gcm_setup_crypto(ptls_aead_context_t *ctx, int is_enc, const void *key)
size_t quic_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)
void(* quicly_do_transform_fn)(ptls_cipher_context_t *, void *, const void *, size_t)
ptls_cipher_suite_t quic_crypto_aes128gcmsha256
static void quic_crypto_cipher_do_init(ptls_cipher_context_t *_ctx, const void *iv)
static vlib_main_t * vlib_get_main(void)
static void quic_crypto_aead_dispose_crypto(ptls_aead_context_t *_ctx)
ptls_cipher_algorithm_t quic_crypto_aes256ctr
static void quic_crypto_cipher_dispose(ptls_cipher_context_t *_ctx)
ptls_aead_algorithm_t quic_crypto_aes256gcm
ptls_aead_context_t super
vnet_crypto_main_t crypto_main
static int quic_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)
ptls_aead_algorithm_t quic_crypto_aes128gcm
static int aes128ctr_setup_crypto(ptls_cipher_context_t *ctx, int is_enc, const void *key)
static void quic_crypto_cipher_encrypt(ptls_cipher_context_t *_ctx, void *output, const void *input, size_t _len)