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)  * Public Key Encryption
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2015, Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Authors: Tadeusz Struk <tadeusz.struk@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #ifndef _CRYPTO_AKCIPHER_INT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #define _CRYPTO_AKCIPHER_INT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <crypto/akcipher.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <crypto/algapi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) struct akcipher_instance {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	void (*free)(struct akcipher_instance *inst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 			char head[offsetof(struct akcipher_alg, base)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 			struct crypto_instance base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 		} s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 		struct akcipher_alg alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) struct crypto_akcipher_spawn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	struct crypto_spawn base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * Transform internal helpers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static inline void *akcipher_request_ctx(struct akcipher_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	return req->__ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static inline void akcipher_set_reqsize(struct crypto_akcipher *akcipher,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 					unsigned int reqsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	crypto_akcipher_alg(akcipher)->reqsize = reqsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static inline void *akcipher_tfm_ctx(struct crypto_akcipher *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	return tfm->base.__crt_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static inline void akcipher_request_complete(struct akcipher_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 					     int err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	req->base.complete(&req->base, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static inline const char *akcipher_alg_name(struct crypto_akcipher *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	return crypto_akcipher_tfm(tfm)->__crt_alg->cra_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static inline struct crypto_instance *akcipher_crypto_instance(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		struct akcipher_instance *inst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	return container_of(&inst->alg.base, struct crypto_instance, alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static inline struct akcipher_instance *akcipher_instance(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		struct crypto_instance *inst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	return container_of(&inst->alg, struct akcipher_instance, alg.base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) static inline struct akcipher_instance *akcipher_alg_instance(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		struct crypto_akcipher *akcipher)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	return akcipher_instance(crypto_tfm_alg_instance(&akcipher->base));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) static inline void *akcipher_instance_ctx(struct akcipher_instance *inst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	return crypto_instance_ctx(akcipher_crypto_instance(inst));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) int crypto_grab_akcipher(struct crypto_akcipher_spawn *spawn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			 struct crypto_instance *inst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			 const char *name, u32 type, u32 mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static inline struct crypto_akcipher *crypto_spawn_akcipher(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		struct crypto_akcipher_spawn *spawn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	return crypto_spawn_tfm2(&spawn->base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) static inline void crypto_drop_akcipher(struct crypto_akcipher_spawn *spawn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	crypto_drop_spawn(&spawn->base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) static inline struct akcipher_alg *crypto_spawn_akcipher_alg(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		struct crypto_akcipher_spawn *spawn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return container_of(spawn->base.alg, struct akcipher_alg, base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * crypto_register_akcipher() -- Register public key algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * Function registers an implementation of a public key verify algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * @alg:	algorithm definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * Return: zero on success; error code in case of error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int crypto_register_akcipher(struct akcipher_alg *alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * crypto_unregister_akcipher() -- Unregister public key algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * Function unregisters an implementation of a public key verify algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  * @alg:	algorithm definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) void crypto_unregister_akcipher(struct akcipher_alg *alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * akcipher_register_instance() -- Unregister public key template instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * Function registers an implementation of an asymmetric key algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * created from a template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * @tmpl:	the template from which the algorithm was created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * @inst:	the template instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int akcipher_register_instance(struct crypto_template *tmpl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		struct akcipher_instance *inst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #endif