1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
3 #ifndef _BPF_CRYPTO_H
4 #define _BPF_CRYPTO_H
5 
6 struct bpf_crypto_type {
7 	void *(*alloc_tfm)(const char *algo);
8 	void (*free_tfm)(void *tfm);
9 	int (*has_algo)(const char *algo);
10 	int (*setkey)(void *tfm, const u8 *key, unsigned int keylen);
11 	int (*setauthsize)(void *tfm, unsigned int authsize);
12 	int (*encrypt)(void *tfm, const u8 *src, u8 *dst, unsigned int len, u8 *iv);
13 	int (*decrypt)(void *tfm, const u8 *src, u8 *dst, unsigned int len, u8 *iv);
14 	unsigned int (*ivsize)(void *tfm);
15 	unsigned int (*statesize)(void *tfm);
16 	u32 (*get_flags)(void *tfm);
17 	struct module *owner;
18 	char name[14];
19 };
20 
21 int bpf_crypto_register_type(const struct bpf_crypto_type *type);
22 int bpf_crypto_unregister_type(const struct bpf_crypto_type *type);
23 
24 #endif /* _BPF_CRYPTO_H */
25