/* * crypto.C: Cryptographic module support. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Rights to this code are documented in doc/pod/license.pod. * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) */ static char const rcsid[] = "$Id: crypto.C,v 1.6 2007/09/16 18:54:44 pippijn Exp $"; #include "atheme.h" #include static char saltbuf[BUFSIZE]; bool crypto::handler::loaded = false; /* * crypto::handler::crypt is just like crypt(3) under UNIX * systems. Modules provide this function, otherwise * it returns the string unencrypted. */ namespace crypto { char const * handler::crypt (char const * const str, char const * const salt) { return str; } /* * crypt_verify_password is a frontend to crypt_string(). */ bool verify_password (char const * const uinput, char const * const pass) { char const * const cstr = crypter->crypt (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); sfree (ht); return saltbuf; } } // namespace crypto