Skip to content

Commit

Permalink
Revert "crypto: aegis128 - add support for SIMD acceleration"
Browse files Browse the repository at this point in the history
This reverts commit ecc8bc8
("crypto: aegis128 - provide a SIMD implementation based on NEON
intrinsics") and commit 7cdc0dd
("crypto: aegis128 - add support for SIMD acceleration").

They cause compile errors on platforms other than ARM because
the mechanism to selectively compile the SIMD code is broken.

Repoted-by: Heiko Carstens <[email protected]>
Reported-by: Stephen Rothwell <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Aug 2, 2019
1 parent 82cb548 commit c9f1fd4
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 247 deletions.
5 changes: 0 additions & 5 deletions crypto/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,6 @@ config CRYPTO_AEGIS128
help
Support for the AEGIS-128 dedicated AEAD algorithm.

config CRYPTO_AEGIS128_SIMD
bool "Support SIMD acceleration for AEGIS-128"
depends on CRYPTO_AEGIS128 && ((ARM || ARM64) && KERNEL_MODE_NEON)
default y

config CRYPTO_AEGIS128_AESNI_SSE2
tristate "AEGIS-128 AEAD algorithm (x86_64 AESNI+SSE2 implementation)"
depends on X86 && 64BIT
Expand Down
12 changes: 0 additions & 12 deletions crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,6 @@ obj-$(CONFIG_CRYPTO_GCM) += gcm.o
obj-$(CONFIG_CRYPTO_CCM) += ccm.o
obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
aegis128-y := aegis128-core.o

ifeq ($(ARCH),arm)
CFLAGS_aegis128-neon-inner.o += -ffreestanding -march=armv7-a -mfloat-abi=softfp -mfpu=crypto-neon-fp-armv8
aegis128-$(CONFIG_CRYPTO_AEGIS128_SIMD) += aegis128-neon.o aegis128-neon-inner.o
endif
ifeq ($(ARCH),arm64)
CFLAGS_aegis128-neon-inner.o += -ffreestanding -mcpu=generic+crypto
CFLAGS_REMOVE_aegis128-neon-inner.o += -mgeneral-regs-only
aegis128-$(CONFIG_CRYPTO_AEGIS128_SIMD) += aegis128-neon.o aegis128-neon-inner.o
endif

obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
obj-$(CONFIG_CRYPTO_DES) += des_generic.o
Expand Down
149 changes: 0 additions & 149 deletions crypto/aegis128-neon-inner.c

This file was deleted.

43 changes: 0 additions & 43 deletions crypto/aegis128-neon.c

This file was deleted.

42 changes: 4 additions & 38 deletions crypto/aegis128-core.c → crypto/aegis128.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@

#include <crypto/algapi.h>
#include <crypto/internal/aead.h>
#include <crypto/internal/simd.h>
#include <crypto/internal/skcipher.h>
#include <crypto/scatterwalk.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/scatterlist.h>
#include <asm/simd.h>

#include "aegis.h"

Expand All @@ -42,15 +40,6 @@ struct aegis128_ops {
const u8 *src, unsigned int size);
};

static bool have_simd;

bool crypto_aegis128_have_simd(void);
void crypto_aegis128_update_simd(struct aegis_state *state, const void *msg);
void crypto_aegis128_encrypt_chunk_simd(struct aegis_state *state, u8 *dst,
const u8 *src, unsigned int size);
void crypto_aegis128_decrypt_chunk_simd(struct aegis_state *state, u8 *dst,
const u8 *src, unsigned int size);

static void crypto_aegis128_update(struct aegis_state *state)
{
union aegis_block tmp;
Expand All @@ -66,22 +55,12 @@ static void crypto_aegis128_update(struct aegis_state *state)
static void crypto_aegis128_update_a(struct aegis_state *state,
const union aegis_block *msg)
{
if (have_simd && crypto_simd_usable()) {
crypto_aegis128_update_simd(state, msg);
return;
}

crypto_aegis128_update(state);
crypto_aegis_block_xor(&state->blocks[0], msg);
}

static void crypto_aegis128_update_u(struct aegis_state *state, const void *msg)
{
if (have_simd && crypto_simd_usable()) {
crypto_aegis128_update_simd(state, msg);
return;
}

crypto_aegis128_update(state);
crypto_xor(state->blocks[0].bytes, msg, AEGIS_BLOCK_SIZE);
}
Expand Down Expand Up @@ -386,7 +365,7 @@ static void crypto_aegis128_crypt(struct aead_request *req,

static int crypto_aegis128_encrypt(struct aead_request *req)
{
const struct aegis128_ops *ops = &(struct aegis128_ops){
static const struct aegis128_ops ops = {
.skcipher_walk_init = skcipher_walk_aead_encrypt,
.crypt_chunk = crypto_aegis128_encrypt_chunk,
};
Expand All @@ -396,12 +375,7 @@ static int crypto_aegis128_encrypt(struct aead_request *req)
unsigned int authsize = crypto_aead_authsize(tfm);
unsigned int cryptlen = req->cryptlen;

if (have_simd && crypto_simd_usable())
ops = &(struct aegis128_ops){
.skcipher_walk_init = skcipher_walk_aead_encrypt,
.crypt_chunk = crypto_aegis128_encrypt_chunk_simd };

crypto_aegis128_crypt(req, &tag, cryptlen, ops);
crypto_aegis128_crypt(req, &tag, cryptlen, &ops);

scatterwalk_map_and_copy(tag.bytes, req->dst, req->assoclen + cryptlen,
authsize, 1);
Expand All @@ -410,7 +384,7 @@ static int crypto_aegis128_encrypt(struct aead_request *req)

static int crypto_aegis128_decrypt(struct aead_request *req)
{
const struct aegis128_ops *ops = &(struct aegis128_ops){
static const struct aegis128_ops ops = {
.skcipher_walk_init = skcipher_walk_aead_decrypt,
.crypt_chunk = crypto_aegis128_decrypt_chunk,
};
Expand All @@ -424,12 +398,7 @@ static int crypto_aegis128_decrypt(struct aead_request *req)
scatterwalk_map_and_copy(tag.bytes, req->src, req->assoclen + cryptlen,
authsize, 0);

if (have_simd && crypto_simd_usable())
ops = &(struct aegis128_ops){
.skcipher_walk_init = skcipher_walk_aead_decrypt,
.crypt_chunk = crypto_aegis128_decrypt_chunk_simd };

crypto_aegis128_crypt(req, &tag, cryptlen, ops);
crypto_aegis128_crypt(req, &tag, cryptlen, &ops);

return crypto_memneq(tag.bytes, zeros, authsize) ? -EBADMSG : 0;
}
Expand Down Expand Up @@ -460,9 +429,6 @@ static struct aead_alg crypto_aegis128_alg = {

static int __init crypto_aegis128_module_init(void)
{
if (IS_ENABLED(CONFIG_CRYPTO_AEGIS128_SIMD))
have_simd = crypto_aegis128_have_simd();

return crypto_register_aead(&crypto_aegis128_alg);
}

Expand Down

0 comments on commit c9f1fd4

Please sign in to comment.