archive_crypto.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429
  1. /*-
  2. * Copyright (c) 2003-2007 Tim Kientzle
  3. * Copyright (c) 2011 Andres Mejia
  4. * Copyright (c) 2011 Michihiro NAKAJIMA
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
  17. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19. * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #include "archive_platform.h"
  28. #include "archive.h"
  29. #include "archive_crypto_private.h"
  30. /* In particular, force the configure probe to break if it tries
  31. * to test a combination of OpenSSL and libmd. */
  32. #if defined(ARCHIVE_CRYPTO_OPENSSL) && defined(ARCHIVE_CRYPTO_LIBMD)
  33. #error Cannot use both OpenSSL and libmd.
  34. #endif
  35. /*
  36. * Message digest functions for Windows platform.
  37. */
  38. #if defined(ARCHIVE_CRYPTO_MD5_WIN) ||\
  39. defined(ARCHIVE_CRYPTO_SHA1_WIN) ||\
  40. defined(ARCHIVE_CRYPTO_SHA256_WIN) ||\
  41. defined(ARCHIVE_CRYPTO_SHA384_WIN) ||\
  42. defined(ARCHIVE_CRYPTO_SHA512_WIN)
  43. /*
  44. * Initialize a Message digest.
  45. */
  46. static int
  47. win_crypto_init(Digest_CTX *ctx, ALG_ID algId)
  48. {
  49. ctx->valid = 0;
  50. if (!CryptAcquireContext(&ctx->cryptProv, NULL, NULL,
  51. PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
  52. if (GetLastError() != (DWORD)NTE_BAD_KEYSET)
  53. return (ARCHIVE_FAILED);
  54. if (!CryptAcquireContext(&ctx->cryptProv, NULL, NULL,
  55. PROV_RSA_FULL, CRYPT_NEWKEYSET))
  56. return (ARCHIVE_FAILED);
  57. }
  58. if (!CryptCreateHash(ctx->cryptProv, algId, 0, 0, &ctx->hash)) {
  59. CryptReleaseContext(ctx->cryptProv, 0);
  60. return (ARCHIVE_FAILED);
  61. }
  62. ctx->valid = 1;
  63. return (ARCHIVE_OK);
  64. }
  65. /*
  66. * Update a Message digest.
  67. */
  68. static int
  69. win_crypto_Update(Digest_CTX *ctx, const unsigned char *buf, size_t len)
  70. {
  71. if (!ctx->valid)
  72. return (ARCHIVE_FAILED);
  73. CryptHashData(ctx->hash,
  74. (unsigned char *)(uintptr_t)buf,
  75. (DWORD)len, 0);
  76. return (ARCHIVE_OK);
  77. }
  78. static int
  79. win_crypto_Final(unsigned char *buf, size_t bufsize, Digest_CTX *ctx)
  80. {
  81. DWORD siglen = (DWORD)bufsize;
  82. if (!ctx->valid)
  83. return (ARCHIVE_FAILED);
  84. CryptGetHashParam(ctx->hash, HP_HASHVAL, buf, &siglen, 0);
  85. CryptDestroyHash(ctx->hash);
  86. CryptReleaseContext(ctx->cryptProv, 0);
  87. ctx->valid = 0;
  88. return (ARCHIVE_OK);
  89. }
  90. #endif /* defined(ARCHIVE_CRYPTO_*_WIN) */
  91. /* MD5 implementations */
  92. #if defined(ARCHIVE_CRYPTO_MD5_LIBC)
  93. static int
  94. __archive_libc_md5init(archive_md5_ctx *ctx)
  95. {
  96. MD5Init(ctx);
  97. return (ARCHIVE_OK);
  98. }
  99. static int
  100. __archive_libc_md5update(archive_md5_ctx *ctx, const void *indata,
  101. size_t insize)
  102. {
  103. MD5Update(ctx, indata, insize);
  104. return (ARCHIVE_OK);
  105. }
  106. static int
  107. __archive_libc_md5final(archive_md5_ctx *ctx, void *md)
  108. {
  109. MD5Final(md, ctx);
  110. return (ARCHIVE_OK);
  111. }
  112. #elif defined(ARCHIVE_CRYPTO_MD5_LIBMD)
  113. static int
  114. __archive_libmd_md5init(archive_md5_ctx *ctx)
  115. {
  116. MD5Init(ctx);
  117. return (ARCHIVE_OK);
  118. }
  119. static int
  120. __archive_libmd_md5update(archive_md5_ctx *ctx, const void *indata,
  121. size_t insize)
  122. {
  123. MD5Update(ctx, indata, insize);
  124. return (ARCHIVE_OK);
  125. }
  126. static int
  127. __archive_libmd_md5final(archive_md5_ctx *ctx, void *md)
  128. {
  129. MD5Final(md, ctx);
  130. return (ARCHIVE_OK);
  131. }
  132. #elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM)
  133. static int
  134. __archive_libsystem_md5init(archive_md5_ctx *ctx)
  135. {
  136. CC_MD5_Init(ctx);
  137. return (ARCHIVE_OK);
  138. }
  139. static int
  140. __archive_libsystem_md5update(archive_md5_ctx *ctx, const void *indata,
  141. size_t insize)
  142. {
  143. CC_MD5_Update(ctx, indata, insize);
  144. return (ARCHIVE_OK);
  145. }
  146. static int
  147. __archive_libsystem_md5final(archive_md5_ctx *ctx, void *md)
  148. {
  149. CC_MD5_Final(md, ctx);
  150. return (ARCHIVE_OK);
  151. }
  152. #elif defined(ARCHIVE_CRYPTO_MD5_NETTLE)
  153. static int
  154. __archive_nettle_md5init(archive_md5_ctx *ctx)
  155. {
  156. md5_init(ctx);
  157. return (ARCHIVE_OK);
  158. }
  159. static int
  160. __archive_nettle_md5update(archive_md5_ctx *ctx, const void *indata,
  161. size_t insize)
  162. {
  163. md5_update(ctx, insize, indata);
  164. return (ARCHIVE_OK);
  165. }
  166. static int
  167. __archive_nettle_md5final(archive_md5_ctx *ctx, void *md)
  168. {
  169. md5_digest(ctx, MD5_DIGEST_SIZE, md);
  170. return (ARCHIVE_OK);
  171. }
  172. #elif defined(ARCHIVE_CRYPTO_MD5_OPENSSL)
  173. static int
  174. __archive_openssl_md5init(archive_md5_ctx *ctx)
  175. {
  176. EVP_DigestInit(ctx, EVP_md5());
  177. return (ARCHIVE_OK);
  178. }
  179. static int
  180. __archive_openssl_md5update(archive_md5_ctx *ctx, const void *indata,
  181. size_t insize)
  182. {
  183. EVP_DigestUpdate(ctx, indata, insize);
  184. return (ARCHIVE_OK);
  185. }
  186. static int
  187. __archive_openssl_md5final(archive_md5_ctx *ctx, void *md)
  188. {
  189. /* HACK: archive_write_set_format_xar.c is finalizing empty contexts, so
  190. * this is meant to cope with that. Real fix is probably to fix
  191. * archive_write_set_format_xar.c
  192. */
  193. if (ctx->digest)
  194. EVP_DigestFinal(ctx, md, NULL);
  195. return (ARCHIVE_OK);
  196. }
  197. #elif defined(ARCHIVE_CRYPTO_MD5_WIN)
  198. static int
  199. __archive_windowsapi_md5init(archive_md5_ctx *ctx)
  200. {
  201. return (win_crypto_init(ctx, CALG_MD5));
  202. }
  203. static int
  204. __archive_windowsapi_md5update(archive_md5_ctx *ctx, const void *indata,
  205. size_t insize)
  206. {
  207. return (win_crypto_Update(ctx, indata, insize));
  208. }
  209. static int
  210. __archive_windowsapi_md5final(archive_md5_ctx *ctx, void *md)
  211. {
  212. return (win_crypto_Final(md, 16, ctx));
  213. }
  214. #else
  215. static int
  216. __archive_stub_md5init(archive_md5_ctx *ctx)
  217. {
  218. (void)ctx; /* UNUSED */
  219. return (ARCHIVE_FAILED);
  220. }
  221. static int
  222. __archive_stub_md5update(archive_md5_ctx *ctx, const void *indata,
  223. size_t insize)
  224. {
  225. (void)ctx; /* UNUSED */
  226. (void)indata; /* UNUSED */
  227. (void)insize; /* UNUSED */
  228. return (ARCHIVE_FAILED);
  229. }
  230. static int
  231. __archive_stub_md5final(archive_md5_ctx *ctx, void *md)
  232. {
  233. (void)ctx; /* UNUSED */
  234. (void)md; /* UNUSED */
  235. return (ARCHIVE_FAILED);
  236. }
  237. #endif
  238. /* RIPEMD160 implementations */
  239. #if defined(ARCHIVE_CRYPTO_RMD160_LIBC)
  240. static int
  241. __archive_libc_ripemd160init(archive_rmd160_ctx *ctx)
  242. {
  243. RMD160Init(ctx);
  244. return (ARCHIVE_OK);
  245. }
  246. static int
  247. __archive_libc_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
  248. size_t insize)
  249. {
  250. RMD160Update(ctx, indata, insize);
  251. return (ARCHIVE_OK);
  252. }
  253. static int
  254. __archive_libc_ripemd160final(archive_rmd160_ctx *ctx, void *md)
  255. {
  256. RMD160Final(md, ctx);
  257. return (ARCHIVE_OK);
  258. }
  259. #elif defined(ARCHIVE_CRYPTO_RMD160_LIBMD)
  260. static int
  261. __archive_libmd_ripemd160init(archive_rmd160_ctx *ctx)
  262. {
  263. RIPEMD160_Init(ctx);
  264. return (ARCHIVE_OK);
  265. }
  266. static int
  267. __archive_libmd_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
  268. size_t insize)
  269. {
  270. RIPEMD160_Update(ctx, indata, insize);
  271. return (ARCHIVE_OK);
  272. }
  273. static int
  274. __archive_libmd_ripemd160final(archive_rmd160_ctx *ctx, void *md)
  275. {
  276. RIPEMD160_Final(md, ctx);
  277. return (ARCHIVE_OK);
  278. }
  279. #elif defined(ARCHIVE_CRYPTO_RMD160_NETTLE)
  280. static int
  281. __archive_nettle_ripemd160init(archive_rmd160_ctx *ctx)
  282. {
  283. ripemd160_init(ctx);
  284. return (ARCHIVE_OK);
  285. }
  286. static int
  287. __archive_nettle_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
  288. size_t insize)
  289. {
  290. ripemd160_update(ctx, insize, indata);
  291. return (ARCHIVE_OK);
  292. }
  293. static int
  294. __archive_nettle_ripemd160final(archive_rmd160_ctx *ctx, void *md)
  295. {
  296. ripemd160_digest(ctx, RIPEMD160_DIGEST_SIZE, md);
  297. return (ARCHIVE_OK);
  298. }
  299. #elif defined(ARCHIVE_CRYPTO_RMD160_OPENSSL)
  300. static int
  301. __archive_openssl_ripemd160init(archive_rmd160_ctx *ctx)
  302. {
  303. EVP_DigestInit(ctx, EVP_ripemd160());
  304. return (ARCHIVE_OK);
  305. }
  306. static int
  307. __archive_openssl_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
  308. size_t insize)
  309. {
  310. EVP_DigestUpdate(ctx, indata, insize);
  311. return (ARCHIVE_OK);
  312. }
  313. static int
  314. __archive_openssl_ripemd160final(archive_rmd160_ctx *ctx, void *md)
  315. {
  316. EVP_DigestFinal(ctx, md, NULL);
  317. return (ARCHIVE_OK);
  318. }
  319. #else
  320. static int
  321. __archive_stub_ripemd160init(archive_rmd160_ctx *ctx)
  322. {
  323. (void)ctx; /* UNUSED */
  324. return (ARCHIVE_FAILED);
  325. }
  326. static int
  327. __archive_stub_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
  328. size_t insize)
  329. {
  330. (void)ctx; /* UNUSED */
  331. (void)indata; /* UNUSED */
  332. (void)insize; /* UNUSED */
  333. return (ARCHIVE_FAILED);
  334. }
  335. static int
  336. __archive_stub_ripemd160final(archive_rmd160_ctx *ctx, void *md)
  337. {
  338. (void)ctx; /* UNUSED */
  339. (void)md; /* UNUSED */
  340. return (ARCHIVE_FAILED);
  341. }
  342. #endif
  343. /* SHA1 implementations */
  344. #if defined(ARCHIVE_CRYPTO_SHA1_LIBC)
  345. static int
  346. __archive_libc_sha1init(archive_sha1_ctx *ctx)
  347. {
  348. SHA1Init(ctx);
  349. return (ARCHIVE_OK);
  350. }
  351. static int
  352. __archive_libc_sha1update(archive_sha1_ctx *ctx, const void *indata,
  353. size_t insize)
  354. {
  355. SHA1Update(ctx, indata, insize);
  356. return (ARCHIVE_OK);
  357. }
  358. static int
  359. __archive_libc_sha1final(archive_sha1_ctx *ctx, void *md)
  360. {
  361. SHA1Final(md, ctx);
  362. return (ARCHIVE_OK);
  363. }
  364. #elif defined(ARCHIVE_CRYPTO_SHA1_LIBMD)
  365. static int
  366. __archive_libmd_sha1init(archive_sha1_ctx *ctx)
  367. {
  368. SHA1_Init(ctx);
  369. return (ARCHIVE_OK);
  370. }
  371. static int
  372. __archive_libmd_sha1update(archive_sha1_ctx *ctx, const void *indata,
  373. size_t insize)
  374. {
  375. SHA1_Update(ctx, indata, insize);
  376. return (ARCHIVE_OK);
  377. }
  378. static int
  379. __archive_libmd_sha1final(archive_sha1_ctx *ctx, void *md)
  380. {
  381. SHA1_Final(md, ctx);
  382. return (ARCHIVE_OK);
  383. }
  384. #elif defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM)
  385. static int
  386. __archive_libsystem_sha1init(archive_sha1_ctx *ctx)
  387. {
  388. CC_SHA1_Init(ctx);
  389. return (ARCHIVE_OK);
  390. }
  391. static int
  392. __archive_libsystem_sha1update(archive_sha1_ctx *ctx, const void *indata,
  393. size_t insize)
  394. {
  395. CC_SHA1_Update(ctx, indata, insize);
  396. return (ARCHIVE_OK);
  397. }
  398. static int
  399. __archive_libsystem_sha1final(archive_sha1_ctx *ctx, void *md)
  400. {
  401. CC_SHA1_Final(md, ctx);
  402. return (ARCHIVE_OK);
  403. }
  404. #elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE)
  405. static int
  406. __archive_nettle_sha1init(archive_sha1_ctx *ctx)
  407. {
  408. sha1_init(ctx);
  409. return (ARCHIVE_OK);
  410. }
  411. static int
  412. __archive_nettle_sha1update(archive_sha1_ctx *ctx, const void *indata,
  413. size_t insize)
  414. {
  415. sha1_update(ctx, insize, indata);
  416. return (ARCHIVE_OK);
  417. }
  418. static int
  419. __archive_nettle_sha1final(archive_sha1_ctx *ctx, void *md)
  420. {
  421. sha1_digest(ctx, SHA1_DIGEST_SIZE, md);
  422. return (ARCHIVE_OK);
  423. }
  424. #elif defined(ARCHIVE_CRYPTO_SHA1_OPENSSL)
  425. static int
  426. __archive_openssl_sha1init(archive_sha1_ctx *ctx)
  427. {
  428. EVP_DigestInit(ctx, EVP_sha1());
  429. return (ARCHIVE_OK);
  430. }
  431. static int
  432. __archive_openssl_sha1update(archive_sha1_ctx *ctx, const void *indata,
  433. size_t insize)
  434. {
  435. EVP_DigestUpdate(ctx, indata, insize);
  436. return (ARCHIVE_OK);
  437. }
  438. static int
  439. __archive_openssl_sha1final(archive_sha1_ctx *ctx, void *md)
  440. {
  441. /* HACK: archive_write_set_format_xar.c is finalizing empty contexts, so
  442. * this is meant to cope with that. Real fix is probably to fix
  443. * archive_write_set_format_xar.c
  444. */
  445. if (ctx->digest)
  446. EVP_DigestFinal(ctx, md, NULL);
  447. return (ARCHIVE_OK);
  448. }
  449. #elif defined(ARCHIVE_CRYPTO_SHA1_WIN)
  450. static int
  451. __archive_windowsapi_sha1init(archive_sha1_ctx *ctx)
  452. {
  453. return (win_crypto_init(ctx, CALG_SHA1));
  454. }
  455. static int
  456. __archive_windowsapi_sha1update(archive_sha1_ctx *ctx, const void *indata,
  457. size_t insize)
  458. {
  459. return (win_crypto_Update(ctx, indata, insize));
  460. }
  461. static int
  462. __archive_windowsapi_sha1final(archive_sha1_ctx *ctx, void *md)
  463. {
  464. return (win_crypto_Final(md, 20, ctx));
  465. }
  466. #else
  467. static int
  468. __archive_stub_sha1init(archive_sha1_ctx *ctx)
  469. {
  470. (void)ctx; /* UNUSED */
  471. return (ARCHIVE_FAILED);
  472. }
  473. static int
  474. __archive_stub_sha1update(archive_sha1_ctx *ctx, const void *indata,
  475. size_t insize)
  476. {
  477. (void)ctx; /* UNUSED */
  478. (void)indata; /* UNUSED */
  479. (void)insize; /* UNUSED */
  480. return (ARCHIVE_FAILED);
  481. }
  482. static int
  483. __archive_stub_sha1final(archive_sha1_ctx *ctx, void *md)
  484. {
  485. (void)ctx; /* UNUSED */
  486. (void)md; /* UNUSED */
  487. return (ARCHIVE_FAILED);
  488. }
  489. #endif
  490. /* SHA256 implementations */
  491. #if defined(ARCHIVE_CRYPTO_SHA256_LIBC)
  492. static int
  493. __archive_libc_sha256init(archive_sha256_ctx *ctx)
  494. {
  495. SHA256_Init(ctx);
  496. return (ARCHIVE_OK);
  497. }
  498. static int
  499. __archive_libc_sha256update(archive_sha256_ctx *ctx, const void *indata,
  500. size_t insize)
  501. {
  502. SHA256_Update(ctx, indata, insize);
  503. return (ARCHIVE_OK);
  504. }
  505. static int
  506. __archive_libc_sha256final(archive_sha256_ctx *ctx, void *md)
  507. {
  508. SHA256_Final(md, ctx);
  509. return (ARCHIVE_OK);
  510. }
  511. #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC2)
  512. static int
  513. __archive_libc2_sha256init(archive_sha256_ctx *ctx)
  514. {
  515. SHA256Init(ctx);
  516. return (ARCHIVE_OK);
  517. }
  518. static int
  519. __archive_libc2_sha256update(archive_sha256_ctx *ctx, const void *indata,
  520. size_t insize)
  521. {
  522. SHA256Update(ctx, indata, insize);
  523. return (ARCHIVE_OK);
  524. }
  525. static int
  526. __archive_libc2_sha256final(archive_sha256_ctx *ctx, void *md)
  527. {
  528. SHA256Final(md, ctx);
  529. return (ARCHIVE_OK);
  530. }
  531. #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC3)
  532. static int
  533. __archive_libc3_sha256init(archive_sha256_ctx *ctx)
  534. {
  535. SHA256Init(ctx);
  536. return (ARCHIVE_OK);
  537. }
  538. static int
  539. __archive_libc3_sha256update(archive_sha256_ctx *ctx, const void *indata,
  540. size_t insize)
  541. {
  542. SHA256Update(ctx, indata, insize);
  543. return (ARCHIVE_OK);
  544. }
  545. static int
  546. __archive_libc3_sha256final(archive_sha256_ctx *ctx, void *md)
  547. {
  548. SHA256Final(md, ctx);
  549. return (ARCHIVE_OK);
  550. }
  551. #elif defined(ARCHIVE_CRYPTO_SHA256_LIBMD)
  552. static int
  553. __archive_libmd_sha256init(archive_sha256_ctx *ctx)
  554. {
  555. SHA256_Init(ctx);
  556. return (ARCHIVE_OK);
  557. }
  558. static int
  559. __archive_libmd_sha256update(archive_sha256_ctx *ctx, const void *indata,
  560. size_t insize)
  561. {
  562. SHA256_Update(ctx, indata, insize);
  563. return (ARCHIVE_OK);
  564. }
  565. static int
  566. __archive_libmd_sha256final(archive_sha256_ctx *ctx, void *md)
  567. {
  568. SHA256_Final(md, ctx);
  569. return (ARCHIVE_OK);
  570. }
  571. #elif defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM)
  572. static int
  573. __archive_libsystem_sha256init(archive_sha256_ctx *ctx)
  574. {
  575. CC_SHA256_Init(ctx);
  576. return (ARCHIVE_OK);
  577. }
  578. static int
  579. __archive_libsystem_sha256update(archive_sha256_ctx *ctx, const void *indata,
  580. size_t insize)
  581. {
  582. CC_SHA256_Update(ctx, indata, insize);
  583. return (ARCHIVE_OK);
  584. }
  585. static int
  586. __archive_libsystem_sha256final(archive_sha256_ctx *ctx, void *md)
  587. {
  588. CC_SHA256_Final(md, ctx);
  589. return (ARCHIVE_OK);
  590. }
  591. #elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE)
  592. static int
  593. __archive_nettle_sha256init(archive_sha256_ctx *ctx)
  594. {
  595. sha256_init(ctx);
  596. return (ARCHIVE_OK);
  597. }
  598. static int
  599. __archive_nettle_sha256update(archive_sha256_ctx *ctx, const void *indata,
  600. size_t insize)
  601. {
  602. sha256_update(ctx, insize, indata);
  603. return (ARCHIVE_OK);
  604. }
  605. static int
  606. __archive_nettle_sha256final(archive_sha256_ctx *ctx, void *md)
  607. {
  608. sha256_digest(ctx, SHA256_DIGEST_SIZE, md);
  609. return (ARCHIVE_OK);
  610. }
  611. #elif defined(ARCHIVE_CRYPTO_SHA256_OPENSSL)
  612. static int
  613. __archive_openssl_sha256init(archive_sha256_ctx *ctx)
  614. {
  615. EVP_DigestInit(ctx, EVP_sha256());
  616. return (ARCHIVE_OK);
  617. }
  618. static int
  619. __archive_openssl_sha256update(archive_sha256_ctx *ctx, const void *indata,
  620. size_t insize)
  621. {
  622. EVP_DigestUpdate(ctx, indata, insize);
  623. return (ARCHIVE_OK);
  624. }
  625. static int
  626. __archive_openssl_sha256final(archive_sha256_ctx *ctx, void *md)
  627. {
  628. EVP_DigestFinal(ctx, md, NULL);
  629. return (ARCHIVE_OK);
  630. }
  631. #elif defined(ARCHIVE_CRYPTO_SHA256_WIN)
  632. static int
  633. __archive_windowsapi_sha256init(archive_sha256_ctx *ctx)
  634. {
  635. return (win_crypto_init(ctx, CALG_SHA_256));
  636. }
  637. static int
  638. __archive_windowsapi_sha256update(archive_sha256_ctx *ctx, const void *indata,
  639. size_t insize)
  640. {
  641. return (win_crypto_Update(ctx, indata, insize));
  642. }
  643. static int
  644. __archive_windowsapi_sha256final(archive_sha256_ctx *ctx, void *md)
  645. {
  646. return (win_crypto_Final(md, 32, ctx));
  647. }
  648. #else
  649. static int
  650. __archive_stub_sha256init(archive_sha256_ctx *ctx)
  651. {
  652. (void)ctx; /* UNUSED */
  653. return (ARCHIVE_FAILED);
  654. }
  655. static int
  656. __archive_stub_sha256update(archive_sha256_ctx *ctx, const void *indata,
  657. size_t insize)
  658. {
  659. (void)ctx; /* UNUSED */
  660. (void)indata; /* UNUSED */
  661. (void)insize; /* UNUSED */
  662. return (ARCHIVE_FAILED);
  663. }
  664. static int
  665. __archive_stub_sha256final(archive_sha256_ctx *ctx, void *md)
  666. {
  667. (void)ctx; /* UNUSED */
  668. (void)md; /* UNUSED */
  669. return (ARCHIVE_FAILED);
  670. }
  671. #endif
  672. /* SHA384 implementations */
  673. #if defined(ARCHIVE_CRYPTO_SHA384_LIBC)
  674. static int
  675. __archive_libc_sha384init(archive_sha384_ctx *ctx)
  676. {
  677. SHA384_Init(ctx);
  678. return (ARCHIVE_OK);
  679. }
  680. static int
  681. __archive_libc_sha384update(archive_sha384_ctx *ctx, const void *indata,
  682. size_t insize)
  683. {
  684. SHA384_Update(ctx, indata, insize);
  685. return (ARCHIVE_OK);
  686. }
  687. static int
  688. __archive_libc_sha384final(archive_sha384_ctx *ctx, void *md)
  689. {
  690. SHA384_Final(md, ctx);
  691. return (ARCHIVE_OK);
  692. }
  693. #elif defined(ARCHIVE_CRYPTO_SHA384_LIBC2)
  694. static int
  695. __archive_libc2_sha384init(archive_sha384_ctx *ctx)
  696. {
  697. SHA384Init(ctx);
  698. return (ARCHIVE_OK);
  699. }
  700. static int
  701. __archive_libc2_sha384update(archive_sha384_ctx *ctx, const void *indata,
  702. size_t insize)
  703. {
  704. SHA384Update(ctx, indata, insize);
  705. return (ARCHIVE_OK);
  706. }
  707. static int
  708. __archive_libc2_sha384final(archive_sha384_ctx *ctx, void *md)
  709. {
  710. SHA384Final(md, ctx);
  711. return (ARCHIVE_OK);
  712. }
  713. #elif defined(ARCHIVE_CRYPTO_SHA384_LIBC3)
  714. static int
  715. __archive_libc3_sha384init(archive_sha384_ctx *ctx)
  716. {
  717. SHA384Init(ctx);
  718. return (ARCHIVE_OK);
  719. }
  720. static int
  721. __archive_libc3_sha384update(archive_sha384_ctx *ctx, const void *indata,
  722. size_t insize)
  723. {
  724. SHA384Update(ctx, indata, insize);
  725. return (ARCHIVE_OK);
  726. }
  727. static int
  728. __archive_libc3_sha384final(archive_sha384_ctx *ctx, void *md)
  729. {
  730. SHA384Final(md, ctx);
  731. return (ARCHIVE_OK);
  732. }
  733. #elif defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM)
  734. static int
  735. __archive_libsystem_sha384init(archive_sha384_ctx *ctx)
  736. {
  737. CC_SHA384_Init(ctx);
  738. return (ARCHIVE_OK);
  739. }
  740. static int
  741. __archive_libsystem_sha384update(archive_sha384_ctx *ctx, const void *indata,
  742. size_t insize)
  743. {
  744. CC_SHA384_Update(ctx, indata, insize);
  745. return (ARCHIVE_OK);
  746. }
  747. static int
  748. __archive_libsystem_sha384final(archive_sha384_ctx *ctx, void *md)
  749. {
  750. CC_SHA384_Final(md, ctx);
  751. return (ARCHIVE_OK);
  752. }
  753. #elif defined(ARCHIVE_CRYPTO_SHA384_NETTLE)
  754. static int
  755. __archive_nettle_sha384init(archive_sha384_ctx *ctx)
  756. {
  757. sha384_init(ctx);
  758. return (ARCHIVE_OK);
  759. }
  760. static int
  761. __archive_nettle_sha384update(archive_sha384_ctx *ctx, const void *indata,
  762. size_t insize)
  763. {
  764. sha384_update(ctx, insize, indata);
  765. return (ARCHIVE_OK);
  766. }
  767. static int
  768. __archive_nettle_sha384final(archive_sha384_ctx *ctx, void *md)
  769. {
  770. sha384_digest(ctx, SHA384_DIGEST_SIZE, md);
  771. return (ARCHIVE_OK);
  772. }
  773. #elif defined(ARCHIVE_CRYPTO_SHA384_OPENSSL)
  774. static int
  775. __archive_openssl_sha384init(archive_sha384_ctx *ctx)
  776. {
  777. EVP_DigestInit(ctx, EVP_sha384());
  778. return (ARCHIVE_OK);
  779. }
  780. static int
  781. __archive_openssl_sha384update(archive_sha384_ctx *ctx, const void *indata,
  782. size_t insize)
  783. {
  784. EVP_DigestUpdate(ctx, indata, insize);
  785. return (ARCHIVE_OK);
  786. }
  787. static int
  788. __archive_openssl_sha384final(archive_sha384_ctx *ctx, void *md)
  789. {
  790. EVP_DigestFinal(ctx, md, NULL);
  791. return (ARCHIVE_OK);
  792. }
  793. #elif defined(ARCHIVE_CRYPTO_SHA384_WIN)
  794. static int
  795. __archive_windowsapi_sha384init(archive_sha384_ctx *ctx)
  796. {
  797. return (win_crypto_init(ctx, CALG_SHA_384));
  798. }
  799. static int
  800. __archive_windowsapi_sha384update(archive_sha384_ctx *ctx, const void *indata,
  801. size_t insize)
  802. {
  803. return (win_crypto_Update(ctx, indata, insize));
  804. }
  805. static int
  806. __archive_windowsapi_sha384final(archive_sha384_ctx *ctx, void *md)
  807. {
  808. return (win_crypto_Final(md, 48, ctx));
  809. }
  810. #else
  811. static int
  812. __archive_stub_sha384init(archive_sha384_ctx *ctx)
  813. {
  814. (void)ctx; /* UNUSED */
  815. return (ARCHIVE_FAILED);
  816. }
  817. static int
  818. __archive_stub_sha384update(archive_sha384_ctx *ctx, const void *indata,
  819. size_t insize)
  820. {
  821. (void)ctx; /* UNUSED */
  822. (void)indata; /* UNUSED */
  823. (void)insize; /* UNUSED */
  824. return (ARCHIVE_FAILED);
  825. }
  826. static int
  827. __archive_stub_sha384final(archive_sha384_ctx *ctx, void *md)
  828. {
  829. (void)ctx; /* UNUSED */
  830. (void)md; /* UNUSED */
  831. return (ARCHIVE_FAILED);
  832. }
  833. #endif
  834. /* SHA512 implementations */
  835. #if defined(ARCHIVE_CRYPTO_SHA512_LIBC)
  836. static int
  837. __archive_libc_sha512init(archive_sha512_ctx *ctx)
  838. {
  839. SHA512_Init(ctx);
  840. return (ARCHIVE_OK);
  841. }
  842. static int
  843. __archive_libc_sha512update(archive_sha512_ctx *ctx, const void *indata,
  844. size_t insize)
  845. {
  846. SHA512_Update(ctx, indata, insize);
  847. return (ARCHIVE_OK);
  848. }
  849. static int
  850. __archive_libc_sha512final(archive_sha512_ctx *ctx, void *md)
  851. {
  852. SHA512_Final(md, ctx);
  853. return (ARCHIVE_OK);
  854. }
  855. #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC2)
  856. static int
  857. __archive_libc2_sha512init(archive_sha512_ctx *ctx)
  858. {
  859. SHA512Init(ctx);
  860. return (ARCHIVE_OK);
  861. }
  862. static int
  863. __archive_libc2_sha512update(archive_sha512_ctx *ctx, const void *indata,
  864. size_t insize)
  865. {
  866. SHA512Update(ctx, indata, insize);
  867. return (ARCHIVE_OK);
  868. }
  869. static int
  870. __archive_libc2_sha512final(archive_sha512_ctx *ctx, void *md)
  871. {
  872. SHA512Final(md, ctx);
  873. return (ARCHIVE_OK);
  874. }
  875. #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC3)
  876. static int
  877. __archive_libc3_sha512init(archive_sha512_ctx *ctx)
  878. {
  879. SHA512Init(ctx);
  880. return (ARCHIVE_OK);
  881. }
  882. static int
  883. __archive_libc3_sha512update(archive_sha512_ctx *ctx, const void *indata,
  884. size_t insize)
  885. {
  886. SHA512Update(ctx, indata, insize);
  887. return (ARCHIVE_OK);
  888. }
  889. static int
  890. __archive_libc3_sha512final(archive_sha512_ctx *ctx, void *md)
  891. {
  892. SHA512Final(md, ctx);
  893. return (ARCHIVE_OK);
  894. }
  895. #elif defined(ARCHIVE_CRYPTO_SHA512_LIBMD)
  896. static int
  897. __archive_libmd_sha512init(archive_sha512_ctx *ctx)
  898. {
  899. SHA512_Init(ctx);
  900. return (ARCHIVE_OK);
  901. }
  902. static int
  903. __archive_libmd_sha512update(archive_sha512_ctx *ctx, const void *indata,
  904. size_t insize)
  905. {
  906. SHA512_Update(ctx, indata, insize);
  907. return (ARCHIVE_OK);
  908. }
  909. static int
  910. __archive_libmd_sha512final(archive_sha512_ctx *ctx, void *md)
  911. {
  912. SHA512_Final(md, ctx);
  913. return (ARCHIVE_OK);
  914. }
  915. #elif defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM)
  916. static int
  917. __archive_libsystem_sha512init(archive_sha512_ctx *ctx)
  918. {
  919. CC_SHA512_Init(ctx);
  920. return (ARCHIVE_OK);
  921. }
  922. static int
  923. __archive_libsystem_sha512update(archive_sha512_ctx *ctx, const void *indata,
  924. size_t insize)
  925. {
  926. CC_SHA512_Update(ctx, indata, insize);
  927. return (ARCHIVE_OK);
  928. }
  929. static int
  930. __archive_libsystem_sha512final(archive_sha512_ctx *ctx, void *md)
  931. {
  932. CC_SHA512_Final(md, ctx);
  933. return (ARCHIVE_OK);
  934. }
  935. #elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
  936. static int
  937. __archive_nettle_sha512init(archive_sha512_ctx *ctx)
  938. {
  939. sha512_init(ctx);
  940. return (ARCHIVE_OK);
  941. }
  942. static int
  943. __archive_nettle_sha512update(archive_sha512_ctx *ctx, const void *indata,
  944. size_t insize)
  945. {
  946. sha512_update(ctx, insize, indata);
  947. return (ARCHIVE_OK);
  948. }
  949. static int
  950. __archive_nettle_sha512final(archive_sha512_ctx *ctx, void *md)
  951. {
  952. sha512_digest(ctx, SHA512_DIGEST_SIZE, md);
  953. return (ARCHIVE_OK);
  954. }
  955. #elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
  956. static int
  957. __archive_openssl_sha512init(archive_sha512_ctx *ctx)
  958. {
  959. EVP_DigestInit(ctx, EVP_sha512());
  960. return (ARCHIVE_OK);
  961. }
  962. static int
  963. __archive_openssl_sha512update(archive_sha512_ctx *ctx, const void *indata,
  964. size_t insize)
  965. {
  966. EVP_DigestUpdate(ctx, indata, insize);
  967. return (ARCHIVE_OK);
  968. }
  969. static int
  970. __archive_openssl_sha512final(archive_sha512_ctx *ctx, void *md)
  971. {
  972. EVP_DigestFinal(ctx, md, NULL);
  973. return (ARCHIVE_OK);
  974. }
  975. #elif defined(ARCHIVE_CRYPTO_SHA512_WIN)
  976. static int
  977. __archive_windowsapi_sha512init(archive_sha512_ctx *ctx)
  978. {
  979. return (win_crypto_init(ctx, CALG_SHA_512));
  980. }
  981. static int
  982. __archive_windowsapi_sha512update(archive_sha512_ctx *ctx, const void *indata,
  983. size_t insize)
  984. {
  985. return (win_crypto_Update(ctx, indata, insize));
  986. }
  987. static int
  988. __archive_windowsapi_sha512final(archive_sha512_ctx *ctx, void *md)
  989. {
  990. return (win_crypto_Final(md, 64, ctx));
  991. }
  992. #else
  993. static int
  994. __archive_stub_sha512init(archive_sha512_ctx *ctx)
  995. {
  996. (void)ctx; /* UNUSED */
  997. return (ARCHIVE_FAILED);
  998. }
  999. static int
  1000. __archive_stub_sha512update(archive_sha512_ctx *ctx, const void *indata,
  1001. size_t insize)
  1002. {
  1003. (void)ctx; /* UNUSED */
  1004. (void)indata; /* UNUSED */
  1005. (void)insize; /* UNUSED */
  1006. return (ARCHIVE_FAILED);
  1007. }
  1008. static int
  1009. __archive_stub_sha512final(archive_sha512_ctx *ctx, void *md)
  1010. {
  1011. (void)ctx; /* UNUSED */
  1012. (void)md; /* UNUSED */
  1013. return (ARCHIVE_FAILED);
  1014. }
  1015. #endif
  1016. /* NOTE: Crypto functions are set based on availability and by the following
  1017. * order of preference.
  1018. * 1. libc
  1019. * 2. libc2
  1020. * 3. libc3
  1021. * 4. libSystem
  1022. * 5. Nettle
  1023. * 6. OpenSSL
  1024. * 7. libmd
  1025. * 8. Windows API
  1026. */
  1027. const struct archive_crypto __archive_crypto =
  1028. {
  1029. /* MD5 */
  1030. #if defined(ARCHIVE_CRYPTO_MD5_LIBC)
  1031. &__archive_libc_md5init,
  1032. &__archive_libc_md5update,
  1033. &__archive_libc_md5final,
  1034. #elif defined(ARCHIVE_CRYPTO_MD5_LIBMD)
  1035. &__archive_libmd_md5init,
  1036. &__archive_libmd_md5update,
  1037. &__archive_libmd_md5final,
  1038. #elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM)
  1039. &__archive_libsystem_md5init,
  1040. &__archive_libsystem_md5update,
  1041. &__archive_libsystem_md5final,
  1042. #elif defined(ARCHIVE_CRYPTO_MD5_NETTLE)
  1043. &__archive_nettle_md5init,
  1044. &__archive_nettle_md5update,
  1045. &__archive_nettle_md5final,
  1046. #elif defined(ARCHIVE_CRYPTO_MD5_OPENSSL)
  1047. &__archive_openssl_md5init,
  1048. &__archive_openssl_md5update,
  1049. &__archive_openssl_md5final,
  1050. #elif defined(ARCHIVE_CRYPTO_MD5_WIN)
  1051. &__archive_windowsapi_md5init,
  1052. &__archive_windowsapi_md5update,
  1053. &__archive_windowsapi_md5final,
  1054. #elif !defined(ARCHIVE_MD5_COMPILE_TEST)
  1055. &__archive_stub_md5init,
  1056. &__archive_stub_md5update,
  1057. &__archive_stub_md5final,
  1058. #endif
  1059. /* RIPEMD160 */
  1060. #if defined(ARCHIVE_CRYPTO_RMD160_LIBC)
  1061. &__archive_libc_ripemd160init,
  1062. &__archive_libc_ripemd160update,
  1063. &__archive_libc_ripemd160final,
  1064. #elif defined(ARCHIVE_CRYPTO_RMD160_LIBMD)
  1065. &__archive_libmd_ripemd160init,
  1066. &__archive_libmd_ripemd160update,
  1067. &__archive_libmd_ripemd160final,
  1068. #elif defined(ARCHIVE_CRYPTO_RMD160_NETTLE)
  1069. &__archive_nettle_ripemd160init,
  1070. &__archive_nettle_ripemd160update,
  1071. &__archive_nettle_ripemd160final,
  1072. #elif defined(ARCHIVE_CRYPTO_RMD160_OPENSSL)
  1073. &__archive_openssl_ripemd160init,
  1074. &__archive_openssl_ripemd160update,
  1075. &__archive_openssl_ripemd160final,
  1076. #elif !defined(ARCHIVE_RMD160_COMPILE_TEST)
  1077. &__archive_stub_ripemd160init,
  1078. &__archive_stub_ripemd160update,
  1079. &__archive_stub_ripemd160final,
  1080. #endif
  1081. /* SHA1 */
  1082. #if defined(ARCHIVE_CRYPTO_SHA1_LIBC)
  1083. &__archive_libc_sha1init,
  1084. &__archive_libc_sha1update,
  1085. &__archive_libc_sha1final,
  1086. #elif defined(ARCHIVE_CRYPTO_SHA1_LIBMD)
  1087. &__archive_libmd_sha1init,
  1088. &__archive_libmd_sha1update,
  1089. &__archive_libmd_sha1final,
  1090. #elif defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM)
  1091. &__archive_libsystem_sha1init,
  1092. &__archive_libsystem_sha1update,
  1093. &__archive_libsystem_sha1final,
  1094. #elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE)
  1095. &__archive_nettle_sha1init,
  1096. &__archive_nettle_sha1update,
  1097. &__archive_nettle_sha1final,
  1098. #elif defined(ARCHIVE_CRYPTO_SHA1_OPENSSL)
  1099. &__archive_openssl_sha1init,
  1100. &__archive_openssl_sha1update,
  1101. &__archive_openssl_sha1final,
  1102. #elif defined(ARCHIVE_CRYPTO_SHA1_WIN)
  1103. &__archive_windowsapi_sha1init,
  1104. &__archive_windowsapi_sha1update,
  1105. &__archive_windowsapi_sha1final,
  1106. #elif !defined(ARCHIVE_SHA1_COMPILE_TEST)
  1107. &__archive_stub_sha1init,
  1108. &__archive_stub_sha1update,
  1109. &__archive_stub_sha1final,
  1110. #endif
  1111. /* SHA256 */
  1112. #if defined(ARCHIVE_CRYPTO_SHA256_LIBC)
  1113. &__archive_libc_sha256init,
  1114. &__archive_libc_sha256update,
  1115. &__archive_libc_sha256final,
  1116. #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC2)
  1117. &__archive_libc2_sha256init,
  1118. &__archive_libc2_sha256update,
  1119. &__archive_libc2_sha256final,
  1120. #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC3)
  1121. &__archive_libc3_sha256init,
  1122. &__archive_libc3_sha256update,
  1123. &__archive_libc3_sha256final,
  1124. #elif defined(ARCHIVE_CRYPTO_SHA256_LIBMD)
  1125. &__archive_libmd_sha256init,
  1126. &__archive_libmd_sha256update,
  1127. &__archive_libmd_sha256final,
  1128. #elif defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM)
  1129. &__archive_libsystem_sha256init,
  1130. &__archive_libsystem_sha256update,
  1131. &__archive_libsystem_sha256final,
  1132. #elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE)
  1133. &__archive_nettle_sha256init,
  1134. &__archive_nettle_sha256update,
  1135. &__archive_nettle_sha256final,
  1136. #elif defined(ARCHIVE_CRYPTO_SHA256_OPENSSL)
  1137. &__archive_openssl_sha256init,
  1138. &__archive_openssl_sha256update,
  1139. &__archive_openssl_sha256final,
  1140. #elif defined(ARCHIVE_CRYPTO_SHA256_WIN)
  1141. &__archive_windowsapi_sha256init,
  1142. &__archive_windowsapi_sha256update,
  1143. &__archive_windowsapi_sha256final,
  1144. #elif !defined(ARCHIVE_SHA256_COMPILE_TEST)
  1145. &__archive_stub_sha256init,
  1146. &__archive_stub_sha256update,
  1147. &__archive_stub_sha256final,
  1148. #endif
  1149. /* SHA384 */
  1150. #if defined(ARCHIVE_CRYPTO_SHA384_LIBC)
  1151. &__archive_libc_sha384init,
  1152. &__archive_libc_sha384update,
  1153. &__archive_libc_sha384final,
  1154. #elif defined(ARCHIVE_CRYPTO_SHA384_LIBC2)
  1155. &__archive_libc2_sha384init,
  1156. &__archive_libc2_sha384update,
  1157. &__archive_libc2_sha384final,
  1158. #elif defined(ARCHIVE_CRYPTO_SHA384_LIBC3)
  1159. &__archive_libc3_sha384init,
  1160. &__archive_libc3_sha384update,
  1161. &__archive_libc3_sha384final,
  1162. #elif defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM)
  1163. &__archive_libsystem_sha384init,
  1164. &__archive_libsystem_sha384update,
  1165. &__archive_libsystem_sha384final,
  1166. #elif defined(ARCHIVE_CRYPTO_SHA384_NETTLE)
  1167. &__archive_nettle_sha384init,
  1168. &__archive_nettle_sha384update,
  1169. &__archive_nettle_sha384final,
  1170. #elif defined(ARCHIVE_CRYPTO_SHA384_OPENSSL)
  1171. &__archive_openssl_sha384init,
  1172. &__archive_openssl_sha384update,
  1173. &__archive_openssl_sha384final,
  1174. #elif defined(ARCHIVE_CRYPTO_SHA384_WIN)
  1175. &__archive_windowsapi_sha384init,
  1176. &__archive_windowsapi_sha384update,
  1177. &__archive_windowsapi_sha384final,
  1178. #elif !defined(ARCHIVE_SHA384_COMPILE_TEST)
  1179. &__archive_stub_sha384init,
  1180. &__archive_stub_sha384update,
  1181. &__archive_stub_sha384final,
  1182. #endif
  1183. /* SHA512 */
  1184. #if defined(ARCHIVE_CRYPTO_SHA512_LIBC)
  1185. &__archive_libc_sha512init,
  1186. &__archive_libc_sha512update,
  1187. &__archive_libc_sha512final
  1188. #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC2)
  1189. &__archive_libc2_sha512init,
  1190. &__archive_libc2_sha512update,
  1191. &__archive_libc2_sha512final
  1192. #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC3)
  1193. &__archive_libc3_sha512init,
  1194. &__archive_libc3_sha512update,
  1195. &__archive_libc3_sha512final
  1196. #elif defined(ARCHIVE_CRYPTO_SHA512_LIBMD)
  1197. &__archive_libmd_sha512init,
  1198. &__archive_libmd_sha512update,
  1199. &__archive_libmd_sha512final
  1200. #elif defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM)
  1201. &__archive_libsystem_sha512init,
  1202. &__archive_libsystem_sha512update,
  1203. &__archive_libsystem_sha512final
  1204. #elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
  1205. &__archive_nettle_sha512init,
  1206. &__archive_nettle_sha512update,
  1207. &__archive_nettle_sha512final,
  1208. #elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
  1209. &__archive_openssl_sha512init,
  1210. &__archive_openssl_sha512update,
  1211. &__archive_openssl_sha512final
  1212. #elif defined(ARCHIVE_CRYPTO_SHA512_WIN)
  1213. &__archive_windowsapi_sha512init,
  1214. &__archive_windowsapi_sha512update,
  1215. &__archive_windowsapi_sha512final
  1216. #elif !defined(ARCHIVE_SHA512_COMPILE_TEST)
  1217. &__archive_stub_sha512init,
  1218. &__archive_stub_sha512update,
  1219. &__archive_stub_sha512final
  1220. #endif
  1221. };