summaryrefslogtreecommitdiffstats
path: root/source3/tests
diff options
context:
space:
mode:
authorDavid O'Neill <dmo@samba.org>2001-01-12 00:10:24 +0000
committerDavid O'Neill <dmo@samba.org>2001-01-12 00:10:24 +0000
commitda08b5374eaeeec6269fff0e22cec16c1b774b61 (patch)
tree0be0f0392e7ec80a32c05fd0801c4e880180bff0 /source3/tests
parent13d99e3ea90cf15296630bea2b2bb38e9485fc4e (diff)
downloadsamba-da08b5374eaeeec6269fff0e22cec16c1b774b61.tar.gz
samba-da08b5374eaeeec6269fff0e22cec16c1b774b61.tar.xz
samba-da08b5374eaeeec6269fff0e22cec16c1b774b61.zip
Changes from APPLIANCE_HEAD:
source/tests/crypttest.c - another one missed from a while ago: Add back tests/crypttest.c so that we can check for truncated crypt on those systems that it is relevant for and we avoid setting if for those systems that it is not true for. (Originally from SAMBA_2_2, Nov 13th 2000) (This used to be commit 5358f8abc1e1dea591446e926c00821fadfe0d84)
Diffstat (limited to 'source3/tests')
-rw-r--r--source3/tests/crypttest.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c
new file mode 100644
index 00000000000..c9133f40bee
--- /dev/null
+++ b/source3/tests/crypttest.c
@@ -0,0 +1,74 @@
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
+#include <sys/types.h>
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+main()
+{
+ char passwd[9];
+ char salt[9];
+ char c_out1[256];
+ char c_out2[256];
+
+ char expected_out[14];
+
+ strcpy(expected_out, "12yJ.Of/NQ.Pk");
+ strcpy(passwd, "12345678");
+ strcpy(salt, "12345678");
+
+ strcpy(c_out1, crypt(passwd, salt));
+ salt[2] = '\0';
+ strcpy(c_out2, crypt(passwd, salt));
+
+ /*
+ * If the non-trucated salt fails but the
+ * truncated salt succeeds then exit 1.
+ */
+
+ if((strcmp(c_out1, expected_out) != 0) &&
+ (strcmp(c_out2, expected_out) == 0))
+ exit(1);
+
+#ifdef HAVE_BIGCRYPT
+ /*
+ * Try the same with bigcrypt...
+ */
+
+ {
+ char big_passwd[17];
+ char big_salt[17];
+ char big_c_out1[256];
+ char big_c_out2[256];
+ char big_expected_out[27];
+
+ strcpy(big_passwd, "1234567812345678");
+ strcpy(big_salt, "1234567812345678");
+ strcpy(big_expected_out, "12yJ.Of/NQ.PklfyCuHi/rwM");
+
+ strcpy(big_c_out1, bigcrypt(big_passwd, big_salt));
+ big_salt[2] = '\0';
+ strcpy(big_c_out2, bigcrypt(big_passwd, big_salt));
+
+ /*
+ * If the non-trucated salt fails but the
+ * truncated salt succeeds then exit 1.
+ */
+
+ if((strcmp(big_c_out1, big_expected_out) != 0) &&
+ (strcmp(big_c_out2, big_expected_out) == 0))
+ exit(1);
+
+ }
+#endif
+
+ exit(0);
+}