summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Esser <besser82@fedoraproject.org>2021-08-05 14:54:37 +0200
committerBjörn Esser <besser82@fedoraproject.org>2021-08-08 21:07:41 +0200
commit2a1697c889db76218686ab1f26a65a0175fac2e9 (patch)
tree189a83f30bb0fc11f1fa5691e9720746b9eb9e97
parent25e3fbcd4006d569daf830f7c50828da63fa5f31 (diff)
downloadlibxcrypt-2a1697c889db76218686ab1f26a65a0175fac2e9.tar.gz
libxcrypt-2a1697c889db76218686ab1f26a65a0175fac2e9.tar.bz2
libxcrypt-2a1697c889db76218686ab1f26a65a0175fac2e9.zip
test/checksalt.c: Add some testcases for invalid salt characters.
Add some more testcases for stricter checks of valid salt strings.
-rw-r--r--test/checksalt.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/test/checksalt.c b/test/checksalt.c
index 4297bb5..e220bb3 100644
--- a/test/checksalt.c
+++ b/test/checksalt.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018 Björn Esser <besser82@fedoraproject.org>
+/* Copyright (C) 2018-2021 Björn Esser <besser82@fedoraproject.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
@@ -110,16 +110,28 @@ static const struct testcase testcases[] =
#endif
/* All of these are invalid. */
- { "$@", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
- { "%A", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
- { "A%", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
- { "$2$", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
- { "*0", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
- { "*1", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "$@", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "%A", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "A%", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "$2$", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "*0", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "*1", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { " ", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "!!", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "**", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "::", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { ";;", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "\\\\", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "\x01\x01", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "\x19\x19", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "\x20\x20", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "\x7f\x7f", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "\xfe\xfe", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { "\xff\xff", CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
#if defined HASH_ALGORITHM_DEFAULT
- { NULL, CRYPT_SALT_INVALID, CRYPT_SALT_OK, CRYPT_SALT_OK },
+ { NULL, CRYPT_SALT_INVALID, CRYPT_SALT_OK, CRYPT_SALT_OK },
#else
- { NULL, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
+ { NULL, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID, CRYPT_SALT_INVALID },
#endif
};