md5.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.haxx.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. ***************************************************************************/
  22. #include "curl_setup.h"
  23. #ifndef CURL_DISABLE_CRYPTO_AUTH
  24. #include "curl_md5.h"
  25. #include "curl_hmac.h"
  26. #include "warnless.h"
  27. #if defined(USE_GNUTLS_NETTLE)
  28. #include <nettle/md5.h>
  29. #include "curl_memory.h"
  30. /* The last #include file should be: */
  31. #include "memdebug.h"
  32. typedef struct md5_ctx MD5_CTX;
  33. static void MD5_Init(MD5_CTX * ctx)
  34. {
  35. md5_init(ctx);
  36. }
  37. static void MD5_Update(MD5_CTX * ctx,
  38. const unsigned char * input,
  39. unsigned int inputLen)
  40. {
  41. md5_update(ctx, inputLen, input);
  42. }
  43. static void MD5_Final(unsigned char digest[16], MD5_CTX * ctx)
  44. {
  45. md5_digest(ctx, 16, digest);
  46. }
  47. #elif defined(USE_GNUTLS)
  48. #include <gcrypt.h>
  49. #include "curl_memory.h"
  50. /* The last #include file should be: */
  51. #include "memdebug.h"
  52. typedef gcry_md_hd_t MD5_CTX;
  53. static void MD5_Init(MD5_CTX * ctx)
  54. {
  55. gcry_md_open(ctx, GCRY_MD_MD5, 0);
  56. }
  57. static void MD5_Update(MD5_CTX * ctx,
  58. const unsigned char * input,
  59. unsigned int inputLen)
  60. {
  61. gcry_md_write(*ctx, input, inputLen);
  62. }
  63. static void MD5_Final(unsigned char digest[16], MD5_CTX * ctx)
  64. {
  65. memcpy(digest, gcry_md_read(*ctx, 0), 16);
  66. gcry_md_close(*ctx);
  67. }
  68. #elif defined(USE_OPENSSL)
  69. /* When OpenSSL is available we use the MD5-function from OpenSSL */
  70. #include <openssl/md5.h>
  71. #include "curl_memory.h"
  72. /* The last #include file should be: */
  73. #include "memdebug.h"
  74. #elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \
  75. (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040)) || \
  76. (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \
  77. (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000))
  78. /* For Apple operating systems: CommonCrypto has the functions we need.
  79. These functions are available on Tiger and later, as well as iOS 2.0
  80. and later. If you're building for an older cat, well, sorry.
  81. Declaring the functions as static like this seems to be a bit more
  82. reliable than defining COMMON_DIGEST_FOR_OPENSSL on older cats. */
  83. # include <CommonCrypto/CommonDigest.h>
  84. # define MD5_CTX CC_MD5_CTX
  85. #include "curl_memory.h"
  86. /* The last #include file should be: */
  87. #include "memdebug.h"
  88. static void MD5_Init(MD5_CTX *ctx)
  89. {
  90. CC_MD5_Init(ctx);
  91. }
  92. static void MD5_Update(MD5_CTX *ctx,
  93. const unsigned char *input,
  94. unsigned int inputLen)
  95. {
  96. CC_MD5_Update(ctx, input, inputLen);
  97. }
  98. static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
  99. {
  100. CC_MD5_Final(digest, ctx);
  101. }
  102. #elif defined(_WIN32)
  103. #include <wincrypt.h>
  104. #include "curl_memory.h"
  105. /* The last #include file should be: */
  106. #include "memdebug.h"
  107. typedef struct {
  108. HCRYPTPROV hCryptProv;
  109. HCRYPTHASH hHash;
  110. } MD5_CTX;
  111. static void MD5_Init(MD5_CTX *ctx)
  112. {
  113. if(CryptAcquireContext(&ctx->hCryptProv, NULL, NULL,
  114. PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
  115. CryptCreateHash(ctx->hCryptProv, CALG_MD5, 0, 0, &ctx->hHash);
  116. }
  117. }
  118. static void MD5_Update(MD5_CTX *ctx,
  119. const unsigned char *input,
  120. unsigned int inputLen)
  121. {
  122. CryptHashData(ctx->hHash, (unsigned char *)input, inputLen, 0);
  123. }
  124. static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
  125. {
  126. unsigned long length = 0;
  127. CryptGetHashParam(ctx->hHash, HP_HASHVAL, NULL, &length, 0);
  128. if(length == 16)
  129. CryptGetHashParam(ctx->hHash, HP_HASHVAL, digest, &length, 0);
  130. if(ctx->hHash)
  131. CryptDestroyHash(ctx->hHash);
  132. if(ctx->hCryptProv)
  133. CryptReleaseContext(ctx->hCryptProv, 0);
  134. }
  135. #elif defined(USE_AXTLS)
  136. #include <axTLS/config.h>
  137. #include <axTLS/os_int.h>
  138. #include <axTLS/crypto.h>
  139. #include "curl_memory.h"
  140. /* The last #include file should be: */
  141. #include "memdebug.h"
  142. #else
  143. /* When no other crypto library is available we use this code segment */
  144. /*
  145. * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
  146. * MD5 Message-Digest Algorithm (RFC 1321).
  147. *
  148. * Homepage:
  149. http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
  150. *
  151. * Author:
  152. * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
  153. *
  154. * This software was written by Alexander Peslyak in 2001. No copyright is
  155. * claimed, and the software is hereby placed in the public domain.
  156. * In case this attempt to disclaim copyright and place the software in the
  157. * public domain is deemed null and void, then the software is
  158. * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
  159. * general public under the following terms:
  160. *
  161. * Redistribution and use in source and binary forms, with or without
  162. * modification, are permitted.
  163. *
  164. * There's ABSOLUTELY NO WARRANTY, express or implied.
  165. *
  166. * (This is a heavily cut-down "BSD license".)
  167. *
  168. * This differs from Colin Plumb's older public domain implementation in that
  169. * no exactly 32-bit integer data type is required (any 32-bit or wider
  170. * unsigned integer data type will do), there's no compile-time endianness
  171. * configuration, and the function prototypes match OpenSSL's. No code from
  172. * Colin Plumb's implementation has been reused; this comment merely compares
  173. * the properties of the two independent implementations.
  174. *
  175. * The primary goals of this implementation are portability and ease of use.
  176. * It is meant to be fast, but not as fast as possible. Some known
  177. * optimizations are not included to reduce source code size and avoid
  178. * compile-time configuration.
  179. */
  180. #include <string.h>
  181. /* The last #include files should be: */
  182. #include "curl_memory.h"
  183. #include "memdebug.h"
  184. /* Any 32-bit or wider unsigned integer data type will do */
  185. typedef unsigned int MD5_u32plus;
  186. typedef struct {
  187. MD5_u32plus lo, hi;
  188. MD5_u32plus a, b, c, d;
  189. unsigned char buffer[64];
  190. MD5_u32plus block[16];
  191. } MD5_CTX;
  192. static void MD5_Init(MD5_CTX *ctx);
  193. static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
  194. static void MD5_Final(unsigned char *result, MD5_CTX *ctx);
  195. /*
  196. * The basic MD5 functions.
  197. *
  198. * F and G are optimized compared to their RFC 1321 definitions for
  199. * architectures that lack an AND-NOT instruction, just like in Colin Plumb's
  200. * implementation.
  201. */
  202. #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  203. #define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
  204. #define H(x, y, z) (((x) ^ (y)) ^ (z))
  205. #define H2(x, y, z) ((x) ^ ((y) ^ (z)))
  206. #define I(x, y, z) ((y) ^ ((x) | ~(z)))
  207. /*
  208. * The MD5 transformation for all four rounds.
  209. */
  210. #define STEP(f, a, b, c, d, x, t, s) \
  211. (a) += f((b), (c), (d)) + (x) + (t); \
  212. (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
  213. (a) += (b);
  214. /*
  215. * SET reads 4 input bytes in little-endian byte order and stores them
  216. * in a properly aligned word in host byte order.
  217. *
  218. * The check for little-endian architectures that tolerate unaligned
  219. * memory accesses is just an optimization. Nothing will break if it
  220. * doesn't work.
  221. */
  222. #if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
  223. #define SET(n) \
  224. (*(MD5_u32plus *)&ptr[(n) * 4])
  225. #define GET(n) \
  226. SET(n)
  227. #else
  228. #define SET(n) \
  229. (ctx->block[(n)] = \
  230. (MD5_u32plus)ptr[(n) * 4] | \
  231. ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
  232. ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
  233. ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
  234. #define GET(n) \
  235. (ctx->block[(n)])
  236. #endif
  237. /*
  238. * This processes one or more 64-byte data blocks, but does NOT update
  239. * the bit counters. There are no alignment requirements.
  240. */
  241. static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
  242. {
  243. const unsigned char *ptr;
  244. MD5_u32plus a, b, c, d;
  245. MD5_u32plus saved_a, saved_b, saved_c, saved_d;
  246. ptr = (const unsigned char *)data;
  247. a = ctx->a;
  248. b = ctx->b;
  249. c = ctx->c;
  250. d = ctx->d;
  251. do {
  252. saved_a = a;
  253. saved_b = b;
  254. saved_c = c;
  255. saved_d = d;
  256. /* Round 1 */
  257. STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)
  258. STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
  259. STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
  260. STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
  261. STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
  262. STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
  263. STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
  264. STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
  265. STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
  266. STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
  267. STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
  268. STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
  269. STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
  270. STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
  271. STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
  272. STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)
  273. /* Round 2 */
  274. STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
  275. STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
  276. STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
  277. STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
  278. STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
  279. STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
  280. STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
  281. STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
  282. STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
  283. STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
  284. STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
  285. STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
  286. STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
  287. STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
  288. STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
  289. STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)
  290. /* Round 3 */
  291. STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
  292. STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11)
  293. STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
  294. STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23)
  295. STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
  296. STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11)
  297. STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
  298. STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23)
  299. STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
  300. STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11)
  301. STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
  302. STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23)
  303. STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
  304. STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11)
  305. STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
  306. STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23)
  307. /* Round 4 */
  308. STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
  309. STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
  310. STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
  311. STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
  312. STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
  313. STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
  314. STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
  315. STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
  316. STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
  317. STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
  318. STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
  319. STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
  320. STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
  321. STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
  322. STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
  323. STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)
  324. a += saved_a;
  325. b += saved_b;
  326. c += saved_c;
  327. d += saved_d;
  328. ptr += 64;
  329. } while(size -= 64);
  330. ctx->a = a;
  331. ctx->b = b;
  332. ctx->c = c;
  333. ctx->d = d;
  334. return ptr;
  335. }
  336. static void MD5_Init(MD5_CTX *ctx)
  337. {
  338. ctx->a = 0x67452301;
  339. ctx->b = 0xefcdab89;
  340. ctx->c = 0x98badcfe;
  341. ctx->d = 0x10325476;
  342. ctx->lo = 0;
  343. ctx->hi = 0;
  344. }
  345. static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
  346. {
  347. MD5_u32plus saved_lo;
  348. unsigned long used, available;
  349. saved_lo = ctx->lo;
  350. if((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
  351. ctx->hi++;
  352. ctx->hi += (MD5_u32plus)size >> 29;
  353. used = saved_lo & 0x3f;
  354. if(used) {
  355. available = 64 - used;
  356. if(size < available) {
  357. memcpy(&ctx->buffer[used], data, size);
  358. return;
  359. }
  360. memcpy(&ctx->buffer[used], data, available);
  361. data = (const unsigned char *)data + available;
  362. size -= available;
  363. body(ctx, ctx->buffer, 64);
  364. }
  365. if(size >= 64) {
  366. data = body(ctx, data, size & ~(unsigned long)0x3f);
  367. size &= 0x3f;
  368. }
  369. memcpy(ctx->buffer, data, size);
  370. }
  371. static void MD5_Final(unsigned char *result, MD5_CTX *ctx)
  372. {
  373. unsigned long used, available;
  374. used = ctx->lo & 0x3f;
  375. ctx->buffer[used++] = 0x80;
  376. available = 64 - used;
  377. if(available < 8) {
  378. memset(&ctx->buffer[used], 0, available);
  379. body(ctx, ctx->buffer, 64);
  380. used = 0;
  381. available = 64;
  382. }
  383. memset(&ctx->buffer[used], 0, available - 8);
  384. ctx->lo <<= 3;
  385. ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff);
  386. ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff);
  387. ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff);
  388. ctx->buffer[59] = curlx_ultouc(ctx->lo >> 24);
  389. ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff);
  390. ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff);
  391. ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff);
  392. ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24);
  393. body(ctx, ctx->buffer, 64);
  394. result[0] = curlx_ultouc((ctx->a)&0xff);
  395. result[1] = curlx_ultouc((ctx->a >> 8)&0xff);
  396. result[2] = curlx_ultouc((ctx->a >> 16)&0xff);
  397. result[3] = curlx_ultouc(ctx->a >> 24);
  398. result[4] = curlx_ultouc((ctx->b)&0xff);
  399. result[5] = curlx_ultouc((ctx->b >> 8)&0xff);
  400. result[6] = curlx_ultouc((ctx->b >> 16)&0xff);
  401. result[7] = curlx_ultouc(ctx->b >> 24);
  402. result[8] = curlx_ultouc((ctx->c)&0xff);
  403. result[9] = curlx_ultouc((ctx->c >> 8)&0xff);
  404. result[10] = curlx_ultouc((ctx->c >> 16)&0xff);
  405. result[11] = curlx_ultouc(ctx->c >> 24);
  406. result[12] = curlx_ultouc((ctx->d)&0xff);
  407. result[13] = curlx_ultouc((ctx->d >> 8)&0xff);
  408. result[14] = curlx_ultouc((ctx->d >> 16)&0xff);
  409. result[15] = curlx_ultouc(ctx->d >> 24);
  410. memset(ctx, 0, sizeof(*ctx));
  411. }
  412. #endif /* CRYPTO LIBS */
  413. const HMAC_params Curl_HMAC_MD5[] = {
  414. {
  415. (HMAC_hinit_func) MD5_Init, /* Hash initialization function. */
  416. (HMAC_hupdate_func) MD5_Update, /* Hash update function. */
  417. (HMAC_hfinal_func) MD5_Final, /* Hash computation end function. */
  418. sizeof(MD5_CTX), /* Size of hash context structure. */
  419. 64, /* Maximum key length. */
  420. 16 /* Result size. */
  421. }
  422. };
  423. const MD5_params Curl_DIGEST_MD5[] = {
  424. {
  425. (Curl_MD5_init_func) MD5_Init, /* Digest initialization function */
  426. (Curl_MD5_update_func) MD5_Update, /* Digest update function */
  427. (Curl_MD5_final_func) MD5_Final, /* Digest computation end function */
  428. sizeof(MD5_CTX), /* Size of digest context struct */
  429. 16 /* Result size */
  430. }
  431. };
  432. /*
  433. * @unittest: 1601
  434. */
  435. void Curl_md5it(unsigned char *outbuffer, /* 16 bytes */
  436. const unsigned char *input)
  437. {
  438. MD5_CTX ctx;
  439. MD5_Init(&ctx);
  440. MD5_Update(&ctx, input, curlx_uztoui(strlen((char *)input)));
  441. MD5_Final(outbuffer, &ctx);
  442. }
  443. MD5_context *Curl_MD5_init(const MD5_params *md5params)
  444. {
  445. MD5_context *ctxt;
  446. /* Create MD5 context */
  447. ctxt = malloc(sizeof *ctxt);
  448. if(!ctxt)
  449. return ctxt;
  450. ctxt->md5_hashctx = malloc(md5params->md5_ctxtsize);
  451. if(!ctxt->md5_hashctx) {
  452. free(ctxt);
  453. return NULL;
  454. }
  455. ctxt->md5_hash = md5params;
  456. (*md5params->md5_init_func)(ctxt->md5_hashctx);
  457. return ctxt;
  458. }
  459. int Curl_MD5_update(MD5_context *context,
  460. const unsigned char *data,
  461. unsigned int len)
  462. {
  463. (*context->md5_hash->md5_update_func)(context->md5_hashctx, data, len);
  464. return 0;
  465. }
  466. int Curl_MD5_final(MD5_context *context, unsigned char *result)
  467. {
  468. (*context->md5_hash->md5_final_func)(result, context->md5_hashctx);
  469. free(context->md5_hashctx);
  470. free(context);
  471. return 0;
  472. }
  473. #endif /* CURL_DISABLE_CRYPTO_AUTH */