Skip to content

Commit

Permalink
revert sha2_impl.c
Browse files Browse the repository at this point in the history
Signed-off-by: Songling Han <[email protected]>
  • Loading branch information
songlingatpan committed Sep 22, 2024
1 parent 7662f00 commit 88475d8
Showing 1 changed file with 28 additions and 66 deletions.
94 changes: 28 additions & 66 deletions src/common/sha2/sha2_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,126 +24,88 @@
#endif

static void SHA2_sha256_inc_init(OQS_SHA2_sha256_ctx *state) {
if (state != NULL) {
oqs_sha2_sha256_inc_init_c((sha256ctx *) state);
}
oqs_sha2_sha256_inc_init_c((sha256ctx *) state);
}

static void SHA2_sha256_inc_ctx_clone(OQS_SHA2_sha256_ctx *dest, const OQS_SHA2_sha256_ctx *src) {
if (dest != NULL && src != NULL) {
oqs_sha2_sha256_inc_ctx_clone_c((sha256ctx *) dest, (const sha256ctx *) src);
}
oqs_sha2_sha256_inc_ctx_clone_c((sha256ctx *) dest, (const sha256ctx *) src);
}

static void SHA2_sha256_inc(OQS_SHA2_sha256_ctx *state, const uint8_t *in, size_t len) {
if (state != NULL && in != NULL) {
C_OR_ARM(
oqs_sha2_sha256_inc_c((sha256ctx *) state, in, len),
oqs_sha2_sha256_inc_armv8((sha256ctx *) state, in, len)
);
}
C_OR_ARM(
oqs_sha2_sha256_inc_c((sha256ctx *) state, in, len),
oqs_sha2_sha256_inc_armv8((sha256ctx *) state, in, len)
);
}

static void SHA2_sha256_inc_blocks(OQS_SHA2_sha256_ctx *state, const uint8_t *in, size_t inblocks) {
if (state != NULL && in != NULL) {
C_OR_ARM(
oqs_sha2_sha256_inc_blocks_c((sha256ctx *) state, in, inblocks),
oqs_sha2_sha256_inc_blocks_armv8((sha256ctx *) state, in, inblocks)
);
}
C_OR_ARM(
oqs_sha2_sha256_inc_blocks_c((sha256ctx *) state, in, inblocks),
oqs_sha2_sha256_inc_blocks_armv8((sha256ctx *) state, in, inblocks)
);
}

static void SHA2_sha256_inc_finalize(uint8_t *out, OQS_SHA2_sha256_ctx *state, const uint8_t *in, size_t inlen) {
if (out != NULL && state != NULL) {
oqs_sha2_sha256_inc_finalize_c(out, (sha256ctx *) state, in, inlen);
}
oqs_sha2_sha256_inc_finalize_c(out, (sha256ctx *) state, in, inlen);
}

static void SHA2_sha256_inc_ctx_release(OQS_SHA2_sha256_ctx *state) {
if (state != NULL) {
oqs_sha2_sha256_inc_ctx_release_c((sha256ctx *) state);
}
oqs_sha2_sha256_inc_ctx_release_c((sha256ctx *) state);
}

static void SHA2_sha384_inc_init(OQS_SHA2_sha384_ctx *state) {
if (state != NULL) {
oqs_sha2_sha384_inc_init_c((sha384ctx *)state);
}
oqs_sha2_sha384_inc_init_c((sha384ctx *)state);
}

static void SHA2_sha384_inc_ctx_clone(OQS_SHA2_sha384_ctx *dest, const OQS_SHA2_sha384_ctx *src) {
if (dest != NULL && src != NULL) {
oqs_sha2_sha384_inc_ctx_clone_c((sha384ctx *) dest, (const sha384ctx *) src);
}
oqs_sha2_sha384_inc_ctx_clone_c((sha384ctx *) dest, (const sha384ctx *) src);
}

static void SHA2_sha384_inc_blocks(OQS_SHA2_sha384_ctx *state, const uint8_t *in, size_t inblocks) {
if (state != NULL && in != NULL) {
oqs_sha2_sha384_inc_blocks_c((sha384ctx *) state, in, inblocks);
}
oqs_sha2_sha384_inc_blocks_c((sha384ctx *) state, in, inblocks);
}

static void SHA2_sha384_inc_finalize(uint8_t *out, OQS_SHA2_sha384_ctx *state, const uint8_t *in, size_t inlen) {
if (out != NULL && state != NULL) {
oqs_sha2_sha384_inc_finalize_c(out, (sha384ctx *) state, in, inlen);
}
oqs_sha2_sha384_inc_finalize_c(out, (sha384ctx *) state, in, inlen);
}

static void SHA2_sha384_inc_ctx_release(OQS_SHA2_sha384_ctx *state) {
if (state != NULL) {
oqs_sha2_sha384_inc_ctx_release_c((sha384ctx *) state);
}
oqs_sha2_sha384_inc_ctx_release_c((sha384ctx *) state);
}

static void SHA2_sha512_inc_init(OQS_SHA2_sha512_ctx *state) {
if (state != NULL) {
oqs_sha2_sha512_inc_init_c((sha512ctx *)state);
}
oqs_sha2_sha512_inc_init_c((sha512ctx *)state);
}

static void SHA2_sha512_inc_ctx_clone(OQS_SHA2_sha512_ctx *dest, const OQS_SHA2_sha512_ctx *src) {
if (dest != NULL && src != NULL) {
oqs_sha2_sha512_inc_ctx_clone_c((sha512ctx *) dest, (const sha512ctx *) src);
}
oqs_sha2_sha512_inc_ctx_clone_c((sha512ctx *) dest, (const sha512ctx *) src);
}

static void SHA2_sha512_inc_blocks(OQS_SHA2_sha512_ctx *state, const uint8_t *in, size_t inblocks) {
if (state != NULL && in != NULL) {
oqs_sha2_sha512_inc_blocks_c((sha512ctx *) state, in, inblocks);
}
oqs_sha2_sha512_inc_blocks_c((sha512ctx *) state, in, inblocks);
}

static void SHA2_sha512_inc_finalize(uint8_t *out, OQS_SHA2_sha512_ctx *state, const uint8_t *in, size_t inlen) {
if (out != NULL && state != NULL) {
oqs_sha2_sha512_inc_finalize_c(out, (sha512ctx *) state, in, inlen);
}
oqs_sha2_sha512_inc_finalize_c(out, (sha512ctx *) state, in, inlen);
}

static void SHA2_sha512_inc_ctx_release(OQS_SHA2_sha512_ctx *state) {
if (state != NULL) {
oqs_sha2_sha512_inc_ctx_release_c((sha512ctx *) state);
}
oqs_sha2_sha512_inc_ctx_release_c((sha512ctx *) state);
}

static void SHA2_sha256(uint8_t *out, const uint8_t *in, size_t inlen) {
if (out != NULL && in != NULL) {
C_OR_ARM (
oqs_sha2_sha256_c(out, in, inlen),
oqs_sha2_sha256_armv8(out, in, inlen)
);
}
C_OR_ARM (
oqs_sha2_sha256_c(out, in, inlen),
oqs_sha2_sha256_armv8(out, in, inlen)
);
}

static void SHA2_sha384(uint8_t *out, const uint8_t *in, size_t inlen) {
if (out != NULL && in != NULL) {
oqs_sha2_sha384_c(out, in, inlen);
}
oqs_sha2_sha384_c(out, in, inlen);
}

static void SHA2_sha512(uint8_t *out, const uint8_t *in, size_t inlen) {
if (out != NULL && in != NULL) {
oqs_sha2_sha512_c(out, in, inlen);
}
oqs_sha2_sha512_c(out, in, inlen);
}

struct OQS_SHA2_callbacks sha2_default_callbacks = {
Expand Down

0 comments on commit 88475d8

Please sign in to comment.