wireguard: add dos mitigation support
[vpp.git] / src / plugins / wireguard / wireguard_chachapoly.h
1 /*
2  * Copyright (c) 2022 Rubicon Communications, LLC.
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_wg_chachapoly_h__
17 #define __included_wg_chachapoly_h__
18
19 #include <vlib/vlib.h>
20 #include <vnet/crypto/crypto.h>
21
22 #define XCHACHA20POLY1305_NONCE_SIZE 24
23 #define CHACHA20POLY1305_KEY_SIZE    32
24
25 bool wg_chacha20poly1305_calc (vlib_main_t *vm, u8 *src, u32 src_len, u8 *dst,
26                                u8 *aad, u32 aad_len, u64 nonce,
27                                vnet_crypto_op_id_t op_id,
28                                vnet_crypto_key_index_t key_index);
29
30 void wg_xchacha20poly1305_encrypt (vlib_main_t *vm, u8 *src, u32 src_len,
31                                    u8 *dst, u8 *aad, u32 aad_len,
32                                    u8 nonce[XCHACHA20POLY1305_NONCE_SIZE],
33                                    u8 key[CHACHA20POLY1305_KEY_SIZE]);
34
35 bool wg_xchacha20poly1305_decrypt (vlib_main_t *vm, u8 *src, u32 src_len,
36                                    u8 *dst, u8 *aad, u32 aad_len,
37                                    u8 nonce[XCHACHA20POLY1305_NONCE_SIZE],
38                                    u8 key[CHACHA20POLY1305_KEY_SIZE]);
39
40 #endif /* __included_wg_chachapoly_h__ */
41
42 /*
43  * fd.io coding-style-patch-verification: ON
44  *
45  * Local Variables:
46  * eval: (c-set-style "gnu")
47  * End:
48  */