/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*/
/*
* Ported from FreeBSD to Linux, only minimal changes. --marekm
*/
/*
* Adapted from shadow-19990607 by Tudor Bosman, tudorb@jm.nu
*/
#include "lib.h"
#include "safe-memset.h"
#include "str.h"
#include "md5.h"
#include "password-scheme.h"
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
* This string is magic for
* this algorithm. Having
* it this way, we can get
* get better later on
*/
static void
{
while (--n >= 0) {
v >>= 6;
}
}
/*
* UNIX password
*
* Use MD5 for what it is best at...
*/
{
unsigned long l;
/* Refine the Salt first */
/* If it starts with the magic string, then skip that */
/* It stops at the first '$', max 8 chars */
continue;
/* get the length of the true salt */
/* The password first, since that is what is most unknown */
/* Then our magic string */
/* Then the raw salt */
/* Then just as many characters of the MD5(pw,salt,pw) */
/* Don't leave anything around in vm they could use. */
/* Then something really weird... */
for (j=0,i = pw_len; i != 0; i >>= 1)
if ((i&1) != 0)
else
/* Now make the output string */
/*
* and now, just to make sure things don't run too fast
* On a 60 Mhz Pentium this takes 34 msec, so you would
* need 30 seconds to build a 1000 entry dictionary...
*/
for(i=0;i<1000;i++) {
if((i & 1) != 0)
else
if((i % 3) != 0)
if((i % 7) != 0)
if((i & 1) != 0)
else
}
/* Don't leave anything around in vm they could use. */
}