From 6bb86cf4da27d6b92a8d820ec6159ad09686318b Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Wed, 10 Nov 2021 15:16:21 -0700 Subject: [PATCH] OE30 and OE31 changes external to FIPS module for NetBSD builds --- wolfcrypt/benchmark/benchmark.c | 19 +++++++++++++++++++ wolfcrypt/src/asn.c | 2 +- wolfcrypt/src/evp.c | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 8f5719586..1aeb695bb 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -218,6 +218,21 @@ #include #endif +#ifdef HAVE_FIPS + #include + + static void myFipsCb(int ok, int err, const char* hash) + { + printf("in my Fips callback, ok = %d, err = %d\n", ok, err); + printf("message = %s\n", wc_GetErrorString(err)); + printf("hash = %s\n", hash); + + if (err == IN_CORE_FIPS_E) { + printf("In core integrity hash check failure, copy above hash\n"); + printf("into verifyCore[] in fips_test.c and rebuild\n"); + } + } +#endif #ifdef WOLFSSL_STATIC_MEMORY static WOLFSSL_HEAP_HINT* HEAP_HINT; @@ -2127,6 +2142,10 @@ int benchmark_test(void *args) printf(" wolfSSL version %s\n", LIBWOLFSSL_VERSION_STRING); printf("------------------------------------------------------------------------------\n"); +#ifdef HAVE_FIPS + wolfCrypt_SetCb_fips(myFipsCb); +#endif + ret = benchmark_init(); if (ret != 0) EXIT_TEST(ret); diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 6b7e18d86..eb8e4671a 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -10187,7 +10187,7 @@ int wc_OBJ_sn2nid(const char *sn) sn = "SECP256R1"; /* OpenSSL allows lowercase curve names */ for (i = 0; i < (int)(sizeof(curveName) - 1) && *sn; i++) { - curveName[i] = (char)XTOUPPER(*sn++); + curveName[i] = (char)XTOUPPER((unsigned int) *sn++); } curveName[i] = '\0'; /* find based on name and return NID */ diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index a604c7792..acf2763f8 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -3695,7 +3695,7 @@ const WOLFSSL_EVP_MD *wolfSSL_EVP_get_digestbyname(const char *name) const struct s_ent *ent; for (i = 0; i < sizeof(nameUpper) && name[i] != '\0'; i++) { - nameUpper[i] = (char)XTOUPPER(name[i]); + nameUpper[i] = (char)XTOUPPER((unsigned int) name[i]); } if (i < sizeof(nameUpper)) nameUpper[i] = '\0';