summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2021-09-09 21:07:29 +0200
committerNiels Möller <nisse@lysator.liu.se>2021-09-09 21:07:29 +0200
commit419d7af5505230f378fd3f8340e374e07908b82d (patch)
tree2d6ca9b45c37eb0b52b6f572a880e53642b02709
parent121290e0a64be203df5961299db01fc26367a2ba (diff)
downloadnettle-419d7af5505230f378fd3f8340e374e07908b82d.tar.gz
x86_64: Fat setup for assembly CBC AES.
-rw-r--r--ChangeLog9
-rw-r--r--cbc-aes128-encrypt.c9
-rw-r--r--cbc-aes192-encrypt.c9
-rw-r--r--cbc-aes256-encrypt.c9
-rw-r--r--configure.ac4
-rw-r--r--fat-setup.h10
-rw-r--r--fat-x86_64.c29
-rw-r--r--x86_64/fat/cbc-aes128-encrypt-2.asm36
-rw-r--r--x86_64/fat/cbc-aes192-encrypt-2.asm36
-rw-r--r--x86_64/fat/cbc-aes256-encrypt-2.asm36
10 files changed, 186 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 96da9573..ddadd7cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,7 +5,14 @@
* x86_64/aesni/cbc-aes128-encrypt.asm: New file.
* x86_64/aesni/cbc-aes192-encrypt.asm: New file.
* x86_64/aesni/cbc-aes256-encrypt.asm: New file.
- * configure.ac (asm_replace_list): Add new asm files.
+ * x86_64/fat/cbc-aes128-encrypt-2.asm: New file.
+ * x86_64/fat/cbc-aes192-encrypt-2.asm: New file.
+ * x86_64/fat/cbc-aes256-encrypt-2.asm: New file.
+ * configure.ac (asm_nettle_optional_list, asm_replace_list): Add
+ new asm files.
+ * fat-setup.h (cbc_aes128_encrypt_func, cbc_aes192_encrypt_func)
+ (cbc_aes256_encrypt_func): New typedefs.
+ * fat-x86_64.c (fat_init): Use new functions, when aesni is available
2021-09-08 Niels Möller <nisse@lysator.liu.se>
diff --git a/cbc-aes128-encrypt.c b/cbc-aes128-encrypt.c
index 7b86645c..8a7a2fd4 100644
--- a/cbc-aes128-encrypt.c
+++ b/cbc-aes128-encrypt.c
@@ -35,6 +35,15 @@
#include "cbc.h"
+/* For fat builds */
+#if HAVE_NATIVE_aes128_encrypt
+void
+_nettle_cbc_aes128_encrypt_c(struct cbc_aes128_ctx *ctx,
+ size_t length, uint8_t *dst,
+ const uint8_t *src);
+# define nettle_cbc_aes128_encrypt _nettle_cbc_aes128_encrypt_c
+#endif
+
void
cbc_aes128_encrypt(struct cbc_aes128_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
{
diff --git a/cbc-aes192-encrypt.c b/cbc-aes192-encrypt.c
index 6226e360..e0586d34 100644
--- a/cbc-aes192-encrypt.c
+++ b/cbc-aes192-encrypt.c
@@ -35,6 +35,15 @@
#include "cbc.h"
+/* For fat builds */
+#if HAVE_NATIVE_aes192_encrypt
+void
+_nettle_cbc_aes192_encrypt_c(struct cbc_aes192_ctx *ctx,
+ size_t length, uint8_t *dst,
+ const uint8_t *src);
+# define nettle_cbc_aes192_encrypt _nettle_cbc_aes192_encrypt_c
+#endif
+
void
cbc_aes192_encrypt(struct cbc_aes192_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
{
diff --git a/cbc-aes256-encrypt.c b/cbc-aes256-encrypt.c
index 49240b3d..db39dd57 100644
--- a/cbc-aes256-encrypt.c
+++ b/cbc-aes256-encrypt.c
@@ -35,6 +35,15 @@
#include "cbc.h"
+/* For fat builds */
+#if HAVE_NATIVE_aes256_encrypt
+void
+_nettle_cbc_aes256_encrypt_c(struct cbc_aes256_ctx *ctx,
+ size_t length, uint8_t *dst,
+ const uint8_t *src);
+# define nettle_cbc_aes256_encrypt _nettle_cbc_aes256_encrypt_c
+#endif
+
void
cbc_aes256_encrypt(struct cbc_aes256_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
{
diff --git a/configure.ac b/configure.ac
index e7778fa8..54df43ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -583,6 +583,7 @@ asm_nettle_optional_list="gcm-hash.asm gcm-hash8.asm cpuid.asm cpu-facility.asm
aes192-encrypt-2.asm aes192-decrypt-2.asm \
aes256-set-encrypt-key-2.asm aes256-set-decrypt-key-2.asm \
aes256-encrypt-2.asm aes256-decrypt-2.asm \
+ cbc-aes128-encrypt-2.asm cbc-aes192-encrypt-2.asm cbc-aes256-encrypt-2.asm \
chacha-2core.asm chacha-3core.asm chacha-4core.asm chacha-core-internal-2.asm \
salsa20-2core.asm salsa20-core-internal-2.asm \
sha1-compress-2.asm sha256-compress-2.asm \
@@ -707,6 +708,9 @@ AH_VERBATIM([HAVE_NATIVE],
#undef HAVE_NATIVE_aes256_invert_key
#undef HAVE_NATIVE_aes256_set_decrypt_key
#undef HAVE_NATIVE_aes256_set_encrypt_key
+#undef HAVE_NATIVE_cbc_aes128_encrypt
+#undef HAVE_NATIVE_cbc_aes192_encrypt
+#undef HAVE_NATIVE_cbc_aes256_encrypt
#undef HAVE_NATIVE_chacha_core
#undef HAVE_NATIVE_chacha_2core
#undef HAVE_NATIVE_chacha_3core
diff --git a/fat-setup.h b/fat-setup.h
index 78a6e396..9ef5c22d 100644
--- a/fat-setup.h
+++ b/fat-setup.h
@@ -213,3 +213,13 @@ typedef void aes256_set_key_func (struct aes256_ctx *ctx, const uint8_t *key);
typedef void aes256_invert_key_func (struct aes256_ctx *dst, const struct aes256_ctx *src);
typedef void aes256_crypt_func (const struct aes256_ctx *ctx, size_t length, uint8_t *dst,
const uint8_t *src);
+
+struct cbc_aes128_ctx;
+typedef void cbc_aes128_encrypt_func (struct cbc_aes128_ctx *ctx,
+ size_t length, uint8_t *dst, const uint8_t *src);
+struct cbc_aes192_ctx;
+typedef void cbc_aes192_encrypt_func (struct cbc_aes192_ctx *ctx,
+ size_t length, uint8_t *dst, const uint8_t *src);
+struct cbc_aes256_ctx;
+typedef void cbc_aes256_encrypt_func (struct cbc_aes256_ctx *ctx,
+ size_t length, uint8_t *dst, const uint8_t *src);
diff --git a/fat-x86_64.c b/fat-x86_64.c
index 80731eef..b5da39a1 100644
--- a/fat-x86_64.c
+++ b/fat-x86_64.c
@@ -130,6 +130,16 @@ DECLARE_FAT_FUNC_VAR(aes256_encrypt, aes256_crypt_func, aesni)
DECLARE_FAT_FUNC_VAR(aes256_decrypt, aes256_crypt_func, c)
DECLARE_FAT_FUNC_VAR(aes256_decrypt, aes256_crypt_func, aesni)
+DECLARE_FAT_FUNC(nettle_cbc_aes128_encrypt, cbc_aes128_encrypt_func);
+DECLARE_FAT_FUNC_VAR(cbc_aes128_encrypt, cbc_aes128_encrypt_func, c);
+DECLARE_FAT_FUNC_VAR(cbc_aes128_encrypt, cbc_aes128_encrypt_func, aesni);
+DECLARE_FAT_FUNC(nettle_cbc_aes192_encrypt, cbc_aes192_encrypt_func);
+DECLARE_FAT_FUNC_VAR(cbc_aes192_encrypt, cbc_aes192_encrypt_func, c);
+DECLARE_FAT_FUNC_VAR(cbc_aes192_encrypt, cbc_aes192_encrypt_func, aesni);
+DECLARE_FAT_FUNC(nettle_cbc_aes256_encrypt, cbc_aes256_encrypt_func);
+DECLARE_FAT_FUNC_VAR(cbc_aes256_encrypt, cbc_aes256_encrypt_func, c);
+DECLARE_FAT_FUNC_VAR(cbc_aes256_encrypt, cbc_aes256_encrypt_func, aesni);
+
DECLARE_FAT_FUNC(nettle_memxor, memxor_func)
DECLARE_FAT_FUNC_VAR(memxor, memxor_func, x86_64)
DECLARE_FAT_FUNC_VAR(memxor, memxor_func, sse2)
@@ -177,6 +187,9 @@ fat_init (void)
nettle_aes192_decrypt_vec = _nettle_aes192_decrypt_aesni;
nettle_aes256_encrypt_vec = _nettle_aes256_encrypt_aesni;
nettle_aes256_decrypt_vec = _nettle_aes256_decrypt_aesni;
+ nettle_cbc_aes128_encrypt_vec = _nettle_cbc_aes128_encrypt_aesni;
+ nettle_cbc_aes192_encrypt_vec = _nettle_cbc_aes192_encrypt_aesni;
+ nettle_cbc_aes256_encrypt_vec = _nettle_cbc_aes256_encrypt_aesni;
}
else
{
@@ -188,6 +201,9 @@ fat_init (void)
nettle_aes192_decrypt_vec = _nettle_aes192_decrypt_c;
nettle_aes256_encrypt_vec = _nettle_aes256_encrypt_c;
nettle_aes256_decrypt_vec = _nettle_aes256_decrypt_c;
+ nettle_cbc_aes128_encrypt_vec = _nettle_cbc_aes128_encrypt_c;
+ nettle_cbc_aes192_encrypt_vec = _nettle_cbc_aes192_encrypt_c;
+ nettle_cbc_aes256_encrypt_vec = _nettle_cbc_aes256_encrypt_c;
}
if (features.have_sha_ni)
@@ -245,6 +261,19 @@ DEFINE_FAT_FUNC(nettle_aes256_decrypt, void,
uint8_t *dst,const uint8_t *src),
(ctx, length, dst, src))
+DEFINE_FAT_FUNC(nettle_cbc_aes128_encrypt, void,
+ (struct cbc_aes128_ctx *ctx,
+ size_t length, uint8_t *dst, const uint8_t *src),
+ (ctx, length, dst, src))
+DEFINE_FAT_FUNC(nettle_cbc_aes192_encrypt, void,
+ (struct cbc_aes192_ctx *ctx,
+ size_t length, uint8_t *dst, const uint8_t *src),
+ (ctx, length, dst, src))
+DEFINE_FAT_FUNC(nettle_cbc_aes256_encrypt, void,
+ (struct cbc_aes256_ctx *ctx,
+ size_t length, uint8_t *dst, const uint8_t *src),
+ (ctx, length, dst, src))
+
DEFINE_FAT_FUNC(nettle_memxor, void *,
(void *dst, const void *src, size_t n),
(dst, src, n))
diff --git a/x86_64/fat/cbc-aes128-encrypt-2.asm b/x86_64/fat/cbc-aes128-encrypt-2.asm
new file mode 100644
index 00000000..9782cd94
--- /dev/null
+++ b/x86_64/fat/cbc-aes128-encrypt-2.asm
@@ -0,0 +1,36 @@
+C x86_64/fat/cbc-aes128-encrypt.asm
+
+ifelse(`
+ Copyright (C) 2021 Niels Möller
+
+ This file is part of GNU Nettle.
+
+ GNU Nettle is free software: you can redistribute it and/or
+ modify it under the terms of either:
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ or both in parallel, as here.
+
+ GNU Nettle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see http://www.gnu.org/licenses/.
+')
+
+dnl PROLOGUE(nettle_cbc_aes128_encrypt) picked up by configure
+
+define(`fat_transform', `_$1_aesni')
+include_src(`x86_64/aesni/cbc-aes128-encrypt.asm')
diff --git a/x86_64/fat/cbc-aes192-encrypt-2.asm b/x86_64/fat/cbc-aes192-encrypt-2.asm
new file mode 100644
index 00000000..81322418
--- /dev/null
+++ b/x86_64/fat/cbc-aes192-encrypt-2.asm
@@ -0,0 +1,36 @@
+C x86_64/fat/cbc_aes192-encrypt.asm
+
+ifelse(`
+ Copyright (C) 2021 Niels Möller
+
+ This file is part of GNU Nettle.
+
+ GNU Nettle is free software: you can redistribute it and/or
+ modify it under the terms of either:
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ or both in parallel, as here.
+
+ GNU Nettle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see http://www.gnu.org/licenses/.
+')
+
+dnl PROLOGUE(nettle_cbc_aes192_encrypt) picked up by configure
+
+define(`fat_transform', `_$1_aesni')
+include_src(`x86_64/aesni/cbc-aes192-encrypt.asm')
diff --git a/x86_64/fat/cbc-aes256-encrypt-2.asm b/x86_64/fat/cbc-aes256-encrypt-2.asm
new file mode 100644
index 00000000..abd1fcf3
--- /dev/null
+++ b/x86_64/fat/cbc-aes256-encrypt-2.asm
@@ -0,0 +1,36 @@
+C x86_64/fat/cbc_aes256-encrypt.asm
+
+ifelse(`
+ Copyright (C) 2021 Niels Möller
+
+ This file is part of GNU Nettle.
+
+ GNU Nettle is free software: you can redistribute it and/or
+ modify it under the terms of either:
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ or both in parallel, as here.
+
+ GNU Nettle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see http://www.gnu.org/licenses/.
+')
+
+dnl PROLOGUE(nettle_cbc_aes256_encrypt) picked up by configure
+
+define(`fat_transform', `_$1_aesni')
+include_src(`x86_64/aesni/cbc-aes256-encrypt.asm')