VSF Documented
akcipher.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_CRYPTO_AKCIPHER_H__
2#define __VSF_LINUX_CRYPTO_AKCIPHER_H__
3
4#include <linux/atomic.h>
5#include <linux/crypto.h>
6
9 struct scatterlist *src;
11 unsigned int src_len;
12 unsigned int dst_len;
13};
14
16 unsigned int reqsize;
18};
19
21 int (*set_pub_key)(struct crypto_akcipher *tfm, const void *key, unsigned int keylen);
22 int (*set_priv_key)(struct crypto_akcipher *tfm, const void *key, unsigned int keylen);
24};
25
26static inline struct crypto_tfm *crypto_akcipher_tfm(struct crypto_akcipher *tfm)
27{
28 return &tfm->base;
29}
30
31static inline struct akcipher_alg *crypto_akcipher_alg(struct crypto_akcipher *tfm)
32{
33 struct crypto_alg *alg = crypto_akcipher_tfm(tfm)->__crt_alg;
34 return vsf_container_of(alg, struct akcipher_alg, base);
35}
36
37static inline unsigned int crypto_akcipher_reqsize(struct crypto_akcipher *tfm)
38{
39 return tfm->reqsize;
40}
41
42static inline void akcipher_request_set_tfm(struct akcipher_request *req, struct crypto_akcipher *tfm)
43{
44 req->base.tfm = crypto_akcipher_tfm(tfm);
45}
46
47static inline struct crypto_akcipher *crypto_akcipher_reqtfm(struct akcipher_request *req)
48{
49 return vsf_container_of(req->base.tfm, struct crypto_akcipher, base);
50}
51
52static inline int crypto_akcipher_set_pub_key(struct crypto_akcipher *tfm, const void *key, unsigned int keylen)
53{
54 struct akcipher_alg *alg = crypto_akcipher_alg(tfm);
55 return alg->set_pub_key(tfm, key, keylen);
56}
57
58static inline int crypto_akcipher_set_priv_key(struct crypto_akcipher *tfm, const void *key, unsigned int keylen)
59{
60 struct akcipher_alg *alg = crypto_akcipher_alg(tfm);
61 return alg->set_priv_key(tfm, key, keylen);
62}
63
64static inline struct akcipher_request *akcipher_request_alloc(struct crypto_akcipher *tfm, gfp_t gfp)
65{
66 struct akcipher_request *req = kmalloc(sizeof(*req) + crypto_akcipher_reqsize(tfm), gfp);
67 if (req) { akcipher_request_set_tfm(req, tfm); }
68 return req;
69}
70
71static inline void akcipher_request_free(struct akcipher_request *req)
72{
73 kfree(req);
74}
75
76static inline void akcipher_request_set_callback(struct akcipher_request *req, u32 flgs, crypto_completion_t cmpl, void *data)
77{
78 req->base.complete = cmpl;
79 req->base.data = data;
80 req->base.flags = flgs;
81}
82
83static inline void akcipher_request_set_crypt(struct akcipher_request *req, struct scatterlist *src, struct scatterlist *dst, unsigned int src_len, unsigned int dst_len)
84{
85 req->src = src;
86 req->dst = dst;
87 req->src_len = src_len;
88 req->dst_len = dst_len;
89}
90
92
93static inline void crypto_free_akcipher(struct crypto_akcipher *tfm)
94{
95 crypto_destroy_tfm(tfm, crypto_akcipher_tfm(tfm));
96}
97
98static inline struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type, u32 mask)
99{
100 extern const struct crypto_type crypto_akcipher_type;
101 struct crypto_akcipher *tfm = crypto_alloc_tfm(alg_name, &crypto_akcipher_type, type, mask);
102 if (!IS_ERR(tfm)) {
103 tfm->reqsize = sizeof(struct akcipher_request);
104 }
105 return tfm;
106}
107
108#endif
#define vsf_container_of(__ptr, __type, __member)
Definition __type.h:164
int crypto_akcipher_encrypt(struct akcipher_request *req)
Definition vsf_linux_core_crypto.c:569
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
unsigned int gfp_t
Definition gfp.h:10
struct ieee80211_ext_chansw_ie data
Definition ieee80211.h:80
void * crypto_alloc_tfm(const char *alg_name, const struct crypto_type *frontend, u32 type, u32 mask)
Definition vsf_linux_core_crypto.c:327
uint32_t u32
Definition lvgl.h:43
Definition akcipher.h:20
struct crypto_alg base
Definition akcipher.h:23
int(* set_priv_key)(struct crypto_akcipher *tfm, const void *key, unsigned int keylen)
Definition akcipher.h:22
int(* set_pub_key)(struct crypto_akcipher *tfm, const void *key, unsigned int keylen)
Definition akcipher.h:21
Definition akcipher.h:7
struct crypto_async_request base
Definition akcipher.h:8
unsigned int src_len
Definition akcipher.h:11
struct scatterlist * src
Definition akcipher.h:9
struct scatterlist * dst
Definition akcipher.h:10
unsigned int dst_len
Definition akcipher.h:12
Definition akcipher.h:15
struct crypto_tfm base
Definition akcipher.h:17
unsigned int reqsize
Definition akcipher.h:16
Definition crypto.h:37
psa_algorithm_t alg
Definition crypto.h:47
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:62
struct crypto_alg * __crt_alg
Definition crypto.h:63
Definition internal.h:6
Definition scatterlist.h:4
vk_av_control_type_t type
Definition vsf_audio.h:170
const struct crypto_type crypto_akcipher_type
Definition vsf_linux_core_crypto.c:71
Generated from commit: vsfteam/vsf@f33b89f