Skip to content

Commit

Permalink
use OPENSSL_cleanse if OpenSSL is used (#1773)
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Mali <[email protected]>
  • Loading branch information
bencemali authored May 20, 2024
1 parent a5ec23c commit 9c097d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/common/common.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 AND MIT

#if !defined(_WIN32) && !defined(OQS_HAVE_EXPLICIT_BZERO)
#if !defined(OQS_USE_OPENSSL) && !defined(_WIN32) && !defined(OQS_HAVE_EXPLICIT_BZERO)
// Request memset_s
#define __STDC_WANT_LIB_EXT1__ 1
#endif
Expand Down Expand Up @@ -256,7 +256,9 @@ OQS_API int OQS_MEM_secure_bcmp(const void *a, const void *b, size_t len) {
}

OQS_API void OQS_MEM_cleanse(void *ptr, size_t len) {
#if defined(_WIN32)
#if defined(OQS_USE_OPENSSL)
OSSL_FUNC(OPENSSL_cleanse)(ptr, len);
#elif defined(_WIN32)
SecureZeroMemory(ptr, len);
#elif defined(OQS_HAVE_EXPLICIT_BZERO)
explicit_bzero(ptr, len);
Expand Down
1 change: 1 addition & 0 deletions src/common/ossl_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ FUNC(const EVP_MD *, EVP_sha512, (void), ())
FUNC(const EVP_MD *, EVP_shake128, (void), ())
FUNC(const EVP_MD *, EVP_shake256, (void), ())
#endif
VOID_FUNC(void, OPENSSL_cleanse, (void *ptr, size_t len), (ptr, len))
FUNC(int, RAND_bytes, (unsigned char *buf, int num), (buf, num))
FUNC(int, RAND_poll, (void), ())
FUNC(int, RAND_status, (void), ())

0 comments on commit 9c097d9

Please sign in to comment.