]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Fat functions for arm neon.
authorNiels Möller <nisse@lysator.liu.se>
Wed, 21 Jan 2015 20:23:28 +0000 (21:23 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Wed, 21 Jan 2015 20:23:28 +0000 (21:23 +0100)
ChangeLog
arm/fat/salsa20-core-internal-2.asm [new file with mode: 0644]
arm/fat/sha3-permute-2.asm [new file with mode: 0644]
arm/fat/sha512-compress-2.asm [new file with mode: 0644]
arm/fat/umac-nh-2.asm [new file with mode: 0644]
arm/fat/umac-nh-n-2.asm [new file with mode: 0644]
fat-arm.c

index fa25c0ed270f187e9f212ddc21253c3ed0e9261d..b49e1c42af880e575c48c151b27bf082aa5a0aec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2015-01-21  Niels Möller  <nisse@lysator.liu.se>
 
+       * fat-arm.c (fat_init): Setup for use of neon assembly functions.
+
+       * arm/fat/salsa20-core-internal-2.asm: New file.
+       * arm/fat/sha3-permute-2.asm: New file.
+       * arm/fat/sha512-compress-2.asm: New file.
+       * arm/fat/umac-nh-2.asm: New file.
+       * arm/fat/umac-nh-n-2.asm: New file.
+
        * salsa20-core-internal.c: Prepare for fat build with C and
        assembly implementations.
        * sha512-compress.c: Likewise.
diff --git a/arm/fat/salsa20-core-internal-2.asm b/arm/fat/salsa20-core-internal-2.asm
new file mode 100644 (file)
index 0000000..64d9030
--- /dev/null
@@ -0,0 +1,37 @@
+C arm/fat/salsa20-core-internal-2.asm
+
+
+ifelse(<
+   Copyright (C) 2015 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_salsa20_core) picked up by configure
+
+define(<fat_transform>, <$1_neon>)
+include_src(<arm/neon/salsa20-core-internal.asm>)
diff --git a/arm/fat/sha3-permute-2.asm b/arm/fat/sha3-permute-2.asm
new file mode 100644 (file)
index 0000000..b423a76
--- /dev/null
@@ -0,0 +1,37 @@
+C arm/fat/sha3-permute-2.asm
+
+
+ifelse(<
+   Copyright (C) 2015 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_sha3_permute) picked up by configure
+
+define(<fat_transform>, <_$1_neon>)
+include_src(<arm/neon/sha3-permute.asm>)
diff --git a/arm/fat/sha512-compress-2.asm b/arm/fat/sha512-compress-2.asm
new file mode 100644 (file)
index 0000000..428604e
--- /dev/null
@@ -0,0 +1,37 @@
+C arm/fat/sha3-compress-2.asm
+
+
+ifelse(<
+   Copyright (C) 2015 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_sha512_compress) picked up by configure
+
+define(<fat_transform>, <$1_neon>)
+include_src(<arm/neon/sha512-compress.asm>)
diff --git a/arm/fat/umac-nh-2.asm b/arm/fat/umac-nh-2.asm
new file mode 100644 (file)
index 0000000..fc97cc6
--- /dev/null
@@ -0,0 +1,37 @@
+C arm/fat/umac-nh-2.asm
+
+
+ifelse(<
+   Copyright (C) 2015 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_umac_nh) picked up by configure
+
+define(<fat_transform>, <$1_neon>)
+include_src(<arm/neon/umac-nh.asm>)
diff --git a/arm/fat/umac-nh-n-2.asm b/arm/fat/umac-nh-n-2.asm
new file mode 100644 (file)
index 0000000..32b7a83
--- /dev/null
@@ -0,0 +1,37 @@
+C arm/fat/umac-nh-n-2.asm
+
+
+ifelse(<
+   Copyright (C) 2015 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_umac_nh_n) picked up by configure
+
+define(<fat_transform>, <$1_neon>)
+include_src(<arm/neon/umac-nh-n.asm>)
index e577494accba18efc0a081d3ee26728cb88f891f..e351fdcba8f336e7fc213353d37801f2c3f2025e 100644 (file)
--- a/fat-arm.c
+++ b/fat-arm.c
@@ -141,6 +141,26 @@ DECLARE_FAT_FUNC(_nettle_aes_decrypt, aes_crypt_internal_func)
 DECLARE_FAT_FUNC_VAR(aes_decrypt, aes_crypt_internal_func, arm)
 DECLARE_FAT_FUNC_VAR(aes_decrypt, aes_crypt_internal_func, armv6)
 
+DECLARE_FAT_FUNC(_nettle_salsa20_core, salsa20_core_func)
+DECLARE_FAT_FUNC_VAR(salsa20_core, salsa20_core_func, c)
+DECLARE_FAT_FUNC_VAR(salsa20_core, salsa20_core_func, neon)
+
+DECLARE_FAT_FUNC(_nettle_sha512_compress, sha512_compress_func)
+DECLARE_FAT_FUNC_VAR(sha512_compress, sha512_compress_func, c)
+DECLARE_FAT_FUNC_VAR(sha512_compress, sha512_compress_func, neon)
+
+DECLARE_FAT_FUNC(nettle_sha3_permute, sha3_permute_func)
+DECLARE_FAT_FUNC_VAR(sha3_permute, sha3_permute_func, c)
+DECLARE_FAT_FUNC_VAR(sha3_permute, sha3_permute_func, neon)
+
+DECLARE_FAT_FUNC(_nettle_umac_nh, umac_nh_func)
+DECLARE_FAT_FUNC_VAR(umac_nh, umac_nh_func, c);
+DECLARE_FAT_FUNC_VAR(umac_nh, umac_nh_func, neon);
+
+DECLARE_FAT_FUNC(_nettle_umac_nh_n, umac_nh_n_func)
+DECLARE_FAT_FUNC_VAR(umac_nh_n, umac_nh_n_func, c);
+DECLARE_FAT_FUNC_VAR(umac_nh_n, umac_nh_n_func, neon);
+
 static void CONSTRUCTOR
 fat_init (void)
 {
@@ -173,6 +193,26 @@ fat_init (void)
       _nettle_aes_encrypt_vec = _nettle_aes_encrypt_arm;
       _nettle_aes_decrypt_vec = _nettle_aes_decrypt_arm;
     }
+  if (features.have_neon)
+    {
+      if (verbose)
+       fprintf (stderr, "libnettle: enabling neon code.\n");
+      _nettle_salsa20_core_vec = _nettle_salsa20_core_neon;
+      _nettle_sha512_compress_vec = _nettle_sha512_compress_neon;
+      nettle_sha3_permute_vec = _nettle_sha3_permute_neon;
+      _nettle_umac_nh_vec = _nettle_umac_nh_neon;
+      _nettle_umac_nh_n_vec = _nettle_umac_nh_n_neon;
+    }
+  else
+    {
+      if (verbose)
+       fprintf (stderr, "libnettle: not enabling neon code.\n");
+      _nettle_salsa20_core_vec = _nettle_salsa20_core_c;
+      _nettle_sha512_compress_vec = _nettle_sha512_compress_c;
+      nettle_sha3_permute_vec = _nettle_sha3_permute_c;
+      _nettle_umac_nh_vec = _nettle_umac_nh_c;
+      _nettle_umac_nh_n_vec = _nettle_umac_nh_n_c;
+    }
   /* FIXME: Needs memory barrier, to enforce store ordering. */
   initialized = 1;
 }
@@ -190,3 +230,24 @@ DEFINE_FAT_FUNC(_nettle_aes_decrypt, void,
                 size_t length, uint8_t *dst,
                 const uint8_t *src),
                (rounds, keys, T, length, dst, src))
+
+DEFINE_FAT_FUNC(_nettle_salsa20_core, void,
+               (uint32_t *dst, const uint32_t *src, unsigned rounds),
+               (dst, src, rounds))
+
+DEFINE_FAT_FUNC(_nettle_sha512_compress, void,
+               (uint64_t *state, const uint8_t *input, const uint64_t *k),
+               (state, input, k))
+
+DEFINE_FAT_FUNC(nettle_sha3_permute, void,
+               (struct sha3_state *state), (state))
+
+DEFINE_FAT_FUNC(_nettle_umac_nh, uint64_t,
+               (const uint32_t *key, unsigned length, const uint8_t *msg),
+               (key, length, msg))
+
+DEFINE_FAT_FUNC(_nettle_umac_nh_n, void,
+               (uint64_t *out, unsigned n, const uint32_t *key,
+                unsigned length, const uint8_t *msg),
+               (out, n, key, length, msg))
+