mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
Merge tag 'v6.6-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto updates from Herbert Xu: "API: - Move crypto engine callback from tfm ctx into algorithm object - Fix atomic sleep bug in crypto_destroy_instance - Move lib/mpi into lib/crypto Algorithms: - Add chacha20 and poly1305 implementation for powerpc p10 Drivers: - Add AES skcipher and aead support to starfive - Add Dynamic Boost Control support to ccp - Add support for STM32P13 platform to stm32" * tag 'v6.6-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (149 commits) Revert "dt-bindings: crypto: qcom,prng: Add SM8450" crypto: chelsio - Remove unused declarations X.509: if signature is unsupported skip validation crypto: qat - fix crypto capability detection for 4xxx crypto: drivers - Explicitly include correct DT includes crypto: engine - Remove crypto_engine_ctx crypto: zynqmp - Use new crypto_engine_op interface crypto: virtio - Use new crypto_engine_op interface crypto: stm32 - Use new crypto_engine_op interface crypto: jh7110 - Use new crypto_engine_op interface crypto: rk3288 - Use new crypto_engine_op interface crypto: omap - Use new crypto_engine_op interface crypto: keembay - Use new crypto_engine_op interface crypto: sl3516 - Use new crypto_engine_op interface crypto: caam - Use new crypto_engine_op interface crypto: aspeed - Remove non-standard sha512 algorithms crypto: aspeed - Use new crypto_engine_op interface crypto: amlogic - Use new crypto_engine_op interface crypto: sun8i-ss - Use new crypto_engine_op interface crypto: sun8i-ce - Use new crypto_engine_op interface ...
This commit is contained in:
61
Documentation/ABI/testing/debugfs-driver-qat
Normal file
61
Documentation/ABI/testing/debugfs-driver-qat
Normal file
@@ -0,0 +1,61 @@
|
||||
What: /sys/kernel/debug/qat_<device>_<BDF>/qat/fw_counters
|
||||
Date: November 2023
|
||||
KernelVersion: 6.6
|
||||
Contact: qat-linux@intel.com
|
||||
Description: (RO) Read returns the number of requests sent to the FW and the number of responses
|
||||
received from the FW for each Acceleration Engine
|
||||
Reported firmware counters::
|
||||
|
||||
<N>: Number of requests sent from Acceleration Engine N to FW and responses
|
||||
Acceleration Engine N received from FW
|
||||
|
||||
What: /sys/kernel/debug/qat_<device>_<BDF>/heartbeat/config
|
||||
Date: November 2023
|
||||
KernelVersion: 6.6
|
||||
Contact: qat-linux@intel.com
|
||||
Description: (RW) Read returns value of the Heartbeat update period.
|
||||
Write to the file changes this period value.
|
||||
|
||||
This period should reflect planned polling interval of device
|
||||
health status. High frequency Heartbeat monitoring wastes CPU cycles
|
||||
but minimizes the customer’s system downtime. Also, if there are
|
||||
large service requests that take some time to complete, high frequency
|
||||
Heartbeat monitoring could result in false reports of unresponsiveness
|
||||
and in those cases, period needs to be increased.
|
||||
|
||||
This parameter is effective only for c3xxx, c62x, dh895xcc devices.
|
||||
4xxx has this value internally fixed to 200ms.
|
||||
|
||||
Default value is set to 500. Minimal allowed value is 200.
|
||||
All values are expressed in milliseconds.
|
||||
|
||||
What: /sys/kernel/debug/qat_<device>_<BDF>/heartbeat/queries_failed
|
||||
Date: November 2023
|
||||
KernelVersion: 6.6
|
||||
Contact: qat-linux@intel.com
|
||||
Description: (RO) Read returns the number of times the device became unresponsive.
|
||||
|
||||
Attribute returns value of the counter which is incremented when
|
||||
status query results negative.
|
||||
|
||||
What: /sys/kernel/debug/qat_<device>_<BDF>/heartbeat/queries_sent
|
||||
Date: November 2023
|
||||
KernelVersion: 6.6
|
||||
Contact: qat-linux@intel.com
|
||||
Description: (RO) Read returns the number of times the control process checked
|
||||
if the device is responsive.
|
||||
|
||||
Attribute returns value of the counter which is incremented on
|
||||
every status query.
|
||||
|
||||
What: /sys/kernel/debug/qat_<device>_<BDF>/heartbeat/status
|
||||
Date: November 2023
|
||||
KernelVersion: 6.6
|
||||
Contact: qat-linux@intel.com
|
||||
Description: (RO) Read returns the device health status.
|
||||
|
||||
Returns 0 when device is healthy or -1 when is unresponsive
|
||||
or the query failed to send.
|
||||
|
||||
The driver does not monitor for Heartbeat. It is left for a user
|
||||
to poll the status periodically.
|
||||
@@ -85,3 +85,21 @@ Description:
|
||||
Possible values:
|
||||
0: Not enforced
|
||||
1: Enforced
|
||||
|
||||
What: /sys/bus/pci/devices/<BDF>/bootloader_version
|
||||
Date: June 2023
|
||||
KernelVersion: 6.4
|
||||
Contact: mario.limonciello@amd.com
|
||||
Description:
|
||||
The /sys/bus/pci/devices/<BDF>/bootloader_version
|
||||
file reports the firmware version of the AMD AGESA
|
||||
bootloader.
|
||||
|
||||
What: /sys/bus/pci/devices/<BDF>/tee_version
|
||||
Date: June 2023
|
||||
KernelVersion: 6.4
|
||||
Contact: mario.limonciello@amd.com
|
||||
Description:
|
||||
The /sys/bus/pci/devices/<BDF>/tee_version
|
||||
file reports the firmware version of the AMD Trusted
|
||||
Execution Environment (TEE).
|
||||
|
||||
@@ -20,6 +20,7 @@ properties:
|
||||
- stericsson,ux500-hash
|
||||
- st,stm32f456-hash
|
||||
- st,stm32f756-hash
|
||||
- st,stm32mp13-hash
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
12
MAINTAINERS
12
MAINTAINERS
@@ -915,6 +915,18 @@ S: Supported
|
||||
F: drivers/crypto/ccp/sev*
|
||||
F: include/uapi/linux/psp-sev.h
|
||||
|
||||
AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - DBC SUPPORT
|
||||
M: Mario Limonciello <mario.limonciello@amd.com>
|
||||
L: linux-crypto@vger.kernel.org
|
||||
S: Supported
|
||||
F: drivers/crypto/ccp/dbc.c
|
||||
F: drivers/crypto/ccp/dbc.h
|
||||
F: drivers/crypto/ccp/platform-access.c
|
||||
F: drivers/crypto/ccp/platform-access.h
|
||||
F: include/uapi/linux/psp-dbc.h
|
||||
F: tools/crypto/ccp/*.c
|
||||
F: tools/crypto/ccp/*.py
|
||||
|
||||
AMD DISPLAY CORE
|
||||
M: Harry Wentland <harry.wentland@amd.com>
|
||||
M: Leo Li <sunpeng.li@amd.com>
|
||||
|
||||
@@ -81,11 +81,6 @@ aes-arm64-y := aes-cipher-core.o aes-cipher-glue.o
|
||||
obj-$(CONFIG_CRYPTO_AES_ARM64_BS) += aes-neon-bs.o
|
||||
aes-neon-bs-y := aes-neonbs-core.o aes-neonbs-glue.o
|
||||
|
||||
CFLAGS_aes-glue-ce.o := -DUSE_V8_CRYPTO_EXTENSIONS
|
||||
|
||||
$(obj)/aes-glue-%.o: $(src)/aes-glue.c FORCE
|
||||
$(call if_changed_rule,cc_o_c)
|
||||
|
||||
quiet_cmd_perlasm = PERLASM $@
|
||||
cmd_perlasm = $(PERL) $(<) void $(@)
|
||||
|
||||
|
||||
2
arch/arm64/crypto/aes-glue-ce.c
Normal file
2
arch/arm64/crypto/aes-glue-ce.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define USE_V8_CRYPTO_EXTENSIONS
|
||||
#include "aes-glue.c"
|
||||
1
arch/arm64/crypto/aes-glue-neon.c
Normal file
1
arch/arm64/crypto/aes-glue-neon.c
Normal file
@@ -0,0 +1 @@
|
||||
#include "aes-glue.c"
|
||||
@@ -111,4 +111,30 @@ config CRYPTO_AES_GCM_P10
|
||||
Support for cryptographic acceleration instructions on Power10 or
|
||||
later CPU. This module supports stitched acceleration for AES/GCM.
|
||||
|
||||
config CRYPTO_CHACHA20_P10
|
||||
tristate "Ciphers: ChaCha20, XChacha20, XChacha12 (P10 or later)"
|
||||
depends on PPC64 && CPU_LITTLE_ENDIAN
|
||||
select CRYPTO_SKCIPHER
|
||||
select CRYPTO_LIB_CHACHA_GENERIC
|
||||
select CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
help
|
||||
Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12
|
||||
stream cipher algorithms
|
||||
|
||||
Architecture: PowerPC64
|
||||
- Power10 or later
|
||||
- Little-endian
|
||||
|
||||
config CRYPTO_POLY1305_P10
|
||||
tristate "Hash functions: Poly1305 (P10 or later)"
|
||||
depends on PPC64 && CPU_LITTLE_ENDIAN
|
||||
select CRYPTO_HASH
|
||||
select CRYPTO_LIB_POLY1305_GENERIC
|
||||
help
|
||||
Poly1305 authenticator algorithm (RFC7539)
|
||||
|
||||
Architecture: PowerPC64
|
||||
- Power10 or later
|
||||
- Little-endian
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -14,6 +14,8 @@ obj-$(CONFIG_CRYPTO_CRC32C_VPMSUM) += crc32c-vpmsum.o
|
||||
obj-$(CONFIG_CRYPTO_CRCT10DIF_VPMSUM) += crct10dif-vpmsum.o
|
||||
obj-$(CONFIG_CRYPTO_VPMSUM_TESTER) += crc-vpmsum_test.o
|
||||
obj-$(CONFIG_CRYPTO_AES_GCM_P10) += aes-gcm-p10-crypto.o
|
||||
obj-$(CONFIG_CRYPTO_CHACHA20_P10) += chacha-p10-crypto.o
|
||||
obj-$(CONFIG_CRYPTO_POLY1305_P10) += poly1305-p10-crypto.o
|
||||
|
||||
aes-ppc-spe-y := aes-spe-core.o aes-spe-keys.o aes-tab-4k.o aes-spe-modes.o aes-spe-glue.o
|
||||
md5-ppc-y := md5-asm.o md5-glue.o
|
||||
@@ -23,6 +25,8 @@ sha256-ppc-spe-y := sha256-spe-asm.o sha256-spe-glue.o
|
||||
crc32c-vpmsum-y := crc32c-vpmsum_asm.o crc32c-vpmsum_glue.o
|
||||
crct10dif-vpmsum-y := crct10dif-vpmsum_asm.o crct10dif-vpmsum_glue.o
|
||||
aes-gcm-p10-crypto-y := aes-gcm-p10-glue.o aes-gcm-p10.o ghashp10-ppc.o aesp10-ppc.o
|
||||
chacha-p10-crypto-y := chacha-p10-glue.o chacha-p10le-8x.o
|
||||
poly1305-p10-crypto-y := poly1305-p10-glue.o poly1305-p10le_64.o
|
||||
|
||||
quiet_cmd_perl = PERL $@
|
||||
cmd_perl = $(PERL) $< $(if $(CONFIG_CPU_LITTLE_ENDIAN), linux-ppc64le, linux-ppc64) > $@
|
||||
|
||||
221
arch/powerpc/crypto/chacha-p10-glue.c
Normal file
221
arch/powerpc/crypto/chacha-p10-glue.c
Normal file
@@ -0,0 +1,221 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* PowerPC P10 (ppc64le) accelerated ChaCha and XChaCha stream ciphers,
|
||||
* including ChaCha20 (RFC7539)
|
||||
*
|
||||
* Copyright 2023- IBM Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
#include <crypto/internal/chacha.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <crypto/internal/skcipher.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/cpufeature.h>
|
||||
#include <linux/sizes.h>
|
||||
#include <asm/simd.h>
|
||||
#include <asm/switch_to.h>
|
||||
|
||||
asmlinkage void chacha_p10le_8x(u32 *state, u8 *dst, const u8 *src,
|
||||
unsigned int len, int nrounds);
|
||||
|
||||
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_p10);
|
||||
|
||||
static void vsx_begin(void)
|
||||
{
|
||||
preempt_disable();
|
||||
enable_kernel_vsx();
|
||||
}
|
||||
|
||||
static void vsx_end(void)
|
||||
{
|
||||
disable_kernel_vsx();
|
||||
preempt_enable();
|
||||
}
|
||||
|
||||
static void chacha_p10_do_8x(u32 *state, u8 *dst, const u8 *src,
|
||||
unsigned int bytes, int nrounds)
|
||||
{
|
||||
unsigned int l = bytes & ~0x0FF;
|
||||
|
||||
if (l > 0) {
|
||||
chacha_p10le_8x(state, dst, src, l, nrounds);
|
||||
bytes -= l;
|
||||
src += l;
|
||||
dst += l;
|
||||
state[12] += l / CHACHA_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
if (bytes > 0)
|
||||
chacha_crypt_generic(state, dst, src, bytes, nrounds);
|
||||
}
|
||||
|
||||
void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
|
||||
{
|
||||
hchacha_block_generic(state, stream, nrounds);
|
||||
}
|
||||
EXPORT_SYMBOL(hchacha_block_arch);
|
||||
|
||||
void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
|
||||
{
|
||||
chacha_init_generic(state, key, iv);
|
||||
}
|
||||
EXPORT_SYMBOL(chacha_init_arch);
|
||||
|
||||
void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
|
||||
int nrounds)
|
||||
{
|
||||
if (!static_branch_likely(&have_p10) || bytes <= CHACHA_BLOCK_SIZE ||
|
||||
!crypto_simd_usable())
|
||||
return chacha_crypt_generic(state, dst, src, bytes, nrounds);
|
||||
|
||||
do {
|
||||
unsigned int todo = min_t(unsigned int, bytes, SZ_4K);
|
||||
|
||||
vsx_begin();
|
||||
chacha_p10_do_8x(state, dst, src, todo, nrounds);
|
||||
vsx_end();
|
||||
|
||||
bytes -= todo;
|
||||
src += todo;
|
||||
dst += todo;
|
||||
} while (bytes);
|
||||
}
|
||||
EXPORT_SYMBOL(chacha_crypt_arch);
|
||||
|
||||
static int chacha_p10_stream_xor(struct skcipher_request *req,
|
||||
const struct chacha_ctx *ctx, const u8 *iv)
|
||||
{
|
||||
struct skcipher_walk walk;
|
||||
u32 state[16];
|
||||
int err;
|
||||
|
||||
err = skcipher_walk_virt(&walk, req, false);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
chacha_init_generic(state, ctx->key, iv);
|
||||
|
||||
while (walk.nbytes > 0) {
|
||||
unsigned int nbytes = walk.nbytes;
|
||||
|
||||
if (nbytes < walk.total)
|
||||
nbytes = rounddown(nbytes, walk.stride);
|
||||
|
||||
if (!crypto_simd_usable()) {
|
||||
chacha_crypt_generic(state, walk.dst.virt.addr,
|
||||
walk.src.virt.addr, nbytes,
|
||||
ctx->nrounds);
|
||||
} else {
|
||||
vsx_begin();
|
||||
chacha_p10_do_8x(state, walk.dst.virt.addr,
|
||||
walk.src.virt.addr, nbytes, ctx->nrounds);
|
||||
vsx_end();
|
||||
}
|
||||
err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int chacha_p10(struct skcipher_request *req)
|
||||
{
|
||||
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
|
||||
return chacha_p10_stream_xor(req, ctx, req->iv);
|
||||
}
|
||||
|
||||
static int xchacha_p10(struct skcipher_request *req)
|
||||
{
|
||||
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
struct chacha_ctx subctx;
|
||||
u32 state[16];
|
||||
u8 real_iv[16];
|
||||
|
||||
chacha_init_generic(state, ctx->key, req->iv);
|
||||
hchacha_block_arch(state, subctx.key, ctx->nrounds);
|
||||
subctx.nrounds = ctx->nrounds;
|
||||
|
||||
memcpy(&real_iv[0], req->iv + 24, 8);
|
||||
memcpy(&real_iv[8], req->iv + 16, 8);
|
||||
return chacha_p10_stream_xor(req, &subctx, real_iv);
|
||||
}
|
||||
|
||||
static struct skcipher_alg algs[] = {
|
||||
{
|
||||
.base.cra_name = "chacha20",
|
||||
.base.cra_driver_name = "chacha20-p10",
|
||||
.base.cra_priority = 300,
|
||||
.base.cra_blocksize = 1,
|
||||
.base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
|
||||
.min_keysize = CHACHA_KEY_SIZE,
|
||||
.max_keysize = CHACHA_KEY_SIZE,
|
||||
.ivsize = CHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
.setkey = chacha20_setkey,
|
||||
.encrypt = chacha_p10,
|
||||
.decrypt = chacha_p10,
|
||||
}, {
|
||||
.base.cra_name = "xchacha20",
|
||||
.base.cra_driver_name = "xchacha20-p10",
|
||||
.base.cra_priority = 300,
|
||||
.base.cra_blocksize = 1,
|
||||
.base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
|
||||
.min_keysize = CHACHA_KEY_SIZE,
|
||||
.max_keysize = CHACHA_KEY_SIZE,
|
||||
.ivsize = XCHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
.setkey = chacha20_setkey,
|
||||
.encrypt = xchacha_p10,
|
||||
.decrypt = xchacha_p10,
|
||||
}, {
|
||||
.base.cra_name = "xchacha12",
|
||||
.base.cra_driver_name = "xchacha12-p10",
|
||||
.base.cra_priority = 300,
|
||||
.base.cra_blocksize = 1,
|
||||
.base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
|
||||
.min_keysize = CHACHA_KEY_SIZE,
|
||||
.max_keysize = CHACHA_KEY_SIZE,
|
||||
.ivsize = XCHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
.setkey = chacha12_setkey,
|
||||
.encrypt = xchacha_p10,
|
||||
.decrypt = xchacha_p10,
|
||||
}
|
||||
};
|
||||
|
||||
static int __init chacha_p10_init(void)
|
||||
{
|
||||
static_branch_enable(&have_p10);
|
||||
|
||||
return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
|
||||
}
|
||||
|
||||
static void __exit chacha_p10_exit(void)
|
||||
{
|
||||
crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
}
|
||||
|
||||
module_cpu_feature_match(PPC_MODULE_FEATURE_P10, chacha_p10_init);
|
||||
module_exit(chacha_p10_exit);
|
||||
|
||||
MODULE_DESCRIPTION("ChaCha and XChaCha stream ciphers (P10 accelerated)");
|
||||
MODULE_AUTHOR("Danny Tsen <dtsen@linux.ibm.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_ALIAS_CRYPTO("chacha20");
|
||||
MODULE_ALIAS_CRYPTO("chacha20-p10");
|
||||
MODULE_ALIAS_CRYPTO("xchacha20");
|
||||
MODULE_ALIAS_CRYPTO("xchacha20-p10");
|
||||
MODULE_ALIAS_CRYPTO("xchacha12");
|
||||
MODULE_ALIAS_CRYPTO("xchacha12-p10");
|
||||
842
arch/powerpc/crypto/chacha-p10le-8x.S
Normal file
842
arch/powerpc/crypto/chacha-p10le-8x.S
Normal file
File diff suppressed because it is too large
Load Diff
186
arch/powerpc/crypto/poly1305-p10-glue.c
Normal file
186
arch/powerpc/crypto/poly1305-p10-glue.c
Normal file
@@ -0,0 +1,186 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Poly1305 authenticator algorithm, RFC7539.
|
||||
*
|
||||
* Copyright 2023- IBM Corp. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/jump_label.h>
|
||||
#include <crypto/internal/hash.h>
|
||||
#include <crypto/internal/poly1305.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <linux/cpufeature.h>
|
||||
#include <asm/unaligned.h>
|
||||
#include <asm/simd.h>
|
||||
#include <asm/switch_to.h>
|
||||
|
||||
asmlinkage void poly1305_p10le_4blocks(void *h, const u8 *m, u32 mlen);
|
||||
asmlinkage void poly1305_64s(void *h, const u8 *m, u32 mlen, int highbit);
|
||||
asmlinkage void poly1305_emit_64(void *h, void *s, u8 *dst);
|
||||
|
||||
static void vsx_begin(void)
|
||||
{
|
||||
preempt_disable();
|
||||
enable_kernel_vsx();
|
||||
}
|
||||
|
||||
static void vsx_end(void)
|
||||
{
|
||||
disable_kernel_vsx();
|
||||
preempt_enable();
|
||||
}
|
||||
|
||||
static int crypto_poly1305_p10_init(struct shash_desc *desc)
|
||||
{
|
||||
struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
|
||||
poly1305_core_init(&dctx->h);
|
||||
dctx->buflen = 0;
|
||||
dctx->rset = 0;
|
||||
dctx->sset = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int crypto_poly1305_setdctxkey(struct poly1305_desc_ctx *dctx,
|
||||
const u8 *inp, unsigned int len)
|
||||
{
|
||||
unsigned int acc = 0;
|
||||
|
||||
if (unlikely(!dctx->sset)) {
|
||||
if (!dctx->rset && len >= POLY1305_BLOCK_SIZE) {
|
||||
struct poly1305_core_key *key = &dctx->core_r;
|
||||
|
||||
key->key.r64[0] = get_unaligned_le64(&inp[0]);
|
||||
key->key.r64[1] = get_unaligned_le64(&inp[8]);
|
||||
inp += POLY1305_BLOCK_SIZE;
|
||||
len -= POLY1305_BLOCK_SIZE;
|
||||
acc += POLY1305_BLOCK_SIZE;
|
||||
dctx->rset = 1;
|
||||
}
|
||||
if (len >= POLY1305_BLOCK_SIZE) {
|
||||
dctx->s[0] = get_unaligned_le32(&inp[0]);
|
||||
dctx->s[1] = get_unaligned_le32(&inp[4]);
|
||||
dctx->s[2] = get_unaligned_le32(&inp[8]);
|
||||
dctx->s[3] = get_unaligned_le32(&inp[12]);
|
||||
acc += POLY1305_BLOCK_SIZE;
|
||||
dctx->sset = true;
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
static int crypto_poly1305_p10_update(struct shash_desc *desc,
|
||||
const u8 *src, unsigned int srclen)
|
||||
{
|
||||
struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
unsigned int bytes, used;
|
||||
|
||||
if (unlikely(dctx->buflen)) {
|
||||
bytes = min(srclen, POLY1305_BLOCK_SIZE - dctx->buflen);
|
||||
memcpy(dctx->buf + dctx->buflen, src, bytes);
|
||||
src += bytes;
|
||||
srclen -= bytes;
|
||||
dctx->buflen += bytes;
|
||||
|
||||
if (dctx->buflen == POLY1305_BLOCK_SIZE) {
|
||||
if (likely(!crypto_poly1305_setdctxkey(dctx, dctx->buf,
|
||||
POLY1305_BLOCK_SIZE))) {
|
||||
vsx_begin();
|
||||
poly1305_64s(&dctx->h, dctx->buf,
|
||||
POLY1305_BLOCK_SIZE, 1);
|
||||
vsx_end();
|
||||
}
|
||||
dctx->buflen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (likely(srclen >= POLY1305_BLOCK_SIZE)) {
|
||||
bytes = round_down(srclen, POLY1305_BLOCK_SIZE);
|
||||
used = crypto_poly1305_setdctxkey(dctx, src, bytes);
|
||||
if (likely(used)) {
|
||||
srclen -= used;
|
||||
src += used;
|
||||
}
|
||||
if (crypto_simd_usable() && (srclen >= POLY1305_BLOCK_SIZE*4)) {
|
||||
vsx_begin();
|
||||
poly1305_p10le_4blocks(&dctx->h, src, srclen);
|
||||
vsx_end();
|
||||
src += srclen - (srclen % (POLY1305_BLOCK_SIZE * 4));
|
||||
srclen %= POLY1305_BLOCK_SIZE * 4;
|
||||
}
|
||||
while (srclen >= POLY1305_BLOCK_SIZE) {
|
||||
vsx_begin();
|
||||
poly1305_64s(&dctx->h, src, POLY1305_BLOCK_SIZE, 1);
|
||||
vsx_end();
|
||||
srclen -= POLY1305_BLOCK_SIZE;
|
||||
src += POLY1305_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely(srclen)) {
|
||||
dctx->buflen = srclen;
|
||||
memcpy(dctx->buf, src, srclen);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int crypto_poly1305_p10_final(struct shash_desc *desc, u8 *dst)
|
||||
{
|
||||
struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
|
||||
if (unlikely(!dctx->sset))
|
||||
return -ENOKEY;
|
||||
|
||||
if ((dctx->buflen)) {
|
||||
dctx->buf[dctx->buflen++] = 1;
|
||||
memset(dctx->buf + dctx->buflen, 0,
|
||||
POLY1305_BLOCK_SIZE - dctx->buflen);
|
||||
vsx_begin();
|
||||
poly1305_64s(&dctx->h, dctx->buf, POLY1305_BLOCK_SIZE, 0);
|
||||
vsx_end();
|
||||
dctx->buflen = 0;
|
||||
}
|
||||
|
||||
poly1305_emit_64(&dctx->h, &dctx->s, dst);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct shash_alg poly1305_alg = {
|
||||
.digestsize = POLY1305_DIGEST_SIZE,
|
||||
.init = crypto_poly1305_p10_init,
|
||||
.update = crypto_poly1305_p10_update,
|
||||
.final = crypto_poly1305_p10_final,
|
||||
.descsize = sizeof(struct poly1305_desc_ctx),
|
||||
.base = {
|
||||
.cra_name = "poly1305",
|
||||
.cra_driver_name = "poly1305-p10",
|
||||
.cra_priority = 300,
|
||||
.cra_blocksize = POLY1305_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init poly1305_p10_init(void)
|
||||
{
|
||||
return crypto_register_shash(&poly1305_alg);
|
||||
}
|
||||
|
||||
static void __exit poly1305_p10_exit(void)
|
||||
{
|
||||
crypto_unregister_shash(&poly1305_alg);
|
||||
}
|
||||
|
||||
module_cpu_feature_match(PPC_MODULE_FEATURE_P10, poly1305_p10_init);
|
||||
module_exit(poly1305_p10_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Danny Tsen <dtsen@linux.ibm.com>");
|
||||
MODULE_DESCRIPTION("Optimized Poly1305 for P10");
|
||||
MODULE_ALIAS_CRYPTO("poly1305");
|
||||
MODULE_ALIAS_CRYPTO("poly1305-p10");
|
||||
1075
arch/powerpc/crypto/poly1305-p10le_64.S
Normal file
1075
arch/powerpc/crypto/poly1305-p10le_64.S
Normal file
File diff suppressed because it is too large
Load Diff
@@ -229,10 +229,9 @@ static inline struct crypto_aes_ctx *aes_ctx(void *raw_ctx)
|
||||
return (struct crypto_aes_ctx *)ALIGN(addr, align);
|
||||
}
|
||||
|
||||
static int aes_set_key_common(struct crypto_tfm *tfm, void *raw_ctx,
|
||||
static int aes_set_key_common(struct crypto_aes_ctx *ctx,
|
||||
const u8 *in_key, unsigned int key_len)
|
||||
{
|
||||
struct crypto_aes_ctx *ctx = aes_ctx(raw_ctx);
|
||||
int err;
|
||||
|
||||
if (key_len != AES_KEYSIZE_128 && key_len != AES_KEYSIZE_192 &&
|
||||
@@ -253,7 +252,8 @@ static int aes_set_key_common(struct crypto_tfm *tfm, void *raw_ctx,
|
||||
static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
|
||||
unsigned int key_len)
|
||||
{
|
||||
return aes_set_key_common(tfm, crypto_tfm_ctx(tfm), in_key, key_len);
|
||||
return aes_set_key_common(aes_ctx(crypto_tfm_ctx(tfm)), in_key,
|
||||
key_len);
|
||||
}
|
||||
|
||||
static void aesni_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
|
||||
@@ -285,8 +285,7 @@ static void aesni_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
|
||||
static int aesni_skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
unsigned int len)
|
||||
{
|
||||
return aes_set_key_common(crypto_skcipher_tfm(tfm),
|
||||
crypto_skcipher_ctx(tfm), key, len);
|
||||
return aes_set_key_common(aes_ctx(crypto_skcipher_ctx(tfm)), key, len);
|
||||
}
|
||||
|
||||
static int ecb_encrypt(struct skcipher_request *req)
|
||||
@@ -627,8 +626,7 @@ static int common_rfc4106_set_key(struct crypto_aead *aead, const u8 *key,
|
||||
|
||||
memcpy(ctx->nonce, key + key_len, sizeof(ctx->nonce));
|
||||
|
||||
return aes_set_key_common(crypto_aead_tfm(aead),
|
||||
&ctx->aes_key_expanded, key, key_len) ?:
|
||||
return aes_set_key_common(&ctx->aes_key_expanded, key, key_len) ?:
|
||||
rfc4106_set_hash_subkey(ctx->hash_subkey, key, key_len);
|
||||
}
|
||||
|
||||
@@ -893,14 +891,13 @@ static int xts_aesni_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
keylen /= 2;
|
||||
|
||||
/* first half of xts-key is for crypt */
|
||||
err = aes_set_key_common(crypto_skcipher_tfm(tfm), ctx->raw_crypt_ctx,
|
||||
key, keylen);
|
||||
err = aes_set_key_common(aes_ctx(ctx->raw_crypt_ctx), key, keylen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* second half of xts-key is for tweak */
|
||||
return aes_set_key_common(crypto_skcipher_tfm(tfm), ctx->raw_tweak_ctx,
|
||||
key + keylen, keylen);
|
||||
return aes_set_key_common(aes_ctx(ctx->raw_tweak_ctx), key + keylen,
|
||||
keylen);
|
||||
}
|
||||
|
||||
static int xts_crypt(struct skcipher_request *req, bool encrypt)
|
||||
@@ -1150,8 +1147,7 @@ static int generic_gcmaes_set_key(struct crypto_aead *aead, const u8 *key,
|
||||
{
|
||||
struct generic_gcmaes_ctx *ctx = generic_gcmaes_ctx_get(aead);
|
||||
|
||||
return aes_set_key_common(crypto_aead_tfm(aead),
|
||||
&ctx->aes_key_expanded, key, key_len) ?:
|
||||
return aes_set_key_common(&ctx->aes_key_expanded, key, key_len) ?:
|
||||
rfc4106_set_hash_subkey(ctx->hash_subkey, key, key_len);
|
||||
}
|
||||
|
||||
|
||||
@@ -320,18 +320,21 @@ static int alg_setkey_by_key_serial(struct alg_sock *ask, sockptr_t optval,
|
||||
|
||||
if (IS_ERR(ret)) {
|
||||
up_read(&key->sem);
|
||||
key_put(key);
|
||||
return PTR_ERR(ret);
|
||||
}
|
||||
|
||||
key_data = sock_kmalloc(&ask->sk, key_datalen, GFP_KERNEL);
|
||||
if (!key_data) {
|
||||
up_read(&key->sem);
|
||||
key_put(key);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(key_data, ret, key_datalen);
|
||||
|
||||
up_read(&key->sem);
|
||||
key_put(key);
|
||||
|
||||
err = type->setkey(ask->private, key_data, key_datalen);
|
||||
|
||||
@@ -1192,6 +1195,7 @@ struct af_alg_async_req *af_alg_alloc_areq(struct sock *sk,
|
||||
|
||||
areq->areqlen = areqlen;
|
||||
areq->sk = sk;
|
||||
areq->first_rsgl.sgl.sgt.sgl = areq->first_rsgl.sgl.sgl;
|
||||
areq->last_rsgl = NULL;
|
||||
INIT_LIST_HEAD(&areq->rsgl_list);
|
||||
areq->tsgl = NULL;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@@ -74,15 +75,26 @@ static void crypto_free_instance(struct crypto_instance *inst)
|
||||
inst->alg.cra_type->free(inst);
|
||||
}
|
||||
|
||||
static void crypto_destroy_instance(struct crypto_alg *alg)
|
||||
static void crypto_destroy_instance_workfn(struct work_struct *w)
|
||||
{
|
||||
struct crypto_instance *inst = (void *)alg;
|
||||
struct crypto_instance *inst = container_of(w, struct crypto_instance,
|
||||
free_work);
|
||||
struct crypto_template *tmpl = inst->tmpl;
|
||||
|
||||
crypto_free_instance(inst);
|
||||
crypto_tmpl_put(tmpl);
|
||||
}
|
||||
|
||||
static void crypto_destroy_instance(struct crypto_alg *alg)
|
||||
{
|
||||
struct crypto_instance *inst = container_of(alg,
|
||||
struct crypto_instance,
|
||||
alg);
|
||||
|
||||
INIT_WORK(&inst->free_work, crypto_destroy_instance_workfn);
|
||||
schedule_work(&inst->free_work);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function adds a spawn to the list secondary_spawns which
|
||||
* will be used at the end of crypto_remove_spawns to unregister
|
||||
|
||||
@@ -42,7 +42,7 @@ static void public_key_describe(const struct key *asymmetric_key,
|
||||
void public_key_free(struct public_key *key)
|
||||
{
|
||||
if (key) {
|
||||
kfree(key->key);
|
||||
kfree_sensitive(key->key);
|
||||
kfree(key->params);
|
||||
kfree(key);
|
||||
}
|
||||
@@ -263,7 +263,7 @@ error_free_tfm:
|
||||
else
|
||||
crypto_free_akcipher(tfm);
|
||||
error_free_key:
|
||||
kfree(key);
|
||||
kfree_sensitive(key);
|
||||
pr_devel("<==%s() = %d\n", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -369,7 +369,7 @@ error_free_tfm:
|
||||
else
|
||||
crypto_free_akcipher(tfm);
|
||||
error_free_key:
|
||||
kfree(key);
|
||||
kfree_sensitive(key);
|
||||
pr_devel("<==%s() = %d\n", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -441,7 +441,7 @@ int public_key_verify_signature(const struct public_key *pkey,
|
||||
sig->digest, sig->digest_size);
|
||||
|
||||
error_free_key:
|
||||
kfree(key);
|
||||
kfree_sensitive(key);
|
||||
error_free_tfm:
|
||||
crypto_free_sig(tfm);
|
||||
pr_devel("<==%s() = %d\n", __func__, ret);
|
||||
|
||||
@@ -391,7 +391,7 @@ error_no_desc:
|
||||
* verify_pefile_signature - Verify the signature on a PE binary image
|
||||
* @pebuf: Buffer containing the PE binary image
|
||||
* @pelen: Length of the binary image
|
||||
* @trust_keys: Signing certificate(s) to use as starting points
|
||||
* @trusted_keys: Signing certificate(s) to use as starting points
|
||||
* @usage: The use to which the key is being put.
|
||||
*
|
||||
* Validate that the certificate chain inside the PKCS#7 message inside the PE
|
||||
|
||||
@@ -130,6 +130,11 @@ int x509_check_for_self_signed(struct x509_certificate *cert)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (cert->unsupported_sig) {
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = public_key_verify_signature(cert->pub, cert->sig);
|
||||
if (ret < 0) {
|
||||
if (ret == -ENOPKG) {
|
||||
|
||||
@@ -7,15 +7,30 @@
|
||||
* Author: Baolin Wang <baolin.wang@linaro.org>
|
||||
*/
|
||||
|
||||
#include <crypto/internal/aead.h>
|
||||
#include <crypto/internal/akcipher.h>
|
||||
#include <crypto/internal/engine.h>
|
||||
#include <crypto/internal/hash.h>
|
||||
#include <crypto/internal/kpp.h>
|
||||
#include <crypto/internal/skcipher.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <crypto/engine.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <uapi/linux/sched/types.h>
|
||||
#include "internal.h"
|
||||
|
||||
#define CRYPTO_ENGINE_MAX_QLEN 10
|
||||
|
||||
/* Temporary algorithm flag used to indicate an updated driver. */
|
||||
#define CRYPTO_ALG_ENGINE 0x200
|
||||
|
||||
struct crypto_engine_alg {
|
||||
struct crypto_alg base;
|
||||
struct crypto_engine_op op;
|
||||
};
|
||||
|
||||
/**
|
||||
* crypto_finalize_request - finalize one request if the request is done
|
||||
* @engine: the hardware engine
|
||||
@@ -26,9 +41,6 @@ static void crypto_finalize_request(struct crypto_engine *engine,
|
||||
struct crypto_async_request *req, int err)
|
||||
{
|
||||
unsigned long flags;
|
||||
bool finalize_req = false;
|
||||
int ret;
|
||||
struct crypto_engine_ctx *enginectx;
|
||||
|
||||
/*
|
||||
* If hardware cannot enqueue more requests
|
||||
@@ -38,21 +50,11 @@ static void crypto_finalize_request(struct crypto_engine *engine,
|
||||
if (!engine->retry_support) {
|
||||
spin_lock_irqsave(&engine->queue_lock, flags);
|
||||
if (engine->cur_req == req) {
|
||||
finalize_req = true;
|
||||
engine->cur_req = NULL;
|
||||
}
|
||||
spin_unlock_irqrestore(&engine->queue_lock, flags);
|
||||
}
|
||||
|
||||
if (finalize_req || engine->retry_support) {
|
||||
enginectx = crypto_tfm_ctx(req->tfm);
|
||||
if (enginectx->op.prepare_request &&
|
||||
enginectx->op.unprepare_request) {
|
||||
ret = enginectx->op.unprepare_request(engine, req);
|
||||
if (ret)
|
||||
dev_err(engine->dev, "failed to unprepare request\n");
|
||||
}
|
||||
}
|
||||
lockdep_assert_in_softirq();
|
||||
crypto_request_complete(req, err);
|
||||
|
||||
@@ -72,10 +74,11 @@ static void crypto_pump_requests(struct crypto_engine *engine,
|
||||
bool in_kthread)
|
||||
{
|
||||
struct crypto_async_request *async_req, *backlog;
|
||||
struct crypto_engine_alg *alg;
|
||||
struct crypto_engine_op *op;
|
||||
unsigned long flags;
|
||||
bool was_busy = false;
|
||||
int ret;
|
||||
struct crypto_engine_ctx *enginectx;
|
||||
|
||||
spin_lock_irqsave(&engine->queue_lock, flags);
|
||||
|
||||
@@ -141,27 +144,21 @@ start_request:
|
||||
ret = engine->prepare_crypt_hardware(engine);
|
||||
if (ret) {
|
||||
dev_err(engine->dev, "failed to prepare crypt hardware\n");
|
||||
goto req_err_2;
|
||||
goto req_err_1;
|
||||
}
|
||||
}
|
||||
|
||||
enginectx = crypto_tfm_ctx(async_req->tfm);
|
||||
|
||||
if (enginectx->op.prepare_request) {
|
||||
ret = enginectx->op.prepare_request(engine, async_req);
|
||||
if (ret) {
|
||||
dev_err(engine->dev, "failed to prepare request: %d\n",
|
||||
ret);
|
||||
goto req_err_2;
|
||||
}
|
||||
}
|
||||
if (!enginectx->op.do_one_request) {
|
||||
if (async_req->tfm->__crt_alg->cra_flags & CRYPTO_ALG_ENGINE) {
|
||||
alg = container_of(async_req->tfm->__crt_alg,
|
||||
struct crypto_engine_alg, base);
|
||||
op = &alg->op;
|
||||
} else {
|
||||
dev_err(engine->dev, "failed to do request\n");
|
||||
ret = -EINVAL;
|
||||
goto req_err_1;
|
||||
}
|
||||
|
||||
ret = enginectx->op.do_one_request(engine, async_req);
|
||||
ret = op->do_one_request(engine, async_req);
|
||||
|
||||
/* Request unsuccessfully executed by hardware */
|
||||
if (ret < 0) {
|
||||
@@ -177,18 +174,6 @@ start_request:
|
||||
ret);
|
||||
goto req_err_1;
|
||||
}
|
||||
/*
|
||||
* If retry mechanism is supported,
|
||||
* unprepare current request and
|
||||
* enqueue it back into crypto-engine queue.
|
||||
*/
|
||||
if (enginectx->op.unprepare_request) {
|
||||
ret = enginectx->op.unprepare_request(engine,
|
||||
async_req);
|
||||
if (ret)
|
||||
dev_err(engine->dev,
|
||||
"failed to unprepare request\n");
|
||||
}
|
||||
spin_lock_irqsave(&engine->queue_lock, flags);
|
||||
/*
|
||||
* If hardware was unable to execute request, enqueue it
|
||||
@@ -204,13 +189,6 @@ start_request:
|
||||
goto retry;
|
||||
|
||||
req_err_1:
|
||||
if (enginectx->op.unprepare_request) {
|
||||
ret = enginectx->op.unprepare_request(engine, async_req);
|
||||
if (ret)
|
||||
dev_err(engine->dev, "failed to unprepare request\n");
|
||||
}
|
||||
|
||||
req_err_2:
|
||||
crypto_request_complete(async_req, ret);
|
||||
|
||||
retry:
|
||||
@@ -591,5 +569,177 @@ int crypto_engine_exit(struct crypto_engine *engine)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_exit);
|
||||
|
||||
int crypto_engine_register_aead(struct aead_engine_alg *alg)
|
||||
{
|
||||
if (!alg->op.do_one_request)
|
||||
return -EINVAL;
|
||||
|
||||
alg->base.base.cra_flags |= CRYPTO_ALG_ENGINE;
|
||||
|
||||
return crypto_register_aead(&alg->base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_register_aead);
|
||||
|
||||
void crypto_engine_unregister_aead(struct aead_engine_alg *alg)
|
||||
{
|
||||
crypto_unregister_aead(&alg->base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_unregister_aead);
|
||||
|
||||
int crypto_engine_register_aeads(struct aead_engine_alg *algs, int count)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ret = crypto_engine_register_aead(&algs[i]);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
crypto_engine_unregister_aeads(algs, i);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_register_aeads);
|
||||
|
||||
void crypto_engine_unregister_aeads(struct aead_engine_alg *algs, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = count - 1; i >= 0; --i)
|
||||
crypto_engine_unregister_aead(&algs[i]);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_unregister_aeads);
|
||||
|
||||
int crypto_engine_register_ahash(struct ahash_engine_alg *alg)
|
||||
{
|
||||
if (!alg->op.do_one_request)
|
||||
return -EINVAL;
|
||||
|
||||
alg->base.halg.base.cra_flags |= CRYPTO_ALG_ENGINE;
|
||||
|
||||
return crypto_register_ahash(&alg->base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_register_ahash);
|
||||
|
||||
void crypto_engine_unregister_ahash(struct ahash_engine_alg *alg)
|
||||
{
|
||||
crypto_unregister_ahash(&alg->base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_unregister_ahash);
|
||||
|
||||
int crypto_engine_register_ahashes(struct ahash_engine_alg *algs, int count)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ret = crypto_engine_register_ahash(&algs[i]);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
crypto_engine_unregister_ahashes(algs, i);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_register_ahashes);
|
||||
|
||||
void crypto_engine_unregister_ahashes(struct ahash_engine_alg *algs,
|
||||
int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = count - 1; i >= 0; --i)
|
||||
crypto_engine_unregister_ahash(&algs[i]);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_unregister_ahashes);
|
||||
|
||||
int crypto_engine_register_akcipher(struct akcipher_engine_alg *alg)
|
||||
{
|
||||
if (!alg->op.do_one_request)
|
||||
return -EINVAL;
|
||||
|
||||
alg->base.base.cra_flags |= CRYPTO_ALG_ENGINE;
|
||||
|
||||
return crypto_register_akcipher(&alg->base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_register_akcipher);
|
||||
|
||||
void crypto_engine_unregister_akcipher(struct akcipher_engine_alg *alg)
|
||||
{
|
||||
crypto_unregister_akcipher(&alg->base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_unregister_akcipher);
|
||||
|
||||
int crypto_engine_register_kpp(struct kpp_engine_alg *alg)
|
||||
{
|
||||
if (!alg->op.do_one_request)
|
||||
return -EINVAL;
|
||||
|
||||
alg->base.base.cra_flags |= CRYPTO_ALG_ENGINE;
|
||||
|
||||
return crypto_register_kpp(&alg->base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_register_kpp);
|
||||
|
||||
void crypto_engine_unregister_kpp(struct kpp_engine_alg *alg)
|
||||
{
|
||||
crypto_unregister_kpp(&alg->base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_unregister_kpp);
|
||||
|
||||
int crypto_engine_register_skcipher(struct skcipher_engine_alg *alg)
|
||||
{
|
||||
if (!alg->op.do_one_request)
|
||||
return -EINVAL;
|
||||
|
||||
alg->base.base.cra_flags |= CRYPTO_ALG_ENGINE;
|
||||
|
||||
return crypto_register_skcipher(&alg->base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_register_skcipher);
|
||||
|
||||
void crypto_engine_unregister_skcipher(struct skcipher_engine_alg *alg)
|
||||
{
|
||||
return crypto_unregister_skcipher(&alg->base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_unregister_skcipher);
|
||||
|
||||
int crypto_engine_register_skciphers(struct skcipher_engine_alg *algs,
|
||||
int count)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ret = crypto_engine_register_skcipher(&algs[i]);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
crypto_engine_unregister_skciphers(algs, i);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_register_skciphers);
|
||||
|
||||
void crypto_engine_unregister_skciphers(struct skcipher_engine_alg *algs,
|
||||
int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = count - 1; i >= 0; --i)
|
||||
crypto_engine_unregister_skcipher(&algs[i]);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_engine_unregister_skciphers);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("Crypto hardware engine framework");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user