From 7ac557498fd9fb18c6165ca1245387cf55b8d2e9 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 3 Jan 2019 09:49:33 +0100 Subject: [PATCH] C++ compat --- test/default/cmptest.h | 12 ++++++------ test/default/misuse.c | 10 ++++++---- test/default/pwhash_argon2id.c | 8 ++++---- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/test/default/cmptest.h b/test/default/cmptest.h index 6f5bebe4..4625d551 100644 --- a/test/default/cmptest.h +++ b/test/default/cmptest.h @@ -35,7 +35,7 @@ int xmain(void); -static void *guard_page; +static unsigned char *guard_page; #ifdef BENCHMARKS @@ -167,9 +167,9 @@ static FILE *fp_res; int main(void) { - FILE *fp_out; - void *_guard_page; - int c; + FILE *fp_out; + unsigned char *_guard_page; + int c; if ((fp_res = fopen(TEST_NAME_RES, "w+")) == NULL) { perror("fopen(" TEST_NAME_RES ")"); @@ -178,11 +178,11 @@ int main(void) if (sodium_init() != 0) { return 99; } - if ((_guard_page = sodium_malloc(0)) == NULL) { + if ((_guard_page = (unsigned char *) sodium_malloc(0)) == NULL) { perror("sodium_malloc()"); return 99; } - guard_page = (void *) (((unsigned char *) _guard_page) + 1); + guard_page = _guard_page + 1; if (xmain() != 0) { return 99; } diff --git a/test/default/misuse.c b/test/default/misuse.c index 8767c5e9..407d526f 100644 --- a/test/default/misuse.c +++ b/test/default/misuse.c @@ -45,7 +45,8 @@ sigabrt_handler_12(int sig) # else signal(SIGABRT, sigabrt_handler_13); # endif - assert(crypto_pwhash_str_alg(guard_page, "", 0U, 1U, 1U, -1) == -1); + assert(crypto_pwhash_str_alg((char *) guard_page, + "", 0U, 1U, 1U, -1) == -1); exit(1); } @@ -76,7 +77,7 @@ sigabrt_handler_9(int sig) { (void) sig; signal(SIGABRT, sigabrt_handler_10); - assert(sodium_base642bin(guard_page, 1, guard_page, 1, + assert(sodium_base642bin(guard_page, 1, (const char *) guard_page, 1, NULL, NULL, NULL, -1) == -1); exit(1); } @@ -86,7 +87,7 @@ sigabrt_handler_8(int sig) { (void) sig; signal(SIGABRT, sigabrt_handler_9); - assert(sodium_bin2base64(guard_page, 1, guard_page, 1, + assert(sodium_bin2base64((char *) guard_page, 1, guard_page, 1, sodium_base64_VARIANT_ORIGINAL) == NULL); exit(1); } @@ -96,7 +97,8 @@ sigabrt_handler_7(int sig) { (void) sig; signal(SIGABRT, sigabrt_handler_8); - assert(sodium_bin2base64(guard_page, 1, guard_page, 1, -1) == NULL); + assert(sodium_bin2base64((char *) guard_page, 1, + guard_page, 1, -1) == NULL); exit(1); } diff --git a/test/default/pwhash_argon2id.c b/test/default/pwhash_argon2id.c index f4e7450f..95463492 100644 --- a/test/default/pwhash_argon2id.c +++ b/test/default/pwhash_argon2id.c @@ -480,19 +480,19 @@ main(void) assert(crypto_pwhash_alg_argon2id13() != crypto_pwhash_alg_argon2i13()); assert(crypto_pwhash_alg_argon2id13() == crypto_pwhash_alg_default()); - assert(crypto_pwhash_argon2id(guard_page, 0, guard_page, 0, guard_page, + assert(crypto_pwhash_argon2id(guard_page, 0, (const char *) guard_page, 0, guard_page, crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE, crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE, 0) == -1); - assert(crypto_pwhash_argon2id(guard_page, 0, guard_page, 0, guard_page, + assert(crypto_pwhash_argon2id(guard_page, 0, (const char *) guard_page, 0, guard_page, crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE, crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE, crypto_pwhash_ALG_ARGON2I13) == -1); - assert(crypto_pwhash_argon2i(guard_page, 0, guard_page, 0, guard_page, + assert(crypto_pwhash_argon2i(guard_page, 0, (const char *) guard_page, 0, guard_page, crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE, crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE, 0) == -1); - assert(crypto_pwhash_argon2i(guard_page, 0, guard_page, 0, guard_page, + assert(crypto_pwhash_argon2i(guard_page, 0, (const char *) guard_page, 0, guard_page, crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE, crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE, crypto_pwhash_ALG_ARGON2ID13) == -1);