Skip to content

Commit

Permalink
Fix astyle
Browse files Browse the repository at this point in the history
  • Loading branch information
ducnguyen-sb committed Jan 8, 2024
1 parent 5156dcf commit 34adef9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 33 deletions.
54 changes: 27 additions & 27 deletions src/common/sha2/sha2_armv8.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,33 +274,33 @@ void oqs_sha2_sha256_inc_blocks_armv8(sha256ctx *state, const uint8_t *in, size_
}

void oqs_sha2_sha256_inc_armv8(sha256ctx *state, const uint8_t *in, size_t len) {
while (len) {
size_t incr = 64 - state->data_len;
if (incr > len) {
incr = len;
}

memcpy(state->data + state->data_len, in, incr);
state->data_len += incr;
in += incr;

if (state->data_len < 64) {
break;
}

/*
* Process a complete block now
*/
uint64_t bytes = load_bigendian_64(state->ctx + 32) + 64;
crypto_hashblocks_sha256_armv8(state->ctx, state->data, 64);
store_bigendian_64(state->ctx + 32, bytes);

/*
* update the remaining input
*/
len -= incr;
state->data_len = 0;
}
while (len) {
size_t incr = 64 - state->data_len;
if (incr > len) {
incr = len;
}

memcpy(state->data + state->data_len, in, incr);
state->data_len += incr;
in += incr;

if (state->data_len < 64) {
break;
}

/*
* Process a complete block now
*/
uint64_t bytes = load_bigendian_64(state->ctx + 32) + 64;
crypto_hashblocks_sha256_armv8(state->ctx, state->data, 64);
store_bigendian_64(state->ctx + 32, bytes);

/*
* update the remaining input
*/
len -= incr;
state->data_len = 0;
}
}

void oqs_sha2_sha224_inc_blocks_armv8(sha224ctx *state, const uint8_t *in, size_t inblocks) {
Expand Down
11 changes: 5 additions & 6 deletions src/common/sha2/sha2_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,15 +571,15 @@ void oqs_sha2_sha256_inc_ctx_clone_c(sha256ctx *stateout, const sha256ctx *state
}

void oqs_sha2_sha384_inc_ctx_clone_c(sha384ctx *stateout, const sha384ctx *statein) {
stateout->ctx = OQS_MEM_checked_malloc(PQC_SHA512CTX_BYTES);
stateout->ctx = OQS_MEM_checked_malloc(PQC_SHA512CTX_BYTES);

stateout->data_len = statein->data_len;
memcpy(stateout->data, statein->data, 128);
memcpy(stateout->ctx, statein->ctx, PQC_SHA512CTX_BYTES);
}

void oqs_sha2_sha512_inc_ctx_clone_c(sha512ctx *stateout, const sha512ctx *statein) {
stateout->ctx = OQS_MEM_checked_malloc(PQC_SHA512CTX_BYTES);
stateout->ctx = OQS_MEM_checked_malloc(PQC_SHA512CTX_BYTES);

stateout->data_len = statein->data_len;
memcpy(stateout->data, statein->data, 128);
Expand Down Expand Up @@ -614,7 +614,7 @@ void oqs_sha2_sha256_inc_blocks_c(sha256ctx *state, const uint8_t *in, size_t in

/* Process any existing incremental data first */
if (state->data_len) {
tmp_in = OQS_MEM_checked_malloc(tmp_buflen);
tmp_in = OQS_MEM_checked_malloc(tmp_buflen);

memcpy(tmp_in, state->data, state->data_len);
memcpy(tmp_in + state->data_len, in, tmp_buflen - state->data_len);
Expand All @@ -641,8 +641,8 @@ void oqs_sha2_sha256_inc_c(sha256ctx *state, const uint8_t *in, size_t len) {
}

memcpy(state->data + state->data_len, in, incr);
state->data_len += incr;
in += incr;
state->data_len += incr;
in += incr;

if (state->data_len < 64) {
break;
Expand Down Expand Up @@ -843,4 +843,3 @@ void oqs_sha2_sha512_c(uint8_t *out, const uint8_t *in, size_t inlen) {
oqs_sha2_sha512_inc_init_c(&state);
oqs_sha2_sha512_inc_finalize_c(out, &state, in, inlen);
}

0 comments on commit 34adef9

Please sign in to comment.