~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/crypto/internal/akcipher.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php