md5.hpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /*
  2. * This RFC 1321 compatible MD5 implementation originated at:
  3. * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
  4. *
  5. * Author:
  6. * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
  7. *
  8. * This software was written by Alexander Peslyak in 2001. No copyright is
  9. * claimed, and the software is hereby placed in the public domain.
  10. * In case this attempt to disclaim copyright and place the software in the
  11. * public domain is deemed null and void, then the software is
  12. * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
  13. * general public under the following terms:
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted.
  17. *
  18. * There's ABSOLUTELY NO WARRANTY, express or implied.
  19. *
  20. */
  21. // Distributed under the Boost Software License, Version 1.0. (See
  22. // accompanying file LICENSE_1_0.txt or copy at
  23. // http://www.boost.org/LICENSE_1_0.txt)
  24. #ifndef BOOST_UUID_MD5_HPP
  25. #define BOOST_UUID_MD5_HPP
  26. #include <boost/cast.hpp>
  27. #include <boost/config.hpp>
  28. #include <boost/cstdint.hpp>
  29. #include <boost/uuid/uuid.hpp> // for version
  30. #include <string.h>
  31. namespace boost {
  32. namespace uuids {
  33. namespace detail {
  34. class md5
  35. {
  36. public:
  37. typedef unsigned int(digest_type)[4];
  38. md5()
  39. {
  40. MD5_Init(&ctx_);
  41. }
  42. void process_byte(unsigned char byte)
  43. {
  44. MD5_Update(&ctx_, &byte, 1);
  45. }
  46. void process_bytes(void const* buffer, std::size_t byte_count)
  47. {
  48. MD5_Update(&ctx_, buffer, boost::numeric_cast<unsigned long>(byte_count));
  49. }
  50. void get_digest(digest_type& digest)
  51. {
  52. MD5_Final(reinterpret_cast<unsigned char *>(&digest[0]), &ctx_);
  53. }
  54. unsigned char get_version() const
  55. {
  56. // RFC 4122 Section 4.1.3
  57. return uuid::version_name_based_md5;
  58. }
  59. private:
  60. /* Any 32-bit or wider unsigned integer data type will do */
  61. typedef uint32_t MD5_u32plus;
  62. typedef struct {
  63. MD5_u32plus lo, hi;
  64. MD5_u32plus a, b, c, d;
  65. unsigned char buffer[64];
  66. MD5_u32plus block[16];
  67. } MD5_CTX;
  68. /*
  69. * The basic MD5 functions.
  70. *
  71. * F and G are optimized compared to their RFC 1321 definitions for
  72. * architectures that lack an AND-NOT instruction, just like in Colin Plumb's
  73. * implementation.
  74. */
  75. BOOST_FORCEINLINE MD5_u32plus BOOST_UUID_DETAIL_MD5_F(MD5_u32plus x, MD5_u32plus y, MD5_u32plus z) { return ((z) ^ ((x) & ((y) ^ (z)))); }
  76. BOOST_FORCEINLINE MD5_u32plus BOOST_UUID_DETAIL_MD5_G(MD5_u32plus x, MD5_u32plus y, MD5_u32plus z) { return ((y) ^ ((z) & ((x) ^ (y)))); }
  77. BOOST_FORCEINLINE MD5_u32plus BOOST_UUID_DETAIL_MD5_H(MD5_u32plus x, MD5_u32plus y, MD5_u32plus z) { return (((x) ^ (y)) ^ (z)); }
  78. BOOST_FORCEINLINE MD5_u32plus BOOST_UUID_DETAIL_MD5_H2(MD5_u32plus x, MD5_u32plus y, MD5_u32plus z) { return ((x) ^ ((y) ^ (z))); }
  79. BOOST_FORCEINLINE MD5_u32plus BOOST_UUID_DETAIL_MD5_I(MD5_u32plus x, MD5_u32plus y, MD5_u32plus z) { return ((y) ^ ((x) | ~(z))); }
  80. /*
  81. * The MD5 transformation for all four rounds.
  82. */
  83. #define BOOST_UUID_DETAIL_MD5_STEP(f, a, b, c, d, x, t, s) \
  84. (a) += f((b), (c), (d)) + (x) + (t); \
  85. (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
  86. (a) += (b);
  87. /*
  88. * SET reads 4 input bytes in little-endian byte order and stores them in a
  89. * properly aligned word in host byte order.
  90. *
  91. * The check for little-endian architectures that tolerate unaligned memory
  92. * accesses is just an optimization. Nothing will break if it fails to detect
  93. * a suitable architecture.
  94. *
  95. * Unfortunately, this optimization may be a C strict aliasing rules violation
  96. * if the caller's data buffer has effective type that cannot be aliased by
  97. * MD5_u32plus. In practice, this problem may occur if these MD5 routines are
  98. * inlined into a calling function, or with future and dangerously advanced
  99. * link-time optimizations. For the time being, keeping these MD5 routines in
  100. * their own translation unit avoids the problem.
  101. */
  102. #if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
  103. #define BOOST_UUID_DETAIL_MD5_SET(n) \
  104. (*(MD5_u32plus *)&ptr[(n) * 4])
  105. #define BOOST_UUID_DETAIL_MD5_GET(n) \
  106. BOOST_UUID_DETAIL_MD5_SET(n)
  107. #else
  108. #define BOOST_UUID_DETAIL_MD5_SET(n) \
  109. (ctx->block[(n)] = \
  110. (MD5_u32plus)ptr[(n) * 4] | \
  111. ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
  112. ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
  113. ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
  114. #define BOOST_UUID_DETAIL_MD5_GET(n) \
  115. (ctx->block[(n)])
  116. #endif
  117. /*
  118. * This processes one or more 64-byte data blocks, but does NOT update the bit
  119. * counters. There are no alignment requirements.
  120. */
  121. const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
  122. {
  123. const unsigned char *ptr;
  124. MD5_u32plus a, b, c, d;
  125. MD5_u32plus saved_a, saved_b, saved_c, saved_d;
  126. ptr = (const unsigned char *)data;
  127. a = ctx->a;
  128. b = ctx->b;
  129. c = ctx->c;
  130. d = ctx->d;
  131. do {
  132. saved_a = a;
  133. saved_b = b;
  134. saved_c = c;
  135. saved_d = d;
  136. /* Round 1 */
  137. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, a, b, c, d, BOOST_UUID_DETAIL_MD5_SET(0), 0xd76aa478, 7)
  138. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, d, a, b, c, BOOST_UUID_DETAIL_MD5_SET(1), 0xe8c7b756, 12)
  139. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, c, d, a, b, BOOST_UUID_DETAIL_MD5_SET(2), 0x242070db, 17)
  140. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, b, c, d, a, BOOST_UUID_DETAIL_MD5_SET(3), 0xc1bdceee, 22)
  141. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, a, b, c, d, BOOST_UUID_DETAIL_MD5_SET(4), 0xf57c0faf, 7)
  142. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, d, a, b, c, BOOST_UUID_DETAIL_MD5_SET(5), 0x4787c62a, 12)
  143. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, c, d, a, b, BOOST_UUID_DETAIL_MD5_SET(6), 0xa8304613, 17)
  144. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, b, c, d, a, BOOST_UUID_DETAIL_MD5_SET(7), 0xfd469501, 22)
  145. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, a, b, c, d, BOOST_UUID_DETAIL_MD5_SET(8), 0x698098d8, 7)
  146. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, d, a, b, c, BOOST_UUID_DETAIL_MD5_SET(9), 0x8b44f7af, 12)
  147. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, c, d, a, b, BOOST_UUID_DETAIL_MD5_SET(10), 0xffff5bb1, 17)
  148. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, b, c, d, a, BOOST_UUID_DETAIL_MD5_SET(11), 0x895cd7be, 22)
  149. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, a, b, c, d, BOOST_UUID_DETAIL_MD5_SET(12), 0x6b901122, 7)
  150. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, d, a, b, c, BOOST_UUID_DETAIL_MD5_SET(13), 0xfd987193, 12)
  151. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, c, d, a, b, BOOST_UUID_DETAIL_MD5_SET(14), 0xa679438e, 17)
  152. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_F, b, c, d, a, BOOST_UUID_DETAIL_MD5_SET(15), 0x49b40821, 22)
  153. /* Round 2 */
  154. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(1), 0xf61e2562, 5)
  155. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(6), 0xc040b340, 9)
  156. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(11), 0x265e5a51, 14)
  157. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(0), 0xe9b6c7aa, 20)
  158. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(5), 0xd62f105d, 5)
  159. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(10), 0x02441453, 9)
  160. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(15), 0xd8a1e681, 14)
  161. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(4), 0xe7d3fbc8, 20)
  162. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(9), 0x21e1cde6, 5)
  163. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(14), 0xc33707d6, 9)
  164. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(3), 0xf4d50d87, 14)
  165. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(8), 0x455a14ed, 20)
  166. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(13), 0xa9e3e905, 5)
  167. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(2), 0xfcefa3f8, 9)
  168. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(7), 0x676f02d9, 14)
  169. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_G, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(12), 0x8d2a4c8a, 20)
  170. /* Round 3 */
  171. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(5), 0xfffa3942, 4)
  172. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H2, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(8), 0x8771f681, 11)
  173. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(11), 0x6d9d6122, 16)
  174. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H2, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(14), 0xfde5380c, 23)
  175. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(1), 0xa4beea44, 4)
  176. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H2, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(4), 0x4bdecfa9, 11)
  177. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(7), 0xf6bb4b60, 16)
  178. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H2, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(10), 0xbebfbc70, 23)
  179. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(13), 0x289b7ec6, 4)
  180. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H2, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(0), 0xeaa127fa, 11)
  181. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(3), 0xd4ef3085, 16)
  182. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H2, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(6), 0x04881d05, 23)
  183. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(9), 0xd9d4d039, 4)
  184. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H2, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(12), 0xe6db99e5, 11)
  185. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(15), 0x1fa27cf8, 16)
  186. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_H2, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(2), 0xc4ac5665, 23)
  187. /* Round 4 */
  188. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(0), 0xf4292244, 6)
  189. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(7), 0x432aff97, 10)
  190. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(14), 0xab9423a7, 15)
  191. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(5), 0xfc93a039, 21)
  192. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(12), 0x655b59c3, 6)
  193. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(3), 0x8f0ccc92, 10)
  194. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(10), 0xffeff47d, 15)
  195. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(1), 0x85845dd1, 21)
  196. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(8), 0x6fa87e4f, 6)
  197. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(15), 0xfe2ce6e0, 10)
  198. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(6), 0xa3014314, 15)
  199. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(13), 0x4e0811a1, 21)
  200. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, a, b, c, d, BOOST_UUID_DETAIL_MD5_GET(4), 0xf7537e82, 6)
  201. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, d, a, b, c, BOOST_UUID_DETAIL_MD5_GET(11), 0xbd3af235, 10)
  202. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, c, d, a, b, BOOST_UUID_DETAIL_MD5_GET(2), 0x2ad7d2bb, 15)
  203. BOOST_UUID_DETAIL_MD5_STEP(BOOST_UUID_DETAIL_MD5_I, b, c, d, a, BOOST_UUID_DETAIL_MD5_GET(9), 0xeb86d391, 21)
  204. a += saved_a;
  205. b += saved_b;
  206. c += saved_c;
  207. d += saved_d;
  208. ptr += 64;
  209. } while (size -= 64);
  210. ctx->a = a;
  211. ctx->b = b;
  212. ctx->c = c;
  213. ctx->d = d;
  214. return ptr;
  215. }
  216. void MD5_Init(MD5_CTX *ctx)
  217. {
  218. ctx->a = 0x67452301;
  219. ctx->b = 0xefcdab89;
  220. ctx->c = 0x98badcfe;
  221. ctx->d = 0x10325476;
  222. ctx->lo = 0;
  223. ctx->hi = 0;
  224. }
  225. void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
  226. {
  227. MD5_u32plus saved_lo;
  228. unsigned long used, available;
  229. saved_lo = ctx->lo;
  230. if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
  231. ctx->hi++;
  232. ctx->hi += size >> 29;
  233. used = saved_lo & 0x3f;
  234. if (used) {
  235. available = 64 - used;
  236. if (size < available) {
  237. memcpy(&ctx->buffer[used], data, size);
  238. return;
  239. }
  240. memcpy(&ctx->buffer[used], data, available);
  241. data = (const unsigned char *)data + available;
  242. size -= available;
  243. body(ctx, ctx->buffer, 64);
  244. }
  245. if (size >= 64) {
  246. data = body(ctx, data, size & ~(unsigned long)0x3f);
  247. size &= 0x3f;
  248. }
  249. memcpy(ctx->buffer, data, size);
  250. }
  251. #define BOOST_UUID_DETAIL_MD5_OUT(dst, src) \
  252. (dst)[0] = (unsigned char)(src); \
  253. (dst)[1] = (unsigned char)((src) >> 8); \
  254. (dst)[2] = (unsigned char)((src) >> 16); \
  255. (dst)[3] = (unsigned char)((src) >> 24);
  256. void MD5_Final(unsigned char *result, MD5_CTX *ctx)
  257. {
  258. unsigned long used, available;
  259. used = ctx->lo & 0x3f;
  260. ctx->buffer[used++] = 0x80;
  261. available = 64 - used;
  262. if (available < 8) {
  263. memset(&ctx->buffer[used], 0, available);
  264. body(ctx, ctx->buffer, 64);
  265. used = 0;
  266. available = 64;
  267. }
  268. memset(&ctx->buffer[used], 0, available - 8);
  269. ctx->lo <<= 3;
  270. BOOST_UUID_DETAIL_MD5_OUT(&ctx->buffer[56], ctx->lo)
  271. BOOST_UUID_DETAIL_MD5_OUT(&ctx->buffer[60], ctx->hi)
  272. body(ctx, ctx->buffer, 64);
  273. BOOST_UUID_DETAIL_MD5_OUT(&result[0], ctx->a)
  274. BOOST_UUID_DETAIL_MD5_OUT(&result[4], ctx->b)
  275. BOOST_UUID_DETAIL_MD5_OUT(&result[8], ctx->c)
  276. BOOST_UUID_DETAIL_MD5_OUT(&result[12], ctx->d)
  277. memset(ctx, 0, sizeof(*ctx));
  278. }
  279. #undef BOOST_UUID_DETAIL_MD5_OUT
  280. #undef BOOST_UUID_DETAIL_MD5_SET
  281. #undef BOOST_UUID_DETAIL_MD5_GET
  282. #undef BOOST_UUID_DETAIL_MD5_STEP
  283. MD5_CTX ctx_;
  284. };
  285. } // detail
  286. } // uuids
  287. } // boost
  288. #endif // BOOST_UUID_MD5_HPP