Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Cryptographic API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #ifndef _CRYPTO_INTERNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #define _CRYPTO_INTERNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <crypto/algapi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/completion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/numa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/refcount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/rwsem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) struct crypto_instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) struct crypto_template;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) struct crypto_larval {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct crypto_alg alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	struct crypto_alg *adult;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	struct completion completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	u32 mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) extern struct list_head crypto_alg_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) extern struct rw_semaphore crypto_alg_sem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) extern struct blocking_notifier_head crypto_chain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #ifdef CONFIG_PROC_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) void __init crypto_init_proc(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) void __exit crypto_exit_proc(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) static inline void crypto_init_proc(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static inline void crypto_exit_proc(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	return alg->cra_ctxsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) static inline unsigned int crypto_compress_ctxsize(struct crypto_alg *alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	return alg->cra_ctxsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) struct crypto_alg *crypto_mod_get(struct crypto_alg *alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) struct crypto_larval *crypto_larval_alloc(const char *name, u32 type, u32 mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) void crypto_larval_kill(struct crypto_alg *alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) void crypto_alg_tested(const char *name, int err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			  struct crypto_alg *nalg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) void crypto_remove_final(struct list_head *list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) void crypto_shoot_alg(struct crypto_alg *alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 				      u32 mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) void *crypto_create_tfm_node(struct crypto_alg *alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			const struct crypto_type *frontend, int node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) static inline void *crypto_create_tfm(struct crypto_alg *alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			const struct crypto_type *frontend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	return crypto_create_tfm_node(alg, frontend, NUMA_NO_NODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) struct crypto_alg *crypto_find_alg(const char *alg_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 				   const struct crypto_type *frontend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 				   u32 type, u32 mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) void *crypto_alloc_tfm_node(const char *alg_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		       const struct crypto_type *frontend, u32 type, u32 mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		       int node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) static inline void *crypto_alloc_tfm(const char *alg_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		       const struct crypto_type *frontend, u32 type, u32 mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	return crypto_alloc_tfm_node(alg_name, frontend, type, mask, NUMA_NO_NODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) int crypto_probing_notify(unsigned long val, void *v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) unsigned int crypto_alg_extsize(struct crypto_alg *alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) int crypto_type_has_alg(const char *name, const struct crypto_type *frontend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			u32 type, u32 mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	refcount_inc(&alg->cra_refcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	return alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static inline void crypto_alg_put(struct crypto_alg *alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	if (refcount_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		alg->cra_destroy(alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static inline int crypto_tmpl_get(struct crypto_template *tmpl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	return try_module_get(tmpl->module);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static inline void crypto_tmpl_put(struct crypto_template *tmpl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	module_put(tmpl->module);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static inline int crypto_is_larval(struct crypto_alg *alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	return alg->cra_flags & CRYPTO_ALG_LARVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static inline int crypto_is_dead(struct crypto_alg *alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	return alg->cra_flags & CRYPTO_ALG_DEAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static inline int crypto_is_moribund(struct crypto_alg *alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	return alg->cra_flags & (CRYPTO_ALG_DEAD | CRYPTO_ALG_DYING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static inline void crypto_notify(unsigned long val, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	blocking_notifier_call_chain(&crypto_chain, val, v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static inline void crypto_yield(u32 flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	if (flags & CRYPTO_TFM_REQ_MAY_SLEEP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		cond_resched();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #endif	/* _CRYPTO_INTERNAL_H */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)