Skip to content

Commit

Permalink
sha256: don't pass W and S to SHA256_Transform_arm
Browse files Browse the repository at this point in the history
  • Loading branch information
gperciva committed Feb 20, 2021
1 parent 82ba725 commit 9a32639
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
18 changes: 16 additions & 2 deletions libcperciva/alg/sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ SHA256_Transform_shani_with_W_S(uint32_t state[static restrict 8],
SHA256_Transform_shani(state, block);
}
#endif
#if defined(CPUSUPPORT_ARM_SHA256)
/* Shim so that we can test SHA256_Transform_arm() in the standard manner. */
static void
SHA256_Transform_arm_with_W_S(uint32_t state[static restrict 8],
const uint8_t block[static restrict 64], uint32_t W[static restrict 64],
uint32_t S[static restrict 8])
{

(void)W; /* UNUSED */
(void)S; /* UNUSED */

SHA256_Transform_arm(state, block);
}
#endif

/*
* Test whether software and hardware extensions transform code produce the
Expand Down Expand Up @@ -195,7 +209,7 @@ usehw(void)
if (cpusupport_arm_sha256()) {
/* ... test if it works... */
if (hwtest(initial_state, block, W, S,
SHA256_Transform_arm)) {
SHA256_Transform_arm_with_W_S)) {
warn0("Disabling ARM-SHA256 due to failed"
" self-test");
} else
Expand Down Expand Up @@ -266,7 +280,7 @@ SHA256_Transform(uint32_t state[static restrict 8],
#endif
#if defined(CPUSUPPORT_ARM_SHA256)
case HW_ARM_SHA256:
SHA256_Transform_arm(state, block, W, S);
SHA256_Transform_arm(state, block);
return;
#endif
case HW_SOFTWARE:
Expand Down
9 changes: 2 additions & 7 deletions libcperciva/alg/sha256_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,18 @@ static const uint32_t Krnd[64] = {
*/
#ifdef POSIXFAIL_ABSTRACT_DECLARATOR
void
SHA256_Transform_arm(uint32_t state[8], const uint8_t block[64],
uint32_t W[64], uint32_t S[8])
SHA256_Transform_arm(uint32_t state[8], const uint8_t block[64])
#else
void
SHA256_Transform_arm(uint32_t state[static restrict 8],
const uint8_t block[static restrict 64], uint32_t W[static restrict 64],
uint32_t S[static restrict 8])
const uint8_t block[static restrict 64])
#endif
{
uint32x4_t Y[4];
uint32x4_t S0, S1;
uint32x4_t _state[2];
int i;

(void)W; /* UNUSED */
(void)S; /* UNUSED */

/* 1. Prepare the first part of the message schedule W. */
Y[0] = vreinterpretq_u32_u8(vrev32q_u8(vld1q_u8(&block[0])));
Y[1] = vreinterpretq_u32_u8(vrev32q_u8(vld1q_u8(&block[16])));
Expand Down
6 changes: 2 additions & 4 deletions libcperciva/alg/sha256_arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
* should be cleared by the callee.
*/
#ifdef POSIXFAIL_ABSTRACT_DECLARATOR
void SHA256_Transform_arm(uint32_t state[8],
const uint8_t block[64], uint32_t W[64], uint32_t S[8]);
void SHA256_Transform_arm(uint32_t state[8], const uint8_t block[64]);
#else
void SHA256_Transform_arm(uint32_t[static restrict 8],
const uint8_t[static restrict 64], uint32_t W[static restrict 64],
uint32_t S[static restrict 8]);
const uint8_t[static restrict 64]);
#endif

#endif /* !_SHA256_ARM_H_ */

0 comments on commit 9a32639

Please sign in to comment.