diff --git a/src/common/sha2/sha2_impl.c b/src/common/sha2/sha2_impl.c index 404c9e6bb..33805989e 100644 --- a/src/common/sha2/sha2_impl.c +++ b/src/common/sha2/sha2_impl.c @@ -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 = {