Hex Artifact Content
Not logged in

Artifact 67e3e1260e0222c7ef584bfc0da5ce6fa868cb75:


0000: 2f 2a 20 6d 64 35 2e 63 20 2d 20 61 6e 20 69 6d  /* md5.c - an im
0010: 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 20  plementation of 
0020: 74 68 65 20 4d 44 35 20 61 6c 67 6f 72 69 74 68  the MD5 algorith
0030: 6d 2c 20 62 61 73 65 64 20 6f 6e 20 52 46 43 20  m, based on RFC 
0040: 31 33 32 31 2e 0a 20 2a 0a 20 2a 20 43 6f 70 79  1321.. *. * Copy
0050: 72 69 67 68 74 3a 20 32 30 30 37 2d 32 30 31 32  right: 2007-2012
0060: 20 41 6c 65 6b 73 65 79 20 4b 72 61 76 63 68 65   Aleksey Kravche
0070: 6e 6b 6f 20 3c 72 68 61 73 68 2e 61 64 6d 69 6e  nko <rhash.admin
0080: 40 67 6d 61 69 6c 2e 63 6f 6d 3e 0a 20 2a 0a 20  @gmail.com>. *. 
0090: 2a 20 50 65 72 6d 69 73 73 69 6f 6e 20 69 73 20  * Permission is 
00a0: 68 65 72 65 62 79 20 67 72 61 6e 74 65 64 2c 20  hereby granted, 
00b0: 20 66 72 65 65 20 6f 66 20 63 68 61 72 67 65 2c   free of charge,
00c0: 20 20 74 6f 20 61 6e 79 20 70 65 72 73 6f 6e 20    to any person 
00d0: 20 6f 62 74 61 69 6e 69 6e 67 20 61 0a 20 2a 20   obtaining a. * 
00e0: 63 6f 70 79 20 6f 66 20 74 68 69 73 20 73 6f 66  copy of this sof
00f0: 74 77 61 72 65 20 61 6e 64 20 61 73 73 6f 63 69  tware and associ
0100: 61 74 65 64 20 64 6f 63 75 6d 65 6e 74 61 74 69  ated documentati
0110: 6f 6e 20 66 69 6c 65 73 20 28 74 68 65 20 22 53  on files (the "S
0120: 6f 66 74 77 61 72 65 22 29 2c 0a 20 2a 20 74 6f  oftware"),. * to
0130: 20 64 65 61 6c 20 69 6e 20 74 68 65 20 53 6f 66   deal in the Sof
0140: 74 77 61 72 65 20 77 69 74 68 6f 75 74 20 72 65  tware without re
0150: 73 74 72 69 63 74 69 6f 6e 2c 20 20 69 6e 63 6c  striction,  incl
0160: 75 64 69 6e 67 20 77 69 74 68 6f 75 74 20 6c 69  uding without li
0170: 6d 69 74 61 74 69 6f 6e 0a 20 2a 20 74 68 65 20  mitation. * the 
0180: 72 69 67 68 74 73 20 74 6f 20 20 75 73 65 2c 20  rights to  use, 
0190: 63 6f 70 79 2c 20 6d 6f 64 69 66 79 2c 20 20 6d  copy, modify,  m
01a0: 65 72 67 65 2c 20 70 75 62 6c 69 73 68 2c 20 64  erge, publish, d
01b0: 69 73 74 72 69 62 75 74 65 2c 20 73 75 62 6c 69  istribute, subli
01c0: 63 65 6e 73 65 2c 0a 20 2a 20 61 6e 64 2f 6f 72  cense,. * and/or
01d0: 20 73 65 6c 6c 20 63 6f 70 69 65 73 20 20 6f 66   sell copies  of
01e0: 20 20 74 68 65 20 53 6f 66 74 77 61 72 65 2c 20    the Software, 
01f0: 20 61 6e 64 20 74 6f 20 70 65 72 6d 69 74 20 20   and to permit  
0200: 70 65 72 73 6f 6e 73 20 20 74 6f 20 77 68 6f 6d  persons  to whom
0210: 20 74 68 65 0a 20 2a 20 53 6f 66 74 77 61 72 65   the. * Software
0220: 20 69 73 20 66 75 72 6e 69 73 68 65 64 20 74 6f   is furnished to
0230: 20 64 6f 20 73 6f 2e 0a 20 2a 0a 20 2a 20 54 68   do so.. *. * Th
0240: 69 73 20 70 72 6f 67 72 61 6d 20 20 69 73 20 20  is program  is  
0250: 64 69 73 74 72 69 62 75 74 65 64 20 20 69 6e 20  distributed  in 
0260: 20 74 68 65 20 20 68 6f 70 65 20 20 74 68 61 74   the  hope  that
0270: 20 69 74 20 77 69 6c 6c 20 62 65 20 75 73 65 66   it will be usef
0280: 75 6c 2c 20 20 62 75 74 0a 20 2a 20 57 49 54 48  ul,  but. * WITH
0290: 4f 55 54 20 41 4e 59 20 57 41 52 52 41 4e 54 59  OUT ANY WARRANTY
02a0: 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74  ; without even t
02b0: 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61  he implied warra
02c0: 6e 74 79 20 6f 66 20 4d 45 52 43 48 41 4e 54 41  nty of MERCHANTA
02d0: 42 49 4c 49 54 59 0a 20 2a 20 6f 72 20 46 49 54  BILITY. * or FIT
02e0: 4e 45 53 53 20 46 4f 52 20 41 20 50 41 52 54 49  NESS FOR A PARTI
02f0: 43 55 4c 41 52 20 50 55 52 50 4f 53 45 2e 20 20  CULAR PURPOSE.  
0300: 55 73 65 20 74 68 69 73 20 70 72 6f 67 72 61 6d  Use this program
0310: 20 20 61 74 20 20 79 6f 75 72 20 6f 77 6e 20 72    at  your own r
0320: 69 73 6b 21 0a 20 2a 2f 0a 0a 23 69 6e 63 6c 75  isk!. */..#inclu
0330: 64 65 20 3c 73 74 72 69 6e 67 2e 68 3e 0a 23 69  de <string.h>.#i
0340: 6e 63 6c 75 64 65 20 22 62 79 74 65 5f 6f 72 64  nclude "byte_ord
0350: 65 72 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 22  er.h".#include "
0360: 6d 64 35 2e 68 22 0a 0a 2f 2a 2a 0a 20 2a 20 49  md5.h"../**. * I
0370: 6e 69 74 69 61 6c 69 7a 65 20 63 6f 6e 74 65 78  nitialize contex
0380: 74 20 62 65 66 6f 72 65 20 63 61 6c 63 75 6c 61  t before calcula
0390: 69 6e 67 20 68 61 73 68 2e 0a 20 2a 0a 20 2a 20  ing hash.. *. * 
03a0: 40 70 61 72 61 6d 20 63 74 78 20 63 6f 6e 74 65  @param ctx conte
03b0: 78 74 20 74 6f 20 69 6e 69 74 69 61 6c 69 7a 65  xt to initialize
03c0: 0a 20 2a 2f 0a 76 6f 69 64 20 72 68 61 73 68 5f  . */.void rhash_
03d0: 6d 64 35 5f 69 6e 69 74 28 6d 64 35 5f 63 74 78  md5_init(md5_ctx
03e0: 20 2a 63 74 78 29 0a 7b 0a 09 63 74 78 2d 3e 6c   *ctx).{..ctx->l
03f0: 65 6e 67 74 68 20 3d 20 30 3b 0a 0a 09 2f 2a 20  ength = 0;.../* 
0400: 69 6e 69 74 69 61 6c 69 7a 65 20 73 74 61 74 65  initialize state
0410: 20 2a 2f 0a 09 63 74 78 2d 3e 68 61 73 68 5b 30   */..ctx->hash[0
0420: 5d 20 3d 20 30 78 36 37 34 35 32 33 30 31 3b 0a  ] = 0x67452301;.
0430: 09 63 74 78 2d 3e 68 61 73 68 5b 31 5d 20 3d 20  .ctx->hash[1] = 
0440: 30 78 65 66 63 64 61 62 38 39 3b 0a 09 63 74 78  0xefcdab89;..ctx
0450: 2d 3e 68 61 73 68 5b 32 5d 20 3d 20 30 78 39 38  ->hash[2] = 0x98
0460: 62 61 64 63 66 65 3b 0a 09 63 74 78 2d 3e 68 61  badcfe;..ctx->ha
0470: 73 68 5b 33 5d 20 3d 20 30 78 31 30 33 32 35 34  sh[3] = 0x103254
0480: 37 36 3b 0a 7d 0a 0a 2f 2a 20 46 69 72 73 74 2c  76;.}../* First,
0490: 20 64 65 66 69 6e 65 20 66 6f 75 72 20 61 75 78   define four aux
04a0: 69 6c 69 61 72 79 20 66 75 6e 63 74 69 6f 6e 73  iliary functions
04b0: 20 74 68 61 74 20 65 61 63 68 20 74 61 6b 65 20   that each take 
04c0: 61 73 20 69 6e 70 75 74 0a 20 2a 20 74 68 72 65  as input. * thre
04d0: 65 20 33 32 2d 62 69 74 20 77 6f 72 64 73 20 61  e 32-bit words a
04e0: 6e 64 20 72 65 74 75 72 6e 73 20 61 20 33 32 2d  nd returns a 32-
04f0: 62 69 74 20 77 6f 72 64 2e 2a 2f 0a 0a 2f 2a 20  bit word.*/../* 
0500: 46 28 78 2c 79 2c 7a 29 20 3d 20 28 28 79 20 58  F(x,y,z) = ((y X
0510: 4f 52 20 7a 29 20 41 4e 44 20 78 29 20 58 4f 52  OR z) AND x) XOR
0520: 20 7a 20 2d 20 69 73 20 66 61 73 74 65 72 20 74   z - is faster t
0530: 68 65 6e 20 6f 72 69 67 69 6e 61 6c 20 76 65 72  hen original ver
0540: 73 69 6f 6e 20 2a 2f 0a 23 64 65 66 69 6e 65 20  sion */.#define 
0550: 4d 44 35 5f 46 28 78 2c 20 79 2c 20 7a 29 20 28  MD5_F(x, y, z) (
0560: 28 28 28 79 29 20 5e 20 28 7a 29 29 20 26 20 28  (((y) ^ (z)) & (
0570: 78 29 29 20 5e 20 28 7a 29 29 0a 23 64 65 66 69  x)) ^ (z)).#defi
0580: 6e 65 20 4d 44 35 5f 47 28 78 2c 20 79 2c 20 7a  ne MD5_G(x, y, z
0590: 29 20 28 28 28 78 29 20 26 20 28 7a 29 29 20 7c  ) (((x) & (z)) |
05a0: 20 28 28 79 29 20 26 20 28 7e 7a 29 29 29 0a 23   ((y) & (~z))).#
05b0: 64 65 66 69 6e 65 20 4d 44 35 5f 48 28 78 2c 20  define MD5_H(x, 
05c0: 79 2c 20 7a 29 20 28 28 78 29 20 5e 20 28 79 29  y, z) ((x) ^ (y)
05d0: 20 5e 20 28 7a 29 29 0a 23 64 65 66 69 6e 65 20   ^ (z)).#define 
05e0: 4d 44 35 5f 49 28 78 2c 20 79 2c 20 7a 29 20 28  MD5_I(x, y, z) (
05f0: 28 79 29 20 5e 20 28 28 78 29 20 7c 20 28 7e 7a  (y) ^ ((x) | (~z
0600: 29 29 29 0a 0a 2f 2a 20 74 72 61 6e 73 66 6f 72  )))../* transfor
0610: 6d 61 74 69 6f 6e 73 20 66 6f 72 20 72 6f 75 6e  mations for roun
0620: 64 73 20 31 2c 20 32 2c 20 33 2c 20 61 6e 64 20  ds 1, 2, 3, and 
0630: 34 2e 20 2a 2f 0a 23 64 65 66 69 6e 65 20 4d 44  4. */.#define MD
0640: 35 5f 52 4f 55 4e 44 31 28 61 2c 20 62 2c 20 63  5_ROUND1(a, b, c
0650: 2c 20 64 2c 20 78 2c 20 73 2c 20 61 63 29 20 7b  , d, x, s, ac) {
0660: 20 5c 0a 09 28 61 29 20 2b 3d 20 4d 44 35 5f 46   \..(a) += MD5_F
0670: 28 28 62 29 2c 20 28 63 29 2c 20 28 64 29 29 20  ((b), (c), (d)) 
0680: 2b 20 28 78 29 20 2b 20 28 61 63 29 3b 20 5c 0a  + (x) + (ac); \.
0690: 09 28 61 29 20 3d 20 52 4f 54 4c 33 32 28 28 61  .(a) = ROTL32((a
06a0: 29 2c 20 28 73 29 29 3b 20 5c 0a 09 28 61 29 20  ), (s)); \..(a) 
06b0: 2b 3d 20 28 62 29 3b 20 5c 0a 7d 0a 23 64 65 66  += (b); \.}.#def
06c0: 69 6e 65 20 4d 44 35 5f 52 4f 55 4e 44 32 28 61  ine MD5_ROUND2(a
06d0: 2c 20 62 2c 20 63 2c 20 64 2c 20 78 2c 20 73 2c  , b, c, d, x, s,
06e0: 20 61 63 29 20 7b 20 5c 0a 09 28 61 29 20 2b 3d   ac) { \..(a) +=
06f0: 20 4d 44 35 5f 47 28 28 62 29 2c 20 28 63 29 2c   MD5_G((b), (c),
0700: 20 28 64 29 29 20 2b 20 28 78 29 20 2b 20 28 61   (d)) + (x) + (a
0710: 63 29 3b 20 5c 0a 09 28 61 29 20 3d 20 52 4f 54  c); \..(a) = ROT
0720: 4c 33 32 28 28 61 29 2c 20 28 73 29 29 3b 20 5c  L32((a), (s)); \
0730: 0a 09 28 61 29 20 2b 3d 20 28 62 29 3b 20 5c 0a  ..(a) += (b); \.
0740: 7d 0a 23 64 65 66 69 6e 65 20 4d 44 35 5f 52 4f  }.#define MD5_RO
0750: 55 4e 44 33 28 61 2c 20 62 2c 20 63 2c 20 64 2c  UND3(a, b, c, d,
0760: 20 78 2c 20 73 2c 20 61 63 29 20 7b 20 5c 0a 09   x, s, ac) { \..
0770: 28 61 29 20 2b 3d 20 4d 44 35 5f 48 28 28 62 29  (a) += MD5_H((b)
0780: 2c 20 28 63 29 2c 20 28 64 29 29 20 2b 20 28 78  , (c), (d)) + (x
0790: 29 20 2b 20 28 61 63 29 3b 20 5c 0a 09 28 61 29  ) + (ac); \..(a)
07a0: 20 3d 20 52 4f 54 4c 33 32 28 28 61 29 2c 20 28   = ROTL32((a), (
07b0: 73 29 29 3b 20 5c 0a 09 28 61 29 20 2b 3d 20 28  s)); \..(a) += (
07c0: 62 29 3b 20 5c 0a 7d 0a 23 64 65 66 69 6e 65 20  b); \.}.#define 
07d0: 4d 44 35 5f 52 4f 55 4e 44 34 28 61 2c 20 62 2c  MD5_ROUND4(a, b,
07e0: 20 63 2c 20 64 2c 20 78 2c 20 73 2c 20 61 63 29   c, d, x, s, ac)
07f0: 20 7b 20 5c 0a 09 28 61 29 20 2b 3d 20 4d 44 35   { \..(a) += MD5
0800: 5f 49 28 28 62 29 2c 20 28 63 29 2c 20 28 64 29  _I((b), (c), (d)
0810: 29 20 2b 20 28 78 29 20 2b 20 28 61 63 29 3b 20  ) + (x) + (ac); 
0820: 5c 0a 09 28 61 29 20 3d 20 52 4f 54 4c 33 32 28  \..(a) = ROTL32(
0830: 28 61 29 2c 20 28 73 29 29 3b 20 5c 0a 09 28 61  (a), (s)); \..(a
0840: 29 20 2b 3d 20 28 62 29 3b 20 5c 0a 7d 0a 0a 2f  ) += (b); \.}../
0850: 2a 2a 0a 20 2a 20 54 68 65 20 63 6f 72 65 20 74  **. * The core t
0860: 72 61 6e 73 66 6f 72 6d 61 74 69 6f 6e 2e 20 50  ransformation. P
0870: 72 6f 63 65 73 73 20 61 20 35 31 32 2d 62 69 74  rocess a 512-bit
0880: 20 62 6c 6f 63 6b 2e 0a 20 2a 20 54 68 65 20 66   block.. * The f
0890: 75 6e 63 74 69 6f 6e 20 68 61 73 20 62 65 65 6e  unction has been
08a0: 20 74 61 6b 65 6e 20 66 72 6f 6d 20 52 46 43 20   taken from RFC 
08b0: 31 33 32 31 20 77 69 74 68 20 6c 69 74 74 6c 65  1321 with little
08c0: 20 63 68 61 6e 67 65 73 2e 0a 20 2a 0a 20 2a 20   changes.. *. * 
08d0: 40 70 61 72 61 6d 20 73 74 61 74 65 20 61 6c 67  @param state alg
08e0: 6f 72 69 74 68 6d 20 73 74 61 74 65 0a 20 2a 20  orithm state. * 
08f0: 40 70 61 72 61 6d 20 78 20 74 68 65 20 6d 65 73  @param x the mes
0900: 73 61 67 65 20 62 6c 6f 63 6b 20 74 6f 20 70 72  sage block to pr
0910: 6f 63 65 73 73 0a 20 2a 2f 0a 73 74 61 74 69 63  ocess. */.static
0920: 20 76 6f 69 64 20 72 68 61 73 68 5f 6d 64 35 5f   void rhash_md5_
0930: 70 72 6f 63 65 73 73 5f 62 6c 6f 63 6b 28 75 6e  process_block(un
0940: 73 69 67 6e 65 64 20 73 74 61 74 65 5b 34 5d 2c  signed state[4],
0950: 20 63 6f 6e 73 74 20 75 6e 73 69 67 6e 65 64 2a   const unsigned*
0960: 20 78 29 0a 7b 0a 09 72 65 67 69 73 74 65 72 20   x).{..register 
0970: 75 6e 73 69 67 6e 65 64 20 61 2c 20 62 2c 20 63  unsigned a, b, c
0980: 2c 20 64 3b 0a 09 61 20 3d 20 73 74 61 74 65 5b  , d;..a = state[
0990: 30 5d 3b 0a 09 62 20 3d 20 73 74 61 74 65 5b 31  0];..b = state[1
09a0: 5d 3b 0a 09 63 20 3d 20 73 74 61 74 65 5b 32 5d  ];..c = state[2]
09b0: 3b 0a 09 64 20 3d 20 73 74 61 74 65 5b 33 5d 3b  ;..d = state[3];
09c0: 0a 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 61 2c  ...MD5_ROUND1(a,
09d0: 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20 30 5d 2c   b, c, d, x[ 0],
09e0: 20 20 37 2c 20 30 78 64 37 36 61 61 34 37 38 29    7, 0xd76aa478)
09f0: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 64 2c  ;..MD5_ROUND1(d,
0a00: 20 61 2c 20 62 2c 20 63 2c 20 78 5b 20 31 5d 2c   a, b, c, x[ 1],
0a10: 20 31 32 2c 20 30 78 65 38 63 37 62 37 35 36 29   12, 0xe8c7b756)
0a20: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 63 2c  ;..MD5_ROUND1(c,
0a30: 20 64 2c 20 61 2c 20 62 2c 20 78 5b 20 32 5d 2c   d, a, b, x[ 2],
0a40: 20 31 37 2c 20 30 78 32 34 32 30 37 30 64 62 29   17, 0x242070db)
0a50: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 62 2c  ;..MD5_ROUND1(b,
0a60: 20 63 2c 20 64 2c 20 61 2c 20 78 5b 20 33 5d 2c   c, d, a, x[ 3],
0a70: 20 32 32 2c 20 30 78 63 31 62 64 63 65 65 65 29   22, 0xc1bdceee)
0a80: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 61 2c  ;..MD5_ROUND1(a,
0a90: 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20 34 5d 2c   b, c, d, x[ 4],
0aa0: 20 20 37 2c 20 30 78 66 35 37 63 30 66 61 66 29    7, 0xf57c0faf)
0ab0: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 64 2c  ;..MD5_ROUND1(d,
0ac0: 20 61 2c 20 62 2c 20 63 2c 20 78 5b 20 35 5d 2c   a, b, c, x[ 5],
0ad0: 20 31 32 2c 20 30 78 34 37 38 37 63 36 32 61 29   12, 0x4787c62a)
0ae0: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 63 2c  ;..MD5_ROUND1(c,
0af0: 20 64 2c 20 61 2c 20 62 2c 20 78 5b 20 36 5d 2c   d, a, b, x[ 6],
0b00: 20 31 37 2c 20 30 78 61 38 33 30 34 36 31 33 29   17, 0xa8304613)
0b10: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 62 2c  ;..MD5_ROUND1(b,
0b20: 20 63 2c 20 64 2c 20 61 2c 20 78 5b 20 37 5d 2c   c, d, a, x[ 7],
0b30: 20 32 32 2c 20 30 78 66 64 34 36 39 35 30 31 29   22, 0xfd469501)
0b40: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 61 2c  ;..MD5_ROUND1(a,
0b50: 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20 38 5d 2c   b, c, d, x[ 8],
0b60: 20 20 37 2c 20 30 78 36 39 38 30 39 38 64 38 29    7, 0x698098d8)
0b70: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 64 2c  ;..MD5_ROUND1(d,
0b80: 20 61 2c 20 62 2c 20 63 2c 20 78 5b 20 39 5d 2c   a, b, c, x[ 9],
0b90: 20 31 32 2c 20 30 78 38 62 34 34 66 37 61 66 29   12, 0x8b44f7af)
0ba0: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 63 2c  ;..MD5_ROUND1(c,
0bb0: 20 64 2c 20 61 2c 20 62 2c 20 78 5b 31 30 5d 2c   d, a, b, x[10],
0bc0: 20 31 37 2c 20 30 78 66 66 66 66 35 62 62 31 29   17, 0xffff5bb1)
0bd0: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 62 2c  ;..MD5_ROUND1(b,
0be0: 20 63 2c 20 64 2c 20 61 2c 20 78 5b 31 31 5d 2c   c, d, a, x[11],
0bf0: 20 32 32 2c 20 30 78 38 39 35 63 64 37 62 65 29   22, 0x895cd7be)
0c00: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 61 2c  ;..MD5_ROUND1(a,
0c10: 20 62 2c 20 63 2c 20 64 2c 20 78 5b 31 32 5d 2c   b, c, d, x[12],
0c20: 20 20 37 2c 20 30 78 36 62 39 30 31 31 32 32 29    7, 0x6b901122)
0c30: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 64 2c  ;..MD5_ROUND1(d,
0c40: 20 61 2c 20 62 2c 20 63 2c 20 78 5b 31 33 5d 2c   a, b, c, x[13],
0c50: 20 31 32 2c 20 30 78 66 64 39 38 37 31 39 33 29   12, 0xfd987193)
0c60: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 63 2c  ;..MD5_ROUND1(c,
0c70: 20 64 2c 20 61 2c 20 62 2c 20 78 5b 31 34 5d 2c   d, a, b, x[14],
0c80: 20 31 37 2c 20 30 78 61 36 37 39 34 33 38 65 29   17, 0xa679438e)
0c90: 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 31 28 62 2c  ;..MD5_ROUND1(b,
0ca0: 20 63 2c 20 64 2c 20 61 2c 20 78 5b 31 35 5d 2c   c, d, a, x[15],
0cb0: 20 32 32 2c 20 30 78 34 39 62 34 30 38 32 31 29   22, 0x49b40821)
0cc0: 3b 0a 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 61  ;...MD5_ROUND2(a
0cd0: 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20 31 5d  , b, c, d, x[ 1]
0ce0: 2c 20 20 35 2c 20 30 78 66 36 31 65 32 35 36 32  ,  5, 0xf61e2562
0cf0: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 64  );..MD5_ROUND2(d
0d00: 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 20 36 5d  , a, b, c, x[ 6]
0d10: 2c 20 20 39 2c 20 30 78 63 30 34 30 62 33 34 30  ,  9, 0xc040b340
0d20: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 63  );..MD5_ROUND2(c
0d30: 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 31 31 5d  , d, a, b, x[11]
0d40: 2c 20 31 34 2c 20 30 78 32 36 35 65 35 61 35 31  , 14, 0x265e5a51
0d50: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 62  );..MD5_ROUND2(b
0d60: 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 20 30 5d  , c, d, a, x[ 0]
0d70: 2c 20 32 30 2c 20 30 78 65 39 62 36 63 37 61 61  , 20, 0xe9b6c7aa
0d80: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 61  );..MD5_ROUND2(a
0d90: 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20 35 5d  , b, c, d, x[ 5]
0da0: 2c 20 20 35 2c 20 30 78 64 36 32 66 31 30 35 64  ,  5, 0xd62f105d
0db0: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 64  );..MD5_ROUND2(d
0dc0: 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 31 30 5d  , a, b, c, x[10]
0dd0: 2c 20 20 39 2c 20 20 30 78 32 34 34 31 34 35 33  ,  9,  0x2441453
0de0: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 63  );..MD5_ROUND2(c
0df0: 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 31 35 5d  , d, a, b, x[15]
0e00: 2c 20 31 34 2c 20 30 78 64 38 61 31 65 36 38 31  , 14, 0xd8a1e681
0e10: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 62  );..MD5_ROUND2(b
0e20: 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 20 34 5d  , c, d, a, x[ 4]
0e30: 2c 20 32 30 2c 20 30 78 65 37 64 33 66 62 63 38  , 20, 0xe7d3fbc8
0e40: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 61  );..MD5_ROUND2(a
0e50: 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20 39 5d  , b, c, d, x[ 9]
0e60: 2c 20 20 35 2c 20 30 78 32 31 65 31 63 64 65 36  ,  5, 0x21e1cde6
0e70: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 64  );..MD5_ROUND2(d
0e80: 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 31 34 5d  , a, b, c, x[14]
0e90: 2c 20 20 39 2c 20 30 78 63 33 33 37 30 37 64 36  ,  9, 0xc33707d6
0ea0: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 63  );..MD5_ROUND2(c
0eb0: 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 20 33 5d  , d, a, b, x[ 3]
0ec0: 2c 20 31 34 2c 20 30 78 66 34 64 35 30 64 38 37  , 14, 0xf4d50d87
0ed0: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 62  );..MD5_ROUND2(b
0ee0: 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 20 38 5d  , c, d, a, x[ 8]
0ef0: 2c 20 32 30 2c 20 30 78 34 35 35 61 31 34 65 64  , 20, 0x455a14ed
0f00: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 61  );..MD5_ROUND2(a
0f10: 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 31 33 5d  , b, c, d, x[13]
0f20: 2c 20 20 35 2c 20 30 78 61 39 65 33 65 39 30 35  ,  5, 0xa9e3e905
0f30: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 64  );..MD5_ROUND2(d
0f40: 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 20 32 5d  , a, b, c, x[ 2]
0f50: 2c 20 20 39 2c 20 30 78 66 63 65 66 61 33 66 38  ,  9, 0xfcefa3f8
0f60: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 63  );..MD5_ROUND2(c
0f70: 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 20 37 5d  , d, a, b, x[ 7]
0f80: 2c 20 31 34 2c 20 30 78 36 37 36 66 30 32 64 39  , 14, 0x676f02d9
0f90: 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 32 28 62  );..MD5_ROUND2(b
0fa0: 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 31 32 5d  , c, d, a, x[12]
0fb0: 2c 20 32 30 2c 20 30 78 38 64 32 61 34 63 38 61  , 20, 0x8d2a4c8a
0fc0: 29 3b 0a 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  );...MD5_ROUND3(
0fd0: 61 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20 35  a, b, c, d, x[ 5
0fe0: 5d 2c 20 20 34 2c 20 30 78 66 66 66 61 33 39 34  ],  4, 0xfffa394
0ff0: 32 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  2);..MD5_ROUND3(
1000: 64 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 20 38  d, a, b, c, x[ 8
1010: 5d 2c 20 31 31 2c 20 30 78 38 37 37 31 66 36 38  ], 11, 0x8771f68
1020: 31 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  1);..MD5_ROUND3(
1030: 63 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 31 31  c, d, a, b, x[11
1040: 5d 2c 20 31 36 2c 20 30 78 36 64 39 64 36 31 32  ], 16, 0x6d9d612
1050: 32 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  2);..MD5_ROUND3(
1060: 62 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 31 34  b, c, d, a, x[14
1070: 5d 2c 20 32 33 2c 20 30 78 66 64 65 35 33 38 30  ], 23, 0xfde5380
1080: 63 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  c);..MD5_ROUND3(
1090: 61 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20 31  a, b, c, d, x[ 1
10a0: 5d 2c 20 20 34 2c 20 30 78 61 34 62 65 65 61 34  ],  4, 0xa4beea4
10b0: 34 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  4);..MD5_ROUND3(
10c0: 64 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 20 34  d, a, b, c, x[ 4
10d0: 5d 2c 20 31 31 2c 20 30 78 34 62 64 65 63 66 61  ], 11, 0x4bdecfa
10e0: 39 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  9);..MD5_ROUND3(
10f0: 63 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 20 37  c, d, a, b, x[ 7
1100: 5d 2c 20 31 36 2c 20 30 78 66 36 62 62 34 62 36  ], 16, 0xf6bb4b6
1110: 30 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  0);..MD5_ROUND3(
1120: 62 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 31 30  b, c, d, a, x[10
1130: 5d 2c 20 32 33 2c 20 30 78 62 65 62 66 62 63 37  ], 23, 0xbebfbc7
1140: 30 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  0);..MD5_ROUND3(
1150: 61 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 31 33  a, b, c, d, x[13
1160: 5d 2c 20 20 34 2c 20 30 78 32 38 39 62 37 65 63  ],  4, 0x289b7ec
1170: 36 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  6);..MD5_ROUND3(
1180: 64 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 20 30  d, a, b, c, x[ 0
1190: 5d 2c 20 31 31 2c 20 30 78 65 61 61 31 32 37 66  ], 11, 0xeaa127f
11a0: 61 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  a);..MD5_ROUND3(
11b0: 63 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 20 33  c, d, a, b, x[ 3
11c0: 5d 2c 20 31 36 2c 20 30 78 64 34 65 66 33 30 38  ], 16, 0xd4ef308
11d0: 35 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  5);..MD5_ROUND3(
11e0: 62 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 20 36  b, c, d, a, x[ 6
11f0: 5d 2c 20 32 33 2c 20 20 30 78 34 38 38 31 64 30  ], 23,  0x4881d0
1200: 35 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  5);..MD5_ROUND3(
1210: 61 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20 39  a, b, c, d, x[ 9
1220: 5d 2c 20 20 34 2c 20 30 78 64 39 64 34 64 30 33  ],  4, 0xd9d4d03
1230: 39 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  9);..MD5_ROUND3(
1240: 64 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 31 32  d, a, b, c, x[12
1250: 5d 2c 20 31 31 2c 20 30 78 65 36 64 62 39 39 65  ], 11, 0xe6db99e
1260: 35 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  5);..MD5_ROUND3(
1270: 63 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 31 35  c, d, a, b, x[15
1280: 5d 2c 20 31 36 2c 20 30 78 31 66 61 32 37 63 66  ], 16, 0x1fa27cf
1290: 38 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 33 28  8);..MD5_ROUND3(
12a0: 62 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 20 32  b, c, d, a, x[ 2
12b0: 5d 2c 20 32 33 2c 20 30 78 63 34 61 63 35 36 36  ], 23, 0xc4ac566
12c0: 35 29 3b 0a 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  5);...MD5_ROUND4
12d0: 28 61 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20  (a, b, c, d, x[ 
12e0: 30 5d 2c 20 20 36 2c 20 30 78 66 34 32 39 32 32  0],  6, 0xf42922
12f0: 34 34 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  44);..MD5_ROUND4
1300: 28 64 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 20  (d, a, b, c, x[ 
1310: 37 5d 2c 20 31 30 2c 20 30 78 34 33 32 61 66 66  7], 10, 0x432aff
1320: 39 37 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  97);..MD5_ROUND4
1330: 28 63 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 31  (c, d, a, b, x[1
1340: 34 5d 2c 20 31 35 2c 20 30 78 61 62 39 34 32 33  4], 15, 0xab9423
1350: 61 37 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  a7);..MD5_ROUND4
1360: 28 62 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 20  (b, c, d, a, x[ 
1370: 35 5d 2c 20 32 31 2c 20 30 78 66 63 39 33 61 30  5], 21, 0xfc93a0
1380: 33 39 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  39);..MD5_ROUND4
1390: 28 61 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 31  (a, b, c, d, x[1
13a0: 32 5d 2c 20 20 36 2c 20 30 78 36 35 35 62 35 39  2],  6, 0x655b59
13b0: 63 33 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  c3);..MD5_ROUND4
13c0: 28 64 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 20  (d, a, b, c, x[ 
13d0: 33 5d 2c 20 31 30 2c 20 30 78 38 66 30 63 63 63  3], 10, 0x8f0ccc
13e0: 39 32 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  92);..MD5_ROUND4
13f0: 28 63 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 31  (c, d, a, b, x[1
1400: 30 5d 2c 20 31 35 2c 20 30 78 66 66 65 66 66 34  0], 15, 0xffeff4
1410: 37 64 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  7d);..MD5_ROUND4
1420: 28 62 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 20  (b, c, d, a, x[ 
1430: 31 5d 2c 20 32 31 2c 20 30 78 38 35 38 34 35 64  1], 21, 0x85845d
1440: 64 31 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  d1);..MD5_ROUND4
1450: 28 61 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20  (a, b, c, d, x[ 
1460: 38 5d 2c 20 20 36 2c 20 30 78 36 66 61 38 37 65  8],  6, 0x6fa87e
1470: 34 66 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  4f);..MD5_ROUND4
1480: 28 64 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 31  (d, a, b, c, x[1
1490: 35 5d 2c 20 31 30 2c 20 30 78 66 65 32 63 65 36  5], 10, 0xfe2ce6
14a0: 65 30 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  e0);..MD5_ROUND4
14b0: 28 63 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 20  (c, d, a, b, x[ 
14c0: 36 5d 2c 20 31 35 2c 20 30 78 61 33 30 31 34 33  6], 15, 0xa30143
14d0: 31 34 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  14);..MD5_ROUND4
14e0: 28 62 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 31  (b, c, d, a, x[1
14f0: 33 5d 2c 20 32 31 2c 20 30 78 34 65 30 38 31 31  3], 21, 0x4e0811
1500: 61 31 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  a1);..MD5_ROUND4
1510: 28 61 2c 20 62 2c 20 63 2c 20 64 2c 20 78 5b 20  (a, b, c, d, x[ 
1520: 34 5d 2c 20 20 36 2c 20 30 78 66 37 35 33 37 65  4],  6, 0xf7537e
1530: 38 32 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  82);..MD5_ROUND4
1540: 28 64 2c 20 61 2c 20 62 2c 20 63 2c 20 78 5b 31  (d, a, b, c, x[1
1550: 31 5d 2c 20 31 30 2c 20 30 78 62 64 33 61 66 32  1], 10, 0xbd3af2
1560: 33 35 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  35);..MD5_ROUND4
1570: 28 63 2c 20 64 2c 20 61 2c 20 62 2c 20 78 5b 20  (c, d, a, b, x[ 
1580: 32 5d 2c 20 31 35 2c 20 30 78 32 61 64 37 64 32  2], 15, 0x2ad7d2
1590: 62 62 29 3b 0a 09 4d 44 35 5f 52 4f 55 4e 44 34  bb);..MD5_ROUND4
15a0: 28 62 2c 20 63 2c 20 64 2c 20 61 2c 20 78 5b 20  (b, c, d, a, x[ 
15b0: 39 5d 2c 20 32 31 2c 20 30 78 65 62 38 36 64 33  9], 21, 0xeb86d3
15c0: 39 31 29 3b 0a 0a 09 73 74 61 74 65 5b 30 5d 20  91);...state[0] 
15d0: 2b 3d 20 61 3b 0a 09 73 74 61 74 65 5b 31 5d 20  += a;..state[1] 
15e0: 2b 3d 20 62 3b 0a 09 73 74 61 74 65 5b 32 5d 20  += b;..state[2] 
15f0: 2b 3d 20 63 3b 0a 09 73 74 61 74 65 5b 33 5d 20  += c;..state[3] 
1600: 2b 3d 20 64 3b 0a 7d 0a 0a 2f 2a 2a 0a 20 2a 20  += d;.}../**. * 
1610: 43 61 6c 63 75 6c 61 74 65 20 6d 65 73 73 61 67  Calculate messag
1620: 65 20 68 61 73 68 2e 0a 20 2a 20 43 61 6e 20 62  e hash.. * Can b
1630: 65 20 63 61 6c 6c 65 64 20 72 65 70 65 61 74 65  e called repeate
1640: 64 6c 79 20 77 69 74 68 20 63 68 75 6e 6b 73 20  dly with chunks 
1650: 6f 66 20 74 68 65 20 6d 65 73 73 61 67 65 20 74  of the message t
1660: 6f 20 62 65 20 68 61 73 68 65 64 2e 0a 20 2a 0a  o be hashed.. *.
1670: 20 2a 20 40 70 61 72 61 6d 20 63 74 78 20 74 68   * @param ctx th
1680: 65 20 61 6c 67 6f 72 69 74 68 6d 20 63 6f 6e 74  e algorithm cont
1690: 65 78 74 20 63 6f 6e 74 61 69 6e 69 6e 67 20 63  ext containing c
16a0: 75 72 72 65 6e 74 20 68 61 73 68 69 6e 67 20 73  urrent hashing s
16b0: 74 61 74 65 0a 20 2a 20 40 70 61 72 61 6d 20 6d  tate. * @param m
16c0: 73 67 20 6d 65 73 73 61 67 65 20 63 68 75 6e 6b  sg message chunk
16d0: 0a 20 2a 20 40 70 61 72 61 6d 20 73 69 7a 65 20  . * @param size 
16e0: 6c 65 6e 67 74 68 20 6f 66 20 74 68 65 20 6d 65  length of the me
16f0: 73 73 61 67 65 20 63 68 75 6e 6b 0a 20 2a 2f 0a  ssage chunk. */.
1700: 76 6f 69 64 20 72 68 61 73 68 5f 6d 64 35 5f 75  void rhash_md5_u
1710: 70 64 61 74 65 28 6d 64 35 5f 63 74 78 20 2a 63  pdate(md5_ctx *c
1720: 74 78 2c 20 63 6f 6e 73 74 20 75 6e 73 69 67 6e  tx, const unsign
1730: 65 64 20 63 68 61 72 2a 20 6d 73 67 2c 20 73 69  ed char* msg, si
1740: 7a 65 5f 74 20 73 69 7a 65 29 0a 7b 0a 09 75 6e  ze_t size).{..un
1750: 73 69 67 6e 65 64 20 69 6e 64 65 78 20 3d 20 28  signed index = (
1760: 75 6e 73 69 67 6e 65 64 29 63 74 78 2d 3e 6c 65  unsigned)ctx->le
1770: 6e 67 74 68 20 26 20 36 33 3b 0a 09 63 74 78 2d  ngth & 63;..ctx-
1780: 3e 6c 65 6e 67 74 68 20 2b 3d 20 73 69 7a 65 3b  >length += size;
1790: 0a 0a 09 2f 2a 20 66 69 6c 6c 20 70 61 72 74 69  .../* fill parti
17a0: 61 6c 20 62 6c 6f 63 6b 20 2a 2f 0a 09 69 66 20  al block */..if 
17b0: 28 69 6e 64 65 78 29 20 7b 0a 09 09 75 6e 73 69  (index) {...unsi
17c0: 67 6e 65 64 20 6c 65 66 74 20 3d 20 6d 64 35 5f  gned left = md5_
17d0: 62 6c 6f 63 6b 5f 73 69 7a 65 20 2d 20 69 6e 64  block_size - ind
17e0: 65 78 3b 0a 09 09 6c 65 33 32 5f 63 6f 70 79 28  ex;...le32_copy(
17f0: 28 63 68 61 72 2a 29 63 74 78 2d 3e 6d 65 73 73  (char*)ctx->mess
1800: 61 67 65 2c 20 69 6e 64 65 78 2c 20 6d 73 67 2c  age, index, msg,
1810: 20 28 73 69 7a 65 20 3c 20 6c 65 66 74 20 3f 20   (size < left ? 
1820: 73 69 7a 65 20 3a 20 6c 65 66 74 29 29 3b 0a 09  size : left));..
1830: 09 69 66 20 28 73 69 7a 65 20 3c 20 6c 65 66 74  .if (size < left
1840: 29 20 72 65 74 75 72 6e 3b 0a 0a 09 09 2f 2a 20  ) return;..../* 
1850: 70 72 6f 63 65 73 73 20 70 61 72 74 69 61 6c 20  process partial 
1860: 62 6c 6f 63 6b 20 2a 2f 0a 09 09 72 68 61 73 68  block */...rhash
1870: 5f 6d 64 35 5f 70 72 6f 63 65 73 73 5f 62 6c 6f  _md5_process_blo
1880: 63 6b 28 63 74 78 2d 3e 68 61 73 68 2c 20 63 74  ck(ctx->hash, ct
1890: 78 2d 3e 6d 65 73 73 61 67 65 29 3b 0a 09 09 6d  x->message);...m
18a0: 73 67 20 20 2b 3d 20 6c 65 66 74 3b 0a 09 09 73  sg  += left;...s
18b0: 69 7a 65 20 2d 3d 20 6c 65 66 74 3b 0a 09 7d 0a  ize -= left;..}.
18c0: 09 77 68 69 6c 65 20 28 73 69 7a 65 20 3e 3d 20  .while (size >= 
18d0: 6d 64 35 5f 62 6c 6f 63 6b 5f 73 69 7a 65 29 20  md5_block_size) 
18e0: 7b 0a 09 09 75 6e 73 69 67 6e 65 64 2a 20 61 6c  {...unsigned* al
18f0: 69 67 6e 65 64 5f 6d 65 73 73 61 67 65 5f 62 6c  igned_message_bl
1900: 6f 63 6b 3b 0a 09 09 69 66 20 28 49 53 5f 4c 49  ock;...if (IS_LI
1910: 54 54 4c 45 5f 45 4e 44 49 41 4e 20 26 26 20 49  TTLE_ENDIAN && I
1920: 53 5f 41 4c 49 47 4e 45 44 5f 33 32 28 6d 73 67  S_ALIGNED_32(msg
1930: 29 29 20 7b 0a 09 09 09 2f 2a 20 74 68 65 20 6d  )) {..../* the m
1940: 6f 73 74 20 63 6f 6d 6d 6f 6e 20 63 61 73 65 20  ost common case 
1950: 69 73 20 70 72 6f 63 65 73 73 69 6e 67 20 61 20  is processing a 
1960: 33 32 2d 62 69 74 20 61 6c 69 67 6e 65 64 20 6d  32-bit aligned m
1970: 65 73 73 61 67 65 0a 09 09 09 6f 6e 20 61 20 6c  essage....on a l
1980: 69 74 74 6c 65 2d 65 6e 64 69 61 6e 20 43 50 55  ittle-endian CPU
1990: 20 77 69 74 68 6f 75 74 20 63 6f 70 79 69 6e 67   without copying
19a0: 20 69 74 20 2a 2f 0a 09 09 09 61 6c 69 67 6e 65   it */....aligne
19b0: 64 5f 6d 65 73 73 61 67 65 5f 62 6c 6f 63 6b 20  d_message_block 
19c0: 3d 20 28 75 6e 73 69 67 6e 65 64 2a 29 6d 73 67  = (unsigned*)msg
19d0: 3b 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 09  ;...} else {....
19e0: 6c 65 33 32 5f 63 6f 70 79 28 63 74 78 2d 3e 6d  le32_copy(ctx->m
19f0: 65 73 73 61 67 65 2c 20 30 2c 20 6d 73 67 2c 20  essage, 0, msg, 
1a00: 6d 64 35 5f 62 6c 6f 63 6b 5f 73 69 7a 65 29 3b  md5_block_size);
1a10: 0a 09 09 09 61 6c 69 67 6e 65 64 5f 6d 65 73 73  ....aligned_mess
1a20: 61 67 65 5f 62 6c 6f 63 6b 20 3d 20 63 74 78 2d  age_block = ctx-
1a30: 3e 6d 65 73 73 61 67 65 3b 0a 09 09 7d 0a 0a 09  >message;...}...
1a40: 09 72 68 61 73 68 5f 6d 64 35 5f 70 72 6f 63 65  .rhash_md5_proce
1a50: 73 73 5f 62 6c 6f 63 6b 28 63 74 78 2d 3e 68 61  ss_block(ctx->ha
1a60: 73 68 2c 20 61 6c 69 67 6e 65 64 5f 6d 65 73 73  sh, aligned_mess
1a70: 61 67 65 5f 62 6c 6f 63 6b 29 3b 0a 09 09 6d 73  age_block);...ms
1a80: 67 20 20 2b 3d 20 6d 64 35 5f 62 6c 6f 63 6b 5f  g  += md5_block_
1a90: 73 69 7a 65 3b 0a 09 09 73 69 7a 65 20 2d 3d 20  size;...size -= 
1aa0: 6d 64 35 5f 62 6c 6f 63 6b 5f 73 69 7a 65 3b 0a  md5_block_size;.
1ab0: 09 7d 0a 09 69 66 20 28 73 69 7a 65 29 20 7b 0a  .}..if (size) {.
1ac0: 09 09 2f 2a 20 73 61 76 65 20 6c 65 66 74 6f 76  ../* save leftov
1ad0: 65 72 73 20 2a 2f 0a 09 09 6c 65 33 32 5f 63 6f  ers */...le32_co
1ae0: 70 79 28 63 74 78 2d 3e 6d 65 73 73 61 67 65 2c  py(ctx->message,
1af0: 20 30 2c 20 6d 73 67 2c 20 73 69 7a 65 29 3b 0a   0, msg, size);.
1b00: 09 7d 0a 7d 0a 0a 2f 2a 2a 0a 20 2a 20 53 74 6f  .}.}../**. * Sto
1b10: 72 65 20 63 61 6c 63 75 6c 61 74 65 64 20 68 61  re calculated ha
1b20: 73 68 20 69 6e 74 6f 20 74 68 65 20 67 69 76 65  sh into the give
1b30: 6e 20 61 72 72 61 79 2e 0a 20 2a 0a 20 2a 20 40  n array.. *. * @
1b40: 70 61 72 61 6d 20 63 74 78 20 74 68 65 20 61 6c  param ctx the al
1b50: 67 6f 72 69 74 68 6d 20 63 6f 6e 74 65 78 74 20  gorithm context 
1b60: 63 6f 6e 74 61 69 6e 69 6e 67 20 63 75 72 72 65  containing curre
1b70: 6e 74 20 68 61 73 68 69 6e 67 20 73 74 61 74 65  nt hashing state
1b80: 0a 20 2a 20 40 70 61 72 61 6d 20 72 65 73 75 6c  . * @param resul
1b90: 74 20 63 61 6c 63 75 6c 61 74 65 64 20 68 61 73  t calculated has
1ba0: 68 20 69 6e 20 62 69 6e 61 72 79 20 66 6f 72 6d  h in binary form
1bb0: 0a 20 2a 2f 0a 76 6f 69 64 20 72 68 61 73 68 5f  . */.void rhash_
1bc0: 6d 64 35 5f 66 69 6e 61 6c 28 6d 64 35 5f 63 74  md5_final(md5_ct
1bd0: 78 20 2a 63 74 78 2c 20 75 6e 73 69 67 6e 65 64  x *ctx, unsigned
1be0: 20 63 68 61 72 2a 20 72 65 73 75 6c 74 29 0a 7b   char* result).{
1bf0: 0a 09 75 6e 73 69 67 6e 65 64 20 69 6e 64 65 78  ..unsigned index
1c00: 20 3d 20 28 28 75 6e 73 69 67 6e 65 64 29 63 74   = ((unsigned)ct
1c10: 78 2d 3e 6c 65 6e 67 74 68 20 26 20 36 33 29 20  x->length & 63) 
1c20: 3e 3e 20 32 3b 0a 09 75 6e 73 69 67 6e 65 64 20  >> 2;..unsigned 
1c30: 73 68 69 66 74 20 3d 20 28 28 75 6e 73 69 67 6e  shift = ((unsign
1c40: 65 64 29 63 74 78 2d 3e 6c 65 6e 67 74 68 20 26  ed)ctx->length &
1c50: 20 33 29 20 2a 20 38 3b 0a 0a 09 2f 2a 20 70 61   3) * 8;.../* pa
1c60: 64 20 6d 65 73 73 61 67 65 20 61 6e 64 20 72 75  d message and ru
1c70: 6e 20 66 6f 72 20 6c 61 73 74 20 62 6c 6f 63 6b  n for last block
1c80: 20 2a 2f 0a 0a 09 2f 2a 20 61 70 70 65 6e 64 20   */.../* append 
1c90: 74 68 65 20 62 79 74 65 20 30 78 38 30 20 74 6f  the byte 0x80 to
1ca0: 20 74 68 65 20 6d 65 73 73 61 67 65 20 2a 2f 0a   the message */.
1cb0: 09 63 74 78 2d 3e 6d 65 73 73 61 67 65 5b 69 6e  .ctx->message[in
1cc0: 64 65 78 5d 20 20 20 26 3d 20 7e 28 30 78 46 46  dex]   &= ~(0xFF
1cd0: 46 46 46 46 46 46 75 20 3c 3c 20 73 68 69 66 74  FFFFFFu << shift
1ce0: 29 3b 0a 09 63 74 78 2d 3e 6d 65 73 73 61 67 65  );..ctx->message
1cf0: 5b 69 6e 64 65 78 2b 2b 5d 20 5e 3d 20 30 78 38  [index++] ^= 0x8
1d00: 30 75 20 3c 3c 20 73 68 69 66 74 3b 0a 0a 09 2f  0u << shift;.../
1d10: 2a 20 69 66 20 6e 6f 20 72 6f 6f 6d 20 6c 65 66  * if no room lef
1d20: 74 20 69 6e 20 74 68 65 20 6d 65 73 73 61 67 65  t in the message
1d30: 20 74 6f 20 73 74 6f 72 65 20 36 34 2d 62 69 74   to store 64-bit
1d40: 20 6d 65 73 73 61 67 65 20 6c 65 6e 67 74 68 20   message length 
1d50: 2a 2f 0a 09 69 66 20 28 69 6e 64 65 78 20 3e 20  */..if (index > 
1d60: 31 34 29 20 7b 0a 09 09 2f 2a 20 74 68 65 6e 20  14) {.../* then 
1d70: 66 69 6c 6c 20 74 68 65 20 72 65 73 74 20 77 69  fill the rest wi
1d80: 74 68 20 7a 65 72 6f 73 20 61 6e 64 20 70 72 6f  th zeros and pro
1d90: 63 65 73 73 20 69 74 20 2a 2f 0a 09 09 77 68 69  cess it */...whi
1da0: 6c 65 20 28 69 6e 64 65 78 20 3c 20 31 36 29 20  le (index < 16) 
1db0: 7b 0a 09 09 09 63 74 78 2d 3e 6d 65 73 73 61 67  {....ctx->messag
1dc0: 65 5b 69 6e 64 65 78 2b 2b 5d 20 3d 20 30 3b 0a  e[index++] = 0;.
1dd0: 09 09 7d 0a 09 09 72 68 61 73 68 5f 6d 64 35 5f  ..}...rhash_md5_
1de0: 70 72 6f 63 65 73 73 5f 62 6c 6f 63 6b 28 63 74  process_block(ct
1df0: 78 2d 3e 68 61 73 68 2c 20 63 74 78 2d 3e 6d 65  x->hash, ctx->me
1e00: 73 73 61 67 65 29 3b 0a 09 09 69 6e 64 65 78 20  ssage);...index 
1e10: 3d 20 30 3b 0a 09 7d 0a 09 77 68 69 6c 65 20 28  = 0;..}..while (
1e20: 69 6e 64 65 78 20 3c 20 31 34 29 20 7b 0a 09 09  index < 14) {...
1e30: 63 74 78 2d 3e 6d 65 73 73 61 67 65 5b 69 6e 64  ctx->message[ind
1e40: 65 78 2b 2b 5d 20 3d 20 30 3b 0a 09 7d 0a 09 63  ex++] = 0;..}..c
1e50: 74 78 2d 3e 6d 65 73 73 61 67 65 5b 31 34 5d 20  tx->message[14] 
1e60: 3d 20 28 75 6e 73 69 67 6e 65 64 29 28 63 74 78  = (unsigned)(ctx
1e70: 2d 3e 6c 65 6e 67 74 68 20 3c 3c 20 33 29 3b 0a  ->length << 3);.
1e80: 09 63 74 78 2d 3e 6d 65 73 73 61 67 65 5b 31 35  .ctx->message[15
1e90: 5d 20 3d 20 28 75 6e 73 69 67 6e 65 64 29 28 63  ] = (unsigned)(c
1ea0: 74 78 2d 3e 6c 65 6e 67 74 68 20 3e 3e 20 32 39  tx->length >> 29
1eb0: 29 3b 0a 09 72 68 61 73 68 5f 6d 64 35 5f 70 72  );..rhash_md5_pr
1ec0: 6f 63 65 73 73 5f 62 6c 6f 63 6b 28 63 74 78 2d  ocess_block(ctx-
1ed0: 3e 68 61 73 68 2c 20 63 74 78 2d 3e 6d 65 73 73  >hash, ctx->mess
1ee0: 61 67 65 29 3b 0a 0a 09 69 66 20 28 72 65 73 75  age);...if (resu
1ef0: 6c 74 29 20 6c 65 33 32 5f 63 6f 70 79 28 72 65  lt) le32_copy(re
1f00: 73 75 6c 74 2c 20 30 2c 20 26 63 74 78 2d 3e 68  sult, 0, &ctx->h
1f10: 61 73 68 2c 20 31 36 29 3b 0a 7d 0a              ash, 16);.}.