From 0cfab1d5e48036db647f06729fe2a28187e58162 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 21 Mar 2022 14:10:44 -0700 Subject: [PATCH] Peer review feedback. --- tls/client-tls-pkcallback.c | 17 ++++++++++++----- tls/server-tls-pkcallback.c | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/tls/client-tls-pkcallback.c b/tls/client-tls-pkcallback.c index 71318539..9fa1c67b 100644 --- a/tls/client-tls-pkcallback.c +++ b/tls/client-tls-pkcallback.c @@ -281,6 +281,9 @@ static int myRsaPssSign(WOLFSSL* ssl, const byte* in, word32 inSz, hashType = WC_HASH_TYPE_SHA512; break; #endif + default: + hashType = WC_HASH_TYPE_NONE; + break; } ret = wc_InitRsaKey(&cbInfo->keyRsa, NULL); @@ -331,6 +334,13 @@ int main(int argc, char** argv) return 0; } +#ifndef HAVE_PK_CALLBACKS + printf("Warning: PK not compiled in! Please configure wolfSSL with " + " --enable-pkcallbacks and try again\n"); + ret = -1; + goto exit; +#endif + /* Create a socket that uses an internet IPv4 address, * Sets the socket to be stream based (TCP), * 0 means choose the default protocol. */ @@ -364,7 +374,7 @@ int main(int argc, char** argv) /*---------------------------------*/ /* Start of wolfSSL initialization and configuration */ /*---------------------------------*/ -#if 1 +#if 0 wolfSSL_Debugging_ON(); #endif @@ -387,7 +397,7 @@ int main(int argc, char** argv) } #ifdef HAVE_PK_CALLBACKS - /* register a sign callbacks for the long term key */ + /* register sign callbacks for the long term key */ #ifdef HAVE_ECC wolfSSL_CTX_SetEccSignCb(ctx, myEccSign); #endif @@ -397,9 +407,6 @@ int main(int argc, char** argv) wolfSSL_CTX_SetRsaPssSignCb(ctx, myRsaPssSign); #endif #endif -#else - printf("Warning: PK not compiled in! Please configure wolfSSL with " - " --enable-pkcallbacks and try again\n"); #endif /* Mutual Authentication */ diff --git a/tls/server-tls-pkcallback.c b/tls/server-tls-pkcallback.c index 05986aa6..a9791e46 100644 --- a/tls/server-tls-pkcallback.c +++ b/tls/server-tls-pkcallback.c @@ -280,6 +280,9 @@ static int myRsaPssSign(WOLFSSL* ssl, const byte* in, word32 inSz, hashType = WC_HASH_TYPE_SHA512; break; #endif + default: + hashType = WC_HASH_TYPE_NONE; + break; } ret = wc_InitRsaKey(&cbInfo->keyRsa, NULL); @@ -330,6 +333,13 @@ int main(int argc, char** argv) WOLFSSL_CTX* ctx = NULL; WOLFSSL* ssl = NULL; +#ifndef HAVE_PK_CALLBACKS + printf("Warning: PK not compiled in! Please configure wolfSSL with " + " --enable-pkcallbacks and try again\n"); + ret = -1; + goto exit; +#endif + /* Initialize the server address struct with zeros */ memset(&servAddr, 0, sizeof(servAddr)); @@ -376,7 +386,7 @@ int main(int argc, char** argv) /*---------------------------------*/ /* Start of wolfSSL initialization and configuration */ /*---------------------------------*/ -#if 1 +#if 0 wolfSSL_Debugging_ON(); #endif @@ -396,7 +406,7 @@ int main(int argc, char** argv) } #ifdef HAVE_PK_CALLBACKS - /* register a sign callbacks for the long term key */ + /* register sign callbacks for the long term key */ #ifdef HAVE_ECC wolfSSL_CTX_SetEccSignCb(ctx, myEccSign); #endif @@ -406,9 +416,6 @@ int main(int argc, char** argv) wolfSSL_CTX_SetRsaPssSignCb(ctx, myRsaPssSign); #endif #endif -#else - printf("Warning: PK not compiled in! Please configure wolfSSL with " - " --enable-pkcallbacks and try again\n"); #endif /* Load server certificates into WOLFSSL_CTX */