Deleted Added
full compact
crypt-md5.c (91754) crypt-md5.c (91795)
1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
8 */
9
10#include <sys/cdefs.h>
1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
8 */
9
10#include <sys/cdefs.h>
11__FBSDID("$FreeBSD: head/lib/libcrypt/crypt-md5.c 91754 2002-03-06 17:18:09Z markm $");
11__FBSDID("$FreeBSD: head/lib/libcrypt/crypt-md5.c 91795 2002-03-07 10:41:11Z markm $");
12
13#include <unistd.h>
14#include <stdio.h>
15#include <string.h>
16#include <md5.h>
17#include <err.h>
18#include "crypt.h"
19
20/*
21 * UNIX password
22 */
23
24char *
25crypt_md5(const char *pw, const char *salt)
26{
27 MD5_CTX ctx,ctx1;
28 unsigned long l;
12
13#include <unistd.h>
14#include <stdio.h>
15#include <string.h>
16#include <md5.h>
17#include <err.h>
18#include "crypt.h"
19
20/*
21 * UNIX password
22 */
23
24char *
25crypt_md5(const char *pw, const char *salt)
26{
27 MD5_CTX ctx,ctx1;
28 unsigned long l;
29 int sl;
30 u_int pl, i;
29 int sl, pl;
30 u_int i;
31 u_char final[MD5_SIZE];
32 static const char *sp, *ep;
33 static char passwd[120], *p;
34 static const char *magic = "$1$"; /*
35 * This string is magic for
36 * this algorithm. Having
37 * it this way, we can get
38 * get better later on

--- 25 unchanged lines hidden (view full) ---

64 MD5Update(&ctx, (const u_char *)sp, (u_int)sl);
65
66 /* Then just as many characters of the MD5(pw,salt,pw) */
67 MD5Init(&ctx1);
68 MD5Update(&ctx1, (const u_char *)pw, strlen(pw));
69 MD5Update(&ctx1, (const u_char *)sp, (u_int)sl);
70 MD5Update(&ctx1, (const u_char *)pw, strlen(pw));
71 MD5Final(final, &ctx1);
31 u_char final[MD5_SIZE];
32 static const char *sp, *ep;
33 static char passwd[120], *p;
34 static const char *magic = "$1$"; /*
35 * This string is magic for
36 * this algorithm. Having
37 * it this way, we can get
38 * get better later on

--- 25 unchanged lines hidden (view full) ---

64 MD5Update(&ctx, (const u_char *)sp, (u_int)sl);
65
66 /* Then just as many characters of the MD5(pw,salt,pw) */
67 MD5Init(&ctx1);
68 MD5Update(&ctx1, (const u_char *)pw, strlen(pw));
69 MD5Update(&ctx1, (const u_char *)sp, (u_int)sl);
70 MD5Update(&ctx1, (const u_char *)pw, strlen(pw));
71 MD5Final(final, &ctx1);
72 for(pl = strlen(pw); pl > 0; pl -= MD5_SIZE)
72 for(pl = (int)strlen(pw); pl > 0; pl -= MD5_SIZE)
73 MD5Update(&ctx, (const u_char *)final,
73 MD5Update(&ctx, (const u_char *)final,
74 pl > MD5_SIZE ? MD5_SIZE : pl);
74 (u_int)(pl > MD5_SIZE ? MD5_SIZE : pl));
75
76 /* Don't leave anything around in vm they could use. */
77 memset(final, 0, sizeof(final));
78
79 /* Then something really weird... */
80 for (i = strlen(pw); i; i >>= 1)
81 if(i & 1)
82 MD5Update(&ctx, (const u_char *)final, 1);

--- 57 unchanged lines hidden ---
75
76 /* Don't leave anything around in vm they could use. */
77 memset(final, 0, sizeof(final));
78
79 /* Then something really weird... */
80 for (i = strlen(pw); i; i >>= 1)
81 if(i & 1)
82 MD5Update(&ctx, (const u_char *)final, 1);

--- 57 unchanged lines hidden ---