• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Key-agreement Protocol Primitives (KPP)
4  *
5  * Copyright (c) 2016, Intel Corporation
6  * Authors: Salvatore Benedetto <salvatore.benedetto@intel.com>
7  */
8 #ifndef _CRYPTO_KPP_INT_H
9 #define _CRYPTO_KPP_INT_H
10 #include <crypto/kpp.h>
11 #include <crypto/algapi.h>
12 
13 /*
14  * Transform internal helpers.
15  */
kpp_request_ctx(struct kpp_request * req)16 static inline void *kpp_request_ctx(struct kpp_request *req)
17 {
18 	return req->__ctx;
19 }
20 
kpp_set_reqsize(struct crypto_kpp * kpp,unsigned int reqsize)21 static inline void kpp_set_reqsize(struct crypto_kpp *kpp,
22 				   unsigned int reqsize)
23 {
24 	crypto_kpp_alg(kpp)->reqsize = reqsize;
25 }
26 
kpp_tfm_ctx(struct crypto_kpp * tfm)27 static inline void *kpp_tfm_ctx(struct crypto_kpp *tfm)
28 {
29 	return tfm->base.__crt_ctx;
30 }
31 
kpp_request_complete(struct kpp_request * req,int err)32 static inline void kpp_request_complete(struct kpp_request *req, int err)
33 {
34 	req->base.complete(&req->base, err);
35 }
36 
kpp_alg_name(struct crypto_kpp * tfm)37 static inline const char *kpp_alg_name(struct crypto_kpp *tfm)
38 {
39 	return crypto_kpp_tfm(tfm)->__crt_alg->cra_name;
40 }
41 
42 /**
43  * crypto_register_kpp() -- Register key-agreement protocol primitives algorithm
44  *
45  * Function registers an implementation of a key-agreement protocol primitive
46  * algorithm
47  *
48  * @alg:	algorithm definition
49  *
50  * Return: zero on success; error code in case of error
51  */
52 int crypto_register_kpp(struct kpp_alg *alg);
53 
54 /**
55  * crypto_unregister_kpp() -- Unregister key-agreement protocol primitive
56  * algorithm
57  *
58  * Function unregisters an implementation of a key-agreement protocol primitive
59  * algorithm
60  *
61  * @alg:	algorithm definition
62  */
63 void crypto_unregister_kpp(struct kpp_alg *alg);
64 
65 #endif
66