2 * This function is a front-end for the message digest algorithms used
3 * to compute the user's encrypted passwords. No reversible encryption
4 * is used here and I intend to keep it that way.
6 * While there are many sources of encryption outside the United
7 * States, it *may* be illegal to re-export reversible encryption
8 * computer code. Until such time as it is legal to export encryption
9 * software freely from the US, please do not send me any. (AGM)
12 /* this should have been defined in a header file.. Why wasn't it? AGM */
13 extern char *crypt(const char *key, const char *salt);
16 #include "bigcrypt.-c"
21 char * (* mdfn)(const char *key, const char *salt);
24 /* array of non-standard digest algorithms available */
27 const static struct cfns cfn_list[N_MDS] = {
28 { "$1$", 3, Goodcrypt_md5 },
31 static char *_pam_md(const char *key, const char *salt)
36 D(("called with key='%s', salt='%s'", key, salt));
38 /* check for non-standard salts */
40 for (i=0; i<N_MDS; ++i) {
41 if ( !strncmp(cfn_list[i].salt, salt, cfn_list[i].len) ) {
42 e = cfn_list[i].mdfn(key, salt);
48 e = bigcrypt(key, salt); /* (defaults to standard algorithm) */
51 x = x_strdup(e); /* put e in malloc()ed memory */
52 _pam_overwrite(e); /* clean up */
53 return x; /* this must be deleted elsewhere */
56 #ifndef PWDB_NO_MD_COMPAT
57 static char *_pam_md_compat(const char *key, const char *salt)
61 D(("called with key='%s', salt='%s'", key, salt));
63 if ( !strncmp("$1$", salt, 3) ) {
64 e = Brokencrypt_md5(key, salt);
65 x = x_strdup(e); /* put e in malloc()ed memory */
66 _pam_overwrite(e); /* clean up */
71 return x; /* this must be deleted elsewhere */
73 #endif /* PWDB_NO_MD_COMPAT */