summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>2018-10-05 01:05:54 +0200
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>2018-10-05 12:19:48 +0200
commit8529b156421805415bc7b17758255394de580c61 (patch)
tree08dc94426f366c7b6faca92d4fc61bee7936ca83 /test
parent36d3acb91d5d2f0308ab93be9ce5609f784f95a2 (diff)
test/secmemtest: test secure memory only if it is implemented
Fixes #7322 Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> (Merged from https://github.com/openssl/openssl/pull/7351)
Diffstat (limited to 'test')
-rw-r--r--test/secmemtest.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/secmemtest.c b/test/secmemtest.c
index 37c4b8f9d8..42aeb5d0cf 100644
--- a/test/secmemtest.c
+++ b/test/secmemtest.c
@@ -10,13 +10,16 @@
#include <openssl/crypto.h>
#include "testutil.h"
+#include "../e_os.h"
static int test_sec_mem(void)
{
-#if defined(OPENSSL_SYS_LINUX) || defined(OPENSSL_SYS_UNIX)
+#ifdef OPENSSL_SECURE_MEMORY
int testresult = 0;
char *p = NULL, *q = NULL, *r = NULL, *s = NULL;
+ TEST_info("Secure memory is implemented.");
+
s = OPENSSL_secure_malloc(20);
/* s = non-secure 20 */
if (!TEST_ptr(s)
@@ -124,6 +127,7 @@ static int test_sec_mem(void)
OPENSSL_secure_free(s);
return testresult;
#else
+ TEST_info("Secure memory is *not* implemented.");
/* Should fail. */
return TEST_false(CRYPTO_secure_malloc_init(4096, 32));
#endif
@@ -131,7 +135,7 @@ static int test_sec_mem(void)
static int test_sec_mem_clear(void)
{
-#if defined(OPENSSL_SYS_LINUX) || defined(OPENSSL_SYS_UNIX)
+#ifdef OPENSSL_SECURE_MEMORY
const int size = 64;
unsigned char *p = NULL;
int i, res = 0;
@@ -162,7 +166,6 @@ static int test_sec_mem_clear(void)
res = 1;
p = NULL;
-
err:
OPENSSL_secure_free(p);
CRYPTO_secure_malloc_done();