md5.hpp 16 KB

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