Skip to content

Commit

Permalink
Merge pull request #374 from Tarsnap/libcperciva-import
Browse files Browse the repository at this point in the history
Libcperciva import
  • Loading branch information
cperciva authored Sep 20, 2023
2 parents 81abc2a + 6d38ae8 commit 3d75191
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion libcperciva/POSIX/posix-restrict.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
static int
foo(char * restrict x, char * restrict y)
foo(const char * restrict x, const char * restrict y)
{

return (x == y);
Expand Down
14 changes: 7 additions & 7 deletions libcperciva/alg/sha256_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ static const uint32_t Krnd[64] = {

/* Round computation. */
#define RND4(S, M, Kp) do { \
uint32x4_t S0_step; \
uint32x4_t Wk; \
S0_step = S[0]; \
Wk = vaddq_u32(M, vld1q_u32(Kp)); \
S[0] = vsha256hq_u32(S[0], S[1], Wk); \
S[1] = vsha256h2q_u32(S[1], S0_step, Wk); \
} while (0)
uint32x4_t S0_step; \
uint32x4_t Wk; \
S0_step = S[0]; \
Wk = vaddq_u32(M, vld1q_u32(Kp)); \
S[0] = vsha256hq_u32(S[0], S[1], Wk); \
S[1] = vsha256h2q_u32(S[1], S0_step, Wk); \
} while (0)

/* Message schedule computation */
#define MSG4(X0, X1, X2, X3) \
Expand Down
4 changes: 2 additions & 2 deletions libcperciva/crypto/crypto_entropy.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static int instantiated = 0;
#define GENERATE_MAXLEN 65536

static int instantiate(void);
static void update(uint8_t *, size_t);
static void update(const uint8_t *, size_t);
static int reseed(void);
static void generate(uint8_t *, size_t);

Expand Down Expand Up @@ -93,7 +93,7 @@ instantiate(void)
* Update the DRBG state using the provided data. (Section 10.1.2.2)
*/
static void
update(uint8_t * data, size_t datalen)
update(const uint8_t * data, size_t datalen)
{
HMAC_SHA256_CTX ctx;
uint8_t K[32];
Expand Down
20 changes: 11 additions & 9 deletions tests/shared_test_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
# and log files.
# - s_val_basename: this is the basename for the scenario's
# valgrind log files.
# - s_count: this is the count of the scenario's checks (so that
# each check can have distinct files).
# - s_count_str: ${s_count} expressed as a two-digit string.
# - s_retval: this is the overall exit code of the scenario.
# - c_count_next: this is the count of the scenario's checks (so that
# each check can have distinct files).
# - c_count_str: the previous value of ${c_count_next}, expressed as a
# two-digit string. In other words, when we're working on the Nth
# check, ${c_count_next} is N, while ${c_count_str} is N-1.
# - c_exitfile: this contains the exit code of each check.
# - c_valgrind_min: this is the minimum value of USE_VALGRIND
# which will enable valgrind checking for this check.
Expand Down Expand Up @@ -152,7 +154,7 @@ wait_while() {
## setup_check_variables (description, check_prev=1):
# Set up the "check" variables ${c_exitfile} and ${c_valgrind_cmd}, the
# latter depending on the previously-defined ${c_valgrind_min}.
# Advances the number of checks ${s_count} so that the next call to this
# Advance the number of checks ${c_count_next} so that the next call to this
# function will set up new filenames. Write ${description} into a
# file. If ${check_prev} is non-zero, check that the previous
# ${c_exitfile} exists.
Expand All @@ -174,18 +176,18 @@ setup_check_variables() {
fi

# Set up the "exit" file.
s_count_str=$(printf "%02d" "${s_count}")
c_exitfile="${s_basename}-${s_count_str}.exit"
c_count_str=$(printf "%02d" "${c_count_next}")
c_exitfile="${s_basename}-${c_count_str}.exit"

# Write the "description" file.
printf "%s\n" "${description}" > \
"${s_basename}-${s_count_str}.desc"
"${s_basename}-${c_count_str}.desc"

# Set up the valgrind command (or an empty string).
c_valgrind_cmd="$(valgrind_setup_cmd)"

# Advances the number of checks.
s_count=$((s_count + 1))
c_count_next=$((c_count_next + 1))
}

## expected_exitcode (expected, exitcode):
Expand Down Expand Up @@ -286,7 +288,7 @@ scenario_runner() {
# Initialize "scenario" and "check" variables.
s_basename=${out}/${basename}
s_val_basename=${out_valgrind}/${basename}
s_count=0
c_count_next=0
c_exitfile="${NO_EXITFILE}"
c_valgrind_min=9
c_valgrind_cmd=""
Expand Down
2 changes: 1 addition & 1 deletion tests/shared_valgrind_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ valgrind_setup_cmd() {
return
fi

val_logfilename="${s_val_basename}-${s_count_str}-%p.log"
val_logfilename="${s_val_basename}-${c_count_str}-%p.log"
c_valgrind_cmd="valgrind \
--log-file=${val_logfilename} \
--track-fds=yes \
Expand Down

0 comments on commit 3d75191

Please sign in to comment.