diff options
author | markm <markm@FreeBSD.org> | 1995-12-16 09:14:12 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 1995-12-16 09:14:12 +0000 |
commit | 923a80ce6b1074c8d8f0075c1910d54f7057fea5 (patch) | |
tree | b8d16b3aa3b96a23535be51945d642019ef15294 /secure/lib/libcrypt/crypt-des.c | |
parent | 7a94f9e2c9cb1ff2f44c718e7699ef8a906e0133 (diff) | |
download | FreeBSD-src-923a80ce6b1074c8d8f0075c1910d54f7057fea5.zip FreeBSD-src-923a80ce6b1074c8d8f0075c1910d54f7057fea5.tar.gz |
Dual personality crypt(3). This crypt will choose its encryption algorithm
(DES or MD5) based on the type of salt used. Salt beginning with "$1$"
indicates MD5.
Diffstat (limited to 'secure/lib/libcrypt/crypt-des.c')
-rw-r--r-- | secure/lib/libcrypt/crypt-des.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/secure/lib/libcrypt/crypt-des.c b/secure/lib/libcrypt/crypt-des.c index 59f502a..31b2024 100644 --- a/secure/lib/libcrypt/crypt-des.c +++ b/secure/lib/libcrypt/crypt-des.c @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: crypt.c,v 1.5 1994/09/19 19:26:39 csgr Exp $ + * $Id$ * * This is an original implementation of the DES and the crypt(3) interfaces * by David Burren <davidb@werj.com.au>. @@ -58,10 +58,9 @@ #include <sys/types.h> #include <sys/param.h> #include <pwd.h> +#include <string.h> -#ifdef DEBUG -# include <stdio.h> -#endif +char *crypt_md5(const char *pw, const char *salt); /* We can't always assume gcc */ #ifdef __GNUC__ @@ -366,7 +365,7 @@ static int des_setkey(const char *key) { u_long k0, k1, rawkey0, rawkey1; - int shifts, i, b, round; + int shifts, round; if (!des_initialised) des_init(); @@ -413,7 +412,6 @@ des_setkey(const char *key) shifts = 0; for (round = 0; round < 16; round++) { u_long t0, t1; - int bit; shifts += key_shifts[round]; @@ -449,9 +447,9 @@ do_des( u_long l_in, u_long r_in, u_long *l_out, u_long *r_out, int count) /* * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. */ - u_long mask, rawl, rawr, l, r, *kl, *kr, *kl1, *kr1; + u_long l, r, *kl, *kr, *kl1, *kr1; u_long f, r48l, r48r; - int i, j, b, round; + int round; if (count == 0) { return(1); @@ -580,7 +578,6 @@ des_cipher(const char *in, char *out, long salt, int count) return(retval); } - char * crypt(char *key, char *setting) { @@ -589,6 +586,9 @@ crypt(char *key, char *setting) u_char *p, *q; static u_char output[21]; + if (!strncmp(setting, "$1$", 3)) + return crypt_md5(key, setting); + if (!des_initialised) des_init(); @@ -599,7 +599,7 @@ crypt(char *key, char *setting) */ q = (u_char *) keybuf; while (q - (u_char *) keybuf - 8) { - if (*q++ = *key << 1) + if ((*q++ = *key << 1)) key++; } if (des_setkey((u_char *) keybuf)) |