1
0
forked from cory/tildefriends
Files
apps
core
deps
base64c
codemirror
crypt_blowfish
libbacktrace
libbacktrace_config
libsodium
.github
build-aux
builds
contrib
dist-build
m4
msvc-scripts
packaging
regen-msvc
src
test
default
Makefile.am
Makefile.in
aead_aes256gcm.c
aead_aes256gcm.exp
aead_aes256gcm2.c
aead_aes256gcm2.exp
aead_chacha20poly1305.c
aead_chacha20poly1305.exp
aead_chacha20poly13052.c
aead_chacha20poly13052.exp
aead_xchacha20poly1305.c
aead_xchacha20poly1305.exp
auth.c
auth.exp
auth2.c
auth2.exp
auth3.c
auth3.exp
auth5.c
auth5.exp
auth6.c
auth6.exp
auth7.c
auth7.exp
box.c
box.exp
box2.c
box2.exp
box7.c
box7.exp
box8.c
box8.exp
box_easy.c
box_easy.exp
box_easy2.c
box_easy2.exp
box_seal.c
box_seal.exp
box_seed.c
box_seed.exp
chacha20.c
chacha20.exp
cmptest.h
codecs.c
codecs.exp
core1.c
core1.exp
core2.c
core2.exp
core3.c
core3.exp
core4.c
core4.exp
core5.c
core5.exp
core6.c
core6.exp
core_ed25519.c
core_ed25519.exp
core_ristretto255.c
core_ristretto255.exp
ed25519_convert.c
ed25519_convert.exp
generichash.c
generichash.exp
generichash2.c
generichash2.exp
generichash3.c
generichash3.exp
hash.c
hash.exp
hash3.c
hash3.exp
index.html.tpl
kdf.c
kdf.exp
keygen.c
keygen.exp
kx.c
kx.exp
metamorphic.c
metamorphic.exp
misuse.c
misuse.exp
onetimeauth.c
onetimeauth.exp
onetimeauth2.c
onetimeauth2.exp
onetimeauth7.c
onetimeauth7.exp
pre.js.inc
pwhash_argon2i.c
pwhash_argon2i.exp
pwhash_argon2id.c
pwhash_argon2id.exp
pwhash_scrypt.c
pwhash_scrypt.exp
pwhash_scrypt_ll.c
pwhash_scrypt_ll.exp
randombytes.c
randombytes.exp
scalarmult.c
scalarmult.exp
scalarmult2.c
scalarmult2.exp
scalarmult5.c
scalarmult5.exp
scalarmult6.c
scalarmult6.exp
scalarmult7.c
scalarmult7.exp
scalarmult8.c
scalarmult8.exp
scalarmult_ed25519.c
scalarmult_ed25519.exp
scalarmult_ristretto255.c
scalarmult_ristretto255.exp
secretbox.c
secretbox.exp
secretbox2.c
secretbox2.exp
secretbox7.c
secretbox7.exp
secretbox8.c
secretbox8.exp
secretbox_easy.c
secretbox_easy.exp
secretbox_easy2.c
secretbox_easy2.exp
secretstream.c
secretstream.exp
shorthash.c
shorthash.exp
sign.c
sign.exp
siphashx24.c
siphashx24.exp
sodium_core.c
sodium_core.exp
sodium_utils.c
sodium_utils.exp
sodium_utils2.c
sodium_utils2.exp
sodium_utils3.c
sodium_utils3.exp
sodium_version.c
sodium_version.exp
stream.c
stream.exp
stream2.c
stream2.exp
stream3.c
stream3.exp
stream4.c
stream4.exp
verify1.c
verify1.exp
wasi-test-wrapper.sh
wintest.bat
xchacha20.c
xchacha20.exp
quirks
Makefile.am
Makefile.in
constcheck.sh
.gitignore
AUTHORS
ChangeLog
LICENSE
Makefile.am
Makefile.in
README.markdown
THANKS
aclocal.m4
appveyor.yml
autogen.sh
azure-pipelines.yml
build.zig
configure
configure.ac
lgtm.yml
libsodium-uninstalled.pc.in
libsodium.pc.in
libsodium.sln
libsodium.vcxproj
libsodium.vcxproj.filters
logo.png
libuv
perfetto
quickjs
smoothie
split
sqlite
valgrind
xopt
docs
src
tools
.dockerignore
Dockerfile
LICENSE
Makefile
README.md
tildefriends/deps/libsodium/test/default/misuse.c

185 lines
4.4 KiB
C

#define TEST_NAME "misuse"
#include "cmptest.h"
#ifdef HAVE_CATCHABLE_ABRT
# include <signal.h>
static void
sigabrt_handler_15(int sig)
{
(void) sig;
exit(0);
}
# ifndef SODIUM_LIBRARY_MINIMAL
static void
sigabrt_handler_14(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_15);
assert(crypto_box_curve25519xchacha20poly1305_easy
(guard_page, guard_page, crypto_stream_xchacha20_MESSAGEBYTES_MAX - 1,
guard_page, guard_page, guard_page) == -1);
exit(1);
}
static void
sigabrt_handler_13(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_14);
assert(crypto_box_curve25519xchacha20poly1305_easy_afternm
(guard_page, guard_page, crypto_stream_xchacha20_MESSAGEBYTES_MAX - 1,
guard_page, guard_page) == -1);
exit(1);
}
# endif
static void
sigabrt_handler_12(int sig)
{
(void) sig;
# ifdef SODIUM_LIBRARY_MINIMAL
signal(SIGABRT, sigabrt_handler_15);
# else
signal(SIGABRT, sigabrt_handler_13);
# endif
assert(crypto_pwhash_str_alg((char *) guard_page,
"", 0U, 1U, 1U, -1) == -1);
exit(1);
}
static void
sigabrt_handler_11(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_12);
assert(crypto_box_easy(guard_page, guard_page,
crypto_stream_xsalsa20_MESSAGEBYTES_MAX,
guard_page, guard_page, guard_page) == -1);
exit(1);
}
static void
sigabrt_handler_10(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_11);
assert(crypto_box_easy_afternm(guard_page, guard_page,
crypto_stream_xsalsa20_MESSAGEBYTES_MAX,
guard_page, guard_page) == -1);
exit(1);
}
static void
sigabrt_handler_9(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_10);
assert(sodium_base642bin(guard_page, 1, (const char *) guard_page, 1,
NULL, NULL, NULL, -1) == -1);
exit(1);
}
static void
sigabrt_handler_8(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_9);
assert(sodium_bin2base64((char *) guard_page, 1, guard_page, 1,
sodium_base64_VARIANT_ORIGINAL) == NULL);
exit(1);
}
static void
sigabrt_handler_7(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_8);
assert(sodium_bin2base64((char *) guard_page, 1,
guard_page, 1, -1) == NULL);
exit(1);
}
static void
sigabrt_handler_6(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_7);
assert(sodium_pad(NULL, guard_page, SIZE_MAX, 16, 1) == -1);
exit(1);
}
static void
sigabrt_handler_5(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_6);
assert(crypto_aead_xchacha20poly1305_ietf_encrypt(guard_page, NULL, NULL, UINT64_MAX,
NULL, 0, NULL,
guard_page, guard_page) == -1);
exit(1);
}
static void
sigabrt_handler_4(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_5);
assert(crypto_aead_chacha20poly1305_ietf_encrypt(guard_page, NULL, NULL, UINT64_MAX,
NULL, 0, NULL,
guard_page, guard_page) == -1);
exit(1);
}
static void
sigabrt_handler_3(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_4);
assert(crypto_aead_chacha20poly1305_encrypt(guard_page, NULL, NULL, UINT64_MAX,
NULL, 0, NULL,
guard_page, guard_page) == -1);
exit(1);
}
static void
sigabrt_handler_2(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_3);
#if SIZE_MAX > 0x4000000000ULL
randombytes_buf_deterministic(guard_page, 0x4000000001ULL, guard_page);
#else
abort();
#endif
exit(1);
}
static void
sigabrt_handler_1(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_2);
assert(crypto_kx_server_session_keys(NULL, NULL, guard_page, guard_page,
guard_page) == -1);
exit(1);
}
int
main(void)
{
signal(SIGABRT, sigabrt_handler_1);
assert(crypto_kx_client_session_keys(NULL, NULL, guard_page, guard_page,
guard_page) == -1);
return 1;
}
#else
int
main(void)
{
return 0;
}
#endif