17 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
34 px_crypt_md5(
const char *pw,
const char *salt,
char *passwd,
unsigned dstlen)
36 static char *magic =
"$1$";
40 static const char *sp,
51 if (!passwd || dstlen < 120)
58 if (strncmp(sp, magic, strlen(magic)) == 0)
62 for (ep = sp; *ep && *ep !=
'$' && ep < (sp + 8); ep++)
94 for (pl = strlen(pw); pl > 0; pl -=
MD5_SIZE)
101 for (
i = strlen(pw);
i;
i >>= 1)
108 strcpy(passwd, magic);
109 strncat(passwd, sp, sl);
119 for (
i = 0;
i < 1000;
i++)
140 p = passwd + strlen(passwd);
142 l = (
final[0] << 16) | (
final[6] << 8) |
final[12];
145 l = (
final[1] << 16) | (
final[7] << 8) |
final[13];
148 l = (
final[2] << 16) | (
final[8] << 8) |
final[14];
151 l = (
final[3] << 16) | (
final[9] << 8) |
final[15];
154 l = (
final[4] << 16) | (
final[10] << 8) |
final[5];
char * px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen)
static const char _crypt_a64[]
static void _crypt_to64(char *s, unsigned long v, int n)
void err(int eval, const char *fmt,...)
int px_find_digest(const char *name, PX_MD **res)
void px_memset(void *ptr, int c, size_t len)
#define px_md_finish(md, buf)
#define px_md_update(md, data, dlen)