Skip to content

Commit 01f727c

Browse files
committed
crypto: api - Move low-level functions into algapi.h
A number of low-level functions were exposed in crypto.h. Move them into algapi.h (and internal.h). Signed-off-by: Herbert Xu <[email protected]>
1 parent 8ae8a49 commit 01f727c

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

crypto/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ extern struct list_head crypto_alg_list;
4747
extern struct rw_semaphore crypto_alg_sem;
4848
extern struct blocking_notifier_head crypto_chain;
4949

50+
int alg_test(const char *driver, const char *alg, u32 type, u32 mask);
51+
5052
#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
5153
static inline bool crypto_boot_test_finished(void)
5254
{

crypto/tcrypt.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@
2525
#include <linux/err.h>
2626
#include <linux/fips.h>
2727
#include <linux/init.h>
28-
#include <linux/gfp.h>
28+
#include <linux/interrupt.h>
29+
#include <linux/jiffies.h>
30+
#include <linux/kernel.h>
2931
#include <linux/module.h>
32+
#include <linux/moduleparam.h>
3033
#include <linux/scatterlist.h>
34+
#include <linux/slab.h>
3135
#include <linux/string.h>
32-
#include <linux/moduleparam.h>
33-
#include <linux/jiffies.h>
3436
#include <linux/timex.h>
35-
#include <linux/interrupt.h>
37+
38+
#include "internal.h"
3639
#include "tcrypt.h"
3740

3841
/*

include/crypto/algapi.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct crypto_instance;
4949
struct module;
5050
struct notifier_block;
5151
struct rtattr;
52+
struct scatterlist;
5253
struct seq_file;
5354
struct sk_buff;
5455

@@ -132,6 +133,14 @@ struct crypto_attr_type {
132133
u32 mask;
133134
};
134135

136+
/*
137+
* Algorithm registration interface.
138+
*/
139+
int crypto_register_alg(struct crypto_alg *alg);
140+
void crypto_unregister_alg(struct crypto_alg *alg);
141+
int crypto_register_algs(struct crypto_alg *algs, int count);
142+
void crypto_unregister_algs(struct crypto_alg *algs, int count);
143+
135144
void crypto_mod_put(struct crypto_alg *alg);
136145

137146
int crypto_register_template(struct crypto_template *tmpl);
@@ -263,4 +272,9 @@ static inline void crypto_request_complete(struct crypto_async_request *req,
263272
req->complete(req->data, err);
264273
}
265274

275+
static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
276+
{
277+
return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
278+
}
279+
266280
#endif /* _CRYPTO_ALGAPI_H */

include/linux/crypto.h

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
#ifndef _LINUX_CRYPTO_H
1313
#define _LINUX_CRYPTO_H
1414

15-
#include <linux/atomic.h>
16-
#include <linux/kernel.h>
17-
#include <linux/list.h>
18-
#include <linux/bug.h>
15+
#include <linux/completion.h>
1916
#include <linux/refcount.h>
2017
#include <linux/slab.h>
21-
#include <linux/completion.h>
18+
#include <linux/types.h>
2219

2320
/*
2421
* Algorithm masks and types.
@@ -158,10 +155,9 @@
158155

159156
#define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN)))
160157

161-
struct scatterlist;
162-
struct crypto_async_request;
163158
struct crypto_tfm;
164159
struct crypto_type;
160+
struct module;
165161

166162
typedef void (*crypto_completion_t)(void *req, int err);
167163

@@ -411,14 +407,6 @@ static inline void crypto_init_wait(struct crypto_wait *wait)
411407
init_completion(&wait->completion);
412408
}
413409

414-
/*
415-
* Algorithm registration interface.
416-
*/
417-
int crypto_register_alg(struct crypto_alg *alg);
418-
void crypto_unregister_alg(struct crypto_alg *alg);
419-
int crypto_register_algs(struct crypto_alg *algs, int count);
420-
void crypto_unregister_algs(struct crypto_alg *algs, int count);
421-
422410
/*
423411
* Algorithm query interface.
424412
*/
@@ -459,8 +447,6 @@ static inline void crypto_free_tfm(struct crypto_tfm *tfm)
459447
return crypto_destroy_tfm(tfm, tfm);
460448
}
461449

462-
int alg_test(const char *driver, const char *alg, u32 type, u32 mask);
463-
464450
/*
465451
* Transform helpers which query the underlying algorithm.
466452
*/
@@ -474,16 +460,6 @@ static inline const char *crypto_tfm_alg_driver_name(struct crypto_tfm *tfm)
474460
return tfm->__crt_alg->cra_driver_name;
475461
}
476462

477-
static inline int crypto_tfm_alg_priority(struct crypto_tfm *tfm)
478-
{
479-
return tfm->__crt_alg->cra_priority;
480-
}
481-
482-
static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
483-
{
484-
return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
485-
}
486-
487463
static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm)
488464
{
489465
return tfm->__crt_alg->cra_blocksize;

0 commit comments

Comments
 (0)