VSF Documented
crypto.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_CRYPTO_H__
2#define __VSF_LINUX_CRYPTO_H__
3
4#include <linux/completion.h>
5#include <linux/types.h>
6#include <linux/slab.h>
7
8#include <psa/crypto.h>
9
10#define CRYPTO_ALG_TYPE_MASK 0x0000000f
11#define CRYPTO_ALG_TYPE_CIPHER 0x00000001
12#define CRYPTO_ALG_TYPE_AEAD 0x00000003
13#define CRYPTO_ALG_TYPE_LSKCIPHER 0x00000004
14#define CRYPTO_ALG_TYPE_SKCIPHER 0x00000005
15#define CRYPTO_ALG_TYPE_AKCIPHER 0x00000006
16#define CRYPTO_ALG_TYPE_SIG 0x00000007
17#define CRYPTO_ALG_TYPE_KPP 0x00000008
18#define CRYPTO_ALG_TYPE_ACOMPRESS 0x0000000a
19#define CRYPTO_ALG_TYPE_SCOMPRESS 0x0000000b
20#define CRYPTO_ALG_TYPE_RNG 0x0000000c
21#define CRYPTO_ALG_TYPE_HASH 0x0000000e
22#define CRYPTO_ALG_TYPE_SHASH 0x0000000e
23#define CRYPTO_ALG_TYPE_AHASH 0x0000000f
24
25#define CRYPTO_TFM_REQ_MAY_BACKLOG 0x00000400
26
27typedef void (*crypto_completion_t)(void *req, int err);
28
29struct crypto_tfm;
32 void *data;
33 struct crypto_tfm *tfm;
35};
36
37struct crypto_alg {
39
40 unsigned int cra_blocksize;
41 unsigned int cra_ctxsize;
42 const char *cra_name;
43
44 void (*cra_init)(struct crypto_tfm *tfm);
45 void (*cra_exit)(struct crypto_tfm *tfm);
46
47 psa_algorithm_t alg;
48};
49
50struct crypto_template;
53 struct crypto_alg *alg;
54};
55
58 int (*crate)(struct crypto_template *tmpl, struct crypto_alg_tree *arg);
59 const char *name;
60};
61
62struct crypto_tfm {
64 void *__crt_ctx[];
65};
66
69 int err;
70};
71#define DECLARE_CRYPTO_WAIT(_wait) \
72 struct crypto_wait _wait; \
73 init_completion(&_wait.completion)
74
75struct crypto_type;
76void *crypto_alloc_tfm(const char *alg_name, const struct crypto_type *frontend, u32 type, u32 mask);
77void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm);
78
79static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
80{
81 return tfm->__crt_ctx;
82}
83
84void crypto_req_done(void *req, int err);
85static inline int crypto_wait_req(int err, struct crypto_wait *wait)
86{
87 switch (err) {
88 case -EINPROGRESS:
89 case -EBUSY:
90 wait_for_completion(&wait->completion);
91 reinit_completion(&wait->completion);
92 err = wait->err;
93 break;
94 }
95 return err;
96}
97
98static inline void crypto_free_tfm(struct crypto_tfm *tfm)
99{
100 return crypto_destroy_tfm(tfm, tfm);
101}
102
103int vsf_linux_crypto_init(void);
104
105#endif
void * crypto_alloc_tfm(const char *alg_name, const struct crypto_type *frontend, u32 type, u32 mask)
Definition vsf_linux_core_crypto.c:327
void crypto_req_done(void *req, int err)
Definition vsf_linux_core_crypto.c:357
int vsf_linux_crypto_init(void)
Definition vsf_linux_core_crypto.c:818
void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
Definition vsf_linux_core_crypto.c:348
void(* crypto_completion_t)(void *req, int err)
Definition crypto.h:27
#define EINPROGRESS
Definition errno.h:130
#define EBUSY
Definition errno.h:30
uint32_t u32
Definition lvgl.h:43
Definition completion.h:6
Definition crypto.h:51
struct crypto_alg * alg
Definition crypto.h:53
struct crypto_alg_tree * next
Definition crypto.h:52
Definition crypto.h:37
void(* cra_exit)(struct crypto_tfm *tfm)
Definition crypto.h:45
vsf_dlist_node_t node
Definition crypto.h:38
const char * cra_name
Definition crypto.h:42
psa_algorithm_t alg
Definition crypto.h:47
unsigned int cra_blocksize
Definition crypto.h:40
unsigned int cra_ctxsize
Definition crypto.h:41
void(* cra_init)(struct crypto_tfm *tfm)
Definition crypto.h:44
Definition crypto.h:30
crypto_completion_t complete
Definition crypto.h:31
u32 flags
Definition crypto.h:34
void * data
Definition crypto.h:32
struct crypto_tfm * tfm
Definition crypto.h:33
Definition crypto.h:56
vsf_dlist_node_t node
Definition crypto.h:57
const char * name
Definition crypto.h:59
int(* crate)(struct crypto_template *tmpl, struct crypto_alg_tree *arg)
Definition crypto.h:58
Definition crypto.h:62
struct crypto_alg * __crt_alg
Definition crypto.h:63
void * __crt_ctx[]
Definition crypto.h:64
Definition internal.h:6
Definition crypto.h:67
int err
Definition crypto.h:69
Definition vsf_list.h:888
pid_t wait(int *status)
Definition vsf_linux.c:2752
vk_av_control_type_t type
Definition vsf_audio.h:170
Generated from commit: vsfteam/vsf@f33b89f