mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 21:29:49 +07:00
81ff5d2cba
Pull crypto update from Herbert Xu: "API: - Add support for AEAD in simd - Add fuzz testing to testmgr - Add panic_on_fail module parameter to testmgr - Use per-CPU struct instead multiple variables in scompress - Change verify API for akcipher Algorithms: - Convert x86 AEAD algorithms over to simd - Forbid 2-key 3DES in FIPS mode - Add EC-RDSA (GOST 34.10) algorithm Drivers: - Set output IV with ctr-aes in crypto4xx - Set output IV in rockchip - Fix potential length overflow with hashing in sun4i-ss - Fix computation error with ctr in vmx - Add SM4 protected keys support in ccree - Remove long-broken mxc-scc driver - Add rfc4106(gcm(aes)) cipher support in cavium/nitrox" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (179 commits) crypto: ccree - use a proper le32 type for le32 val crypto: ccree - remove set but not used variable 'du_size' crypto: ccree - Make cc_sec_disable static crypto: ccree - fix spelling mistake "protedcted" -> "protected" crypto: caam/qi2 - generate hash keys in-place crypto: caam/qi2 - fix DMA mapping of stack memory crypto: caam/qi2 - fix zero-length buffer DMA mapping crypto: stm32/cryp - update to return iv_out crypto: stm32/cryp - remove request mutex protection crypto: stm32/cryp - add weak key check for DES crypto: atmel - remove set but not used variable 'alg_name' crypto: picoxcell - Use dev_get_drvdata() crypto: crypto4xx - get rid of redundant using_sd variable crypto: crypto4xx - use sync skcipher for fallback crypto: crypto4xx - fix cfb and ofb "overran dst buffer" issues crypto: crypto4xx - fix ctr-aes missing output IV crypto: ecrdsa - select ASN1 and OID_REGISTRY for EC-RDSA crypto: ux500 - use ccflags-y instead of CFLAGS_<basename>.o crypto: ccree - handle tee fips error during power management resume crypto: ccree - add function to handle cryptocell tee fips error ...
79 lines
2.1 KiB
C
79 lines
2.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* NHPoly1305 - ε-almost-∆-universal hash function for Adiantum
|
|
* (ARM64 NEON accelerated version)
|
|
*
|
|
* Copyright 2018 Google LLC
|
|
*/
|
|
|
|
#include <asm/neon.h>
|
|
#include <asm/simd.h>
|
|
#include <crypto/internal/hash.h>
|
|
#include <crypto/internal/simd.h>
|
|
#include <crypto/nhpoly1305.h>
|
|
#include <linux/module.h>
|
|
|
|
asmlinkage void nh_neon(const u32 *key, const u8 *message, size_t message_len,
|
|
u8 hash[NH_HASH_BYTES]);
|
|
|
|
/* wrapper to avoid indirect call to assembly, which doesn't work with CFI */
|
|
static void _nh_neon(const u32 *key, const u8 *message, size_t message_len,
|
|
__le64 hash[NH_NUM_PASSES])
|
|
{
|
|
nh_neon(key, message, message_len, (u8 *)hash);
|
|
}
|
|
|
|
static int nhpoly1305_neon_update(struct shash_desc *desc,
|
|
const u8 *src, unsigned int srclen)
|
|
{
|
|
if (srclen < 64 || !crypto_simd_usable())
|
|
return crypto_nhpoly1305_update(desc, src, srclen);
|
|
|
|
do {
|
|
unsigned int n = min_t(unsigned int, srclen, PAGE_SIZE);
|
|
|
|
kernel_neon_begin();
|
|
crypto_nhpoly1305_update_helper(desc, src, n, _nh_neon);
|
|
kernel_neon_end();
|
|
src += n;
|
|
srclen -= n;
|
|
} while (srclen);
|
|
return 0;
|
|
}
|
|
|
|
static struct shash_alg nhpoly1305_alg = {
|
|
.base.cra_name = "nhpoly1305",
|
|
.base.cra_driver_name = "nhpoly1305-neon",
|
|
.base.cra_priority = 200,
|
|
.base.cra_ctxsize = sizeof(struct nhpoly1305_key),
|
|
.base.cra_module = THIS_MODULE,
|
|
.digestsize = POLY1305_DIGEST_SIZE,
|
|
.init = crypto_nhpoly1305_init,
|
|
.update = nhpoly1305_neon_update,
|
|
.final = crypto_nhpoly1305_final,
|
|
.setkey = crypto_nhpoly1305_setkey,
|
|
.descsize = sizeof(struct nhpoly1305_state),
|
|
};
|
|
|
|
static int __init nhpoly1305_mod_init(void)
|
|
{
|
|
if (!cpu_have_named_feature(ASIMD))
|
|
return -ENODEV;
|
|
|
|
return crypto_register_shash(&nhpoly1305_alg);
|
|
}
|
|
|
|
static void __exit nhpoly1305_mod_exit(void)
|
|
{
|
|
crypto_unregister_shash(&nhpoly1305_alg);
|
|
}
|
|
|
|
module_init(nhpoly1305_mod_init);
|
|
module_exit(nhpoly1305_mod_exit);
|
|
|
|
MODULE_DESCRIPTION("NHPoly1305 ε-almost-∆-universal hash function (NEON-accelerated)");
|
|
MODULE_LICENSE("GPL v2");
|
|
MODULE_AUTHOR("Eric Biggers <ebiggers@google.com>");
|
|
MODULE_ALIAS_CRYPTO("nhpoly1305");
|
|
MODULE_ALIAS_CRYPTO("nhpoly1305-neon");
|