This commit was manufactured by cvs2svn to create branch 'SAMBA_2_2'.
[Samba/ekacnet.git] / source / tests / crypttest.c
blobc9133f40bee9650f0cd2cc041f73beba4c94cfd3
1 #if defined(HAVE_UNISTD_H)
2 #include <unistd.h>
3 #endif
5 #include <sys/types.h>
7 #ifdef HAVE_STRING_H
8 #include <string.h>
9 #endif
11 #ifdef HAVE_STRINGS_H
12 #include <strings.h>
13 #endif
15 main()
17 char passwd[9];
18 char salt[9];
19 char c_out1[256];
20 char c_out2[256];
22 char expected_out[14];
24 strcpy(expected_out, "12yJ.Of/NQ.Pk");
25 strcpy(passwd, "12345678");
26 strcpy(salt, "12345678");
28 strcpy(c_out1, crypt(passwd, salt));
29 salt[2] = '\0';
30 strcpy(c_out2, crypt(passwd, salt));
33 * If the non-trucated salt fails but the
34 * truncated salt succeeds then exit 1.
37 if((strcmp(c_out1, expected_out) != 0) &&
38 (strcmp(c_out2, expected_out) == 0))
39 exit(1);
41 #ifdef HAVE_BIGCRYPT
43 * Try the same with bigcrypt...
47 char big_passwd[17];
48 char big_salt[17];
49 char big_c_out1[256];
50 char big_c_out2[256];
51 char big_expected_out[27];
53 strcpy(big_passwd, "1234567812345678");
54 strcpy(big_salt, "1234567812345678");
55 strcpy(big_expected_out, "12yJ.Of/NQ.PklfyCuHi/rwM");
57 strcpy(big_c_out1, bigcrypt(big_passwd, big_salt));
58 big_salt[2] = '\0';
59 strcpy(big_c_out2, bigcrypt(big_passwd, big_salt));
62 * If the non-trucated salt fails but the
63 * truncated salt succeeds then exit 1.
66 if((strcmp(big_c_out1, big_expected_out) != 0) &&
67 (strcmp(big_c_out2, big_expected_out) == 0))
68 exit(1);
71 #endif
73 exit(0);