1
/* Copyright (C) 2000-2003 Peter Selinger.
2
This file is part of ccrypt. It is free software and it is covered
3
by the GNU general public license. See the file COPYING for details. */
5
/* test the crypt(3) replacement against the library crypt(3). Note
6
that on many systems, crypt(3) does not exist, and even on those
7
systems where it does, it is often buggy.
9
crypt(3) only looks at the lower 7 bits of the characters in a key,
10
and only at the first 8 characters. Some implementations differ in
11
whether they consider 128 as an end-of-string character or not
12
(FreeBSD does, SunOS and GNU do not). The character 128 is unlikely
13
to appear in a password, and we only check compliance for
14
characters 1-127 here. */
16
#include <config.h> /* generated by configure */
18
#ifndef HAVE_LIBCRYPT /* this check doesn't make sense if the
19
reference crypt(3) is not available */
33
#include "../src/unixcrypt3.h"
35
#define bin_to_ascii(c) ((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.')
47
printf("Random seed: %d\n", seed);
50
/* give it a good spin */
51
for (i=0; i<64; i++) {
52
salt[0] = bin_to_ascii(i);
54
for (k=0; k<20; k++) {
56
salt[1] = bin_to_ascii(j);
60
key[n] = rand() % 127 + 1;
65
p = crypt_replacement(key, salt);
69
if (strncmp(res1, res2, 13)!=0) {
70
printf("Discrepancy for salt %c%c, password length %d\n",
78
printf("Failed: %d discrepancies.\n", total);
86
#endif /* HAVE_LIBCRYPT */