/* * crypto.C: Cryptographic module support. * Rights to this code are documented in doc/LICENSE. * * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) */ static char const rcsid[] = "$Id"; #include "atheme.h" static char saltbuf[BUFSIZE]; bool crypto_module_loaded = false; /* * crypt_string is just like crypt(3) under UNIX * systems. Modules provide this function, otherwise * it returns the string unencrypted. */ char *(*crypt_string) (char *str, char *salt) = &generic_crypt_string; char * generic_crypt_string (char *str, char *salt) { return str; } /* * crypt_verify_password is a frontend to crypt_string(). */ bool crypt_verify_password (char *uinput, char *pass) { char *cstr = crypt_string (uinput, pass); if (!strcmp (cstr, pass)) return true; return false; } char * gen_salt (void) { char *ht = gen_pw (6); strlcpy (saltbuf, "$1$", BUFSIZE); strlcat (saltbuf, ht, BUFSIZE); strlcat (saltbuf, "$", BUFSIZE); free (ht); return saltbuf; } /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs * vim:ts=8 * vim:sw=8 * vim:noexpandtab */