]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
x86_64: Fat setup for assembly CBC AES.
authorNiels Möller <nisse@lysator.liu.se>
Thu, 9 Sep 2021 19:07:29 +0000 (21:07 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 9 Sep 2021 19:07:29 +0000 (21:07 +0200)
ChangeLog
cbc-aes128-encrypt.c
cbc-aes192-encrypt.c
cbc-aes256-encrypt.c
configure.ac
fat-setup.h
fat-x86_64.c
x86_64/fat/cbc-aes128-encrypt-2.asm [new file with mode: 0644]
x86_64/fat/cbc-aes192-encrypt-2.asm [new file with mode: 0644]
x86_64/fat/cbc-aes256-encrypt-2.asm [new file with mode: 0644]

index 96da957312eede2720c8716226bd346e3b02f723..ddadd7cb022595768464ee7746fdc878b40ea935 100644 (file)
--- 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>
 
index 7b86645cbe3f226deec3b3033843ad041fed5c7b..8a7a2fd40b55ffa436a8859a747f341895ce0f9c 100644 (file)
 
 #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)
 {
index 6226e360ec693ab515613c7f5eadd5d7949e4cdd..e0586d34b8a5b0467b422127d74edd5063d2c5c8 100644 (file)
 
 #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)
 {
index 49240b3deae634436ac1b0340e7bf444f35bfbe7..db39dd5796a025ac69a6d61d92445f647d29966b 100644 (file)
 
 #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)
 {
index e7778fa89342735b0fe5f0df7fbeec5f81e7dba9..54df43ecf4e499b2650e2b7f3275fe203068c613 100644 (file)
@@ -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
index 78a6e3961b927533a94fae2de35802fe26f1b27f..9ef5c22d195ef09a4c63c89fd928d13fc7301688 100644 (file)
@@ -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);
index 80731eef26d1e70ead8984998eb1c41e51bdfde5..b5da39a1a44ba50c8bc22fea64157b5c2757ec10 100644 (file)
@@ -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 (file)
index 0000000..9782cd9
--- /dev/null
@@ -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 (file)
index 0000000..8132241
--- /dev/null
@@ -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 (file)
index 0000000..abd1fcf
--- /dev/null
@@ -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')