2017-07-17 17:09:44 -04:00
|
|
|
|
|
|
|
#define TEST_NAME "misuse"
|
|
|
|
#include "cmptest.h"
|
|
|
|
|
2017-09-19 16:33:09 -04:00
|
|
|
#ifdef HAVE_CATCHABLE_ABRT
|
2017-09-15 04:19:34 -04:00
|
|
|
# include <signal.h>
|
2017-07-17 17:09:44 -04:00
|
|
|
|
|
|
|
static void
|
2017-12-03 10:39:05 -05:00
|
|
|
sigabrt_handler_15(int sig)
|
2017-07-17 17:09:44 -04:00
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2017-12-03 10:55:46 -05:00
|
|
|
# ifndef SODIUM_LIBRARY_MINIMAL
|
2017-12-03 10:39:05 -05:00
|
|
|
static void
|
|
|
|
sigabrt_handler_14(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_15);
|
|
|
|
assert(crypto_box_curve25519xchacha20poly1305_easy
|
2018-12-24 09:02:59 -05:00
|
|
|
(guard_page, guard_page, crypto_stream_xchacha20_MESSAGEBYTES_MAX - 1,
|
|
|
|
guard_page, guard_page, guard_page) == -1);
|
2017-12-03 10:39:05 -05:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sigabrt_handler_13(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_14);
|
|
|
|
assert(crypto_box_curve25519xchacha20poly1305_easy_afternm
|
2018-12-24 09:02:59 -05:00
|
|
|
(guard_page, guard_page, crypto_stream_xchacha20_MESSAGEBYTES_MAX - 1,
|
|
|
|
guard_page, guard_page) == -1);
|
2017-12-03 10:39:05 -05:00
|
|
|
exit(1);
|
|
|
|
}
|
2017-12-03 10:55:46 -05:00
|
|
|
# endif
|
2017-12-03 10:39:05 -05:00
|
|
|
|
2017-09-19 16:19:50 -04:00
|
|
|
static void
|
|
|
|
sigabrt_handler_12(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
2017-12-03 10:49:55 -05:00
|
|
|
# ifdef SODIUM_LIBRARY_MINIMAL
|
|
|
|
signal(SIGABRT, sigabrt_handler_15);
|
|
|
|
# else
|
2017-09-19 16:19:50 -04:00
|
|
|
signal(SIGABRT, sigabrt_handler_13);
|
2017-12-03 10:49:55 -05:00
|
|
|
# endif
|
2018-12-24 09:02:59 -05:00
|
|
|
assert(crypto_pwhash_str_alg(guard_page, "", 0U, 1U, 1U, -1) == -1);
|
2017-09-19 16:19:50 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2017-09-19 16:17:10 -04:00
|
|
|
static void
|
|
|
|
sigabrt_handler_11(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_12);
|
2018-12-24 09:22:49 -05:00
|
|
|
assert(crypto_box_easy(guard_page, guard_page,
|
|
|
|
crypto_stream_xsalsa20_MESSAGEBYTES_MAX,
|
2018-12-24 09:02:59 -05:00
|
|
|
guard_page, guard_page, guard_page) == -1);
|
2017-09-19 16:17:10 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sigabrt_handler_10(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_11);
|
2018-12-24 09:22:49 -05:00
|
|
|
assert(crypto_box_easy_afternm(guard_page, guard_page,
|
|
|
|
crypto_stream_xsalsa20_MESSAGEBYTES_MAX,
|
2018-12-24 09:02:59 -05:00
|
|
|
guard_page, guard_page) == -1);
|
2017-09-19 16:17:10 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2017-09-19 16:08:31 -04:00
|
|
|
static void
|
|
|
|
sigabrt_handler_9(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_10);
|
2018-12-24 09:22:49 -05:00
|
|
|
assert(sodium_base642bin(guard_page, 1, guard_page, 1,
|
|
|
|
NULL, NULL, NULL, -1) == -1);
|
2017-09-19 16:08:31 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sigabrt_handler_8(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_9);
|
2018-12-24 09:22:49 -05:00
|
|
|
assert(sodium_bin2base64(guard_page, 1, guard_page, 1,
|
|
|
|
sodium_base64_VARIANT_ORIGINAL) == NULL);
|
2017-09-19 16:08:31 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sigabrt_handler_7(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_8);
|
2018-12-24 09:02:59 -05:00
|
|
|
assert(sodium_bin2base64(guard_page, 1, guard_page, 1, -1) == NULL);
|
2017-09-19 16:08:31 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sigabrt_handler_6(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_7);
|
2018-12-24 09:02:59 -05:00
|
|
|
assert(sodium_pad(NULL, guard_page, SIZE_MAX, 16, 1) == -1);
|
2017-09-19 16:08:31 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2017-07-24 09:16:22 -04:00
|
|
|
static void
|
|
|
|
sigabrt_handler_5(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_6);
|
2018-12-24 09:02:59 -05:00
|
|
|
assert(crypto_aead_xchacha20poly1305_ietf_encrypt(guard_page, NULL, NULL, UINT64_MAX,
|
2018-12-24 09:22:49 -05:00
|
|
|
NULL, 0, NULL,
|
|
|
|
guard_page, guard_page) == -1);
|
2017-07-24 09:16:22 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2017-07-21 10:52:01 -04:00
|
|
|
static void
|
|
|
|
sigabrt_handler_4(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_5);
|
2018-12-24 09:02:59 -05:00
|
|
|
assert(crypto_aead_chacha20poly1305_ietf_encrypt(guard_page, NULL, NULL, UINT64_MAX,
|
2018-12-24 09:22:49 -05:00
|
|
|
NULL, 0, NULL,
|
|
|
|
guard_page, guard_page) == -1);
|
2017-07-21 10:52:01 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sigabrt_handler_3(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_4);
|
2018-12-24 09:02:59 -05:00
|
|
|
assert(crypto_aead_chacha20poly1305_encrypt(guard_page, NULL, NULL, UINT64_MAX,
|
2018-12-24 09:22:49 -05:00
|
|
|
NULL, 0, NULL,
|
|
|
|
guard_page, guard_page) == -1);
|
2017-07-21 10:52:01 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2017-07-17 17:09:44 -04:00
|
|
|
static void
|
|
|
|
sigabrt_handler_2(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_3);
|
|
|
|
#if SIZE_MAX > 0x4000000000ULL
|
2018-12-24 09:02:59 -05:00
|
|
|
randombytes_buf_deterministic(guard_page, 0x4000000001ULL, guard_page);
|
2017-07-17 17:09:44 -04:00
|
|
|
#else
|
|
|
|
abort();
|
|
|
|
#endif
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sigabrt_handler_1(int sig)
|
|
|
|
{
|
|
|
|
(void) sig;
|
|
|
|
signal(SIGABRT, sigabrt_handler_2);
|
2018-12-24 09:22:49 -05:00
|
|
|
assert(crypto_kx_server_session_keys(NULL, NULL, guard_page, guard_page,
|
|
|
|
guard_page) == -1);
|
2017-07-17 17:09:44 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
signal(SIGABRT, sigabrt_handler_1);
|
2018-12-24 09:22:49 -05:00
|
|
|
assert(crypto_kx_client_session_keys(NULL, NULL, guard_page, guard_page,
|
|
|
|
guard_page) == -1);
|
2017-07-17 17:09:44 -04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
2017-07-30 11:54:54 -04:00
|
|
|
return 0;
|
2017-07-17 17:09:44 -04:00
|
|
|
}
|
|
|
|
#endif
|