VSF Documented
hash.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_CRYPTO_HASH_H__
2#define __VSF_LINUX_CRYPTO_HASH_H__
3
4#include <linux/crypto.h>
5#include <linux/scatterlist.h>
6#include <linux/slab.h>
7#include <linux/string.h>
8
9struct crypto_ahash;
10
12 unsigned int digestsize;
14};
15
16struct shash_desc {
18};
19
20struct shash_alg {
21 unsigned int descsize;
22
23 union {
24 struct hash_alg_common;
26 };
27};
28
31};
32
33#define SHASH_DESC_ON_STACK(shash, ctx) \
34 char __##shash##_desc[sizeof(struct shash_desc) + sizeof(psa_hash_operation_t)]\
35 VSF_CAL_ALIGN(__alignof__(struct shash_desc));\
36 struct shash_desc *shash = (struct shash_desc *)__##shash##_desc
37
38static inline struct crypto_tfm *crypto_shash_tfm(struct crypto_shash *tfm)
39{
40 return &tfm->base;
41}
42
43static inline void *crypto_shash_ctx(struct crypto_shash *tfm)
44{
45 return crypto_tfm_ctx(&tfm->base);
46}
47
48static inline struct shash_alg *__crypto_shash_alg(struct crypto_alg *alg)
49{
50 return vsf_container_of(alg, struct shash_alg, base);
51}
52
53static inline struct shash_alg *crypto_shash_alg(struct crypto_shash *tfm)
54{
55 return __crypto_shash_alg(crypto_shash_tfm(tfm)->__crt_alg);
56}
57
58static inline unsigned int crypto_shash_descsize(struct crypto_shash *tfm)
59{
60 return crypto_shash_alg(tfm)->descsize;
61}
62
63static inline struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type, u32 mask)
64{
65 extern const struct crypto_type crypto_shash_type;
66 return (struct crypto_shash *)crypto_alloc_tfm(alg_name, &crypto_shash_type, type, mask);
67}
68
69static inline void crypto_free_shash(struct crypto_shash *tfm)
70{
71 crypto_destroy_tfm(tfm, crypto_shash_tfm(tfm));
72}
73
74int crypto_shash_init(struct shash_desc *desc);
75int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen);
76int crypto_shash_export(struct shash_desc *desc, void *out);
77int crypto_shash_import(struct shash_desc *desc, const void *in);
78int crypto_shash_finup(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out);
79int crypto_shash_update(struct shash_desc *desc, const u8 *data, unsigned int len);
80int crypto_shash_final(struct shash_desc *desc, u8 *out);
81
82static inline int crypto_shash_digest(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out)
83{
84 if (crypto_shash_init(desc) || crypto_shash_finup(desc, data, len, out)) {
85 return -EIO;
86 }
87 return 0;
88}
89
90static inline int crypto_shash_tfm_digest(struct crypto_shash *tfm, const u8 *data, unsigned int len, u8 *out)
91{
92 SHASH_DESC_ON_STACK(desc, tfm);
93 desc->tfm = tfm;
94 return crypto_shash_digest(desc, data, len, out);
95}
96
97#endif
#define vsf_container_of(__ptr, __type, __member)
Definition __type.h:164
void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
Definition vsf_linux_core_crypto.c:348
#define EIO
Definition errno.h:19
int crypto_shash_init(struct shash_desc *desc)
Definition vsf_linux_core_crypto.c:426
#define SHASH_DESC_ON_STACK(shash, ctx)
Definition hash.h:33
int crypto_shash_update(struct shash_desc *desc, const u8 *data, unsigned int len)
Definition vsf_linux_core_crypto.c:500
int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen)
Definition vsf_linux_core_crypto.c:407
int crypto_shash_finup(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out)
Definition vsf_linux_core_crypto.c:476
int crypto_shash_export(struct shash_desc *desc, void *out)
Definition vsf_linux_core_crypto.c:446
int crypto_shash_import(struct shash_desc *desc, const void *in)
Definition vsf_linux_core_crypto.c:461
int crypto_shash_final(struct shash_desc *desc, u8 *out)
Definition vsf_linux_core_crypto.c:519
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
uint8_t u8
Definition lvgl.h:40
uint32_t u32
Definition lvgl.h:43
Definition crypto.h:37
Definition hash.h:29
struct crypto_tfm base
Definition hash.h:30
Definition crypto.h:62
Definition internal.h:6
Definition hash.h:11
struct crypto_alg base
Definition hash.h:13
unsigned int digestsize
Definition hash.h:12
Definition hash.h:20
unsigned int descsize
Definition hash.h:21
struct hash_alg_common halg
Definition hash.h:25
Definition hash.h:16
struct crypto_shash * tfm
Definition hash.h:17
vk_av_control_type_t type
Definition vsf_audio.h:170
const struct crypto_type crypto_shash_type
Definition vsf_linux_core_crypto.c:66
Generated from commit: vsfteam/vsf@f33b89f