mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 23:25:37 +07:00
d2912cb15b
Based on 2 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation # extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 4122 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Enrico Weigelt <info@metux.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
95 lines
2.3 KiB
C
95 lines
2.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* sha512-neon-glue.c - accelerated SHA-384/512 for ARM NEON
|
|
*
|
|
* Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
|
|
*/
|
|
|
|
#include <crypto/internal/hash.h>
|
|
#include <crypto/internal/simd.h>
|
|
#include <crypto/sha.h>
|
|
#include <crypto/sha512_base.h>
|
|
#include <linux/crypto.h>
|
|
#include <linux/module.h>
|
|
|
|
#include <asm/simd.h>
|
|
#include <asm/neon.h>
|
|
|
|
#include "sha512.h"
|
|
|
|
MODULE_ALIAS_CRYPTO("sha384-neon");
|
|
MODULE_ALIAS_CRYPTO("sha512-neon");
|
|
|
|
asmlinkage void sha512_block_data_order_neon(u64 *state, u8 const *src,
|
|
int blocks);
|
|
|
|
static int sha512_neon_update(struct shash_desc *desc, const u8 *data,
|
|
unsigned int len)
|
|
{
|
|
struct sha512_state *sctx = shash_desc_ctx(desc);
|
|
|
|
if (!crypto_simd_usable() ||
|
|
(sctx->count[0] % SHA512_BLOCK_SIZE) + len < SHA512_BLOCK_SIZE)
|
|
return sha512_arm_update(desc, data, len);
|
|
|
|
kernel_neon_begin();
|
|
sha512_base_do_update(desc, data, len,
|
|
(sha512_block_fn *)sha512_block_data_order_neon);
|
|
kernel_neon_end();
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int sha512_neon_finup(struct shash_desc *desc, const u8 *data,
|
|
unsigned int len, u8 *out)
|
|
{
|
|
if (!crypto_simd_usable())
|
|
return sha512_arm_finup(desc, data, len, out);
|
|
|
|
kernel_neon_begin();
|
|
if (len)
|
|
sha512_base_do_update(desc, data, len,
|
|
(sha512_block_fn *)sha512_block_data_order_neon);
|
|
sha512_base_do_finalize(desc,
|
|
(sha512_block_fn *)sha512_block_data_order_neon);
|
|
kernel_neon_end();
|
|
|
|
return sha512_base_finish(desc, out);
|
|
}
|
|
|
|
static int sha512_neon_final(struct shash_desc *desc, u8 *out)
|
|
{
|
|
return sha512_neon_finup(desc, NULL, 0, out);
|
|
}
|
|
|
|
struct shash_alg sha512_neon_algs[] = { {
|
|
.init = sha384_base_init,
|
|
.update = sha512_neon_update,
|
|
.final = sha512_neon_final,
|
|
.finup = sha512_neon_finup,
|
|
.descsize = sizeof(struct sha512_state),
|
|
.digestsize = SHA384_DIGEST_SIZE,
|
|
.base = {
|
|
.cra_name = "sha384",
|
|
.cra_driver_name = "sha384-neon",
|
|
.cra_priority = 300,
|
|
.cra_blocksize = SHA384_BLOCK_SIZE,
|
|
.cra_module = THIS_MODULE,
|
|
|
|
}
|
|
}, {
|
|
.init = sha512_base_init,
|
|
.update = sha512_neon_update,
|
|
.final = sha512_neon_final,
|
|
.finup = sha512_neon_finup,
|
|
.descsize = sizeof(struct sha512_state),
|
|
.digestsize = SHA512_DIGEST_SIZE,
|
|
.base = {
|
|
.cra_name = "sha512",
|
|
.cra_driver_name = "sha512-neon",
|
|
.cra_priority = 300,
|
|
.cra_blocksize = SHA512_BLOCK_SIZE,
|
|
.cra_module = THIS_MODULE,
|
|
}
|
|
} };
|