Deleted Added
full compact
t_crypt.c (290907) t_crypt.c (291615)
1/* $NetBSD: t_crypt.c,v 1.3 2011/12/28 22:07:40 christos Exp $ */
2
3/*
4 * This version is derived from the original implementation of FreeSec
5 * (release 1.1) by David Burren. I've reviewed the changes made in
6 * OpenBSD (as of 2.7) and modified the original code in a similar way
7 * where applicable. I've also made it reentrant and made a number of
8 * other changes.

--- 110 unchanged lines hidden (view full) ---

119{
120
121 atf_tc_set_md_var(tc, "descr", "crypt(3) salt consistency checks");
122}
123
124ATF_TC_BODY(crypt_salts, tc)
125{
126 for (size_t i = 0; tests[i].hash; i++) {
1/* $NetBSD: t_crypt.c,v 1.3 2011/12/28 22:07:40 christos Exp $ */
2
3/*
4 * This version is derived from the original implementation of FreeSec
5 * (release 1.1) by David Burren. I've reviewed the changes made in
6 * OpenBSD (as of 2.7) and modified the original code in a similar way
7 * where applicable. I've also made it reentrant and made a number of
8 * other changes.

--- 110 unchanged lines hidden (view full) ---

119{
120
121 atf_tc_set_md_var(tc, "descr", "crypt(3) salt consistency checks");
122}
123
124ATF_TC_BODY(crypt_salts, tc)
125{
126 for (size_t i = 0; tests[i].hash; i++) {
127 char *hash = crypt(tests[i].pw, tests[i].hash);
127#if defined(__FreeBSD__)
128#if defined(__FreeBSD__)
128 if (22 <= i)
129 if (i >= 22 && i != 24 && i != 25)
129 atf_tc_expect_fail("Old-style/bad inputs fail on FreeBSD");
130 atf_tc_expect_fail("Old-style/bad inputs fail on FreeBSD");
131 else
132 atf_tc_expect_pass();
130#endif
133#endif
131 char *hash = crypt(tests[i].pw, tests[i].hash);
132 if (!hash) {
133 ATF_CHECK_MSG(0, "Test %zu NULL\n", i);
134 continue;
135 }
136 if (strcmp(hash, "*0") == 0 && strlen(tests[i].hash) < 13)
137 continue; /* expected failure */
138 if (strcmp(hash, tests[i].hash))
139 ATF_CHECK_MSG(0, "Test %zu %s != %s\n",
140 i, hash, tests[i].hash);
141 }
142}
143
144ATF_TP_ADD_TCS(tp)
145{
146
147 ATF_TP_ADD_TC(tp, crypt_salts);
148 return atf_no_error();
149}
134 if (!hash) {
135 ATF_CHECK_MSG(0, "Test %zu NULL\n", i);
136 continue;
137 }
138 if (strcmp(hash, "*0") == 0 && strlen(tests[i].hash) < 13)
139 continue; /* expected failure */
140 if (strcmp(hash, tests[i].hash))
141 ATF_CHECK_MSG(0, "Test %zu %s != %s\n",
142 i, hash, tests[i].hash);
143 }
144}
145
146ATF_TP_ADD_TCS(tp)
147{
148
149 ATF_TP_ADD_TC(tp, crypt_salts);
150 return atf_no_error();
151}