/* Copyright (C) 2000-2004 Peter Selinger. This file is part of ccrypt. It is free software and it is covered by the GNU general public license. See the file COPYING for details. */ /* test the crypt(3) replacement against the library crypt(3). Note that on many systems, crypt(3) does not exist, and even on those systems where it does, it is often buggy. crypt(3) only looks at the lower 7 bits of the characters in a key, and only at the first 8 characters. Some implementations differ in whether they consider 128 as an end-of-string character or not (FreeBSD does, SunOS and GNU do not). The character 128 is unlikely to appear in a password, and we only check compliance for characters 1-127 here. */ #ifdef HAVE_CONFIG_H #include /* generated by configure */ #endif #ifndef HAVE_LIBCRYPT /* this check doesn't make sense if the reference crypt(3) is not available */ int main() { return 77; } #else #define _XOPEN_SOURCE #include #include #include #include #include #include "../src/unixcrypt3.h" #define bin_to_ascii(c) ((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.') int main() { int seed = time(0); int total = 0; int i,j,l,n,k; char salt[2]; char key[8]; char res1[13]; char res2[13]; char *p; printf("Random seed: %d\n", seed); srand(seed); /* give it a good spin */ for (i=0; i<64; i++) { salt[0] = bin_to_ascii(i); for (k=0; k<20; k++) { j = rand() % 64; salt[1] = bin_to_ascii(j); l = rand() % 9; for (n=0; n