libarchive-static 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (296) hide show
  1. checksums.yaml +5 -5
  2. data/ext/extconf.rb +2 -9
  3. data/ext/libarchive-0.1.1/ext/archive_read_support_compression.c +6 -6
  4. data/ext/libarchive-0.1.1/ext/archive_read_support_compression.o +0 -0
  5. data/ext/libarchive-0.1.1/ext/archive_read_support_format.o +0 -0
  6. data/ext/libarchive-0.1.1/ext/archive_write_open_rb_str.c +1 -1
  7. data/ext/libarchive-0.1.1/ext/archive_write_open_rb_str.o +0 -0
  8. data/ext/libarchive-0.1.1/ext/archive_write_set_compression.c +5 -5
  9. data/ext/libarchive-0.1.1/ext/archive_write_set_compression.o +0 -0
  10. data/ext/libarchive-0.1.1/ext/config.h +23 -0
  11. data/ext/libarchive-0.1.1/ext/config.log +230 -0
  12. data/ext/libarchive-0.1.1/ext/config.status +671 -0
  13. data/ext/libarchive-0.1.1/ext/libarchive.c +1 -1
  14. data/ext/libarchive-0.1.1/ext/libarchive.o +0 -0
  15. data/ext/libarchive-0.1.1/ext/libarchive_archive.c +7 -7
  16. data/ext/libarchive-0.1.1/ext/libarchive_archive.o +0 -0
  17. data/ext/libarchive-0.1.1/ext/libarchive_entry.c +6 -0
  18. data/ext/libarchive-0.1.1/ext/libarchive_entry.o +0 -0
  19. data/ext/libarchive-0.1.1/ext/libarchive_internal.h +0 -1
  20. data/ext/libarchive-0.1.1/ext/libarchive_reader.c +6 -4
  21. data/ext/libarchive-0.1.1/ext/libarchive_reader.o +0 -0
  22. data/ext/libarchive-0.1.1/ext/libarchive_ruby.so +0 -0
  23. data/ext/libarchive-0.1.1/ext/libarchive_win32.h +1 -1
  24. data/ext/libarchive-0.1.1/ext/libarchive_writer.c +2 -2
  25. data/ext/libarchive-0.1.1/ext/libarchive_writer.o +0 -0
  26. data/ext/libarchive-3.6.2/Makefile.in +16892 -0
  27. data/ext/libarchive-3.6.2/build/autoconf/ax_append_compile_flags.m4 +67 -0
  28. data/ext/libarchive-3.6.2/build/autoconf/ax_append_flag.m4 +71 -0
  29. data/ext/libarchive-3.6.2/build/autoconf/ax_check_compile_flag.m4 +74 -0
  30. data/ext/libarchive-3.6.2/build/autoconf/ax_require_defined.m4 +37 -0
  31. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/autoconf/check_stdcall_func.m4 +0 -0
  32. data/ext/libarchive-3.6.2/build/autoconf/compile +348 -0
  33. data/ext/libarchive-3.6.2/build/autoconf/config.guess +1754 -0
  34. data/ext/libarchive-3.6.2/build/autoconf/config.rpath +696 -0
  35. data/ext/libarchive-3.6.2/build/autoconf/config.sub +1890 -0
  36. data/ext/libarchive-3.6.2/build/autoconf/depcomp +791 -0
  37. data/ext/libarchive-3.6.2/build/autoconf/iconv.m4 +271 -0
  38. data/ext/libarchive-3.6.2/build/autoconf/install-sh +541 -0
  39. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/autoconf/la_uid_t.m4 +0 -0
  40. data/ext/libarchive-3.6.2/build/autoconf/lib-ld.m4 +109 -0
  41. data/ext/libarchive-3.6.2/build/autoconf/lib-link.m4 +777 -0
  42. data/ext/libarchive-3.6.2/build/autoconf/lib-prefix.m4 +224 -0
  43. data/ext/libarchive-3.6.2/build/autoconf/ltmain.sh +11251 -0
  44. data/ext/libarchive-3.6.2/build/autoconf/m4_ax_compile_check_sizeof.m4 +115 -0
  45. data/ext/libarchive-3.6.2/build/autoconf/missing +215 -0
  46. data/ext/libarchive-3.6.2/build/autoconf/test-driver +153 -0
  47. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/pkgconfig/libarchive.pc.in +4 -1
  48. data/ext/libarchive-3.6.2/config.h.in +1504 -0
  49. data/ext/libarchive-3.6.2/configure +25558 -0
  50. data/ext/libarchive-3.6.2/libarchive/archive.h +1212 -0
  51. data/ext/libarchive-3.6.2/libarchive/archive_acl.c +2097 -0
  52. data/ext/libarchive-3.6.2/libarchive/archive_acl_private.h +83 -0
  53. data/ext/libarchive-3.6.2/libarchive/archive_blake2.h +197 -0
  54. data/ext/libarchive-3.6.2/libarchive/archive_blake2_impl.h +161 -0
  55. data/ext/libarchive-3.6.2/libarchive/archive_blake2s_ref.c +369 -0
  56. data/ext/libarchive-3.6.2/libarchive/archive_blake2sp_ref.c +361 -0
  57. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_check_magic.c +63 -22
  58. data/ext/libarchive-3.6.2/libarchive/archive_cmdline.c +227 -0
  59. data/ext/libarchive-3.6.2/libarchive/archive_cmdline_private.h +47 -0
  60. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_crc32.h +17 -0
  61. data/ext/libarchive-3.6.2/libarchive/archive_cryptor.c +534 -0
  62. data/ext/libarchive-3.6.2/libarchive/archive_cryptor_private.h +188 -0
  63. data/ext/libarchive-3.6.2/libarchive/archive_digest.c +1505 -0
  64. data/ext/libarchive-3.6.2/libarchive/archive_digest_private.h +416 -0
  65. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_darwin.c +559 -0
  66. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_freebsd.c +712 -0
  67. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_linux.c +760 -0
  68. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_sunos.c +824 -0
  69. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_endian.h +48 -15
  70. data/ext/libarchive-3.6.2/libarchive/archive_entry.c +2149 -0
  71. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry.h +305 -106
  72. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_copy_bhfi.c +5 -4
  73. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_copy_stat.c +9 -3
  74. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_link_resolver.c +104 -62
  75. data/ext/libarchive-3.6.2/libarchive/archive_entry_locale.h +92 -0
  76. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_private.h +65 -49
  77. data/ext/libarchive-3.6.2/libarchive/archive_entry_sparse.c +156 -0
  78. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_stat.c +6 -6
  79. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_strmode.c +1 -1
  80. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_xattr.c +4 -6
  81. data/ext/libarchive-3.6.2/libarchive/archive_getdate.c +1165 -0
  82. data/ext/libarchive-3.6.2/libarchive/archive_getdate.h +39 -0
  83. data/ext/libarchive-3.6.2/libarchive/archive_hmac.c +334 -0
  84. data/ext/libarchive-3.6.2/libarchive/archive_hmac_private.h +117 -0
  85. data/ext/libarchive-3.6.2/libarchive/archive_match.c +1875 -0
  86. data/ext/libarchive-3.6.2/libarchive/archive_openssl_evp_private.h +53 -0
  87. data/ext/libarchive-3.6.2/libarchive/archive_openssl_hmac_private.h +54 -0
  88. data/ext/libarchive-3.6.2/libarchive/archive_options.c +218 -0
  89. data/ext/libarchive-3.6.2/libarchive/archive_options_private.h +51 -0
  90. data/ext/libarchive-3.6.2/libarchive/archive_pack_dev.c +337 -0
  91. data/ext/libarchive-3.6.2/libarchive/archive_pack_dev.h +49 -0
  92. data/ext/libarchive-3.6.2/libarchive/archive_pathmatch.c +463 -0
  93. data/ext/libarchive-3.6.2/libarchive/archive_pathmatch.h +52 -0
  94. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_platform.h +77 -9
  95. data/ext/libarchive-3.6.2/libarchive/archive_platform_acl.h +55 -0
  96. data/ext/libarchive-3.6.2/libarchive/archive_platform_xattr.h +47 -0
  97. data/ext/libarchive-3.6.2/libarchive/archive_ppmd7.c +1168 -0
  98. data/ext/libarchive-3.6.2/libarchive/archive_ppmd7_private.h +119 -0
  99. data/ext/libarchive-3.6.2/libarchive/archive_ppmd8.c +1287 -0
  100. data/ext/libarchive-3.6.2/libarchive/archive_ppmd8_private.h +148 -0
  101. data/ext/libarchive-3.6.2/libarchive/archive_ppmd_private.h +151 -0
  102. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_private.h +74 -18
  103. data/ext/libarchive-3.6.2/libarchive/archive_random.c +272 -0
  104. data/ext/libarchive-3.6.2/libarchive/archive_random_private.h +36 -0
  105. data/ext/libarchive-3.6.2/libarchive/archive_rb.c +709 -0
  106. data/ext/libarchive-3.6.2/libarchive/archive_rb.h +113 -0
  107. data/ext/libarchive-3.6.2/libarchive/archive_read.c +1756 -0
  108. data/ext/libarchive-3.6.2/libarchive/archive_read_add_passphrase.c +190 -0
  109. data/ext/libarchive-3.6.2/libarchive/archive_read_append_filter.c +204 -0
  110. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_data_into_fd.c +64 -18
  111. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_entry_from_file.c +1086 -0
  112. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_posix.c +2732 -0
  113. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_disk_private.h +40 -4
  114. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_disk_set_standard_lookup.c +21 -11
  115. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_windows.c +2479 -0
  116. data/ext/libarchive-3.6.2/libarchive/archive_read_extract.c +60 -0
  117. data/ext/{libarchive-2.8.4/libarchive/archive_read_extract.c → libarchive-3.6.2/libarchive/archive_read_extract2.c} +34 -61
  118. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_fd.c +70 -49
  119. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_file.c +38 -23
  120. data/ext/libarchive-3.6.2/libarchive/archive_read_open_filename.c +586 -0
  121. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_memory.c +58 -28
  122. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_private.h +127 -59
  123. data/ext/libarchive-3.6.2/libarchive/archive_read_set_format.c +117 -0
  124. data/ext/libarchive-3.6.2/libarchive/archive_read_set_options.c +133 -0
  125. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_all.c → libarchive-3.6.2/libarchive/archive_read_support_filter_all.c} +35 -10
  126. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_by_code.c +83 -0
  127. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_bzip2.c → libarchive-3.6.2/libarchive/archive_read_support_filter_bzip2.c} +38 -26
  128. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_compress.c → libarchive-3.6.2/libarchive/archive_read_support_filter_compress.c} +52 -44
  129. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_grzip.c +112 -0
  130. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_gzip.c → libarchive-3.6.2/libarchive/archive_read_support_filter_gzip.c} +108 -37
  131. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lrzip.c +122 -0
  132. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lz4.c +742 -0
  133. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lzop.c +499 -0
  134. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_none.c → libarchive-3.6.2/libarchive/archive_read_support_filter_none.c} +15 -3
  135. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_program.c → libarchive-3.6.2/libarchive/archive_read_support_filter_program.c} +114 -77
  136. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_rpm.c → libarchive-3.6.2/libarchive/archive_read_support_filter_rpm.c} +31 -31
  137. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_uu.c → libarchive-3.6.2/libarchive/archive_read_support_filter_uu.c} +141 -85
  138. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_xz.c → libarchive-3.6.2/libarchive/archive_read_support_filter_xz.c} +369 -284
  139. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_zstd.c +297 -0
  140. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_7zip.c +3900 -0
  141. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_all.c +89 -0
  142. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_ar.c +126 -72
  143. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_by_code.c +92 -0
  144. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_cab.c +3228 -0
  145. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_cpio.c +1104 -0
  146. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_empty.c +14 -11
  147. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_iso9660.c +990 -541
  148. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_lha.c +2916 -0
  149. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_mtree.c +2150 -0
  150. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_rar.c +3797 -0
  151. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_rar5.c +4251 -0
  152. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_raw.c +38 -31
  153. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_tar.c +1157 -629
  154. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_warc.c +848 -0
  155. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_xar.c +439 -258
  156. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_zip.c +4270 -0
  157. data/ext/libarchive-3.6.2/libarchive/archive_string.c +4240 -0
  158. data/ext/libarchive-3.6.2/libarchive/archive_string.h +243 -0
  159. data/ext/libarchive-3.6.2/libarchive/archive_string_composition.h +2292 -0
  160. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_string_sprintf.c +44 -16
  161. data/ext/libarchive-3.6.2/libarchive/archive_util.c +655 -0
  162. data/ext/libarchive-3.6.2/libarchive/archive_version_details.c +151 -0
  163. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_virtual.c +85 -16
  164. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_windows.c +214 -541
  165. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_windows.h +74 -106
  166. data/ext/libarchive-3.6.2/libarchive/archive_write.c +828 -0
  167. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter.c +72 -0
  168. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_b64encode.c +304 -0
  169. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_by_name.c +77 -0
  170. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_bzip2.c +401 -0
  171. data/ext/{libarchive-2.8.4/libarchive/archive_write_set_compression_compress.c → libarchive-3.6.2/libarchive/archive_write_add_filter_compress.c} +86 -131
  172. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_grzip.c +135 -0
  173. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_gzip.c +442 -0
  174. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lrzip.c +197 -0
  175. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lz4.c +700 -0
  176. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lzop.c +478 -0
  177. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_format_all.c → libarchive-3.6.2/libarchive/archive_write_add_filter_none.c} +11 -11
  178. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_program.c +391 -0
  179. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_uuencode.c +295 -0
  180. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_xz.c +545 -0
  181. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_zstd.c +418 -0
  182. data/ext/libarchive-3.6.2/libarchive/archive_write_disk_posix.c +4711 -0
  183. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_disk_private.h +9 -2
  184. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_disk_set_standard_lookup.c +30 -29
  185. data/ext/libarchive-3.6.2/libarchive/archive_write_disk_windows.c +2842 -0
  186. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_fd.c +15 -10
  187. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_file.c +15 -9
  188. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_filename.c +128 -20
  189. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_memory.c +7 -18
  190. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_private.h +72 -29
  191. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format.c +56 -3
  192. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_7zip.c +2322 -0
  193. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_ar.c +54 -34
  194. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_by_name.c +20 -2
  195. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio.c +11 -0
  196. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_binary.c +610 -0
  197. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_newc.c +457 -0
  198. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_odc.c +500 -0
  199. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_filter_by_ext.c +142 -0
  200. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_gnutar.c +755 -0
  201. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_iso9660.c +8165 -0
  202. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_mtree.c +2217 -0
  203. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_pax.c +1049 -387
  204. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_private.h +42 -0
  205. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_raw.c +125 -0
  206. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_shar.c +62 -47
  207. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_ustar.c +279 -108
  208. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_v7tar.c +638 -0
  209. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_warc.c +453 -0
  210. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_xar.c +3259 -0
  211. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_zip.c +1704 -0
  212. data/ext/libarchive-3.6.2/libarchive/archive_write_set_options.c +130 -0
  213. data/ext/libarchive-3.6.2/libarchive/archive_write_set_passphrase.c +95 -0
  214. data/ext/libarchive-3.6.2/libarchive/archive_xxhash.h +48 -0
  215. data/ext/libarchive-3.6.2/libarchive/config_freebsd.h +271 -0
  216. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/filter_fork.h +10 -5
  217. data/ext/{libarchive-2.8.4/libarchive/filter_fork.c → libarchive-3.6.2/libarchive/filter_fork_posix.c} +98 -19
  218. data/ext/libarchive-3.6.2/libarchive/filter_fork_windows.c +236 -0
  219. data/ext/libarchive-3.6.2/libarchive/xxhash.c +525 -0
  220. data/ext/libarchive-static-makefile +144 -80
  221. data/ext/libarchive-static-wrapper-makefile +1 -1
  222. data/ext/zlib-1.2.13/Makefile.in +404 -0
  223. data/ext/{zlib-1.2.5 → zlib-1.2.13}/adler32.c +51 -34
  224. data/ext/{zlib-1.2.5 → zlib-1.2.13}/compress.c +27 -21
  225. data/ext/zlib-1.2.13/configure +922 -0
  226. data/ext/zlib-1.2.13/crc32.c +1125 -0
  227. data/ext/zlib-1.2.13/crc32.h +9446 -0
  228. data/ext/{zlib-1.2.5 → zlib-1.2.13}/deflate.c +842 -459
  229. data/ext/{zlib-1.2.5 → zlib-1.2.13}/deflate.h +37 -33
  230. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzclose.c +0 -0
  231. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzguts.h +103 -16
  232. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzlib.c +155 -53
  233. data/ext/zlib-1.2.13/gzread.c +650 -0
  234. data/ext/zlib-1.2.13/gzwrite.c +677 -0
  235. data/ext/{zlib-1.2.5 → zlib-1.2.13}/infback.c +24 -12
  236. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffast.c +49 -66
  237. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffast.h +0 -0
  238. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffixed.h +3 -3
  239. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inflate.c +209 -94
  240. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inflate.h +9 -5
  241. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inftrees.c +24 -50
  242. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inftrees.h +1 -1
  243. data/ext/{zlib-1.2.5 → zlib-1.2.13}/trees.c +135 -198
  244. data/ext/{zlib-1.2.5 → zlib-1.2.13}/trees.h +0 -0
  245. data/ext/zlib-1.2.13/uncompr.c +93 -0
  246. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zconf.h +182 -63
  247. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zlib.h +617 -295
  248. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zutil.c +50 -41
  249. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zutil.h +83 -82
  250. metadata +244 -137
  251. data/ext/libarchive-0.1.1/libarchive.c +0 -1762
  252. data/ext/libarchive-2.8.4/Makefile.in +0 -7076
  253. data/ext/libarchive-2.8.4/build/autoconf/compile +0 -143
  254. data/ext/libarchive-2.8.4/build/autoconf/config.guess +0 -1502
  255. data/ext/libarchive-2.8.4/build/autoconf/config.sub +0 -1708
  256. data/ext/libarchive-2.8.4/build/autoconf/depcomp +0 -630
  257. data/ext/libarchive-2.8.4/build/autoconf/install-sh +0 -291
  258. data/ext/libarchive-2.8.4/build/autoconf/ltmain.sh +0 -8406
  259. data/ext/libarchive-2.8.4/build/autoconf/missing +0 -376
  260. data/ext/libarchive-2.8.4/config.h.in +0 -772
  261. data/ext/libarchive-2.8.4/configure +0 -17916
  262. data/ext/libarchive-2.8.4/libarchive/archive.h +0 -741
  263. data/ext/libarchive-2.8.4/libarchive/archive_entry.c +0 -2202
  264. data/ext/libarchive-2.8.4/libarchive/archive_hash.h +0 -281
  265. data/ext/libarchive-2.8.4/libarchive/archive_read.c +0 -1249
  266. data/ext/libarchive-2.8.4/libarchive/archive_read_disk.c +0 -198
  267. data/ext/libarchive-2.8.4/libarchive/archive_read_disk_entry_from_file.c +0 -570
  268. data/ext/libarchive-2.8.4/libarchive/archive_read_open_filename.c +0 -272
  269. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_cpio.c +0 -777
  270. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_mtree.c +0 -1304
  271. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_zip.c +0 -903
  272. data/ext/libarchive-2.8.4/libarchive/archive_string.c +0 -453
  273. data/ext/libarchive-2.8.4/libarchive/archive_string.h +0 -148
  274. data/ext/libarchive-2.8.4/libarchive/archive_util.c +0 -391
  275. data/ext/libarchive-2.8.4/libarchive/archive_write.c +0 -466
  276. data/ext/libarchive-2.8.4/libarchive/archive_write_disk.c +0 -2628
  277. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_bzip2.c +0 -408
  278. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_gzip.c +0 -477
  279. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_none.c +0 -257
  280. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_program.c +0 -347
  281. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_xz.c +0 -438
  282. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio.c +0 -344
  283. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio_newc.c +0 -295
  284. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_mtree.c +0 -1050
  285. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_zip.c +0 -667
  286. data/ext/libarchive-2.8.4/libarchive/config_freebsd.h +0 -154
  287. data/ext/libarchive-2.8.4/libarchive/filter_fork_windows.c +0 -113
  288. data/ext/zlib-1.2.5/Makefile.in +0 -257
  289. data/ext/zlib-1.2.5/configure +0 -596
  290. data/ext/zlib-1.2.5/crc32.c +0 -442
  291. data/ext/zlib-1.2.5/crc32.h +0 -441
  292. data/ext/zlib-1.2.5/example.c +0 -565
  293. data/ext/zlib-1.2.5/gzread.c +0 -653
  294. data/ext/zlib-1.2.5/gzwrite.c +0 -531
  295. data/ext/zlib-1.2.5/minigzip.c +0 -440
  296. data/ext/zlib-1.2.5/uncompr.c +0 -59
@@ -0,0 +1,1505 @@
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
+
28
+ #include "archive_platform.h"
29
+
30
+ #include "archive.h"
31
+ #include "archive_digest_private.h"
32
+
33
+ /* In particular, force the configure probe to break if it tries
34
+ * to test a combination of OpenSSL and libmd. */
35
+ #if defined(ARCHIVE_CRYPTO_OPENSSL) && defined(ARCHIVE_CRYPTO_LIBMD)
36
+ #error Cannot use both OpenSSL and libmd.
37
+ #endif
38
+
39
+ /*
40
+ * Message digest functions for Windows platform.
41
+ */
42
+ #if defined(ARCHIVE_CRYPTO_MD5_WIN) ||\
43
+ defined(ARCHIVE_CRYPTO_SHA1_WIN) ||\
44
+ defined(ARCHIVE_CRYPTO_SHA256_WIN) ||\
45
+ defined(ARCHIVE_CRYPTO_SHA384_WIN) ||\
46
+ defined(ARCHIVE_CRYPTO_SHA512_WIN)
47
+
48
+ /*
49
+ * Initialize a Message digest.
50
+ */
51
+ static int
52
+ win_crypto_init(Digest_CTX *ctx, DWORD prov, ALG_ID algId)
53
+ {
54
+
55
+ ctx->valid = 0;
56
+ if (!CryptAcquireContext(&ctx->cryptProv, NULL, NULL,
57
+ prov, CRYPT_VERIFYCONTEXT)) {
58
+ if (GetLastError() != (DWORD)NTE_BAD_KEYSET)
59
+ return (ARCHIVE_FAILED);
60
+ if (!CryptAcquireContext(&ctx->cryptProv, NULL, NULL,
61
+ prov, CRYPT_NEWKEYSET))
62
+ return (ARCHIVE_FAILED);
63
+ }
64
+
65
+ if (!CryptCreateHash(ctx->cryptProv, algId, 0, 0, &ctx->hash)) {
66
+ CryptReleaseContext(ctx->cryptProv, 0);
67
+ return (ARCHIVE_FAILED);
68
+ }
69
+
70
+ ctx->valid = 1;
71
+ return (ARCHIVE_OK);
72
+ }
73
+
74
+ /*
75
+ * Update a Message digest.
76
+ */
77
+ static int
78
+ win_crypto_Update(Digest_CTX *ctx, const unsigned char *buf, size_t len)
79
+ {
80
+
81
+ if (!ctx->valid)
82
+ return (ARCHIVE_FAILED);
83
+
84
+ CryptHashData(ctx->hash,
85
+ (unsigned char *)(uintptr_t)buf,
86
+ (DWORD)len, 0);
87
+ return (ARCHIVE_OK);
88
+ }
89
+
90
+ static int
91
+ win_crypto_Final(unsigned char *buf, size_t bufsize, Digest_CTX *ctx)
92
+ {
93
+ DWORD siglen = (DWORD)bufsize;
94
+
95
+ if (!ctx->valid)
96
+ return (ARCHIVE_FAILED);
97
+
98
+ CryptGetHashParam(ctx->hash, HP_HASHVAL, buf, &siglen, 0);
99
+ CryptDestroyHash(ctx->hash);
100
+ CryptReleaseContext(ctx->cryptProv, 0);
101
+ ctx->valid = 0;
102
+ return (ARCHIVE_OK);
103
+ }
104
+
105
+ #endif /* defined(ARCHIVE_CRYPTO_*_WIN) */
106
+
107
+
108
+ /* MD5 implementations */
109
+ #if defined(ARCHIVE_CRYPTO_MD5_LIBC)
110
+
111
+ static int
112
+ __archive_md5init(archive_md5_ctx *ctx)
113
+ {
114
+ MD5Init(ctx);
115
+ return (ARCHIVE_OK);
116
+ }
117
+
118
+ static int
119
+ __archive_md5update(archive_md5_ctx *ctx, const void *indata,
120
+ size_t insize)
121
+ {
122
+ MD5Update(ctx, indata, insize);
123
+ return (ARCHIVE_OK);
124
+ }
125
+
126
+ static int
127
+ __archive_md5final(archive_md5_ctx *ctx, void *md)
128
+ {
129
+ MD5Final(md, ctx);
130
+ return (ARCHIVE_OK);
131
+ }
132
+
133
+ #elif defined(ARCHIVE_CRYPTO_MD5_LIBMD)
134
+
135
+ static int
136
+ __archive_md5init(archive_md5_ctx *ctx)
137
+ {
138
+ MD5Init(ctx);
139
+ return (ARCHIVE_OK);
140
+ }
141
+
142
+ static int
143
+ __archive_md5update(archive_md5_ctx *ctx, const void *indata,
144
+ size_t insize)
145
+ {
146
+ MD5Update(ctx, indata, insize);
147
+ return (ARCHIVE_OK);
148
+ }
149
+
150
+ static int
151
+ __archive_md5final(archive_md5_ctx *ctx, void *md)
152
+ {
153
+ MD5Final(md, ctx);
154
+ return (ARCHIVE_OK);
155
+ }
156
+
157
+ #elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM)
158
+
159
+ static int
160
+ __archive_md5init(archive_md5_ctx *ctx)
161
+ {
162
+ CC_MD5_Init(ctx);
163
+ return (ARCHIVE_OK);
164
+ }
165
+
166
+ static int
167
+ __archive_md5update(archive_md5_ctx *ctx, const void *indata,
168
+ size_t insize)
169
+ {
170
+ CC_MD5_Update(ctx, indata, insize);
171
+ return (ARCHIVE_OK);
172
+ }
173
+
174
+ static int
175
+ __archive_md5final(archive_md5_ctx *ctx, void *md)
176
+ {
177
+ CC_MD5_Final(md, ctx);
178
+ return (ARCHIVE_OK);
179
+ }
180
+
181
+ #elif defined(ARCHIVE_CRYPTO_MD5_MBEDTLS)
182
+
183
+ static int
184
+ __archive_md5init(archive_md5_ctx *ctx)
185
+ {
186
+ mbedtls_md5_init(ctx);
187
+ if (mbedtls_md5_starts_ret(ctx) == 0)
188
+ return (ARCHIVE_OK);
189
+ else
190
+ return (ARCHIVE_FATAL);
191
+ }
192
+
193
+ static int
194
+ __archive_md5update(archive_md5_ctx *ctx, const void *indata,
195
+ size_t insize)
196
+ {
197
+ if (mbedtls_md5_update_ret(ctx, indata, insize) == 0)
198
+ return (ARCHIVE_OK);
199
+ else
200
+ return (ARCHIVE_FATAL);
201
+ }
202
+
203
+ static int
204
+ __archive_md5final(archive_md5_ctx *ctx, void *md)
205
+ {
206
+ if (mbedtls_md5_finish_ret(ctx, md) == 0) {
207
+ mbedtls_md5_free(ctx);
208
+ return (ARCHIVE_OK);
209
+ } else {
210
+ mbedtls_md5_free(ctx);
211
+ return (ARCHIVE_FATAL);
212
+ }
213
+ }
214
+
215
+ #elif defined(ARCHIVE_CRYPTO_MD5_NETTLE)
216
+
217
+ static int
218
+ __archive_md5init(archive_md5_ctx *ctx)
219
+ {
220
+ md5_init(ctx);
221
+ return (ARCHIVE_OK);
222
+ }
223
+
224
+ static int
225
+ __archive_md5update(archive_md5_ctx *ctx, const void *indata,
226
+ size_t insize)
227
+ {
228
+ md5_update(ctx, insize, indata);
229
+ return (ARCHIVE_OK);
230
+ }
231
+
232
+ static int
233
+ __archive_md5final(archive_md5_ctx *ctx, void *md)
234
+ {
235
+ md5_digest(ctx, MD5_DIGEST_SIZE, md);
236
+ return (ARCHIVE_OK);
237
+ }
238
+
239
+ #elif defined(ARCHIVE_CRYPTO_MD5_OPENSSL)
240
+
241
+ static int
242
+ __archive_md5init(archive_md5_ctx *ctx)
243
+ {
244
+ if ((*ctx = EVP_MD_CTX_new()) == NULL)
245
+ return (ARCHIVE_FAILED);
246
+ if (!EVP_DigestInit(*ctx, EVP_md5()))
247
+ return (ARCHIVE_FAILED);
248
+ return (ARCHIVE_OK);
249
+ }
250
+
251
+ static int
252
+ __archive_md5update(archive_md5_ctx *ctx, const void *indata,
253
+ size_t insize)
254
+ {
255
+ EVP_DigestUpdate(*ctx, indata, insize);
256
+ return (ARCHIVE_OK);
257
+ }
258
+
259
+ static int
260
+ __archive_md5final(archive_md5_ctx *ctx, void *md)
261
+ {
262
+ /* HACK: archive_write_set_format_xar.c is finalizing empty contexts, so
263
+ * this is meant to cope with that. Real fix is probably to fix
264
+ * archive_write_set_format_xar.c
265
+ */
266
+ if (*ctx) {
267
+ EVP_DigestFinal(*ctx, md, NULL);
268
+ EVP_MD_CTX_free(*ctx);
269
+ *ctx = NULL;
270
+ }
271
+ return (ARCHIVE_OK);
272
+ }
273
+
274
+ #elif defined(ARCHIVE_CRYPTO_MD5_WIN)
275
+
276
+ static int
277
+ __archive_md5init(archive_md5_ctx *ctx)
278
+ {
279
+ return (win_crypto_init(ctx, PROV_RSA_FULL, CALG_MD5));
280
+ }
281
+
282
+ static int
283
+ __archive_md5update(archive_md5_ctx *ctx, const void *indata,
284
+ size_t insize)
285
+ {
286
+ return (win_crypto_Update(ctx, indata, insize));
287
+ }
288
+
289
+ static int
290
+ __archive_md5final(archive_md5_ctx *ctx, void *md)
291
+ {
292
+ return (win_crypto_Final(md, 16, ctx));
293
+ }
294
+
295
+ #else
296
+
297
+ static int
298
+ __archive_md5init(archive_md5_ctx *ctx)
299
+ {
300
+ (void)ctx; /* UNUSED */
301
+ return (ARCHIVE_FAILED);
302
+ }
303
+
304
+ static int
305
+ __archive_md5update(archive_md5_ctx *ctx, const void *indata,
306
+ size_t insize)
307
+ {
308
+ (void)ctx; /* UNUSED */
309
+ (void)indata; /* UNUSED */
310
+ (void)insize; /* UNUSED */
311
+ return (ARCHIVE_FAILED);
312
+ }
313
+
314
+ static int
315
+ __archive_md5final(archive_md5_ctx *ctx, void *md)
316
+ {
317
+ (void)ctx; /* UNUSED */
318
+ (void)md; /* UNUSED */
319
+ return (ARCHIVE_FAILED);
320
+ }
321
+
322
+ #endif
323
+
324
+ /* RIPEMD160 implementations */
325
+ #if defined(ARCHIVE_CRYPTO_RMD160_LIBC)
326
+
327
+ static int
328
+ __archive_ripemd160init(archive_rmd160_ctx *ctx)
329
+ {
330
+ RMD160Init(ctx);
331
+ return (ARCHIVE_OK);
332
+ }
333
+
334
+ static int
335
+ __archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
336
+ size_t insize)
337
+ {
338
+ RMD160Update(ctx, indata, insize);
339
+ return (ARCHIVE_OK);
340
+ }
341
+
342
+ static int
343
+ __archive_ripemd160final(archive_rmd160_ctx *ctx, void *md)
344
+ {
345
+ RMD160Final(md, ctx);
346
+ return (ARCHIVE_OK);
347
+ }
348
+
349
+ #elif defined(ARCHIVE_CRYPTO_RMD160_LIBMD)
350
+
351
+ static int
352
+ __archive_ripemd160init(archive_rmd160_ctx *ctx)
353
+ {
354
+ RIPEMD160_Init(ctx);
355
+ return (ARCHIVE_OK);
356
+ }
357
+
358
+ static int
359
+ __archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
360
+ size_t insize)
361
+ {
362
+ RIPEMD160_Update(ctx, indata, insize);
363
+ return (ARCHIVE_OK);
364
+ }
365
+
366
+ static int
367
+ __archive_ripemd160final(archive_rmd160_ctx *ctx, void *md)
368
+ {
369
+ RIPEMD160_Final(md, ctx);
370
+ return (ARCHIVE_OK);
371
+ }
372
+
373
+ #elif defined(ARCHIVE_CRYPTO_RMD160_MBEDTLS)
374
+
375
+ static int
376
+ __archive_ripemd160init(archive_rmd160_ctx *ctx)
377
+ {
378
+ mbedtls_ripemd160_init(ctx);
379
+ if (mbedtls_ripemd160_starts_ret(ctx) == 0)
380
+ return (ARCHIVE_OK);
381
+ else
382
+ return (ARCHIVE_FATAL);
383
+ }
384
+
385
+ static int
386
+ __archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
387
+ size_t insize)
388
+ {
389
+ if (mbedtls_ripemd160_update_ret(ctx, indata, insize) == 0)
390
+ return (ARCHIVE_OK);
391
+ else
392
+ return (ARCHIVE_FATAL);
393
+ }
394
+
395
+ static int
396
+ __archive_ripemd160final(archive_rmd160_ctx *ctx, void *md)
397
+ {
398
+ if (mbedtls_ripemd160_finish_ret(ctx, md) == 0) {
399
+ mbedtls_ripemd160_free(ctx);
400
+ return (ARCHIVE_OK);
401
+ } else {
402
+ mbedtls_ripemd160_free(ctx);
403
+ return (ARCHIVE_FATAL);
404
+ }
405
+ }
406
+
407
+ #elif defined(ARCHIVE_CRYPTO_RMD160_NETTLE)
408
+
409
+ static int
410
+ __archive_ripemd160init(archive_rmd160_ctx *ctx)
411
+ {
412
+ ripemd160_init(ctx);
413
+ return (ARCHIVE_OK);
414
+ }
415
+
416
+ static int
417
+ __archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
418
+ size_t insize)
419
+ {
420
+ ripemd160_update(ctx, insize, indata);
421
+ return (ARCHIVE_OK);
422
+ }
423
+
424
+ static int
425
+ __archive_ripemd160final(archive_rmd160_ctx *ctx, void *md)
426
+ {
427
+ ripemd160_digest(ctx, RIPEMD160_DIGEST_SIZE, md);
428
+ return (ARCHIVE_OK);
429
+ }
430
+
431
+ #elif defined(ARCHIVE_CRYPTO_RMD160_OPENSSL)
432
+
433
+ static int
434
+ __archive_ripemd160init(archive_rmd160_ctx *ctx)
435
+ {
436
+ if ((*ctx = EVP_MD_CTX_new()) == NULL)
437
+ return (ARCHIVE_FAILED);
438
+ if (!EVP_DigestInit(*ctx, EVP_ripemd160()))
439
+ return (ARCHIVE_FAILED);
440
+ return (ARCHIVE_OK);
441
+ }
442
+
443
+ static int
444
+ __archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
445
+ size_t insize)
446
+ {
447
+ EVP_DigestUpdate(*ctx, indata, insize);
448
+ return (ARCHIVE_OK);
449
+ }
450
+
451
+ static int
452
+ __archive_ripemd160final(archive_rmd160_ctx *ctx, void *md)
453
+ {
454
+ if (*ctx) {
455
+ EVP_DigestFinal(*ctx, md, NULL);
456
+ EVP_MD_CTX_free(*ctx);
457
+ *ctx = NULL;
458
+ }
459
+ return (ARCHIVE_OK);
460
+ }
461
+
462
+ #else
463
+
464
+ static int
465
+ __archive_ripemd160init(archive_rmd160_ctx *ctx)
466
+ {
467
+ (void)ctx; /* UNUSED */
468
+ return (ARCHIVE_FAILED);
469
+ }
470
+
471
+ static int
472
+ __archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
473
+ size_t insize)
474
+ {
475
+ (void)ctx; /* UNUSED */
476
+ (void)indata; /* UNUSED */
477
+ (void)insize; /* UNUSED */
478
+ return (ARCHIVE_FAILED);
479
+ }
480
+
481
+ static int
482
+ __archive_ripemd160final(archive_rmd160_ctx *ctx, void *md)
483
+ {
484
+ (void)ctx; /* UNUSED */
485
+ (void)md; /* UNUSED */
486
+ return (ARCHIVE_FAILED);
487
+ }
488
+
489
+ #endif
490
+
491
+ /* SHA1 implementations */
492
+ #if defined(ARCHIVE_CRYPTO_SHA1_LIBC)
493
+
494
+ static int
495
+ __archive_sha1init(archive_sha1_ctx *ctx)
496
+ {
497
+ SHA1Init(ctx);
498
+ return (ARCHIVE_OK);
499
+ }
500
+
501
+ static int
502
+ __archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
503
+ size_t insize)
504
+ {
505
+ SHA1Update(ctx, indata, insize);
506
+ return (ARCHIVE_OK);
507
+ }
508
+
509
+ static int
510
+ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
511
+ {
512
+ SHA1Final(md, ctx);
513
+ return (ARCHIVE_OK);
514
+ }
515
+
516
+ #elif defined(ARCHIVE_CRYPTO_SHA1_LIBMD)
517
+
518
+ static int
519
+ __archive_sha1init(archive_sha1_ctx *ctx)
520
+ {
521
+ SHA1_Init(ctx);
522
+ return (ARCHIVE_OK);
523
+ }
524
+
525
+ static int
526
+ __archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
527
+ size_t insize)
528
+ {
529
+ SHA1_Update(ctx, indata, insize);
530
+ return (ARCHIVE_OK);
531
+ }
532
+
533
+ static int
534
+ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
535
+ {
536
+ SHA1_Final(md, ctx);
537
+ return (ARCHIVE_OK);
538
+ }
539
+
540
+ #elif defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM)
541
+
542
+ static int
543
+ __archive_sha1init(archive_sha1_ctx *ctx)
544
+ {
545
+ CC_SHA1_Init(ctx);
546
+ return (ARCHIVE_OK);
547
+ }
548
+
549
+ static int
550
+ __archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
551
+ size_t insize)
552
+ {
553
+ CC_SHA1_Update(ctx, indata, insize);
554
+ return (ARCHIVE_OK);
555
+ }
556
+
557
+ static int
558
+ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
559
+ {
560
+ CC_SHA1_Final(md, ctx);
561
+ return (ARCHIVE_OK);
562
+ }
563
+
564
+ #elif defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS)
565
+
566
+ static int
567
+ __archive_sha1init(archive_sha1_ctx *ctx)
568
+ {
569
+ mbedtls_sha1_init(ctx);
570
+ if (mbedtls_sha1_starts_ret(ctx) == 0)
571
+ return (ARCHIVE_OK);
572
+ else
573
+ return (ARCHIVE_FATAL);
574
+ }
575
+
576
+ static int
577
+ __archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
578
+ size_t insize)
579
+ {
580
+ if (mbedtls_sha1_update_ret(ctx, indata, insize) == 0)
581
+ return (ARCHIVE_OK);
582
+ else
583
+ return (ARCHIVE_FATAL);
584
+ }
585
+
586
+ static int
587
+ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
588
+ {
589
+ if (mbedtls_sha1_finish_ret(ctx, md) == 0) {
590
+ mbedtls_sha1_free(ctx);
591
+ return (ARCHIVE_OK);
592
+ } else {
593
+ mbedtls_sha1_free(ctx);
594
+ return (ARCHIVE_FATAL);
595
+ }
596
+ }
597
+
598
+ #elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE)
599
+
600
+ static int
601
+ __archive_sha1init(archive_sha1_ctx *ctx)
602
+ {
603
+ sha1_init(ctx);
604
+ return (ARCHIVE_OK);
605
+ }
606
+
607
+ static int
608
+ __archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
609
+ size_t insize)
610
+ {
611
+ sha1_update(ctx, insize, indata);
612
+ return (ARCHIVE_OK);
613
+ }
614
+
615
+ static int
616
+ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
617
+ {
618
+ sha1_digest(ctx, SHA1_DIGEST_SIZE, md);
619
+ return (ARCHIVE_OK);
620
+ }
621
+
622
+ #elif defined(ARCHIVE_CRYPTO_SHA1_OPENSSL)
623
+
624
+ static int
625
+ __archive_sha1init(archive_sha1_ctx *ctx)
626
+ {
627
+ if ((*ctx = EVP_MD_CTX_new()) == NULL)
628
+ return (ARCHIVE_FAILED);
629
+ if (!EVP_DigestInit(*ctx, EVP_sha1()))
630
+ return (ARCHIVE_FAILED);
631
+ return (ARCHIVE_OK);
632
+ }
633
+
634
+ static int
635
+ __archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
636
+ size_t insize)
637
+ {
638
+ EVP_DigestUpdate(*ctx, indata, insize);
639
+ return (ARCHIVE_OK);
640
+ }
641
+
642
+ static int
643
+ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
644
+ {
645
+ /* HACK: archive_write_set_format_xar.c is finalizing empty contexts, so
646
+ * this is meant to cope with that. Real fix is probably to fix
647
+ * archive_write_set_format_xar.c
648
+ */
649
+ if (*ctx) {
650
+ EVP_DigestFinal(*ctx, md, NULL);
651
+ EVP_MD_CTX_free(*ctx);
652
+ *ctx = NULL;
653
+ }
654
+ return (ARCHIVE_OK);
655
+ }
656
+
657
+ #elif defined(ARCHIVE_CRYPTO_SHA1_WIN)
658
+
659
+ static int
660
+ __archive_sha1init(archive_sha1_ctx *ctx)
661
+ {
662
+ return (win_crypto_init(ctx, PROV_RSA_FULL, CALG_SHA1));
663
+ }
664
+
665
+ static int
666
+ __archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
667
+ size_t insize)
668
+ {
669
+ return (win_crypto_Update(ctx, indata, insize));
670
+ }
671
+
672
+ static int
673
+ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
674
+ {
675
+ return (win_crypto_Final(md, 20, ctx));
676
+ }
677
+
678
+ #else
679
+
680
+ static int
681
+ __archive_sha1init(archive_sha1_ctx *ctx)
682
+ {
683
+ (void)ctx; /* UNUSED */
684
+ return (ARCHIVE_FAILED);
685
+ }
686
+
687
+ static int
688
+ __archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
689
+ size_t insize)
690
+ {
691
+ (void)ctx; /* UNUSED */
692
+ (void)indata; /* UNUSED */
693
+ (void)insize; /* UNUSED */
694
+ return (ARCHIVE_FAILED);
695
+ }
696
+
697
+ static int
698
+ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
699
+ {
700
+ (void)ctx; /* UNUSED */
701
+ (void)md; /* UNUSED */
702
+ return (ARCHIVE_FAILED);
703
+ }
704
+
705
+ #endif
706
+
707
+ /* SHA256 implementations */
708
+ #if defined(ARCHIVE_CRYPTO_SHA256_LIBC)
709
+
710
+ static int
711
+ __archive_sha256init(archive_sha256_ctx *ctx)
712
+ {
713
+ SHA256_Init(ctx);
714
+ return (ARCHIVE_OK);
715
+ }
716
+
717
+ static int
718
+ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
719
+ size_t insize)
720
+ {
721
+ SHA256_Update(ctx, indata, insize);
722
+ return (ARCHIVE_OK);
723
+ }
724
+
725
+ static int
726
+ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
727
+ {
728
+ SHA256_Final(md, ctx);
729
+ return (ARCHIVE_OK);
730
+ }
731
+
732
+ #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC2)
733
+
734
+ static int
735
+ __archive_sha256init(archive_sha256_ctx *ctx)
736
+ {
737
+ SHA256Init(ctx);
738
+ return (ARCHIVE_OK);
739
+ }
740
+
741
+ static int
742
+ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
743
+ size_t insize)
744
+ {
745
+ SHA256Update(ctx, indata, insize);
746
+ return (ARCHIVE_OK);
747
+ }
748
+
749
+ static int
750
+ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
751
+ {
752
+ SHA256Final(md, ctx);
753
+ return (ARCHIVE_OK);
754
+ }
755
+
756
+ #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC3)
757
+
758
+ static int
759
+ __archive_sha256init(archive_sha256_ctx *ctx)
760
+ {
761
+ SHA256Init(ctx);
762
+ return (ARCHIVE_OK);
763
+ }
764
+
765
+ static int
766
+ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
767
+ size_t insize)
768
+ {
769
+ SHA256Update(ctx, indata, insize);
770
+ return (ARCHIVE_OK);
771
+ }
772
+
773
+ static int
774
+ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
775
+ {
776
+ SHA256Final(md, ctx);
777
+ return (ARCHIVE_OK);
778
+ }
779
+
780
+ #elif defined(ARCHIVE_CRYPTO_SHA256_LIBMD)
781
+
782
+ static int
783
+ __archive_sha256init(archive_sha256_ctx *ctx)
784
+ {
785
+ SHA256_Init(ctx);
786
+ return (ARCHIVE_OK);
787
+ }
788
+
789
+ static int
790
+ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
791
+ size_t insize)
792
+ {
793
+ SHA256_Update(ctx, indata, insize);
794
+ return (ARCHIVE_OK);
795
+ }
796
+
797
+ static int
798
+ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
799
+ {
800
+ SHA256_Final(md, ctx);
801
+ return (ARCHIVE_OK);
802
+ }
803
+
804
+ #elif defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM)
805
+
806
+ static int
807
+ __archive_sha256init(archive_sha256_ctx *ctx)
808
+ {
809
+ CC_SHA256_Init(ctx);
810
+ return (ARCHIVE_OK);
811
+ }
812
+
813
+ static int
814
+ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
815
+ size_t insize)
816
+ {
817
+ CC_SHA256_Update(ctx, indata, insize);
818
+ return (ARCHIVE_OK);
819
+ }
820
+
821
+ static int
822
+ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
823
+ {
824
+ CC_SHA256_Final(md, ctx);
825
+ return (ARCHIVE_OK);
826
+ }
827
+
828
+ #elif defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS)
829
+
830
+ static int
831
+ __archive_sha256init(archive_sha256_ctx *ctx)
832
+ {
833
+ mbedtls_sha256_init(ctx);
834
+ if (mbedtls_sha256_starts_ret(ctx, 0) == 0)
835
+ return (ARCHIVE_OK);
836
+ else
837
+ return (ARCHIVE_FATAL);
838
+ }
839
+
840
+ static int
841
+ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
842
+ size_t insize)
843
+ {
844
+ if (mbedtls_sha256_update_ret(ctx, indata, insize) == 0)
845
+ return (ARCHIVE_OK);
846
+ else
847
+ return (ARCHIVE_FATAL);
848
+ }
849
+
850
+ static int
851
+ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
852
+ {
853
+ if (mbedtls_sha256_finish_ret(ctx, md) == 0) {
854
+ mbedtls_sha256_free(ctx);
855
+ return (ARCHIVE_OK);
856
+ } else {
857
+ mbedtls_sha256_free(ctx);
858
+ return (ARCHIVE_FATAL);
859
+ }
860
+ }
861
+
862
+ #elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE)
863
+
864
+ static int
865
+ __archive_sha256init(archive_sha256_ctx *ctx)
866
+ {
867
+ sha256_init(ctx);
868
+ return (ARCHIVE_OK);
869
+ }
870
+
871
+ static int
872
+ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
873
+ size_t insize)
874
+ {
875
+ sha256_update(ctx, insize, indata);
876
+ return (ARCHIVE_OK);
877
+ }
878
+
879
+ static int
880
+ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
881
+ {
882
+ sha256_digest(ctx, SHA256_DIGEST_SIZE, md);
883
+ return (ARCHIVE_OK);
884
+ }
885
+
886
+ #elif defined(ARCHIVE_CRYPTO_SHA256_OPENSSL)
887
+
888
+ static int
889
+ __archive_sha256init(archive_sha256_ctx *ctx)
890
+ {
891
+ if ((*ctx = EVP_MD_CTX_new()) == NULL)
892
+ return (ARCHIVE_FAILED);
893
+ if (!EVP_DigestInit(*ctx, EVP_sha256()))
894
+ return (ARCHIVE_FAILED);
895
+ return (ARCHIVE_OK);
896
+ }
897
+
898
+ static int
899
+ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
900
+ size_t insize)
901
+ {
902
+ EVP_DigestUpdate(*ctx, indata, insize);
903
+ return (ARCHIVE_OK);
904
+ }
905
+
906
+ static int
907
+ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
908
+ {
909
+ if (*ctx) {
910
+ EVP_DigestFinal(*ctx, md, NULL);
911
+ EVP_MD_CTX_free(*ctx);
912
+ *ctx = NULL;
913
+ }
914
+ return (ARCHIVE_OK);
915
+ }
916
+
917
+ #elif defined(ARCHIVE_CRYPTO_SHA256_WIN)
918
+
919
+ static int
920
+ __archive_sha256init(archive_sha256_ctx *ctx)
921
+ {
922
+ return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_256));
923
+ }
924
+
925
+ static int
926
+ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
927
+ size_t insize)
928
+ {
929
+ return (win_crypto_Update(ctx, indata, insize));
930
+ }
931
+
932
+ static int
933
+ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
934
+ {
935
+ return (win_crypto_Final(md, 32, ctx));
936
+ }
937
+
938
+ #else
939
+
940
+ static int
941
+ __archive_sha256init(archive_sha256_ctx *ctx)
942
+ {
943
+ (void)ctx; /* UNUSED */
944
+ return (ARCHIVE_FAILED);
945
+ }
946
+
947
+ static int
948
+ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
949
+ size_t insize)
950
+ {
951
+ (void)ctx; /* UNUSED */
952
+ (void)indata; /* UNUSED */
953
+ (void)insize; /* UNUSED */
954
+ return (ARCHIVE_FAILED);
955
+ }
956
+
957
+ static int
958
+ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
959
+ {
960
+ (void)ctx; /* UNUSED */
961
+ (void)md; /* UNUSED */
962
+ return (ARCHIVE_FAILED);
963
+ }
964
+
965
+ #endif
966
+
967
+ /* SHA384 implementations */
968
+ #if defined(ARCHIVE_CRYPTO_SHA384_LIBC)
969
+
970
+ static int
971
+ __archive_sha384init(archive_sha384_ctx *ctx)
972
+ {
973
+ SHA384_Init(ctx);
974
+ return (ARCHIVE_OK);
975
+ }
976
+
977
+ static int
978
+ __archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
979
+ size_t insize)
980
+ {
981
+ SHA384_Update(ctx, indata, insize);
982
+ return (ARCHIVE_OK);
983
+ }
984
+
985
+ static int
986
+ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
987
+ {
988
+ SHA384_Final(md, ctx);
989
+ return (ARCHIVE_OK);
990
+ }
991
+
992
+ #elif defined(ARCHIVE_CRYPTO_SHA384_LIBC2)
993
+
994
+ static int
995
+ __archive_sha384init(archive_sha384_ctx *ctx)
996
+ {
997
+ SHA384Init(ctx);
998
+ return (ARCHIVE_OK);
999
+ }
1000
+
1001
+ static int
1002
+ __archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
1003
+ size_t insize)
1004
+ {
1005
+ SHA384Update(ctx, indata, insize);
1006
+ return (ARCHIVE_OK);
1007
+ }
1008
+
1009
+ static int
1010
+ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
1011
+ {
1012
+ SHA384Final(md, ctx);
1013
+ return (ARCHIVE_OK);
1014
+ }
1015
+
1016
+ #elif defined(ARCHIVE_CRYPTO_SHA384_LIBC3)
1017
+
1018
+ static int
1019
+ __archive_sha384init(archive_sha384_ctx *ctx)
1020
+ {
1021
+ SHA384Init(ctx);
1022
+ return (ARCHIVE_OK);
1023
+ }
1024
+
1025
+ static int
1026
+ __archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
1027
+ size_t insize)
1028
+ {
1029
+ SHA384Update(ctx, indata, insize);
1030
+ return (ARCHIVE_OK);
1031
+ }
1032
+
1033
+ static int
1034
+ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
1035
+ {
1036
+ SHA384Final(md, ctx);
1037
+ return (ARCHIVE_OK);
1038
+ }
1039
+
1040
+ #elif defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM)
1041
+
1042
+ static int
1043
+ __archive_sha384init(archive_sha384_ctx *ctx)
1044
+ {
1045
+ CC_SHA384_Init(ctx);
1046
+ return (ARCHIVE_OK);
1047
+ }
1048
+
1049
+ static int
1050
+ __archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
1051
+ size_t insize)
1052
+ {
1053
+ CC_SHA384_Update(ctx, indata, insize);
1054
+ return (ARCHIVE_OK);
1055
+ }
1056
+
1057
+ static int
1058
+ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
1059
+ {
1060
+ CC_SHA384_Final(md, ctx);
1061
+ return (ARCHIVE_OK);
1062
+ }
1063
+
1064
+ #elif defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS)
1065
+
1066
+ static int
1067
+ __archive_sha384init(archive_sha384_ctx *ctx)
1068
+ {
1069
+ mbedtls_sha512_init(ctx);
1070
+ if (mbedtls_sha512_starts_ret(ctx, 1) == 0)
1071
+ return (ARCHIVE_OK);
1072
+ else
1073
+ return (ARCHIVE_FATAL);
1074
+ }
1075
+
1076
+ static int
1077
+ __archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
1078
+ size_t insize)
1079
+ {
1080
+ if (mbedtls_sha512_update_ret(ctx, indata, insize) == 0)
1081
+ return (ARCHIVE_OK);
1082
+ else
1083
+ return (ARCHIVE_FATAL);
1084
+ }
1085
+
1086
+ static int
1087
+ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
1088
+ {
1089
+ if (mbedtls_sha512_finish_ret(ctx, md) == 0) {
1090
+ mbedtls_sha512_free(ctx);
1091
+ return (ARCHIVE_OK);
1092
+ } else {
1093
+ mbedtls_sha512_free(ctx);
1094
+ return (ARCHIVE_FATAL);
1095
+ }
1096
+ }
1097
+
1098
+ #elif defined(ARCHIVE_CRYPTO_SHA384_NETTLE)
1099
+
1100
+ static int
1101
+ __archive_sha384init(archive_sha384_ctx *ctx)
1102
+ {
1103
+ sha384_init(ctx);
1104
+ return (ARCHIVE_OK);
1105
+ }
1106
+
1107
+ static int
1108
+ __archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
1109
+ size_t insize)
1110
+ {
1111
+ sha384_update(ctx, insize, indata);
1112
+ return (ARCHIVE_OK);
1113
+ }
1114
+
1115
+ static int
1116
+ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
1117
+ {
1118
+ sha384_digest(ctx, SHA384_DIGEST_SIZE, md);
1119
+ return (ARCHIVE_OK);
1120
+ }
1121
+
1122
+ #elif defined(ARCHIVE_CRYPTO_SHA384_OPENSSL)
1123
+
1124
+ static int
1125
+ __archive_sha384init(archive_sha384_ctx *ctx)
1126
+ {
1127
+ if ((*ctx = EVP_MD_CTX_new()) == NULL)
1128
+ return (ARCHIVE_FAILED);
1129
+ if (!EVP_DigestInit(*ctx, EVP_sha384()))
1130
+ return (ARCHIVE_FAILED);
1131
+ return (ARCHIVE_OK);
1132
+ }
1133
+
1134
+ static int
1135
+ __archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
1136
+ size_t insize)
1137
+ {
1138
+ EVP_DigestUpdate(*ctx, indata, insize);
1139
+ return (ARCHIVE_OK);
1140
+ }
1141
+
1142
+ static int
1143
+ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
1144
+ {
1145
+ if (*ctx) {
1146
+ EVP_DigestFinal(*ctx, md, NULL);
1147
+ EVP_MD_CTX_free(*ctx);
1148
+ *ctx = NULL;
1149
+ }
1150
+ return (ARCHIVE_OK);
1151
+ }
1152
+
1153
+ #elif defined(ARCHIVE_CRYPTO_SHA384_WIN)
1154
+
1155
+ static int
1156
+ __archive_sha384init(archive_sha384_ctx *ctx)
1157
+ {
1158
+ return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_384));
1159
+ }
1160
+
1161
+ static int
1162
+ __archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
1163
+ size_t insize)
1164
+ {
1165
+ return (win_crypto_Update(ctx, indata, insize));
1166
+ }
1167
+
1168
+ static int
1169
+ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
1170
+ {
1171
+ return (win_crypto_Final(md, 48, ctx));
1172
+ }
1173
+
1174
+ #else
1175
+
1176
+ static int
1177
+ __archive_sha384init(archive_sha384_ctx *ctx)
1178
+ {
1179
+ (void)ctx; /* UNUSED */
1180
+ return (ARCHIVE_FAILED);
1181
+ }
1182
+
1183
+ static int
1184
+ __archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
1185
+ size_t insize)
1186
+ {
1187
+ (void)ctx; /* UNUSED */
1188
+ (void)indata; /* UNUSED */
1189
+ (void)insize; /* UNUSED */
1190
+ return (ARCHIVE_FAILED);
1191
+ }
1192
+
1193
+ static int
1194
+ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
1195
+ {
1196
+ (void)ctx; /* UNUSED */
1197
+ (void)md; /* UNUSED */
1198
+ return (ARCHIVE_FAILED);
1199
+ }
1200
+
1201
+ #endif
1202
+
1203
+ /* SHA512 implementations */
1204
+ #if defined(ARCHIVE_CRYPTO_SHA512_LIBC)
1205
+
1206
+ static int
1207
+ __archive_sha512init(archive_sha512_ctx *ctx)
1208
+ {
1209
+ SHA512_Init(ctx);
1210
+ return (ARCHIVE_OK);
1211
+ }
1212
+
1213
+ static int
1214
+ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
1215
+ size_t insize)
1216
+ {
1217
+ SHA512_Update(ctx, indata, insize);
1218
+ return (ARCHIVE_OK);
1219
+ }
1220
+
1221
+ static int
1222
+ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
1223
+ {
1224
+ SHA512_Final(md, ctx);
1225
+ return (ARCHIVE_OK);
1226
+ }
1227
+
1228
+ #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC2)
1229
+
1230
+ static int
1231
+ __archive_sha512init(archive_sha512_ctx *ctx)
1232
+ {
1233
+ SHA512Init(ctx);
1234
+ return (ARCHIVE_OK);
1235
+ }
1236
+
1237
+ static int
1238
+ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
1239
+ size_t insize)
1240
+ {
1241
+ SHA512Update(ctx, indata, insize);
1242
+ return (ARCHIVE_OK);
1243
+ }
1244
+
1245
+ static int
1246
+ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
1247
+ {
1248
+ SHA512Final(md, ctx);
1249
+ return (ARCHIVE_OK);
1250
+ }
1251
+
1252
+ #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC3)
1253
+
1254
+ static int
1255
+ __archive_sha512init(archive_sha512_ctx *ctx)
1256
+ {
1257
+ SHA512Init(ctx);
1258
+ return (ARCHIVE_OK);
1259
+ }
1260
+
1261
+ static int
1262
+ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
1263
+ size_t insize)
1264
+ {
1265
+ SHA512Update(ctx, indata, insize);
1266
+ return (ARCHIVE_OK);
1267
+ }
1268
+
1269
+ static int
1270
+ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
1271
+ {
1272
+ SHA512Final(md, ctx);
1273
+ return (ARCHIVE_OK);
1274
+ }
1275
+
1276
+ #elif defined(ARCHIVE_CRYPTO_SHA512_LIBMD)
1277
+
1278
+ static int
1279
+ __archive_sha512init(archive_sha512_ctx *ctx)
1280
+ {
1281
+ SHA512_Init(ctx);
1282
+ return (ARCHIVE_OK);
1283
+ }
1284
+
1285
+ static int
1286
+ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
1287
+ size_t insize)
1288
+ {
1289
+ SHA512_Update(ctx, indata, insize);
1290
+ return (ARCHIVE_OK);
1291
+ }
1292
+
1293
+ static int
1294
+ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
1295
+ {
1296
+ SHA512_Final(md, ctx);
1297
+ return (ARCHIVE_OK);
1298
+ }
1299
+
1300
+ #elif defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM)
1301
+
1302
+ static int
1303
+ __archive_sha512init(archive_sha512_ctx *ctx)
1304
+ {
1305
+ CC_SHA512_Init(ctx);
1306
+ return (ARCHIVE_OK);
1307
+ }
1308
+
1309
+ static int
1310
+ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
1311
+ size_t insize)
1312
+ {
1313
+ CC_SHA512_Update(ctx, indata, insize);
1314
+ return (ARCHIVE_OK);
1315
+ }
1316
+
1317
+ static int
1318
+ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
1319
+ {
1320
+ CC_SHA512_Final(md, ctx);
1321
+ return (ARCHIVE_OK);
1322
+ }
1323
+
1324
+ #elif defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS)
1325
+
1326
+ static int
1327
+ __archive_sha512init(archive_sha512_ctx *ctx)
1328
+ {
1329
+ mbedtls_sha512_init(ctx);
1330
+ if (mbedtls_sha512_starts_ret(ctx, 0) == 0)
1331
+ return (ARCHIVE_OK);
1332
+ else
1333
+ return (ARCHIVE_FATAL);
1334
+ }
1335
+
1336
+ static int
1337
+ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
1338
+ size_t insize)
1339
+ {
1340
+ if (mbedtls_sha512_update_ret(ctx, indata, insize) == 0)
1341
+ return (ARCHIVE_OK);
1342
+ else
1343
+ return (ARCHIVE_FATAL);
1344
+ }
1345
+
1346
+ static int
1347
+ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
1348
+ {
1349
+ if (mbedtls_sha512_finish_ret(ctx, md) == 0) {
1350
+ mbedtls_sha512_free(ctx);
1351
+ return (ARCHIVE_OK);
1352
+ } else {
1353
+ mbedtls_sha512_free(ctx);
1354
+ return (ARCHIVE_FATAL);
1355
+ }
1356
+ }
1357
+
1358
+ #elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
1359
+
1360
+ static int
1361
+ __archive_sha512init(archive_sha512_ctx *ctx)
1362
+ {
1363
+ sha512_init(ctx);
1364
+ return (ARCHIVE_OK);
1365
+ }
1366
+
1367
+ static int
1368
+ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
1369
+ size_t insize)
1370
+ {
1371
+ sha512_update(ctx, insize, indata);
1372
+ return (ARCHIVE_OK);
1373
+ }
1374
+
1375
+ static int
1376
+ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
1377
+ {
1378
+ sha512_digest(ctx, SHA512_DIGEST_SIZE, md);
1379
+ return (ARCHIVE_OK);
1380
+ }
1381
+
1382
+ #elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
1383
+
1384
+ static int
1385
+ __archive_sha512init(archive_sha512_ctx *ctx)
1386
+ {
1387
+ if ((*ctx = EVP_MD_CTX_new()) == NULL)
1388
+ return (ARCHIVE_FAILED);
1389
+ if (!EVP_DigestInit(*ctx, EVP_sha512()))
1390
+ return (ARCHIVE_FAILED);
1391
+ return (ARCHIVE_OK);
1392
+ }
1393
+
1394
+ static int
1395
+ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
1396
+ size_t insize)
1397
+ {
1398
+ EVP_DigestUpdate(*ctx, indata, insize);
1399
+ return (ARCHIVE_OK);
1400
+ }
1401
+
1402
+ static int
1403
+ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
1404
+ {
1405
+ if (*ctx) {
1406
+ EVP_DigestFinal(*ctx, md, NULL);
1407
+ EVP_MD_CTX_free(*ctx);
1408
+ *ctx = NULL;
1409
+ }
1410
+ return (ARCHIVE_OK);
1411
+ }
1412
+
1413
+ #elif defined(ARCHIVE_CRYPTO_SHA512_WIN)
1414
+
1415
+ static int
1416
+ __archive_sha512init(archive_sha512_ctx *ctx)
1417
+ {
1418
+ return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_512));
1419
+ }
1420
+
1421
+ static int
1422
+ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
1423
+ size_t insize)
1424
+ {
1425
+ return (win_crypto_Update(ctx, indata, insize));
1426
+ }
1427
+
1428
+ static int
1429
+ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
1430
+ {
1431
+ return (win_crypto_Final(md, 64, ctx));
1432
+ }
1433
+
1434
+ #else
1435
+
1436
+ static int
1437
+ __archive_sha512init(archive_sha512_ctx *ctx)
1438
+ {
1439
+ (void)ctx; /* UNUSED */
1440
+ return (ARCHIVE_FAILED);
1441
+ }
1442
+
1443
+ static int
1444
+ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
1445
+ size_t insize)
1446
+ {
1447
+ (void)ctx; /* UNUSED */
1448
+ (void)indata; /* UNUSED */
1449
+ (void)insize; /* UNUSED */
1450
+ return (ARCHIVE_FAILED);
1451
+ }
1452
+
1453
+ static int
1454
+ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
1455
+ {
1456
+ (void)ctx; /* UNUSED */
1457
+ (void)md; /* UNUSED */
1458
+ return (ARCHIVE_FAILED);
1459
+ }
1460
+
1461
+ #endif
1462
+
1463
+ /* NOTE: Message Digest functions are set based on availability and by the
1464
+ * following order of preference.
1465
+ * 1. libc
1466
+ * 2. libc2
1467
+ * 3. libc3
1468
+ * 4. libSystem
1469
+ * 5. Nettle
1470
+ * 6. OpenSSL
1471
+ * 7. libmd
1472
+ * 8. Windows API
1473
+ */
1474
+ const struct archive_digest __archive_digest =
1475
+ {
1476
+ /* MD5 */
1477
+ &__archive_md5init,
1478
+ &__archive_md5update,
1479
+ &__archive_md5final,
1480
+
1481
+ /* RIPEMD160 */
1482
+ &__archive_ripemd160init,
1483
+ &__archive_ripemd160update,
1484
+ &__archive_ripemd160final,
1485
+
1486
+ /* SHA1 */
1487
+ &__archive_sha1init,
1488
+ &__archive_sha1update,
1489
+ &__archive_sha1final,
1490
+
1491
+ /* SHA256 */
1492
+ &__archive_sha256init,
1493
+ &__archive_sha256update,
1494
+ &__archive_sha256final,
1495
+
1496
+ /* SHA384 */
1497
+ &__archive_sha384init,
1498
+ &__archive_sha384update,
1499
+ &__archive_sha384final,
1500
+
1501
+ /* SHA512 */
1502
+ &__archive_sha512init,
1503
+ &__archive_sha512update,
1504
+ &__archive_sha512final
1505
+ };