linux/crypto/algapi.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Cryptographic API for algorithms (i.e., low-level API).
 *
 * Copyright (c) 2006 Herbert Xu <[email protected]>
 */

#include <crypto/algapi.h>
#include <crypto/internal/simd.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/fips.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/rtnetlink.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/workqueue.h>

#include "internal.h"

static LIST_HEAD(crypto_template_list);

#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
DEFINE_PER_CPU(bool, crypto_simd_disabled_for_test);
EXPORT_PER_CPU_SYMBOL_GPL(crypto_simd_disabled_for_test);
#endif

static inline void crypto_check_module_sig(struct module *mod)
{}

static int crypto_check_alg(struct crypto_alg *alg)
{}

static void crypto_free_instance(struct crypto_instance *inst)
{}

static void crypto_destroy_instance_workfn(struct work_struct *w)
{}

static void crypto_destroy_instance(struct crypto_alg *alg)
{}

/*
 * This function adds a spawn to the list secondary_spawns which
 * will be used at the end of crypto_remove_spawns to unregister
 * instances, unless the spawn happens to be one that is depended
 * on by the new algorithm (nalg in crypto_remove_spawns).
 *
 * This function is also responsible for resurrecting any algorithms
 * in the dependency chain of nalg by unsetting n->dead.
 */
static struct list_head *crypto_more_spawns(struct crypto_alg *alg,
					    struct list_head *stack,
					    struct list_head *top,
					    struct list_head *secondary_spawns)
{}

static void crypto_remove_instance(struct crypto_instance *inst,
				   struct list_head *list)
{}

/*
 * Given an algorithm alg, remove all algorithms that depend on it
 * through spawns.  If nalg is not null, then exempt any algorithms
 * that is depended on by nalg.  This is useful when nalg itself
 * depends on alg.
 */
void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list,
			  struct crypto_alg *nalg)
{}
EXPORT_SYMBOL_GPL();

static void crypto_alg_finish_registration(struct crypto_alg *alg,
					   bool fulfill_requests,
					   struct list_head *algs_to_put)
{}

static struct crypto_larval *crypto_alloc_test_larval(struct crypto_alg *alg)
{}

static struct crypto_larval *
__crypto_register_alg(struct crypto_alg *alg, struct list_head *algs_to_put)
{}

void crypto_alg_tested(const char *name, int err)
{}
EXPORT_SYMBOL_GPL();

void crypto_remove_final(struct list_head *list)
{}
EXPORT_SYMBOL_GPL();

int crypto_register_alg(struct crypto_alg *alg)
{}
EXPORT_SYMBOL_GPL();

static int crypto_remove_alg(struct crypto_alg *alg, struct list_head *list)
{}

void crypto_unregister_alg(struct crypto_alg *alg)
{}
EXPORT_SYMBOL_GPL();

int crypto_register_algs(struct crypto_alg *algs, int count)
{}
EXPORT_SYMBOL_GPL();

void crypto_unregister_algs(struct crypto_alg *algs, int count)
{}
EXPORT_SYMBOL_GPL();

int crypto_register_template(struct crypto_template *tmpl)
{}
EXPORT_SYMBOL_GPL();

int crypto_register_templates(struct crypto_template *tmpls, int count)
{}
EXPORT_SYMBOL_GPL();

void crypto_unregister_template(struct crypto_template *tmpl)
{}
EXPORT_SYMBOL_GPL();

void crypto_unregister_templates(struct crypto_template *tmpls, int count)
{}
EXPORT_SYMBOL_GPL();

static struct crypto_template *__crypto_lookup_template(const char *name)
{}

struct crypto_template *crypto_lookup_template(const char *name)
{}
EXPORT_SYMBOL_GPL();

int crypto_register_instance(struct crypto_template *tmpl,
			     struct crypto_instance *inst)
{}
EXPORT_SYMBOL_GPL();

void crypto_unregister_instance(struct crypto_instance *inst)
{}
EXPORT_SYMBOL_GPL();

int crypto_grab_spawn(struct crypto_spawn *spawn, struct crypto_instance *inst,
		      const char *name, u32 type, u32 mask)
{}
EXPORT_SYMBOL_GPL();

void crypto_drop_spawn(struct crypto_spawn *spawn)
{}
EXPORT_SYMBOL_GPL();

static struct crypto_alg *crypto_spawn_alg(struct crypto_spawn *spawn)
{}

struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
				    u32 mask)
{}
EXPORT_SYMBOL_GPL();

void *crypto_spawn_tfm2(struct crypto_spawn *spawn)
{}
EXPORT_SYMBOL_GPL();

int crypto_register_notifier(struct notifier_block *nb)
{}
EXPORT_SYMBOL_GPL();

int crypto_unregister_notifier(struct notifier_block *nb)
{}
EXPORT_SYMBOL_GPL();

struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb)
{}
EXPORT_SYMBOL_GPL();

/**
 * crypto_check_attr_type() - check algorithm type and compute inherited mask
 * @tb: the template parameters
 * @type: the algorithm type the template would be instantiated as
 * @mask_ret: (output) the mask that should be passed to crypto_grab_*()
 *	      to restrict the flags of any inner algorithms
 *
 * Validate that the algorithm type the user requested is compatible with the
 * one the template would actually be instantiated as.  E.g., if the user is
 * doing crypto_alloc_shash("cbc(aes)", ...), this would return an error because
 * the "cbc" template creates an "skcipher" algorithm, not an "shash" algorithm.
 *
 * Also compute the mask to use to restrict the flags of any inner algorithms.
 *
 * Return: 0 on success; -errno on failure
 */
int crypto_check_attr_type(struct rtattr **tb, u32 type, u32 *mask_ret)
{}
EXPORT_SYMBOL_GPL();

const char *crypto_attr_alg_name(struct rtattr *rta)
{}
EXPORT_SYMBOL_GPL();

int crypto_inst_setname(struct crypto_instance *inst, const char *name,
			struct crypto_alg *alg)
{}
EXPORT_SYMBOL_GPL();

void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen)
{}
EXPORT_SYMBOL_GPL();

int crypto_enqueue_request(struct crypto_queue *queue,
			   struct crypto_async_request *request)
{}
EXPORT_SYMBOL_GPL();

void crypto_enqueue_request_head(struct crypto_queue *queue,
				 struct crypto_async_request *request)
{}
EXPORT_SYMBOL_GPL();

struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue)
{}
EXPORT_SYMBOL_GPL();

static inline void crypto_inc_byte(u8 *a, unsigned int size)
{}

void crypto_inc(u8 *a, unsigned int size)
{}
EXPORT_SYMBOL_GPL();

unsigned int crypto_alg_extsize(struct crypto_alg *alg)
{}
EXPORT_SYMBOL_GPL();

int crypto_type_has_alg(const char *name, const struct crypto_type *frontend,
			u32 type, u32 mask)
{}
EXPORT_SYMBOL_GPL();

static void __init crypto_start_tests(void)
{}

static int __init crypto_algapi_init(void)
{}

static void __exit crypto_algapi_exit(void)
{}

/*
 * We run this at late_initcall so that all the built-in algorithms
 * have had a chance to register themselves first.
 */
late_initcall(crypto_algapi_init);
module_exit(crypto_algapi_exit);

MODULE_LICENSE();
MODULE_DESCRIPTION();
MODULE_SOFTDEP();