Linux Audio

Check our new training course

Loading...
v6.8
  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
  9#ifndef _CRYPTO_KPP_
 10#define _CRYPTO_KPP_
 11
 12#include <linux/atomic.h>
 13#include <linux/container_of.h>
 14#include <linux/crypto.h>
 15#include <linux/slab.h>
 16
 17/**
 18 * struct kpp_request
 19 *
 20 * @base:	Common attributes for async crypto requests
 21 * @src:	Source data
 22 * @dst:	Destination data
 23 * @src_len:	Size of the input buffer
 24 * @dst_len:	Size of the output buffer. It needs to be at least
 25 *		as big as the expected result depending	on the operation
 26 *		After operation it will be updated with the actual size of the
 27 *		result. In case of error where the dst sgl size was insufficient,
 28 *		it will be updated to the size required for the operation.
 29 * @__ctx:	Start of private context data
 30 */
 31struct kpp_request {
 32	struct crypto_async_request base;
 33	struct scatterlist *src;
 34	struct scatterlist *dst;
 35	unsigned int src_len;
 36	unsigned int dst_len;
 37	void *__ctx[] CRYPTO_MINALIGN_ATTR;
 38};
 39
 40/**
 41 * struct crypto_kpp - user-instantiated object which encapsulate
 42 * algorithms and core processing logic
 43 *
 44 * @reqsize:		Request context size required by algorithm
 45 *			implementation
 46 * @base:	Common crypto API algorithm data structure
 47 */
 48struct crypto_kpp {
 49	unsigned int reqsize;
 50
 51	struct crypto_tfm base;
 52};
 53
 54/*
 55 * struct crypto_istat_kpp - statistics for KPP algorithm
 56 * @setsecret_cnt:		number of setsecrey operation
 57 * @generate_public_key_cnt:	number of generate_public_key operation
 58 * @compute_shared_secret_cnt:	number of compute_shared_secret operation
 59 * @err_cnt:			number of error for KPP requests
 60 */
 61struct crypto_istat_kpp {
 62	atomic64_t setsecret_cnt;
 63	atomic64_t generate_public_key_cnt;
 64	atomic64_t compute_shared_secret_cnt;
 65	atomic64_t err_cnt;
 66};
 67
 68/**
 69 * struct kpp_alg - generic key-agreement protocol primitives
 70 *
 71 * @set_secret:		Function invokes the protocol specific function to
 72 *			store the secret private key along with parameters.
 73 *			The implementation knows how to decode the buffer
 74 * @generate_public_key: Function generate the public key to be sent to the
 75 *			counterpart. In case of error, where output is not big
 76 *			enough req->dst_len will be updated to the size
 77 *			required
 78 * @compute_shared_secret: Function compute the shared secret as defined by
 79 *			the algorithm. The result is given back to the user.
 80 *			In case of error, where output is not big enough,
 81 *			req->dst_len will be updated to the size required
 82 * @max_size:		Function returns the size of the output buffer
 83 * @init:		Initialize the object. This is called only once at
 84 *			instantiation time. In case the cryptographic hardware
 85 *			needs to be initialized. Software fallback should be
 86 *			put in place here.
 87 * @exit:		Undo everything @init did.
 88 *
 
 
 89 * @base:		Common crypto API algorithm data structure
 90 * @stat:		Statistics for KPP algorithm
 91 */
 92struct kpp_alg {
 93	int (*set_secret)(struct crypto_kpp *tfm, const void *buffer,
 94			  unsigned int len);
 95	int (*generate_public_key)(struct kpp_request *req);
 96	int (*compute_shared_secret)(struct kpp_request *req);
 97
 98	unsigned int (*max_size)(struct crypto_kpp *tfm);
 99
100	int (*init)(struct crypto_kpp *tfm);
101	void (*exit)(struct crypto_kpp *tfm);
102
103#ifdef CONFIG_CRYPTO_STATS
104	struct crypto_istat_kpp stat;
105#endif
106
107	struct crypto_alg base;
108};
109
110/**
111 * DOC: Generic Key-agreement Protocol Primitives API
112 *
113 * The KPP API is used with the algorithm type
114 * CRYPTO_ALG_TYPE_KPP (listed as type "kpp" in /proc/crypto)
115 */
116
117/**
118 * crypto_alloc_kpp() - allocate KPP tfm handle
119 * @alg_name: is the name of the kpp algorithm (e.g. "dh", "ecdh")
120 * @type: specifies the type of the algorithm
121 * @mask: specifies the mask for the algorithm
122 *
123 * Allocate a handle for kpp algorithm. The returned struct crypto_kpp
124 * is required for any following API invocation
125 *
126 * Return: allocated handle in case of success; IS_ERR() is true in case of
127 *	   an error, PTR_ERR() returns the error code.
128 */
129struct crypto_kpp *crypto_alloc_kpp(const char *alg_name, u32 type, u32 mask);
130
131int crypto_has_kpp(const char *alg_name, u32 type, u32 mask);
132
133static inline struct crypto_tfm *crypto_kpp_tfm(struct crypto_kpp *tfm)
134{
135	return &tfm->base;
136}
137
138static inline struct kpp_alg *__crypto_kpp_alg(struct crypto_alg *alg)
139{
140	return container_of(alg, struct kpp_alg, base);
141}
142
143static inline struct crypto_kpp *__crypto_kpp_tfm(struct crypto_tfm *tfm)
144{
145	return container_of(tfm, struct crypto_kpp, base);
146}
147
148static inline struct kpp_alg *crypto_kpp_alg(struct crypto_kpp *tfm)
149{
150	return __crypto_kpp_alg(crypto_kpp_tfm(tfm)->__crt_alg);
151}
152
153static inline unsigned int crypto_kpp_reqsize(struct crypto_kpp *tfm)
154{
155	return tfm->reqsize;
156}
157
158static inline void kpp_request_set_tfm(struct kpp_request *req,
159				       struct crypto_kpp *tfm)
160{
161	req->base.tfm = crypto_kpp_tfm(tfm);
162}
163
164static inline struct crypto_kpp *crypto_kpp_reqtfm(struct kpp_request *req)
165{
166	return __crypto_kpp_tfm(req->base.tfm);
167}
168
169static inline u32 crypto_kpp_get_flags(struct crypto_kpp *tfm)
170{
171	return crypto_tfm_get_flags(crypto_kpp_tfm(tfm));
172}
173
174static inline void crypto_kpp_set_flags(struct crypto_kpp *tfm, u32 flags)
175{
176	crypto_tfm_set_flags(crypto_kpp_tfm(tfm), flags);
177}
178
179/**
180 * crypto_free_kpp() - free KPP tfm handle
181 *
182 * @tfm: KPP tfm handle allocated with crypto_alloc_kpp()
183 *
184 * If @tfm is a NULL or error pointer, this function does nothing.
185 */
186static inline void crypto_free_kpp(struct crypto_kpp *tfm)
187{
188	crypto_destroy_tfm(tfm, crypto_kpp_tfm(tfm));
189}
190
191/**
192 * kpp_request_alloc() - allocates kpp request
193 *
194 * @tfm:	KPP tfm handle allocated with crypto_alloc_kpp()
195 * @gfp:	allocation flags
196 *
197 * Return: allocated handle in case of success or NULL in case of an error.
198 */
199static inline struct kpp_request *kpp_request_alloc(struct crypto_kpp *tfm,
200						    gfp_t gfp)
201{
202	struct kpp_request *req;
203
204	req = kmalloc(sizeof(*req) + crypto_kpp_reqsize(tfm), gfp);
205	if (likely(req))
206		kpp_request_set_tfm(req, tfm);
207
208	return req;
209}
210
211/**
212 * kpp_request_free() - zeroize and free kpp request
213 *
214 * @req:	request to free
215 */
216static inline void kpp_request_free(struct kpp_request *req)
217{
218	kfree_sensitive(req);
219}
220
221/**
222 * kpp_request_set_callback() - Sets an asynchronous callback.
223 *
224 * Callback will be called when an asynchronous operation on a given
225 * request is finished.
226 *
227 * @req:	request that the callback will be set for
228 * @flgs:	specify for instance if the operation may backlog
229 * @cmpl:	callback which will be called
230 * @data:	private data used by the caller
231 */
232static inline void kpp_request_set_callback(struct kpp_request *req,
233					    u32 flgs,
234					    crypto_completion_t cmpl,
235					    void *data)
236{
237	req->base.complete = cmpl;
238	req->base.data = data;
239	req->base.flags = flgs;
240}
241
242/**
243 * kpp_request_set_input() - Sets input buffer
244 *
245 * Sets parameters required by generate_public_key
246 *
247 * @req:	kpp request
248 * @input:	ptr to input scatter list
249 * @input_len:	size of the input scatter list
250 */
251static inline void kpp_request_set_input(struct kpp_request *req,
252					 struct scatterlist *input,
253					 unsigned int input_len)
254{
255	req->src = input;
256	req->src_len = input_len;
257}
258
259/**
260 * kpp_request_set_output() - Sets output buffer
261 *
262 * Sets parameters required by kpp operation
263 *
264 * @req:	kpp request
265 * @output:	ptr to output scatter list
266 * @output_len:	size of the output scatter list
267 */
268static inline void kpp_request_set_output(struct kpp_request *req,
269					  struct scatterlist *output,
270					  unsigned int output_len)
271{
272	req->dst = output;
273	req->dst_len = output_len;
274}
275
276enum {
277	CRYPTO_KPP_SECRET_TYPE_UNKNOWN,
278	CRYPTO_KPP_SECRET_TYPE_DH,
279	CRYPTO_KPP_SECRET_TYPE_ECDH,
280};
281
282/**
283 * struct kpp_secret - small header for packing secret buffer
284 *
285 * @type:	define type of secret. Each kpp type will define its own
286 * @len:	specify the len of the secret, include the header, that
287 *		follows the struct
288 */
289struct kpp_secret {
290	unsigned short type;
291	unsigned short len;
292};
293
294static inline struct crypto_istat_kpp *kpp_get_stat(struct kpp_alg *alg)
295{
296#ifdef CONFIG_CRYPTO_STATS
297	return &alg->stat;
298#else
299	return NULL;
300#endif
301}
302
303static inline int crypto_kpp_errstat(struct kpp_alg *alg, int err)
304{
305	if (!IS_ENABLED(CONFIG_CRYPTO_STATS))
306		return err;
307
308	if (err && err != -EINPROGRESS && err != -EBUSY)
309		atomic64_inc(&kpp_get_stat(alg)->err_cnt);
310
311	return err;
312}
313
314/**
315 * crypto_kpp_set_secret() - Invoke kpp operation
316 *
317 * Function invokes the specific kpp operation for a given alg.
318 *
319 * @tfm:	tfm handle
320 * @buffer:	Buffer holding the packet representation of the private
321 *		key. The structure of the packet key depends on the particular
322 *		KPP implementation. Packing and unpacking helpers are provided
323 *		for ECDH and DH (see the respective header files for those
324 *		implementations).
325 * @len:	Length of the packet private key buffer.
326 *
327 * Return: zero on success; error code in case of error
328 */
329static inline int crypto_kpp_set_secret(struct crypto_kpp *tfm,
330					const void *buffer, unsigned int len)
331{
332	struct kpp_alg *alg = crypto_kpp_alg(tfm);
333
334	if (IS_ENABLED(CONFIG_CRYPTO_STATS))
335		atomic64_inc(&kpp_get_stat(alg)->setsecret_cnt);
336
337	return crypto_kpp_errstat(alg, alg->set_secret(tfm, buffer, len));
338}
339
340/**
341 * crypto_kpp_generate_public_key() - Invoke kpp operation
342 *
343 * Function invokes the specific kpp operation for generating the public part
344 * for a given kpp algorithm.
345 *
346 * To generate a private key, the caller should use a random number generator.
347 * The output of the requested length serves as the private key.
348 *
349 * @req:	kpp key request
350 *
351 * Return: zero on success; error code in case of error
352 */
353static inline int crypto_kpp_generate_public_key(struct kpp_request *req)
354{
355	struct crypto_kpp *tfm = crypto_kpp_reqtfm(req);
356	struct kpp_alg *alg = crypto_kpp_alg(tfm);
357
358	if (IS_ENABLED(CONFIG_CRYPTO_STATS))
359		atomic64_inc(&kpp_get_stat(alg)->generate_public_key_cnt);
360
361	return crypto_kpp_errstat(alg, alg->generate_public_key(req));
362}
363
364/**
365 * crypto_kpp_compute_shared_secret() - Invoke kpp operation
366 *
367 * Function invokes the specific kpp operation for computing the shared secret
368 * for a given kpp algorithm.
369 *
370 * @req:	kpp key request
371 *
372 * Return: zero on success; error code in case of error
373 */
374static inline int crypto_kpp_compute_shared_secret(struct kpp_request *req)
375{
376	struct crypto_kpp *tfm = crypto_kpp_reqtfm(req);
377	struct kpp_alg *alg = crypto_kpp_alg(tfm);
378
379	if (IS_ENABLED(CONFIG_CRYPTO_STATS))
380		atomic64_inc(&kpp_get_stat(alg)->compute_shared_secret_cnt);
381
382	return crypto_kpp_errstat(alg, alg->compute_shared_secret(req));
383}
384
385/**
386 * crypto_kpp_maxsize() - Get len for output buffer
387 *
388 * Function returns the output buffer size required for a given key.
389 * Function assumes that the key is already set in the transformation. If this
390 * function is called without a setkey or with a failed setkey, you will end up
391 * in a NULL dereference.
392 *
393 * @tfm:	KPP tfm handle allocated with crypto_alloc_kpp()
 
 
394 */
395static inline unsigned int crypto_kpp_maxsize(struct crypto_kpp *tfm)
396{
397	struct kpp_alg *alg = crypto_kpp_alg(tfm);
398
399	return alg->max_size(tfm);
400}
401
402#endif
v4.10.11
 
  1/*
  2 * Key-agreement Protocol Primitives (KPP)
  3 *
  4 * Copyright (c) 2016, Intel Corporation
  5 * Authors: Salvatore Benedetto <salvatore.benedetto@intel.com>
  6 *
  7 * This program is free software; you can redistribute it and/or modify it
  8 * under the terms of the GNU General Public License as published by the Free
  9 * Software Foundation; either version 2 of the License, or (at your option)
 10 * any later version.
 11 *
 12 */
 13
 14#ifndef _CRYPTO_KPP_
 15#define _CRYPTO_KPP_
 
 
 
 16#include <linux/crypto.h>
 
 17
 18/**
 19 * struct kpp_request
 20 *
 21 * @base:	Common attributes for async crypto requests
 22 * @src:	Source data
 23 * @dst:	Destination data
 24 * @src_len:	Size of the input buffer
 25 * @dst_len:	Size of the output buffer. It needs to be at least
 26 *		as big as the expected result depending	on the operation
 27 *		After operation it will be updated with the actual size of the
 28 *		result. In case of error where the dst sgl size was insufficient,
 29 *		it will be updated to the size required for the operation.
 30 * @__ctx:	Start of private context data
 31 */
 32struct kpp_request {
 33	struct crypto_async_request base;
 34	struct scatterlist *src;
 35	struct scatterlist *dst;
 36	unsigned int src_len;
 37	unsigned int dst_len;
 38	void *__ctx[] CRYPTO_MINALIGN_ATTR;
 39};
 40
 41/**
 42 * struct crypto_kpp - user-instantiated object which encapsulate
 43 * algorithms and core processing logic
 44 *
 
 
 45 * @base:	Common crypto API algorithm data structure
 46 */
 47struct crypto_kpp {
 
 
 48	struct crypto_tfm base;
 49};
 50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 51/**
 52 * struct kpp_alg - generic key-agreement protocol primitives
 53 *
 54 * @set_secret:		Function invokes the protocol specific function to
 55 *			store the secret private key along with parameters.
 56 *			The implementation knows how to decode thie buffer
 57 * @generate_public_key: Function generate the public key to be sent to the
 58 *			counterpart. In case of error, where output is not big
 59 *			enough req->dst_len will be updated to the size
 60 *			required
 61 * @compute_shared_secret: Function compute the shared secret as defined by
 62 *			the algorithm. The result is given back to the user.
 63 *			In case of error, where output is not big enough,
 64 *			req->dst_len will be updated to the size required
 65 * @max_size:		Function returns the size of the output buffer
 66 * @init:		Initialize the object. This is called only once at
 67 *			instantiation time. In case the cryptographic hardware
 68 *			needs to be initialized. Software fallback should be
 69 *			put in place here.
 70 * @exit:		Undo everything @init did.
 71 *
 72 * @reqsize:		Request context size required by algorithm
 73 *			implementation
 74 * @base:		Common crypto API algorithm data structure
 
 75 */
 76struct kpp_alg {
 77	int (*set_secret)(struct crypto_kpp *tfm, void *buffer,
 78			  unsigned int len);
 79	int (*generate_public_key)(struct kpp_request *req);
 80	int (*compute_shared_secret)(struct kpp_request *req);
 81
 82	int (*max_size)(struct crypto_kpp *tfm);
 83
 84	int (*init)(struct crypto_kpp *tfm);
 85	void (*exit)(struct crypto_kpp *tfm);
 86
 87	unsigned int reqsize;
 
 
 
 88	struct crypto_alg base;
 89};
 90
 91/**
 92 * DOC: Generic Key-agreement Protocol Primitives API
 93 *
 94 * The KPP API is used with the algorithm type
 95 * CRYPTO_ALG_TYPE_KPP (listed as type "kpp" in /proc/crypto)
 96 */
 97
 98/**
 99 * crypto_alloc_kpp() - allocate KPP tfm handle
100 * @alg_name: is the name of the kpp algorithm (e.g. "dh", "ecdh")
101 * @type: specifies the type of the algorithm
102 * @mask: specifies the mask for the algorithm
103 *
104 * Allocate a handle for kpp algorithm. The returned struct crypto_kpp
105 * is requeried for any following API invocation
106 *
107 * Return: allocated handle in case of success; IS_ERR() is true in case of
108 *	   an error, PTR_ERR() returns the error code.
109 */
110struct crypto_kpp *crypto_alloc_kpp(const char *alg_name, u32 type, u32 mask);
111
 
 
112static inline struct crypto_tfm *crypto_kpp_tfm(struct crypto_kpp *tfm)
113{
114	return &tfm->base;
115}
116
117static inline struct kpp_alg *__crypto_kpp_alg(struct crypto_alg *alg)
118{
119	return container_of(alg, struct kpp_alg, base);
120}
121
122static inline struct crypto_kpp *__crypto_kpp_tfm(struct crypto_tfm *tfm)
123{
124	return container_of(tfm, struct crypto_kpp, base);
125}
126
127static inline struct kpp_alg *crypto_kpp_alg(struct crypto_kpp *tfm)
128{
129	return __crypto_kpp_alg(crypto_kpp_tfm(tfm)->__crt_alg);
130}
131
132static inline unsigned int crypto_kpp_reqsize(struct crypto_kpp *tfm)
133{
134	return crypto_kpp_alg(tfm)->reqsize;
135}
136
137static inline void kpp_request_set_tfm(struct kpp_request *req,
138				       struct crypto_kpp *tfm)
139{
140	req->base.tfm = crypto_kpp_tfm(tfm);
141}
142
143static inline struct crypto_kpp *crypto_kpp_reqtfm(struct kpp_request *req)
144{
145	return __crypto_kpp_tfm(req->base.tfm);
146}
147
 
 
 
 
 
 
 
 
 
 
148/**
149 * crypto_free_kpp() - free KPP tfm handle
150 *
151 * @tfm: KPP tfm handle allocated with crypto_alloc_kpp()
 
 
152 */
153static inline void crypto_free_kpp(struct crypto_kpp *tfm)
154{
155	crypto_destroy_tfm(tfm, crypto_kpp_tfm(tfm));
156}
157
158/**
159 * kpp_request_alloc() - allocates kpp request
160 *
161 * @tfm:	KPP tfm handle allocated with crypto_alloc_kpp()
162 * @gfp:	allocation flags
163 *
164 * Return: allocated handle in case of success or NULL in case of an error.
165 */
166static inline struct kpp_request *kpp_request_alloc(struct crypto_kpp *tfm,
167						    gfp_t gfp)
168{
169	struct kpp_request *req;
170
171	req = kmalloc(sizeof(*req) + crypto_kpp_reqsize(tfm), gfp);
172	if (likely(req))
173		kpp_request_set_tfm(req, tfm);
174
175	return req;
176}
177
178/**
179 * kpp_request_free() - zeroize and free kpp request
180 *
181 * @req:	request to free
182 */
183static inline void kpp_request_free(struct kpp_request *req)
184{
185	kzfree(req);
186}
187
188/**
189 * kpp_request_set_callback() - Sets an asynchronous callback.
190 *
191 * Callback will be called when an asynchronous operation on a given
192 * request is finished.
193 *
194 * @req:	request that the callback will be set for
195 * @flgs:	specify for instance if the operation may backlog
196 * @cmpl:	callback which will be called
197 * @data:	private data used by the caller
198 */
199static inline void kpp_request_set_callback(struct kpp_request *req,
200					    u32 flgs,
201					    crypto_completion_t cmpl,
202					    void *data)
203{
204	req->base.complete = cmpl;
205	req->base.data = data;
206	req->base.flags = flgs;
207}
208
209/**
210 * kpp_request_set_input() - Sets input buffer
211 *
212 * Sets parameters required by generate_public_key
213 *
214 * @req:	kpp request
215 * @input:	ptr to input scatter list
216 * @input_len:	size of the input scatter list
217 */
218static inline void kpp_request_set_input(struct kpp_request *req,
219					 struct scatterlist *input,
220					 unsigned int input_len)
221{
222	req->src = input;
223	req->src_len = input_len;
224}
225
226/**
227 * kpp_request_set_output() - Sets output buffer
228 *
229 * Sets parameters required by kpp operation
230 *
231 * @req:	kpp request
232 * @output:	ptr to output scatter list
233 * @output_len:	size of the output scatter list
234 */
235static inline void kpp_request_set_output(struct kpp_request *req,
236					  struct scatterlist *output,
237					  unsigned int output_len)
238{
239	req->dst = output;
240	req->dst_len = output_len;
241}
242
243enum {
244	CRYPTO_KPP_SECRET_TYPE_UNKNOWN,
245	CRYPTO_KPP_SECRET_TYPE_DH,
246	CRYPTO_KPP_SECRET_TYPE_ECDH,
247};
248
249/**
250 * struct kpp_secret - small header for packing secret buffer
251 *
252 * @type:	define type of secret. Each kpp type will define its own
253 * @len:	specify the len of the secret, include the header, that
254 *		follows the struct
255 */
256struct kpp_secret {
257	unsigned short type;
258	unsigned short len;
259};
260
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261/**
262 * crypto_kpp_set_secret() - Invoke kpp operation
263 *
264 * Function invokes the specific kpp operation for a given alg.
265 *
266 * @tfm:	tfm handle
267 * @buffer:	Buffer holding the packet representation of the private
268 *		key. The structure of the packet key depends on the particular
269 *		KPP implementation. Packing and unpacking helpers are provided
270 *		for ECDH and DH (see the respective header files for those
271 *		implementations).
272 * @len:	Length of the packet private key buffer.
273 *
274 * Return: zero on success; error code in case of error
275 */
276static inline int crypto_kpp_set_secret(struct crypto_kpp *tfm, void *buffer,
277					unsigned int len)
278{
279	struct kpp_alg *alg = crypto_kpp_alg(tfm);
280
281	return alg->set_secret(tfm, buffer, len);
 
 
 
282}
283
284/**
285 * crypto_kpp_generate_public_key() - Invoke kpp operation
286 *
287 * Function invokes the specific kpp operation for generating the public part
288 * for a given kpp algorithm.
289 *
290 * To generate a private key, the caller should use a random number generator.
291 * The output of the requested length serves as the private key.
292 *
293 * @req:	kpp key request
294 *
295 * Return: zero on success; error code in case of error
296 */
297static inline int crypto_kpp_generate_public_key(struct kpp_request *req)
298{
299	struct crypto_kpp *tfm = crypto_kpp_reqtfm(req);
300	struct kpp_alg *alg = crypto_kpp_alg(tfm);
301
302	return alg->generate_public_key(req);
 
 
 
303}
304
305/**
306 * crypto_kpp_compute_shared_secret() - Invoke kpp operation
307 *
308 * Function invokes the specific kpp operation for computing the shared secret
309 * for a given kpp algorithm.
310 *
311 * @req:	kpp key request
312 *
313 * Return: zero on success; error code in case of error
314 */
315static inline int crypto_kpp_compute_shared_secret(struct kpp_request *req)
316{
317	struct crypto_kpp *tfm = crypto_kpp_reqtfm(req);
318	struct kpp_alg *alg = crypto_kpp_alg(tfm);
319
320	return alg->compute_shared_secret(req);
 
 
 
321}
322
323/**
324 * crypto_kpp_maxsize() - Get len for output buffer
325 *
326 * Function returns the output buffer size required
 
 
 
327 *
328 * @tfm:	KPP tfm handle allocated with crypto_alloc_kpp()
329 *
330 * Return: minimum len for output buffer or error code if key hasn't been set
331 */
332static inline int crypto_kpp_maxsize(struct crypto_kpp *tfm)
333{
334	struct kpp_alg *alg = crypto_kpp_alg(tfm);
335
336	return alg->max_size(tfm);
337}
338
339#endif