mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 16:23:29 +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>
51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Fallback for sync aes(ctr) in contexts where kernel mode NEON
|
|
* is not allowed
|
|
*
|
|
* Copyright (C) 2017 Linaro Ltd <ard.biesheuvel@linaro.org>
|
|
*/
|
|
|
|
#include <crypto/aes.h>
|
|
#include <crypto/internal/skcipher.h>
|
|
|
|
asmlinkage void __aes_arm64_encrypt(u32 *rk, u8 *out, const u8 *in, int rounds);
|
|
|
|
static inline int aes_ctr_encrypt_fallback(struct crypto_aes_ctx *ctx,
|
|
struct skcipher_request *req)
|
|
{
|
|
struct skcipher_walk walk;
|
|
u8 buf[AES_BLOCK_SIZE];
|
|
int err;
|
|
|
|
err = skcipher_walk_virt(&walk, req, true);
|
|
|
|
while (walk.nbytes > 0) {
|
|
u8 *dst = walk.dst.virt.addr;
|
|
u8 *src = walk.src.virt.addr;
|
|
int nbytes = walk.nbytes;
|
|
int tail = 0;
|
|
|
|
if (nbytes < walk.total) {
|
|
nbytes = round_down(nbytes, AES_BLOCK_SIZE);
|
|
tail = walk.nbytes % AES_BLOCK_SIZE;
|
|
}
|
|
|
|
do {
|
|
int bsize = min(nbytes, AES_BLOCK_SIZE);
|
|
|
|
__aes_arm64_encrypt(ctx->key_enc, buf, walk.iv,
|
|
6 + ctx->key_length / 4);
|
|
crypto_xor_cpy(dst, src, buf, bsize);
|
|
crypto_inc(walk.iv, AES_BLOCK_SIZE);
|
|
|
|
dst += AES_BLOCK_SIZE;
|
|
src += AES_BLOCK_SIZE;
|
|
nbytes -= AES_BLOCK_SIZE;
|
|
} while (nbytes > 0);
|
|
|
|
err = skcipher_walk_done(&walk, tail);
|
|
}
|
|
return err;
|
|
}
|