summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2022-07-29 22:05:43 +0200
committerNiels Möller <nisse@lysator.liu.se>2022-07-29 22:05:43 +0200
commit6a384afa5f5b498384d629c3257b6c7f62f459eb (patch)
tree19bdcac5d63b3ca2b123da0bd770547a511c8a73
parent840383935c7331ddc451f05db802137b96e5c564 (diff)
downloadnettle-6a384afa5f5b498384d629c3257b6c7f62f459eb.tar.gz
s390x: Implement sha256_compress_nsha256-compress-n
-rw-r--r--ChangeLog8
-rw-r--r--fat-s390x.c17
-rw-r--r--s390x/fat/sha256-compress-n-2.asm (renamed from s390x/fat/sha256-compress-2.asm)6
-rw-r--r--s390x/msa_x1/sha256-compress-n.asm (renamed from s390x/msa_x1/sha256-compress.asm)24
4 files changed, 31 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index bd97421e..ff505a37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-07-29 Niels Möller <nisse@lysator.liu.se>
+
+ * s390x/msa_x1/sha256-compress-n.asm: New file. replacing...
+ * s390x/msa_x1/sha256-compress.asm: ...deleted file.
+ * s390x/fat/sha256-compress-n-2.asm: New file. replacing...
+ * s390x/fat/sha256-compress-2.asm: ...deleted file.
+ * fat-s390x.c: Update fat setup.
+
2022-07-26 Niels Möller <nisse@lysator.liu.se>
* arm/v6/sha256-compress-n.asm: New file. replacing...
diff --git a/fat-s390x.c b/fat-s390x.c
index fa026018..1bbd8e16 100644
--- a/fat-s390x.c
+++ b/fat-s390x.c
@@ -254,9 +254,9 @@ DECLARE_FAT_FUNC(nettle_sha1_compress, sha1_compress_func)
DECLARE_FAT_FUNC_VAR(sha1_compress, sha1_compress_func, c)
DECLARE_FAT_FUNC_VAR(sha1_compress, sha1_compress_func, s390x)
-DECLARE_FAT_FUNC(_nettle_sha256_compress, sha256_compress_func)
-DECLARE_FAT_FUNC_VAR(sha256_compress, sha256_compress_func, c)
-DECLARE_FAT_FUNC_VAR(sha256_compress, sha256_compress_func, s390x)
+DECLARE_FAT_FUNC(_nettle_sha256_compress_n, sha256_compress_n_func)
+DECLARE_FAT_FUNC_VAR(sha256_compress_n, sha256_compress_n_func, c)
+DECLARE_FAT_FUNC_VAR(sha256_compress_n, sha256_compress_n_func, s390x)
DECLARE_FAT_FUNC(_nettle_sha512_compress, sha512_compress_func)
DECLARE_FAT_FUNC_VAR(sha512_compress, sha512_compress_func, c)
@@ -398,11 +398,11 @@ fat_init (void)
{
if (verbose)
fprintf (stderr, "libnettle: enabling hardware accelerated SHA256 compress code.\n");
- _nettle_sha256_compress_vec = _nettle_sha256_compress_s390x;
+ _nettle_sha256_compress_n_vec = _nettle_sha256_compress_n_s390x;
}
else
{
- _nettle_sha256_compress_vec = _nettle_sha256_compress_c;
+ _nettle_sha256_compress_n_vec = _nettle_sha256_compress_n_c;
}
/* SHA512 */
@@ -495,9 +495,10 @@ DEFINE_FAT_FUNC(nettle_sha1_compress, void,
(state, input))
/* SHA256 */
-DEFINE_FAT_FUNC(_nettle_sha256_compress, void,
- (uint32_t *state, const uint8_t *input, const uint32_t *k),
- (state, input, k))
+DEFINE_FAT_FUNC(_nettle_sha256_compress_n, const uint8_t *,
+ (uint32_t *state, const uint32_t *k,
+ size_t blocks, const uint8_t *input),
+ (state, k, blocks, input))
/* SHA512 */
DEFINE_FAT_FUNC(_nettle_sha512_compress, void,
diff --git a/s390x/fat/sha256-compress-2.asm b/s390x/fat/sha256-compress-n-2.asm
index f4b16181..06fb1014 100644
--- a/s390x/fat/sha256-compress-2.asm
+++ b/s390x/fat/sha256-compress-n-2.asm
@@ -1,4 +1,4 @@
-C s390x/fat/sha256-compress-2.asm
+C s390x/fat/sha256-compress-n-2.asm
ifelse(`
Copyright (C) 2021 Mamone Tarsha
@@ -30,7 +30,7 @@ ifelse(`
not, see http://www.gnu.org/licenses/.
')
-dnl PROLOGUE(_nettle_sha256_compress) picked up by configure
+dnl PROLOGUE(_nettle_sha256_compress_n) picked up by configure
define(`fat_transform', `$1_s390x')
-include_src(`s390x/msa_x1/sha256-compress.asm')
+include_src(`s390x/msa_x1/sha256-compress-n.asm')
diff --git a/s390x/msa_x1/sha256-compress.asm b/s390x/msa_x1/sha256-compress-n.asm
index 9a9511fb..51539927 100644
--- a/s390x/msa_x1/sha256-compress.asm
+++ b/s390x/msa_x1/sha256-compress-n.asm
@@ -1,7 +1,7 @@
-C s390x/msa_x1/sha256-compress.asm
+C s390x/msa_x1/sha256-compress-n.asm
ifelse(`
- Copyright (C) 2021 Mamone Tarsha
+ Copyright (C) 2021, 2022 Mamone Tarsha, Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
@@ -56,25 +56,23 @@ C |----------------------------------------------|
C | H7 (4 bytes) |
C *----------------------------------------------*
-.file "sha256-compress.asm"
+.file "sha256-compress-n.asm"
.text
C SHA function code
define(`SHA256_FUNCTION_CODE', `2')
-C Size of block
-define(`SHA256_BLOCK_SIZE', `64')
-C void
-C _nettle_sha256_compress(uint32_t *state, const uint8_t *input,
-C const uint32_t *k)
+C const uint8_t *
+C _nettle_sha256_compress_n(uint32_t *state, const uint32_t *k,
+C size_t blocks, const uint8_t *input)
-PROLOGUE(_nettle_sha256_compress)
+PROLOGUE(_nettle_sha256_compress_n)
lghi %r0,SHA256_FUNCTION_CODE C SHA-256 Function Code
lgr %r1,%r2
- lgr %r4,%r3
- lghi %r5,SHA256_BLOCK_SIZE
-1: .long 0xb93e0004 C kimd %r0,%r4. perform KIMD-SHA operation on data
+ lgr %r2, %r5
+ sllg %r3, %r4, 6 C 64 * block size
+1: .long 0xb93e0002 C kimd %r0,%r2. perform KIMD-SHA operation on data
brc 1,1b
br RA
-EPILOGUE(_nettle_sha256_compress)
+EPILOGUE(_nettle_sha256_compress_n)