From caecc36a99b50e4acc11afe8a195096a63353f6d Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Mon, 10 Jun 2024 09:32:15 -0700 Subject: [PATCH 1/3] comments: fix API arg descriptions SHA256_arm: W and S should have been removed in: 2021-02-19 sha256: don't pass W and S to SHA256_Transform_arm 05ebafdd870e30e49e5715331414ebcd9e3a1233 SHA256_sse2: W and S should have been included in: 2021-02-06 sha256_sse2: add 192d05beba9502601496102ee89258afc534387d util/entropy.h: ${er} should not have been included in: 2020-09-22 entropy: expose _init(), _fill(), _done() ceaae6784dbc836ca2a789765510ed60c25cd555 --- libcperciva/alg/sha256_arm.c | 5 ++--- libcperciva/alg/sha256_arm.h | 5 ++--- libcperciva/alg/sha256_sse2.c | 2 +- libcperciva/alg/sha256_sse2.h | 2 +- libcperciva/util/entropy.h | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/libcperciva/alg/sha256_arm.c b/libcperciva/alg/sha256_arm.c index e3e5f6b1..96223f4d 100644 --- a/libcperciva/alg/sha256_arm.c +++ b/libcperciva/alg/sha256_arm.c @@ -49,12 +49,11 @@ static const uint32_t Krnd[64] = { X0 = vsha256su1q_u32(vsha256su0q_u32(X0, X1), X2, X3) /** - * SHA256_Transform_arm(state, block, W, S): + * SHA256_Transform_arm(state, block): * Compute the SHA256 block compression function, transforming ${state} using * the data in ${block}. This implementation uses ARM SHA256 instructions, * and should only be used if _SHA256 is defined and cpusupport_arm_sha256() - * returns nonzero. The arrays W and S may be filled with sensitive data, and - * should be cleared by the callee. + * returns nonzero. */ #ifdef POSIXFAIL_ABSTRACT_DECLARATOR void diff --git a/libcperciva/alg/sha256_arm.h b/libcperciva/alg/sha256_arm.h index 4c39b6cf..d9ed3fab 100644 --- a/libcperciva/alg/sha256_arm.h +++ b/libcperciva/alg/sha256_arm.h @@ -4,12 +4,11 @@ #include /** - * SHA256_Transform_arm(state, block, W, S): + * SHA256_Transform_arm(state, block): * Compute the SHA256 block compression function, transforming ${state} using * the data in ${block}. This implementation uses ARM SHA256 instructions, * and should only be used if _SHA256 is defined and cpusupport_arm_sha256() - * returns nonzero. The arrays W and S may be filled with sensitive data, and - * should be cleared by the callee. + * returns nonzero. */ #ifdef POSIXFAIL_ABSTRACT_DECLARATOR void SHA256_Transform_arm(uint32_t state[8], const uint8_t block[64]); diff --git a/libcperciva/alg/sha256_sse2.c b/libcperciva/alg/sha256_sse2.c index 35b58d2f..d2575534 100644 --- a/libcperciva/alg/sha256_sse2.c +++ b/libcperciva/alg/sha256_sse2.c @@ -167,7 +167,7 @@ MSG4(__m128i X0, __m128i X1, __m128i X2, __m128i X3) } /** - * SHA256_Transform_sse2(state, block): + * SHA256_Transform_sse2(state, block, W, S): * Compute the SHA256 block compression function, transforming ${state} using * the data in ${block}. This implementation uses x86 SSE2 instructions, and * should only be used if _SSE2 is defined and cpusupport_x86_sse2() returns diff --git a/libcperciva/alg/sha256_sse2.h b/libcperciva/alg/sha256_sse2.h index 4035d388..16704cec 100644 --- a/libcperciva/alg/sha256_sse2.h +++ b/libcperciva/alg/sha256_sse2.h @@ -4,7 +4,7 @@ #include /** - * SHA256_Transform_sse2(state, block): + * SHA256_Transform_sse2(state, block, W, S): * Compute the SHA256 block compression function, transforming ${state} using * the data in ${block}. This implementation uses x86 SSE2 instructions, and * should only be used if _SSE2 is defined and cpusupport_x86_sse2() returns diff --git a/libcperciva/util/entropy.h b/libcperciva/util/entropy.h index ffe67cfe..abadfa94 100644 --- a/libcperciva/util/entropy.h +++ b/libcperciva/util/entropy.h @@ -25,7 +25,7 @@ int entropy_read_fill(struct entropy_read_cookie *, uint8_t *, size_t); * entropy_read_done(er): * Release any resources used by ${er}. */ -int entropy_read_done(struct entropy_read_cookie * er); +int entropy_read_done(struct entropy_read_cookie *); /** * entropy_read(buf, buflen): From 5e7a5216c67bf58dddb0de019e53569994229c4c Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Thu, 27 Jun 2024 10:48:54 -0700 Subject: [PATCH 2/3] comments: sync with tarsnap --- lib/scryptenc/scryptenc_cpuperf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/scryptenc/scryptenc_cpuperf.c b/lib/scryptenc/scryptenc_cpuperf.c index b7a64fb9..f2919269 100644 --- a/lib/scryptenc/scryptenc_cpuperf.c +++ b/lib/scryptenc/scryptenc_cpuperf.c @@ -110,5 +110,7 @@ scryptenc_cpuperf(double * opps) /* We can do approximately i salsa20/8 cores per diffd seconds. */ *opps = (double)i / diffd; + + /* Success! */ return (SCRYPT_OK); } From f97332f51a8313c0a53efe890574fdc0f0d2bd4d Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Wed, 31 Jul 2024 20:00:04 -0700 Subject: [PATCH 3/3] Style: fix whitespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Checked with: git grep "^ " -- "**.h" "**.c" ":(exclude)external" Reported by: Tim Düsterhus --- libcperciva/alg/sha256_sse2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcperciva/alg/sha256_sse2.c b/libcperciva/alg/sha256_sse2.c index d2575534..0dfc04be 100644 --- a/libcperciva/alg/sha256_sse2.c +++ b/libcperciva/alg/sha256_sse2.c @@ -21,7 +21,7 @@ mm_bswap_epi32(__m128i a) { /* Swap bytes in each 16-bit word. */ - a = _mm_or_si128(_mm_slli_epi16(a, 8), _mm_srli_epi16(a, 8)); + a = _mm_or_si128(_mm_slli_epi16(a, 8), _mm_srli_epi16(a, 8)); /* Swap all 16-bit words. */ a = _mm_shufflelo_epi16(a, _MM_SHUFFLE(2, 3, 0, 1));