Add D.U.M.A., the Electric Fence successor.
1 --- glibc-2.1.3/md5-crypt/md5-crypt.c 2000/03/04 00:47:30 1.1
2 +++ glibc-2.1.3/md5-crypt/md5-crypt.c 2000/08/24 06:10:02 1.8
4 /* One way encryption based on MD5 sum.
5 - Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
6 + Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
7 This file is part of the GNU C Library.
8 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
11 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
12 Boston, MA 02111-1307, USA. */
21 /* Prototypes for local functions. */
22 -extern char *__md5_crypt_r __P ((const char *key, const char *salt,
23 - char *buffer, int buflen));
24 -extern char *__md5_crypt __P ((const char *key, const char *salt));
25 +extern char *__md5_crypt_r (const char *key, const char *salt,
26 + char *buffer, int buflen);
27 +extern char *__md5_crypt (const char *key, const char *salt);
30 /* This entry point is equivalent to the `crypt' function in Unix
35 - unsigned char alt_result[16];
36 + unsigned char alt_result[16]
37 + __attribute__ ((__aligned__ (__alignof__ (md5_uint32))));
39 struct md5_ctx alt_ctx;
44 + char *copied_key = NULL;
45 + char *copied_salt = NULL;
47 /* Find beginning of salt string. The prefix should normally always
48 be present. Just in case it is not. */
50 salt_len = MIN (strcspn (salt, "$"), 8);
51 key_len = strlen (key);
53 + if ((key - (char *) 0) % __alignof__ (md5_uint32) != 0)
55 + char *tmp = (char *) alloca (key_len + __alignof__ (md5_uint32));
57 + memcpy (tmp + __alignof__ (md5_uint32)
58 + - (tmp - (char *) 0) % __alignof__ (md5_uint32),
60 + assert ((key - (char *) 0) % __alignof__ (md5_uint32) == 0);
63 + if ((salt - (char *) 0) % __alignof__ (md5_uint32) != 0)
65 + char *tmp = (char *) alloca (salt_len + __alignof__ (md5_uint32));
66 + salt = copied_salt =
67 + memcpy (tmp + __alignof__ (md5_uint32)
68 + - (tmp - (char *) 0) % __alignof__ (md5_uint32),
70 + assert ((salt - (char *) 0) % __alignof__ (md5_uint32) == 0);
73 /* Prepare for the real work. */
74 __md5_init_ctx (&ctx);
78 /* Clear the buffer for the intermediate result so that people
79 attaching to processes or reading core dumps cannot get any
81 - memset (alt_result, '\0', sizeof (alt_result));
82 + information. We do it in this way to clear correct_words[]
83 + inside the MD5 implementation as well. */
84 + __md5_init_ctx (&ctx);
85 + __md5_finish_ctx (&ctx, alt_result);
86 + memset (&ctx, '\0', sizeof (ctx));
87 + memset (&alt_ctx, '\0', sizeof (alt_ctx));
88 + if (copied_key != NULL)
89 + memset (copied_key, '\0', key_len);
90 + if (copied_salt != NULL)
91 + memset (copied_salt, '\0', salt_len);
100 __md5_crypt (const char *key, const char *salt)
102 /* We don't want to have an arbitrary limit in the size of the
103 password. We can compute the size of the result in advance and
104 so we can prepare the buffer we pass to `md5_crypt_r'. */
105 - static char *buffer = NULL;
106 - static int buflen = 0;
108 int needed = 3 + strlen (salt) + 1 + 26 + 1;
114 return __md5_crypt_r (key, salt, buffer, buflen);
119 +__attribute__ ((__destructor__))
124 --- glibc-2.1.3/md5-crypt/md5.c 2000/03/04 00:47:30 1.1
125 +++ glibc-2.1.3/md5-crypt/md5.c 2000/07/04 18:22:44 1.2
127 -/* md5.c - Functions to compute MD5 message digest of files or memory blocks
128 +/* Functions to compute MD5 message digest of files or memory blocks.
129 according to the definition of MD5 in RFC 1321 from April 1992.
130 - Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
131 + Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
132 This file is part of the GNU C Library.
134 The GNU C Library is free software; you can redistribute it and/or
139 + //const void aligned_buffer = buffer;
141 /* When we already have some bits in our internal buffer concatenate
142 both inputs first. */
143 if (ctx->buflen != 0)
144 @@ -224,16 +226,20 @@
145 size_t left_over = ctx->buflen;
146 size_t add = 128 - left_over > len ? len : 128 - left_over;
148 + /* Only put full words in the buffer. */
149 + add -= add % __alignof__ (md5_uint32);
151 memcpy (&ctx->buffer[left_over], buffer, add);
154 - if (left_over + add > 64)
155 + if (ctx->buflen > 64)
157 - md5_process_block (ctx->buffer, (left_over + add) & ~63, ctx);
158 + md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
161 /* The regions in the following copy operation cannot overlap. */
162 memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
163 - (left_over + add) & 63);
164 - ctx->buflen = (left_over + add) & 63;
168 buffer = (const char *) buffer + add;
170 /* Move remaining bytes in internal buffer. */
173 - memcpy (ctx->buffer, buffer, len);
175 + size_t left_over = ctx->buflen;
177 + memcpy (&ctx->buffer[left_over], buffer, len);
179 + if (left_over >= 64)
181 + md5_process_block (ctx->buffer, 64, ctx);
183 + memcpy (ctx->buffer, &ctx->buffer[64], left_over);
185 + ctx->buflen = left_over;
189 --- glibc-2.1.3/md5-crypt/md5.h 2000/03/04 00:47:30 1.1
190 +++ glibc-2.1.3/md5-crypt/md5.h 2000/07/04 18:22:44 1.2
192 /* Declaration of functions and data types used for MD5 sum computing
194 - Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
195 + Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
196 This file is part of the GNU C Library.
198 The GNU C Library is free software; you can redistribute it and/or
204 + char buffer[128] __attribute__ ((__aligned__ (__alignof__ (md5_uint32))));