30 static const char hexits[17] =
"0123456789abcdef";
33 for (i = 0; i <
len; i++) {
34 md5str[i * 2] = hexits[digest[i] >> 4];
35 md5str[(i * 2) + 1] = hexits[digest[i] & 0x0F];
37 md5str[
len * 2] =
'\0';
47 unsigned char digest[16];
74 unsigned char buf[1024];
75 unsigned char digest[16];
144#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
145#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
146#define H(x, y, z) ((x) ^ (y) ^ (z))
147#define I(x, y, z) ((y) ^ ((x) | ~(z)))
152#define STEP(f, a, b, c, d, x, t, s) \
153 (a) += f((b), (c), (d)) + (x) + (t); \
154 (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
165#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
168 (*(unaligned_uint32_t *)&ptr[(n) * 4])
174 (uint32_t)ptr[(n) * 4] | \
175 ((uint32_t)ptr[(n) * 4 + 1] << 8) | \
176 ((uint32_t)ptr[(n) * 4 + 2] << 16) | \
177 ((uint32_t)ptr[(n) * 4 + 3] << 24))
188 const unsigned char *
ptr;
190 uint32_t saved_a, saved_b, saved_c, saved_d;
206 STEP(
F,
a, b, c, d,
SET(0), 0xd76aa478, 7)
207 STEP(
F, d,
a, b, c,
SET(1), 0xe8c7b756, 12)
208 STEP(
F, c, d,
a, b,
SET(2), 0x242070db, 17)
209 STEP(
F, b, c, d,
a,
SET(3), 0xc1bdceee, 22)
210 STEP(
F,
a, b, c, d,
SET(4), 0xf57c0faf, 7)
211 STEP(
F, d,
a, b, c,
SET(5), 0x4787c62a, 12)
212 STEP(
F, c, d,
a, b,
SET(6), 0xa8304613, 17)
213 STEP(
F, b, c, d,
a,
SET(7), 0xfd469501, 22)
214 STEP(
F,
a, b, c, d,
SET(8), 0x698098d8, 7)
215 STEP(
F, d,
a, b, c,
SET(9), 0x8b44f7af, 12)
216 STEP(
F, c, d,
a, b,
SET(10), 0xffff5bb1, 17)
217 STEP(
F, b, c, d,
a,
SET(11), 0x895cd7be, 22)
218 STEP(
F,
a, b, c, d,
SET(12), 0x6b901122, 7)
219 STEP(
F, d,
a, b, c,
SET(13), 0xfd987193, 12)
220 STEP(
F, c, d,
a, b,
SET(14), 0xa679438e, 17)
221 STEP(
F, b, c, d,
a,
SET(15), 0x49b40821, 22)
224 STEP(
G,
a, b, c, d,
GET(1), 0xf61e2562, 5)
225 STEP(
G, d,
a, b, c,
GET(6), 0xc040b340, 9)
226 STEP(
G, c, d,
a, b,
GET(11), 0x265e5a51, 14)
227 STEP(
G, b, c, d,
a,
GET(0), 0xe9b6c7aa, 20)
228 STEP(
G,
a, b, c, d,
GET(5), 0xd62f105d, 5)
229 STEP(
G, d,
a, b, c,
GET(10), 0x02441453, 9)
230 STEP(
G, c, d,
a, b,
GET(15), 0xd8a1e681, 14)
231 STEP(
G, b, c, d,
a,
GET(4), 0xe7d3fbc8, 20)
232 STEP(
G,
a, b, c, d,
GET(9), 0x21e1cde6, 5)
233 STEP(
G, d,
a, b, c,
GET(14), 0xc33707d6, 9)
234 STEP(
G, c, d,
a, b,
GET(3), 0xf4d50d87, 14)
235 STEP(
G, b, c, d,
a,
GET(8), 0x455a14ed, 20)
236 STEP(
G,
a, b, c, d,
GET(13), 0xa9e3e905, 5)
237 STEP(
G, d,
a, b, c,
GET(2), 0xfcefa3f8, 9)
238 STEP(
G, c, d,
a, b,
GET(7), 0x676f02d9, 14)
239 STEP(
G, b, c, d,
a,
GET(12), 0x8d2a4c8a, 20)
242 STEP(
H,
a, b, c, d,
GET(5), 0xfffa3942, 4)
243 STEP(
H, d,
a, b, c,
GET(8), 0x8771f681, 11)
244 STEP(
H, c, d,
a, b,
GET(11), 0x6d9d6122, 16)
245 STEP(
H, b, c, d,
a,
GET(14), 0xfde5380c, 23)
246 STEP(
H,
a, b, c, d,
GET(1), 0xa4beea44, 4)
247 STEP(
H, d,
a, b, c,
GET(4), 0x4bdecfa9, 11)
248 STEP(
H, c, d,
a, b,
GET(7), 0xf6bb4b60, 16)
249 STEP(
H, b, c, d,
a,
GET(10), 0xbebfbc70, 23)
250 STEP(
H,
a, b, c, d,
GET(13), 0x289b7ec6, 4)
251 STEP(
H, d,
a, b, c,
GET(0), 0xeaa127fa, 11)
252 STEP(
H, c, d,
a, b,
GET(3), 0xd4ef3085, 16)
253 STEP(
H, b, c, d,
a,
GET(6), 0x04881d05, 23)
254 STEP(
H,
a, b, c, d,
GET(9), 0xd9d4d039, 4)
255 STEP(
H, d,
a, b, c,
GET(12), 0xe6db99e5, 11)
256 STEP(
H, c, d,
a, b,
GET(15), 0x1fa27cf8, 16)
257 STEP(
H, b, c, d,
a,
GET(2), 0xc4ac5665, 23)
260 STEP(
I,
a, b, c, d,
GET(0), 0xf4292244, 6)
261 STEP(
I, d,
a, b, c,
GET(7), 0x432aff97, 10)
262 STEP(
I, c, d,
a, b,
GET(14), 0xab9423a7, 15)
263 STEP(
I, b, c, d,
a,
GET(5), 0xfc93a039, 21)
264 STEP(
I,
a, b, c, d,
GET(12), 0x655b59c3, 6)
265 STEP(
I, d,
a, b, c,
GET(3), 0x8f0ccc92, 10)
266 STEP(
I, c, d,
a, b,
GET(10), 0xffeff47d, 15)
267 STEP(
I, b, c, d,
a,
GET(1), 0x85845dd1, 21)
268 STEP(
I,
a, b, c, d,
GET(8), 0x6fa87e4f, 6)
269 STEP(
I, d,
a, b, c,
GET(15), 0xfe2ce6e0, 10)
270 STEP(
I, c, d,
a, b,
GET(6), 0xa3014314, 15)
271 STEP(
I, b, c, d,
a,
GET(13), 0x4e0811a1, 21)
272 STEP(
I,
a, b, c, d,
GET(4), 0xf7537e82, 6)
273 STEP(
I, d,
a, b, c,
GET(11), 0xbd3af235, 10)
274 STEP(
I, c, d,
a, b,
GET(2), 0x2ad7d2bb, 15)
275 STEP(
I, b, c, d,
a,
GET(9), 0xeb86d391, 21)
283 }
while (
size -= 64);
310 if ((ctx->
lo = (saved_lo +
size) & 0x1fffffff) < saved_lo) {
315 used = saved_lo & 0x3f;
326 data = (
unsigned char *)
data + free;
343 used = ctx->
lo & 0x3f;
345 ctx->
buffer[used++] = 0x80;
md5(string $string, bool $binary=false)
md5_file(string $filename, bool $binary=false)
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
PHPAPI void make_digest(char *md5str, const unsigned char *digest)
PHPAPI void make_digest_ex(char *md5str, const unsigned char *digest, int len)
PHPAPI void PHP_MD5InitArgs(PHP_MD5_CTX *ctx, ZEND_ATTRIBUTE_UNUSED HashTable *args)
#define STEP(f, a, b, c, d, x, t, s)
PHPAPI void PHP_MD5Final(unsigned char *result, PHP_MD5_CTX *ctx)
PHPAPI void PHP_MD5Update(PHP_MD5_CTX *ctx, const void *data, size_t size)
struct _php_stream php_stream
#define php_stream_read(stream, buf, count)
#define php_stream_eof(stream)
#define php_stream_close(stream)
#define php_stream_open_wrapper(path, mode, options, opened)
#define RETURN_STRINGL(s, l)
#define ZEND_PARSE_PARAMETERS_END()
#define RETVAL_NEW_STR(s)
#define Z_PARAM_STR(dest)
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
#define Z_PARAM_BOOL(dest)
#define Z_PARAM_PATH(dest, dest_len)
struct _zend_string zend_string
#define ZEND_ATTRIBUTE_UNUSED
#define ZEND_SECURE_ZERO(var, size)
#define ZEND_SET_ALIGNED(alignment, decl)
#define Z_STRVAL_P(zval_p)
struct _zend_array HashTable