Skip to content

Commit

Permalink
fixup! Add missing OpenSSL guards
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Wilson <[email protected]>
  • Loading branch information
SWilson4 committed Jul 25, 2024
1 parent b831ae7 commit 92f7e05
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions src/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ extern "C" {
* Macro for terminating the program if x is
* a null pointer.
*/
#define OQS_EXIT_IF_NULLPTR(x, loc) \
do { \
if ( (x) == (void*)0 ) { \
#define OQS_EXIT_IF_NULLPTR(x, loc) \
do { \
if ( (x) == (void*)0 ) { \
fprintf(stderr, "Unexpected NULL returned from %s API. Exiting.\n", loc); \
exit(EXIT_FAILURE); \
} \
exit(EXIT_FAILURE); \
} \
} while (0)

/**
Expand All @@ -44,21 +44,21 @@ extern "C" {
* handling strategy is developed.
*/
#if defined(OQS_USE_OPENSSL) && !defined(OPENSSL_NO_STDIO)
#define OQS_OPENSSL_GUARD(x) \
do { \
if( 1 != (x) ) { \
#define OQS_OPENSSL_GUARD(x) \
do { \
if( 1 != (x) ) { \
fprintf(stderr, "Error return value from OpenSSL API: %d. Exiting.\n", x); \
OSSL_FUNC(ERR_print_errors_fp)(stderr);
exit(EXIT_FAILURE); \
} \
OSSL_FUNC(ERR_print_errors_fp)(stderr); \
exit(EXIT_FAILURE); \
} \
} while (0)
#else
#define OQS_OPENSSL_GUARD(x) \
do { \
if( 1 != (x) ) { \
#define OQS_OPENSSL_GUARD(x) \
do { \
if( 1 != (x) ) { \
fprintf(stderr, "Error return value from OpenSSL API: %d. Exiting.\n", x); \
exit(EXIT_FAILURE); \
} \
exit(EXIT_FAILURE); \
} \
} while (0)
#endif // defined(OQS_USE_OPENSSL) && !defined(OPENSSL_NO_STDIO)

Expand Down
2 changes: 1 addition & 1 deletion src/common/rand/rand_nist.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void AES256_ECB(unsigned char *key, unsigned char *ctr, unsigned char *bu

/* Create and initialise the context */
ctx = OSSL_FUNC(EVP_CIPHER_CTX_new)();
OQS_EXIT_IF_NULLPTR(ctx);
OQS_EXIT_IF_NULLPTR(ctx, "OpenSSL");

OQS_OPENSSL_GUARD(OSSL_FUNC(EVP_EncryptInit_ex)(ctx, oqs_aes_256_ecb(), NULL, key, NULL));
OQS_OPENSSL_GUARD(OSSL_FUNC(EVP_EncryptUpdate)(ctx, buffer, &len, ctr, 16));
Expand Down

0 comments on commit 92f7e05

Please sign in to comment.