Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / crypto / internal / sig.h
blobb16648c1a986f59fd449727f5f164a9f4a945189
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * Public Key Signature Algorithm
5 * Copyright (c) 2023 Herbert Xu <herbert@gondor.apana.org.au>
6 */
7 #ifndef _CRYPTO_INTERNAL_SIG_H
8 #define _CRYPTO_INTERNAL_SIG_H
10 #include <crypto/algapi.h>
11 #include <crypto/sig.h>
13 struct sig_instance {
14 void (*free)(struct sig_instance *inst);
15 union {
16 struct {
17 char head[offsetof(struct sig_alg, base)];
18 struct crypto_instance base;
20 struct sig_alg alg;
24 struct crypto_sig_spawn {
25 struct crypto_spawn base;
28 static inline void *crypto_sig_ctx(struct crypto_sig *tfm)
30 return crypto_tfm_ctx(&tfm->base);
33 /**
34 * crypto_register_sig() -- Register public key signature algorithm
36 * Function registers an implementation of a public key signature algorithm
38 * @alg: algorithm definition
40 * Return: zero on success; error code in case of error
42 int crypto_register_sig(struct sig_alg *alg);
44 /**
45 * crypto_unregister_sig() -- Unregister public key signature algorithm
47 * Function unregisters an implementation of a public key signature algorithm
49 * @alg: algorithm definition
51 void crypto_unregister_sig(struct sig_alg *alg);
53 int sig_register_instance(struct crypto_template *tmpl,
54 struct sig_instance *inst);
56 static inline struct sig_instance *sig_instance(struct crypto_instance *inst)
58 return container_of(&inst->alg, struct sig_instance, alg.base);
61 static inline struct sig_instance *sig_alg_instance(struct crypto_sig *tfm)
63 return sig_instance(crypto_tfm_alg_instance(&tfm->base));
66 static inline struct crypto_instance *sig_crypto_instance(struct sig_instance
67 *inst)
69 return container_of(&inst->alg.base, struct crypto_instance, alg);
72 static inline void *sig_instance_ctx(struct sig_instance *inst)
74 return crypto_instance_ctx(sig_crypto_instance(inst));
77 int crypto_grab_sig(struct crypto_sig_spawn *spawn,
78 struct crypto_instance *inst,
79 const char *name, u32 type, u32 mask);
81 static inline struct crypto_sig *crypto_spawn_sig(struct crypto_sig_spawn
82 *spawn)
84 return crypto_spawn_tfm2(&spawn->base);
87 static inline void crypto_drop_sig(struct crypto_sig_spawn *spawn)
89 crypto_drop_spawn(&spawn->base);
92 static inline struct sig_alg *crypto_spawn_sig_alg(struct crypto_sig_spawn
93 *spawn)
95 return container_of(spawn->base.alg, struct sig_alg, base);
97 #endif