2 * Copyright © 2000 Keith Packard
3 * Copyright © 2005 Patrick Lam
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of Keith Packard not be used in
10 * advertising or publicity pertaining to distribution of the software without
11 * specific, written prior permission. Keith Packard makes no
12 * representations about the suitability of this software for any purpose. It
13 * is provided "as is" without express or implied warranty.
15 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21 * PERFORMANCE OF THIS SOFTWARE.
25 #include "../fc-arch/fcarch.h"
30 #include <sys/types.h>
32 #if defined(HAVE_MMAP) || defined(__CYGWIN__)
34 # include <sys/mman.h>
49 static void MD5Init(struct MD5Context *ctx);
50 static void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len);
51 static void MD5Final(unsigned char digest[16], struct MD5Context *ctx);
52 static void MD5Transform(FcChar32 buf[4], FcChar32 in[16]);
54 #define CACHEBASE_LEN (1 + 32 + 1 + sizeof (FC_ARCHITECTURE) + sizeof (FC_CACHE_SUFFIX))
56 static const char bin2hex[] = { '0', '1', '2', '3',
62 FcDirCacheBasename (const FcChar8 * dir, FcChar8 cache_base[CACHEBASE_LEN])
64 unsigned char hash[16];
67 struct MD5Context ctx;
70 MD5Update (&ctx, (unsigned char *)dir, strlen ((char *) dir));
72 MD5Final (hash, &ctx);
75 hex_hash = cache_base + 1;
76 for (cnt = 0; cnt < 16; ++cnt)
78 hex_hash[2*cnt ] = bin2hex[hash[cnt] >> 4];
79 hex_hash[2*cnt+1] = bin2hex[hash[cnt] & 0xf];
82 strcat ((char *) cache_base, "-" FC_ARCHITECTURE FC_CACHE_SUFFIX);
88 FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config)
90 FcChar8 *cache_hashed = NULL;
91 FcChar8 cache_base[CACHEBASE_LEN];
95 FcDirCacheBasename (dir, cache_base);
97 list = FcStrListCreate (config->cacheDirs);
101 while ((cache_dir = FcStrListNext (list)))
103 cache_hashed = FcStrPlus (cache_dir, cache_base);
106 (void) unlink ((char *) cache_hashed);
108 FcStrListDone (list);
109 /* return FcFalse if something went wrong */
116 FcDirCacheOpenFile (const FcChar8 *cache_file, struct stat *file_stat)
120 fd = open((char *) cache_file, O_RDONLY | O_BINARY);
123 if (fstat (fd, file_stat) < 0)
132 * Look for a cache file for the specified dir. Attempt
133 * to use each one we find, stopping when the callback
137 FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
138 FcBool (*callback) (int fd, struct stat *stat, void *closure),
139 void *closure, FcChar8 **cache_file_ret)
142 FcChar8 cache_base[CACHEBASE_LEN];
145 struct stat file_stat, dir_stat;
146 FcBool ret = FcFalse;
148 if (stat ((char *) dir, &dir_stat) < 0)
151 FcDirCacheBasename (dir, cache_base);
153 list = FcStrListCreate (config->cacheDirs);
157 while ((cache_dir = FcStrListNext (list)))
159 FcChar8 *cache_hashed = FcStrPlus (cache_dir, cache_base);
162 fd = FcDirCacheOpenFile (cache_hashed, &file_stat);
164 if (dir_stat.st_mtime <= file_stat.st_mtime)
166 ret = (*callback) (fd, &file_stat, closure);
170 *cache_file_ret = cache_hashed;
172 FcStrFree (cache_hashed);
179 FcStrFree (cache_hashed);
181 FcStrListDone (list);
186 #define FC_CACHE_MIN_MMAP 1024
189 * Skip list element, make sure the 'next' pointer is the last thing
190 * in the structure, it will be allocated large enough to hold all
191 * of the necessary pointers
194 typedef struct _FcCacheSkip FcCacheSkip;
196 struct _FcCacheSkip {
203 FcCacheSkip *next[1];
207 * The head of the skip list; pointers for every possible level
208 * in the skip list, plus the largest level in the list
211 #define FC_CACHE_MAX_LEVEL 16
213 static FcCacheSkip *fcCacheChains[FC_CACHE_MAX_LEVEL];
214 static int fcCacheMaxLevel;
217 * Generate a random level number, distributed
218 * so that each level is 1/4 as likely as the one before
220 * Note that level numbers run 1 <= level <= MAX_LEVEL
225 /* tricky bit -- each bit is '1' 75% of the time */
226 long int bits = random () | random ();
229 while (++level < FC_CACHE_MAX_LEVEL)
239 * Insert cache into the list
242 FcCacheInsert (FcCache *cache, struct stat *cache_stat)
244 FcCacheSkip **update[FC_CACHE_MAX_LEVEL];
245 FcCacheSkip *s, **next;
249 * Find links along each chain
251 next = fcCacheChains;
252 for (i = fcCacheMaxLevel; --i >= 0; )
254 for (; (s = next[i]); next = s->next)
255 if (s->cache > cache)
257 update[i] = &next[i];
261 * Create new list element
263 level = random_level ();
264 if (level > fcCacheMaxLevel)
266 level = fcCacheMaxLevel + 1;
267 update[fcCacheMaxLevel] = &fcCacheChains[fcCacheMaxLevel];
268 fcCacheMaxLevel = level;
271 s = malloc (sizeof (FcCacheSkip) + (level - 1) * sizeof (FcCacheSkip *));
276 s->size = cache->size;
278 s->cache_dev = cache_stat->st_dev;
279 s->cache_ino = cache_stat->st_ino;
280 s->cache_mtime = cache_stat->st_mtime;
283 * Insert into all fcCacheChains
285 for (i = 0; i < level; i++)
287 s->next[i] = *update[i];
294 FcCacheFindByAddr (void *object)
297 FcCacheSkip **next = fcCacheChains;
301 * Walk chain pointers one level at a time
303 for (i = fcCacheMaxLevel; --i >= 0;)
304 while (next[i] && (char *) object >= ((char *) next[i]->cache + next[i]->size))
305 next = next[i]->next;
310 if (s && (char *) object < ((char *) s->cache + s->size))
316 FcCacheRemove (FcCache *cache)
318 FcCacheSkip **update[FC_CACHE_MAX_LEVEL];
319 FcCacheSkip *s, **next;
323 * Find links along each chain
325 next = fcCacheChains;
326 for (i = fcCacheMaxLevel; --i >= 0; )
328 for (; (s = next[i]); next = s->next)
329 if (s->cache >= cache)
331 update[i] = &next[i];
334 for (i = 0; i < fcCacheMaxLevel && *update[i] == s; i++)
335 *update[i] = s->next[i];
336 while (fcCacheMaxLevel > 0 && fcCacheChains[fcCacheMaxLevel - 1] == NULL)
342 FcCacheFindByStat (struct stat *cache_stat)
346 for (s = fcCacheChains[0]; s; s = s->next[0])
347 if (s->cache_dev == cache_stat->st_dev &&
348 s->cache_ino == cache_stat->st_ino &&
349 s->cache_mtime == cache_stat->st_mtime)
358 FcDirCacheDispose (FcCache *cache)
360 switch (cache->magic) {
361 case FC_CACHE_MAGIC_ALLOC:
364 case FC_CACHE_MAGIC_MMAP:
365 #if defined(HAVE_MMAP) || defined(__CYGWIN__)
366 munmap (cache, cache->size);
367 #elif defined(_WIN32)
368 UnmapViewOfFile (cache);
372 FcCacheRemove (cache);
376 FcCacheObjectReference (void *object)
378 FcCacheSkip *skip = FcCacheFindByAddr (object);
385 FcCacheObjectDereference (void *object)
387 FcCacheSkip *skip = FcCacheFindByAddr (object);
393 FcDirCacheDispose (skip->cache);
402 for (i = 0; i < FC_CACHE_MAX_LEVEL; i++)
403 assert (fcCacheChains[i] == NULL);
404 assert (fcCacheMaxLevel == 0);
408 * Map a cache file into memory
411 FcDirCacheMapFd (int fd, struct stat *fd_stat)
414 FcBool allocated = FcFalse;
416 if (fd_stat->st_size < sizeof (FcCache))
418 cache = FcCacheFindByStat (fd_stat);
422 * For small cache files, just read them into memory
424 if (fd_stat->st_size >= FC_CACHE_MIN_MMAP)
426 #if defined(HAVE_MMAP) || defined(__CYGWIN__)
427 cache = mmap (0, fd_stat->st_size, PROT_READ, MAP_SHARED, fd, 0);
428 #elif defined(_WIN32)
433 hFileMap = CreateFileMapping((HANDLE) _get_osfhandle(fd), NULL,
434 PAGE_READONLY, 0, 0, NULL);
435 if (hFileMap != NULL)
437 cache = MapViewOfFile (hFileMap, FILE_MAP_READ, 0, 0, size);
438 CloseHandle (hFileMap);
445 cache = malloc (fd_stat->st_size);
449 if (read (fd, cache, fd_stat->st_size) != fd_stat->st_size)
456 if (cache->magic != FC_CACHE_MAGIC_MMAP ||
457 cache->version < FC_CACHE_CONTENT_VERSION ||
458 cache->size != fd_stat->st_size ||
459 !FcCacheInsert (cache, fd_stat))
465 #if defined(HAVE_MMAP) || defined(__CYGWIN__)
466 munmap (cache, fd_stat->st_size);
467 #elif defined(_WIN32)
468 UnmapViewOfFile (cache);
474 /* Mark allocated caches so they're freed rather than unmapped */
476 cache->magic = FC_CACHE_MAGIC_ALLOC;
482 FcDirCacheReference (FcCache *cache, int nref)
484 FcCacheSkip *skip = FcCacheFindByAddr (cache);
491 FcDirCacheUnload (FcCache *cache)
493 FcCacheObjectDereference (cache);
497 FcDirCacheMapHelper (int fd, struct stat *fd_stat, void *closure)
499 FcCache *cache = FcDirCacheMapFd (fd, fd_stat);
503 *((FcCache **) closure) = cache;
508 FcDirCacheLoad (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file)
510 FcCache *cache = NULL;
512 if (!FcDirCacheProcess (config, dir,
520 FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat)
525 fd = FcDirCacheOpenFile (cache_file, file_stat);
528 cache = FcDirCacheMapFd (fd, file_stat);
534 * Validate a cache file by reading the header and checking
535 * the magic number and the size field
538 FcDirCacheValidateHelper (int fd, struct stat *fd_stat, void *closure)
543 if (read (fd, &c, sizeof (FcCache)) != sizeof (FcCache))
545 else if (c.magic != FC_CACHE_MAGIC_MMAP)
547 else if (c.version < FC_CACHE_CONTENT_VERSION)
549 else if (fd_stat->st_size != c.size)
555 FcDirCacheValidConfig (const FcChar8 *dir, FcConfig *config)
557 return FcDirCacheProcess (config, dir,
558 FcDirCacheValidateHelper,
563 FcDirCacheValid (const FcChar8 *dir)
567 config = FcConfigGetCurrent ();
571 return FcDirCacheValidConfig (dir, config);
575 * Build a cache structure from the given contents
578 FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, FcStrSet *dirs)
580 FcSerialize *serialize = FcSerializeCreate ();
583 intptr_t cache_offset;
584 intptr_t dirs_offset;
585 FcChar8 *dir_serialize;
586 intptr_t *dirs_serialize;
587 FcFontSet *set_serialize;
592 * Space for cache structure
594 cache_offset = FcSerializeReserve (serialize, sizeof (FcCache));
598 if (!FcStrSerializeAlloc (serialize, dir))
603 dirs_offset = FcSerializeAlloc (serialize, dirs, dirs->num * sizeof (FcChar8 *));
604 for (i = 0; i < dirs->num; i++)
605 if (!FcStrSerializeAlloc (serialize, dirs->strs[i]))
611 if (!FcFontSetSerializeAlloc (serialize, set))
614 /* Serialize layout complete. Now allocate space and fill it */
615 cache = malloc (serialize->size);
618 /* shut up valgrind */
619 memset (cache, 0, serialize->size);
621 serialize->linear = cache;
623 cache->magic = FC_CACHE_MAGIC_ALLOC;
624 cache->version = FC_CACHE_CONTENT_VERSION;
625 cache->size = serialize->size;
628 * Serialize directory name
630 dir_serialize = FcStrSerialize (serialize, dir);
633 cache->dir = FcPtrToOffset (cache, dir_serialize);
638 dirs_serialize = FcSerializePtr (serialize, dirs);
641 cache->dirs = FcPtrToOffset (cache, dirs_serialize);
642 cache->dirs_count = dirs->num;
643 for (i = 0; i < dirs->num; i++)
645 FcChar8 *d_serialize = FcStrSerialize (serialize, dirs->strs[i]);
648 dirs_serialize[i] = FcPtrToOffset (dirs_serialize, d_serialize);
654 set_serialize = FcFontSetSerialize (serialize, set);
657 cache->set = FcPtrToOffset (cache, set_serialize);
659 FcSerializeDestroy (serialize);
666 FcSerializeDestroy (serialize);
671 FcMakeDirectory (const FcChar8 *dir)
676 if (strlen ((char *) dir) == 0)
679 parent = FcStrDirname (dir);
682 if (access ((char *) parent, W_OK|X_OK) == 0)
683 ret = mkdir ((char *) dir, 0777) == 0;
684 else if (access ((char *) parent, F_OK) == -1)
685 ret = FcMakeDirectory (parent) && (mkdir ((char *) dir, 0777) == 0);
692 /* write serialized state to the cache file */
694 FcDirCacheWrite (FcCache *cache, FcConfig *config)
696 FcChar8 *dir = FcCacheDir (cache);
697 FcChar8 cache_base[CACHEBASE_LEN];
698 FcChar8 *cache_hashed;
702 FcChar8 *cache_dir = NULL;
708 * Write it to the first directory in the list which is writable
711 list = FcStrListCreate (config->cacheDirs);
714 while ((test_dir = FcStrListNext (list))) {
715 if (access ((char *) test_dir, W_OK|X_OK) == 0)
717 cache_dir = test_dir;
723 * If the directory doesn't exist, try to create it
725 if (access ((char *) test_dir, F_OK) == -1) {
726 if (FcMakeDirectory (test_dir))
728 cache_dir = test_dir;
734 FcStrListDone (list);
738 FcDirCacheBasename (dir, cache_base);
739 cache_hashed = FcStrPlus (cache_dir, cache_base);
743 if (FcDebug () & FC_DBG_CACHE)
744 printf ("FcDirCacheWriteDir dir \"%s\" file \"%s\"\n",
747 atomic = FcAtomicCreate ((FcChar8 *)cache_hashed);
751 if (!FcAtomicLock (atomic))
754 fd = open((char *)FcAtomicNewFile (atomic), O_RDWR | O_CREAT | O_BINARY, 0666);
758 /* Temporarily switch magic to MMAP while writing to file */
759 magic = cache->magic;
760 if (magic != FC_CACHE_MAGIC_MMAP)
761 cache->magic = FC_CACHE_MAGIC_MMAP;
764 * Write cache contents to file
766 written = write (fd, cache, cache->size);
768 /* Switch magic back */
769 if (magic != FC_CACHE_MAGIC_MMAP)
770 cache->magic = magic;
772 if (written != cache->size)
774 perror ("write cache");
779 if (!FcAtomicReplaceOrig(atomic))
781 FcStrFree (cache_hashed);
782 FcAtomicUnlock (atomic);
783 FcAtomicDestroy (atomic);
789 FcAtomicUnlock (atomic);
791 FcAtomicDestroy (atomic);
793 FcStrFree (cache_hashed);
798 * Hokey little macro trick to permit the definitions of C functions
799 * with the same name as CPP macros
801 #define args(x...) (x)
804 FcCacheDir args(const FcCache *c)
806 return FcCacheDir (c);
810 FcCacheCopySet args(const FcCache *c)
812 FcFontSet *old = FcCacheSet (c);
813 FcFontSet *new = FcFontSetCreate ();
818 for (i = 0; i < old->nfont; i++)
820 FcPattern *font = FcFontSetFont (old, i);
822 FcPatternReference (font);
823 if (!FcFontSetAdd (new, font))
825 FcFontSetDestroy (new);
833 FcCacheSubdir args(const FcCache *c, int i)
835 return FcCacheSubdir (c, i);
839 FcCacheNumSubdir args(const FcCache *c)
841 return c->dirs_count;
845 FcCacheNumFont args(const FcCache *c)
847 return FcCacheSet(c)->nfont;
851 * This code implements the MD5 message-digest algorithm.
852 * The algorithm is due to Ron Rivest. This code was
853 * written by Colin Plumb in 1993, no copyright is claimed.
854 * This code is in the public domain; do with it what you wish.
856 * Equivalent code is available from RSA Data Security, Inc.
857 * This code has been tested against that, and is equivalent,
858 * except that you don't need to include two pages of legalese
861 * To compute the message digest of a chunk of bytes, declare an
862 * MD5Context structure, pass it to MD5Init, call MD5Update as
863 * needed on buffers full of bytes, and then call MD5Final, which
864 * will fill a supplied 16-byte array with the digest.
868 #define byteReverse(buf, len) /* Nothing */
871 * Note: this code is harmless on little-endian machines.
873 void byteReverse(unsigned char *buf, unsigned longs)
877 t = (FcChar32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
878 ((unsigned) buf[1] << 8 | buf[0]);
879 *(FcChar32 *) buf = t;
886 * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
887 * initialization constants.
889 static void MD5Init(struct MD5Context *ctx)
891 ctx->buf[0] = 0x67452301;
892 ctx->buf[1] = 0xefcdab89;
893 ctx->buf[2] = 0x98badcfe;
894 ctx->buf[3] = 0x10325476;
901 * Update context to reflect the concatenation of another buffer full
904 static void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len)
908 /* Update bitcount */
911 if ((ctx->bits[0] = t + ((FcChar32) len << 3)) < t)
912 ctx->bits[1]++; /* Carry from low to high */
913 ctx->bits[1] += len >> 29;
915 t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
917 /* Handle any leading odd-sized chunks */
920 unsigned char *p = (unsigned char *) ctx->in + t;
928 byteReverse(ctx->in, 16);
929 MD5Transform(ctx->buf, (FcChar32 *) ctx->in);
933 /* Process data in 64-byte chunks */
936 memcpy(ctx->in, buf, 64);
937 byteReverse(ctx->in, 16);
938 MD5Transform(ctx->buf, (FcChar32 *) ctx->in);
943 /* Handle any remaining bytes of data. */
945 memcpy(ctx->in, buf, len);
949 * Final wrapup - pad to 64-byte boundary with the bit pattern
950 * 1 0* (64-bit count of bits processed, MSB-first)
952 static void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
957 /* Compute number of bytes mod 64 */
958 count = (ctx->bits[0] >> 3) & 0x3F;
960 /* Set the first char of padding to 0x80. This is safe since there is
961 always at least one byte free */
965 /* Bytes of padding needed to make 64 bytes */
966 count = 64 - 1 - count;
968 /* Pad out to 56 mod 64 */
970 /* Two lots of padding: Pad the first block to 64 bytes */
972 byteReverse(ctx->in, 16);
973 MD5Transform(ctx->buf, (FcChar32 *) ctx->in);
975 /* Now fill the next block with 56 bytes */
976 memset(ctx->in, 0, 56);
978 /* Pad block to 56 bytes */
979 memset(p, 0, count - 8);
981 byteReverse(ctx->in, 14);
983 /* Append length in bits and transform */
984 ((FcChar32 *) ctx->in)[14] = ctx->bits[0];
985 ((FcChar32 *) ctx->in)[15] = ctx->bits[1];
987 MD5Transform(ctx->buf, (FcChar32 *) ctx->in);
988 byteReverse((unsigned char *) ctx->buf, 4);
989 memcpy(digest, ctx->buf, 16);
990 memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
994 /* The four core functions - F1 is optimized somewhat */
996 /* #define F1(x, y, z) (x & y | ~x & z) */
997 #define F1(x, y, z) (z ^ (x & (y ^ z)))
998 #define F2(x, y, z) F1(z, x, y)
999 #define F3(x, y, z) (x ^ y ^ z)
1000 #define F4(x, y, z) (y ^ (x | ~z))
1002 /* This is the central step in the MD5 algorithm. */
1003 #define MD5STEP(f, w, x, y, z, data, s) \
1004 ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
1007 * The core of the MD5 algorithm, this alters an existing MD5 hash to
1008 * reflect the addition of 16 longwords of new data. MD5Update blocks
1009 * the data and converts bytes into longwords for this routine.
1011 static void MD5Transform(FcChar32 buf[4], FcChar32 in[16])
1013 register FcChar32 a, b, c, d;
1020 MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
1021 MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
1022 MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
1023 MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
1024 MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
1025 MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
1026 MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
1027 MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
1028 MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
1029 MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
1030 MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
1031 MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
1032 MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
1033 MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
1034 MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
1035 MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
1037 MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
1038 MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
1039 MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
1040 MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
1041 MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
1042 MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
1043 MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
1044 MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
1045 MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
1046 MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
1047 MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
1048 MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
1049 MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
1050 MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
1051 MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
1052 MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
1054 MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
1055 MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
1056 MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
1057 MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
1058 MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
1059 MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
1060 MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
1061 MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
1062 MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
1063 MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
1064 MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
1065 MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
1066 MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
1067 MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
1068 MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
1069 MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
1071 MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
1072 MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
1073 MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
1074 MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
1075 MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
1076 MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
1077 MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
1078 MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
1079 MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
1080 MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
1081 MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
1082 MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
1083 MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
1084 MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
1085 MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
1086 MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
1094 #include "fcaliastail.h"