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 <herbert@gondor.apana.org.au>
This commit is contained in:
Herbert Xu 2023-04-03 12:48:42 +08:00
parent 8ae8a494ea
commit 01f727cdc4
4 changed files with 29 additions and 34 deletions

View File

@ -47,6 +47,8 @@ extern struct list_head crypto_alg_list;
extern struct rw_semaphore crypto_alg_sem; extern struct rw_semaphore crypto_alg_sem;
extern struct blocking_notifier_head crypto_chain; extern struct blocking_notifier_head crypto_chain;
int alg_test(const char *driver, const char *alg, u32 type, u32 mask);
#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS #ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
static inline bool crypto_boot_test_finished(void) static inline bool crypto_boot_test_finished(void)
{ {

View File

@ -25,14 +25,17 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/fips.h> #include <linux/fips.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gfp.h>
#include <linux/module.h>
#include <linux/scatterlist.h>
#include <linux/string.h>
#include <linux/moduleparam.h>
#include <linux/jiffies.h>
#include <linux/timex.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/scatterlist.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timex.h>
#include "internal.h"
#include "tcrypt.h" #include "tcrypt.h"
/* /*

View File

@ -49,6 +49,7 @@ struct crypto_instance;
struct module; struct module;
struct notifier_block; struct notifier_block;
struct rtattr; struct rtattr;
struct scatterlist;
struct seq_file; struct seq_file;
struct sk_buff; struct sk_buff;
@ -132,6 +133,14 @@ struct crypto_attr_type {
u32 mask; u32 mask;
}; };
/*
* Algorithm registration interface.
*/
int crypto_register_alg(struct crypto_alg *alg);
void crypto_unregister_alg(struct crypto_alg *alg);
int crypto_register_algs(struct crypto_alg *algs, int count);
void crypto_unregister_algs(struct crypto_alg *algs, int count);
void crypto_mod_put(struct crypto_alg *alg); void crypto_mod_put(struct crypto_alg *alg);
int crypto_register_template(struct crypto_template *tmpl); int crypto_register_template(struct crypto_template *tmpl);
@ -263,4 +272,9 @@ static inline void crypto_request_complete(struct crypto_async_request *req,
req->complete(req->data, err); req->complete(req->data, err);
} }
static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
{
return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
}
#endif /* _CRYPTO_ALGAPI_H */ #endif /* _CRYPTO_ALGAPI_H */

View File

@ -12,13 +12,10 @@
#ifndef _LINUX_CRYPTO_H #ifndef _LINUX_CRYPTO_H
#define _LINUX_CRYPTO_H #define _LINUX_CRYPTO_H
#include <linux/atomic.h> #include <linux/completion.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/bug.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/completion.h> #include <linux/types.h>
/* /*
* Algorithm masks and types. * Algorithm masks and types.
@ -158,10 +155,9 @@
#define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN))) #define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN)))
struct scatterlist;
struct crypto_async_request;
struct crypto_tfm; struct crypto_tfm;
struct crypto_type; struct crypto_type;
struct module;
typedef void (*crypto_completion_t)(void *req, int err); typedef void (*crypto_completion_t)(void *req, int err);
@ -411,14 +407,6 @@ static inline void crypto_init_wait(struct crypto_wait *wait)
init_completion(&wait->completion); init_completion(&wait->completion);
} }
/*
* Algorithm registration interface.
*/
int crypto_register_alg(struct crypto_alg *alg);
void crypto_unregister_alg(struct crypto_alg *alg);
int crypto_register_algs(struct crypto_alg *algs, int count);
void crypto_unregister_algs(struct crypto_alg *algs, int count);
/* /*
* Algorithm query interface. * Algorithm query interface.
*/ */
@ -459,8 +447,6 @@ static inline void crypto_free_tfm(struct crypto_tfm *tfm)
return crypto_destroy_tfm(tfm, tfm); return crypto_destroy_tfm(tfm, tfm);
} }
int alg_test(const char *driver, const char *alg, u32 type, u32 mask);
/* /*
* Transform helpers which query the underlying algorithm. * Transform helpers which query the underlying algorithm.
*/ */
@ -474,16 +460,6 @@ static inline const char *crypto_tfm_alg_driver_name(struct crypto_tfm *tfm)
return tfm->__crt_alg->cra_driver_name; return tfm->__crt_alg->cra_driver_name;
} }
static inline int crypto_tfm_alg_priority(struct crypto_tfm *tfm)
{
return tfm->__crt_alg->cra_priority;
}
static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
{
return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
}
static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm) static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm)
{ {
return tfm->__crt_alg->cra_blocksize; return tfm->__crt_alg->cra_blocksize;