linux/crypto/simd.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Shared crypto simd helpers
 *
 * Copyright (c) 2012 Jussi Kivilinna <[email protected]>
 * Copyright (c) 2016 Herbert Xu <[email protected]>
 * Copyright (c) 2019 Google LLC
 *
 * Based on aesni-intel_glue.c by:
 *  Copyright (C) 2008, Intel Corp.
 *    Author: Huang Ying <[email protected]>
 */

/*
 * Shared crypto SIMD helpers.  These functions dynamically create and register
 * an skcipher or AEAD algorithm that wraps another, internal algorithm.  The
 * wrapper ensures that the internal algorithm is only executed in a context
 * where SIMD instructions are usable, i.e. where may_use_simd() returns true.
 * If SIMD is already usable, the wrapper directly calls the internal algorithm.
 * Otherwise it defers execution to a workqueue via cryptd.
 *
 * This is an alternative to the internal algorithm implementing a fallback for
 * the !may_use_simd() case itself.
 *
 * Note that the wrapper algorithm is asynchronous, i.e. it has the
 * CRYPTO_ALG_ASYNC flag set.  Therefore it won't be found by users who
 * explicitly allocate a synchronous algorithm.
 */

#include <crypto/cryptd.h>
#include <crypto/internal/aead.h>
#include <crypto/internal/simd.h>
#include <crypto/internal/skcipher.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/preempt.h>
#include <asm/simd.h>

/* skcipher support */

struct simd_skcipher_alg {};

struct simd_skcipher_ctx {};

static int simd_skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key,
				unsigned int key_len)
{}

static int simd_skcipher_encrypt(struct skcipher_request *req)
{}

static int simd_skcipher_decrypt(struct skcipher_request *req)
{}

static void simd_skcipher_exit(struct crypto_skcipher *tfm)
{}

static int simd_skcipher_init(struct crypto_skcipher *tfm)
{}

struct simd_skcipher_alg *simd_skcipher_create_compat(const char *algname,
						      const char *drvname,
						      const char *basename)
{}
EXPORT_SYMBOL_GPL();

struct simd_skcipher_alg *simd_skcipher_create(const char *algname,
					       const char *basename)
{}
EXPORT_SYMBOL_GPL();

void simd_skcipher_free(struct simd_skcipher_alg *salg)
{}
EXPORT_SYMBOL_GPL();

int simd_register_skciphers_compat(struct skcipher_alg *algs, int count,
				   struct simd_skcipher_alg **simd_algs)
{}
EXPORT_SYMBOL_GPL();

void simd_unregister_skciphers(struct skcipher_alg *algs, int count,
			       struct simd_skcipher_alg **simd_algs)
{}
EXPORT_SYMBOL_GPL();

/* AEAD support */

struct simd_aead_alg {};

struct simd_aead_ctx {};

static int simd_aead_setkey(struct crypto_aead *tfm, const u8 *key,
				unsigned int key_len)
{}

static int simd_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
{}

static int simd_aead_encrypt(struct aead_request *req)
{}

static int simd_aead_decrypt(struct aead_request *req)
{}

static void simd_aead_exit(struct crypto_aead *tfm)
{}

static int simd_aead_init(struct crypto_aead *tfm)
{}

struct simd_aead_alg *simd_aead_create_compat(const char *algname,
					      const char *drvname,
					      const char *basename)
{}
EXPORT_SYMBOL_GPL();

struct simd_aead_alg *simd_aead_create(const char *algname,
				       const char *basename)
{}
EXPORT_SYMBOL_GPL();

void simd_aead_free(struct simd_aead_alg *salg)
{}
EXPORT_SYMBOL_GPL();

int simd_register_aeads_compat(struct aead_alg *algs, int count,
			       struct simd_aead_alg **simd_algs)
{}
EXPORT_SYMBOL_GPL();

void simd_unregister_aeads(struct aead_alg *algs, int count,
			   struct simd_aead_alg **simd_algs)
{}
EXPORT_SYMBOL_GPL();

MODULE_DESCRIPTION();
MODULE_LICENSE();