Skip to content

Commit

Permalink
Merge pull request #8515 from SparkiDev/test_sha512_be
Browse files Browse the repository at this point in the history
Tests api.c: sha512 big endian
  • Loading branch information
douzzer authored Feb 28, 2025
2 parents 4f8a39c + 14651ed commit 7698546
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
24 changes: 24 additions & 0 deletions tests/api/test_digest.h
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,30 @@ do { \

#endif

#define DIGEST_TRANSFORM_FINAL_RAW_ALL_TEST(type, name, upper, abcBlockStr, \
abcHashStr) \
type dgst; \
const char* abc##name##Data = abcBlockStr; \
const char* abcHash = abcHashStr; \
byte abcData[WC_##upper##_BLOCK_SIZE]; \
byte hash[WC_##upper##_DIGEST_SIZE]; \
\
XMEMCPY(abcData, abc##name##Data, WC_##upper##_BLOCK_SIZE); \
\
ExpectIntEQ(wc_Init##name(&dgst), 0); \
\
/* Test bad args. */ \
ExpectIntEQ(wc_##name##Transform(NULL, NULL), BAD_FUNC_ARG); \
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), BAD_FUNC_ARG); \
ExpectIntEQ(wc_##name##Transform(NULL, (byte*)abc##name##Data), \
BAD_FUNC_ARG); \
\
ExpectIntEQ(wc_##name##Transform(&dgst, (byte*)abcData), 0); \
ExpectIntEQ(wc_##name##FinalRaw(&dgst, hash), 0); \
ExpectBufEQ(hash, (byte*)abcHash, WC_##upper##_DIGEST_SIZE); \
\
wc_##name##Free(&dgst)

#define DIGEST_FLAGS_TEST(type, name) \
type dgst; \
type dgst_copy; \
Expand Down
6 changes: 3 additions & 3 deletions tests/api/test_sha512.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ int test_wc_Sha512Transform(void)
(defined(OPENSSL_EXTRA) || defined(HAVE_CURL)) && \
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3)))
DIGEST_TRANSFORM_FINAL_RAW_TEST(wc_Sha512, Sha512, SHA512,
DIGEST_TRANSFORM_FINAL_RAW_ALL_TEST(wc_Sha512, Sha512, SHA512,
"\x80\x63\x62\x61\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00"
Expand Down Expand Up @@ -458,7 +458,7 @@ int test_wc_Sha512_224Transform(void)
(defined(OPENSSL_EXTRA) || defined(HAVE_CURL)) && \
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3)))
DIGEST_TRANSFORM_FINAL_RAW_TEST(wc_Sha512, Sha512_224, SHA512_224,
DIGEST_TRANSFORM_FINAL_RAW_ALL_TEST(wc_Sha512, Sha512_224, SHA512_224,
"\x61\x62\x63\x80\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00"
Expand Down Expand Up @@ -656,7 +656,7 @@ int test_wc_Sha512_256Transform(void)
(defined(OPENSSL_EXTRA) || defined(HAVE_CURL)) && \
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3)))
DIGEST_TRANSFORM_FINAL_RAW_TEST(wc_Sha512, Sha512_256, SHA512_256,
DIGEST_TRANSFORM_FINAL_RAW_ALL_TEST(wc_Sha512, Sha512_256, SHA512_256,
"\x61\x62\x63\x80\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00"
Expand Down

0 comments on commit 7698546

Please sign in to comment.