+2022-07-11 Niels Möller <nisse@lysator.liu.se>
+
+ * arm64/crypto/sha256-compress-n.asm: New file. replacing...
+ * arm64/crypto/sha256-compress.asm: ...deleted file.
+ * arm64/fat/sha256-compress-n-2.asm: New file. replacing...
+ * arm64/fat/sha256-compress-2.asm: ...deleted file.
+ * fat-arm64.c: Update fat setup.
+
2022-07-05 Niels Möller <nisse@lysator.liu.se>
* md-internal.h (MD_FILL_OR_RETURN): New file, new macro.
-C arm64/crypto/sha256-compress.asm
+C arm64/crypto/sha256-compress-n.asm
ifelse(`
Copyright (C) 2021 Mamone Tarsha
C SHA256SU0: SHA256 schedule update 0
C SHA256SU1: SHA256 schedule update 1
-.file "sha256-compress.asm"
+.file "sha256-compress-n.asm"
.arch armv8-a+crypto
.text
C Register usage:
define(`STATE', `x0')
-define(`INPUT', `x1')
-define(`K', `x2')
+define(`K', `x1')
+define(`BLOCKS', `x2')
+define(`INPUT', `x3')
define(`MSG0', `v0')
define(`MSG1', `v1')
define(`STATE0_SAVED', `v16')
define(`STATE1_SAVED', `v17')
-C void
-C _nettle_sha256_compress(uint32_t *state, const uint8_t *input, 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_n)
+ cbz BLOCKS, .Lend
-PROLOGUE(_nettle_sha256_compress)
C Load state
ld1 {STATE0.4s,STATE1.4s},[STATE]
+.Loop:
C Save state
mov STATE0_SAVED.16b,STATE0.16b
mov STATE1_SAVED.16b,STATE1.16b
C Load message
- ld1 {MSG0.16b,MSG1.16b,MSG2.16b,MSG3.16b},[INPUT]
+ ld1 {MSG0.16b,MSG1.16b,MSG2.16b,MSG3.16b},[INPUT],#64
C Reverse for little endian
rev32 MSG0.16b,MSG0.16b
C Combine state
add STATE0.4s,STATE0.4s,STATE0_SAVED.4s
add STATE1.4s,STATE1.4s,STATE1_SAVED.4s
-
+ subs BLOCKS, BLOCKS, #1
+ sub K, K, #240
+ b.ne .Loop
+
C Store state
st1 {STATE0.4s,STATE1.4s},[STATE]
-
+.Lend:
+ mov x0, INPUT
ret
-EPILOGUE(_nettle_sha256_compress)
+EPILOGUE(_nettle_sha256_compress_n)
-C arm64/fat/sha256-compress-2.asm
+C arm64/fat/sha256-compress-n-2.asm
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_arm64')
-include_src(`arm64/crypto/sha256-compress.asm')
+include_src(`arm64/crypto/sha256-compress-n.asm')
DECLARE_FAT_FUNC_VAR(sha1_compress, sha1_compress_func, c)
DECLARE_FAT_FUNC_VAR(sha1_compress, sha1_compress_func, arm64)
-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, arm64)
+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, arm64)
static void CONSTRUCTOR
fat_init (void)
{
if (verbose)
fprintf (stderr, "libnettle: enabling hardware-accelerated sha256 compress code.\n");
- _nettle_sha256_compress_vec = _nettle_sha256_compress_arm64;
+ _nettle_sha256_compress_n_vec = _nettle_sha256_compress_n_arm64;
}
else
{
- _nettle_sha256_compress_vec = _nettle_sha256_compress_c;
+ _nettle_sha256_compress_n_vec = _nettle_sha256_compress_n_c;
}
}
(uint32_t *state, const uint8_t *input),
(state, input))
-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))