libarchive-static 1.0.6 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. checksums.yaml +4 -4
  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_reader.c +6 -4
  20. data/ext/libarchive-0.1.1/ext/libarchive_reader.o +0 -0
  21. data/ext/libarchive-0.1.1/ext/libarchive_ruby.so +0 -0
  22. data/ext/libarchive-0.1.1/ext/libarchive_win32.h +1 -1
  23. data/ext/libarchive-0.1.1/ext/libarchive_writer.c +2 -2
  24. data/ext/libarchive-0.1.1/ext/libarchive_writer.o +0 -0
  25. data/ext/libarchive-3.6.2/Makefile.in +16892 -0
  26. data/ext/libarchive-3.6.2/build/autoconf/ax_append_compile_flags.m4 +67 -0
  27. data/ext/libarchive-3.6.2/build/autoconf/ax_append_flag.m4 +71 -0
  28. data/ext/libarchive-3.6.2/build/autoconf/ax_check_compile_flag.m4 +74 -0
  29. data/ext/libarchive-3.6.2/build/autoconf/ax_require_defined.m4 +37 -0
  30. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/autoconf/check_stdcall_func.m4 +0 -0
  31. data/ext/libarchive-3.6.2/build/autoconf/compile +348 -0
  32. data/ext/libarchive-3.6.2/build/autoconf/config.guess +1754 -0
  33. data/ext/libarchive-3.6.2/build/autoconf/config.rpath +696 -0
  34. data/ext/libarchive-3.6.2/build/autoconf/config.sub +1890 -0
  35. data/ext/libarchive-3.6.2/build/autoconf/depcomp +791 -0
  36. data/ext/libarchive-3.6.2/build/autoconf/iconv.m4 +271 -0
  37. data/ext/libarchive-3.6.2/build/autoconf/install-sh +541 -0
  38. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/autoconf/la_uid_t.m4 +0 -0
  39. data/ext/libarchive-3.6.2/build/autoconf/lib-ld.m4 +109 -0
  40. data/ext/libarchive-3.6.2/build/autoconf/lib-link.m4 +777 -0
  41. data/ext/libarchive-3.6.2/build/autoconf/lib-prefix.m4 +224 -0
  42. data/ext/libarchive-3.6.2/build/autoconf/ltmain.sh +11251 -0
  43. data/ext/libarchive-3.6.2/build/autoconf/m4_ax_compile_check_sizeof.m4 +115 -0
  44. data/ext/libarchive-3.6.2/build/autoconf/missing +215 -0
  45. data/ext/libarchive-3.6.2/build/autoconf/test-driver +153 -0
  46. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/pkgconfig/libarchive.pc.in +4 -1
  47. data/ext/libarchive-3.6.2/config.h.in +1504 -0
  48. data/ext/libarchive-3.6.2/configure +25558 -0
  49. data/ext/libarchive-3.6.2/libarchive/archive.h +1212 -0
  50. data/ext/libarchive-3.6.2/libarchive/archive_acl.c +2097 -0
  51. data/ext/libarchive-3.6.2/libarchive/archive_acl_private.h +83 -0
  52. data/ext/libarchive-3.6.2/libarchive/archive_blake2.h +197 -0
  53. data/ext/libarchive-3.6.2/libarchive/archive_blake2_impl.h +161 -0
  54. data/ext/libarchive-3.6.2/libarchive/archive_blake2s_ref.c +369 -0
  55. data/ext/libarchive-3.6.2/libarchive/archive_blake2sp_ref.c +361 -0
  56. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_check_magic.c +63 -22
  57. data/ext/libarchive-3.6.2/libarchive/archive_cmdline.c +227 -0
  58. data/ext/libarchive-3.6.2/libarchive/archive_cmdline_private.h +47 -0
  59. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_crc32.h +17 -0
  60. data/ext/libarchive-3.6.2/libarchive/archive_cryptor.c +534 -0
  61. data/ext/libarchive-3.6.2/libarchive/archive_cryptor_private.h +188 -0
  62. data/ext/libarchive-3.6.2/libarchive/archive_digest.c +1505 -0
  63. data/ext/libarchive-3.6.2/libarchive/archive_digest_private.h +416 -0
  64. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_darwin.c +559 -0
  65. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_freebsd.c +712 -0
  66. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_linux.c +760 -0
  67. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_sunos.c +824 -0
  68. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_endian.h +48 -15
  69. data/ext/libarchive-3.6.2/libarchive/archive_entry.c +2149 -0
  70. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry.h +305 -106
  71. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_copy_bhfi.c +5 -4
  72. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_copy_stat.c +9 -3
  73. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_link_resolver.c +104 -62
  74. data/ext/libarchive-3.6.2/libarchive/archive_entry_locale.h +92 -0
  75. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_private.h +65 -49
  76. data/ext/libarchive-3.6.2/libarchive/archive_entry_sparse.c +156 -0
  77. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_stat.c +6 -6
  78. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_strmode.c +1 -1
  79. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_xattr.c +4 -6
  80. data/ext/libarchive-3.6.2/libarchive/archive_getdate.c +1165 -0
  81. data/ext/libarchive-3.6.2/libarchive/archive_getdate.h +39 -0
  82. data/ext/libarchive-3.6.2/libarchive/archive_hmac.c +334 -0
  83. data/ext/libarchive-3.6.2/libarchive/archive_hmac_private.h +117 -0
  84. data/ext/libarchive-3.6.2/libarchive/archive_match.c +1875 -0
  85. data/ext/libarchive-3.6.2/libarchive/archive_openssl_evp_private.h +53 -0
  86. data/ext/libarchive-3.6.2/libarchive/archive_openssl_hmac_private.h +54 -0
  87. data/ext/libarchive-3.6.2/libarchive/archive_options.c +218 -0
  88. data/ext/libarchive-3.6.2/libarchive/archive_options_private.h +51 -0
  89. data/ext/libarchive-3.6.2/libarchive/archive_pack_dev.c +337 -0
  90. data/ext/libarchive-3.6.2/libarchive/archive_pack_dev.h +49 -0
  91. data/ext/libarchive-3.6.2/libarchive/archive_pathmatch.c +463 -0
  92. data/ext/libarchive-3.6.2/libarchive/archive_pathmatch.h +52 -0
  93. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_platform.h +77 -9
  94. data/ext/libarchive-3.6.2/libarchive/archive_platform_acl.h +55 -0
  95. data/ext/libarchive-3.6.2/libarchive/archive_platform_xattr.h +47 -0
  96. data/ext/libarchive-3.6.2/libarchive/archive_ppmd7.c +1168 -0
  97. data/ext/libarchive-3.6.2/libarchive/archive_ppmd7_private.h +119 -0
  98. data/ext/libarchive-3.6.2/libarchive/archive_ppmd8.c +1287 -0
  99. data/ext/libarchive-3.6.2/libarchive/archive_ppmd8_private.h +148 -0
  100. data/ext/libarchive-3.6.2/libarchive/archive_ppmd_private.h +151 -0
  101. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_private.h +74 -18
  102. data/ext/libarchive-3.6.2/libarchive/archive_random.c +272 -0
  103. data/ext/libarchive-3.6.2/libarchive/archive_random_private.h +36 -0
  104. data/ext/libarchive-3.6.2/libarchive/archive_rb.c +709 -0
  105. data/ext/libarchive-3.6.2/libarchive/archive_rb.h +113 -0
  106. data/ext/libarchive-3.6.2/libarchive/archive_read.c +1756 -0
  107. data/ext/libarchive-3.6.2/libarchive/archive_read_add_passphrase.c +190 -0
  108. data/ext/libarchive-3.6.2/libarchive/archive_read_append_filter.c +204 -0
  109. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_data_into_fd.c +64 -18
  110. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_entry_from_file.c +1086 -0
  111. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_posix.c +2732 -0
  112. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_disk_private.h +40 -4
  113. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_disk_set_standard_lookup.c +21 -11
  114. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_windows.c +2479 -0
  115. data/ext/libarchive-3.6.2/libarchive/archive_read_extract.c +60 -0
  116. data/ext/{libarchive-2.8.4/libarchive/archive_read_extract.c → libarchive-3.6.2/libarchive/archive_read_extract2.c} +34 -61
  117. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_fd.c +70 -49
  118. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_file.c +38 -23
  119. data/ext/libarchive-3.6.2/libarchive/archive_read_open_filename.c +586 -0
  120. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_memory.c +58 -28
  121. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_private.h +127 -59
  122. data/ext/libarchive-3.6.2/libarchive/archive_read_set_format.c +117 -0
  123. data/ext/libarchive-3.6.2/libarchive/archive_read_set_options.c +133 -0
  124. 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
  125. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_by_code.c +83 -0
  126. 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
  127. 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
  128. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_grzip.c +112 -0
  129. 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
  130. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lrzip.c +122 -0
  131. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lz4.c +742 -0
  132. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lzop.c +499 -0
  133. 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
  134. 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
  135. 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
  136. 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
  137. 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
  138. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_zstd.c +297 -0
  139. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_7zip.c +3900 -0
  140. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_all.c +89 -0
  141. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_ar.c +126 -72
  142. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_by_code.c +92 -0
  143. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_cab.c +3228 -0
  144. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_cpio.c +1104 -0
  145. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_empty.c +14 -11
  146. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_iso9660.c +990 -541
  147. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_lha.c +2916 -0
  148. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_mtree.c +2150 -0
  149. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_rar.c +3797 -0
  150. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_rar5.c +4251 -0
  151. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_raw.c +38 -31
  152. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_tar.c +1157 -629
  153. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_warc.c +848 -0
  154. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_xar.c +439 -258
  155. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_zip.c +4270 -0
  156. data/ext/libarchive-3.6.2/libarchive/archive_string.c +4240 -0
  157. data/ext/libarchive-3.6.2/libarchive/archive_string.h +243 -0
  158. data/ext/libarchive-3.6.2/libarchive/archive_string_composition.h +2292 -0
  159. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_string_sprintf.c +44 -16
  160. data/ext/libarchive-3.6.2/libarchive/archive_util.c +655 -0
  161. data/ext/libarchive-3.6.2/libarchive/archive_version_details.c +151 -0
  162. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_virtual.c +85 -16
  163. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_windows.c +214 -541
  164. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_windows.h +74 -106
  165. data/ext/libarchive-3.6.2/libarchive/archive_write.c +828 -0
  166. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter.c +72 -0
  167. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_b64encode.c +304 -0
  168. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_by_name.c +77 -0
  169. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_bzip2.c +401 -0
  170. 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
  171. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_grzip.c +135 -0
  172. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_gzip.c +442 -0
  173. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lrzip.c +197 -0
  174. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lz4.c +700 -0
  175. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lzop.c +478 -0
  176. 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
  177. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_program.c +391 -0
  178. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_uuencode.c +295 -0
  179. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_xz.c +545 -0
  180. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_zstd.c +418 -0
  181. data/ext/libarchive-3.6.2/libarchive/archive_write_disk_posix.c +4711 -0
  182. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_disk_private.h +9 -2
  183. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_disk_set_standard_lookup.c +30 -29
  184. data/ext/libarchive-3.6.2/libarchive/archive_write_disk_windows.c +2842 -0
  185. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_fd.c +15 -10
  186. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_file.c +15 -9
  187. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_filename.c +128 -20
  188. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_memory.c +7 -18
  189. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_private.h +72 -29
  190. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format.c +56 -3
  191. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_7zip.c +2322 -0
  192. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_ar.c +54 -34
  193. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_by_name.c +20 -2
  194. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio.c +11 -0
  195. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_binary.c +610 -0
  196. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_newc.c +457 -0
  197. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_odc.c +500 -0
  198. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_filter_by_ext.c +142 -0
  199. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_gnutar.c +755 -0
  200. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_iso9660.c +8165 -0
  201. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_mtree.c +2217 -0
  202. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_pax.c +1049 -387
  203. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_private.h +42 -0
  204. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_raw.c +125 -0
  205. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_shar.c +62 -47
  206. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_ustar.c +279 -108
  207. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_v7tar.c +638 -0
  208. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_warc.c +453 -0
  209. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_xar.c +3259 -0
  210. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_zip.c +1704 -0
  211. data/ext/libarchive-3.6.2/libarchive/archive_write_set_options.c +130 -0
  212. data/ext/libarchive-3.6.2/libarchive/archive_write_set_passphrase.c +95 -0
  213. data/ext/libarchive-3.6.2/libarchive/archive_xxhash.h +48 -0
  214. data/ext/libarchive-3.6.2/libarchive/config_freebsd.h +271 -0
  215. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/filter_fork.h +10 -5
  216. data/ext/{libarchive-2.8.4/libarchive/filter_fork.c → libarchive-3.6.2/libarchive/filter_fork_posix.c} +98 -19
  217. data/ext/libarchive-3.6.2/libarchive/filter_fork_windows.c +236 -0
  218. data/ext/libarchive-3.6.2/libarchive/xxhash.c +525 -0
  219. data/ext/libarchive-static-makefile +144 -80
  220. data/ext/libarchive-static-wrapper-makefile +1 -1
  221. data/ext/zlib-1.2.13/Makefile.in +404 -0
  222. data/ext/{zlib-1.2.5 → zlib-1.2.13}/adler32.c +51 -34
  223. data/ext/{zlib-1.2.5 → zlib-1.2.13}/compress.c +27 -21
  224. data/ext/zlib-1.2.13/configure +922 -0
  225. data/ext/zlib-1.2.13/crc32.c +1125 -0
  226. data/ext/zlib-1.2.13/crc32.h +9446 -0
  227. data/ext/{zlib-1.2.5 → zlib-1.2.13}/deflate.c +842 -459
  228. data/ext/{zlib-1.2.5 → zlib-1.2.13}/deflate.h +37 -33
  229. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzclose.c +0 -0
  230. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzguts.h +103 -16
  231. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzlib.c +155 -53
  232. data/ext/zlib-1.2.13/gzread.c +650 -0
  233. data/ext/zlib-1.2.13/gzwrite.c +677 -0
  234. data/ext/{zlib-1.2.5 → zlib-1.2.13}/infback.c +24 -12
  235. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffast.c +49 -66
  236. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffast.h +0 -0
  237. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffixed.h +3 -3
  238. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inflate.c +209 -94
  239. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inflate.h +9 -5
  240. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inftrees.c +24 -50
  241. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inftrees.h +1 -1
  242. data/ext/{zlib-1.2.5 → zlib-1.2.13}/trees.c +135 -198
  243. data/ext/{zlib-1.2.5 → zlib-1.2.13}/trees.h +0 -0
  244. data/ext/zlib-1.2.13/uncompr.c +93 -0
  245. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zconf.h +182 -63
  246. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zlib.h +617 -295
  247. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zutil.c +50 -41
  248. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zutil.h +83 -82
  249. metadata +241 -133
  250. data/ext/libarchive-0.1.1/libarchive.c +0 -1762
  251. data/ext/libarchive-2.8.4/Makefile.in +0 -7076
  252. data/ext/libarchive-2.8.4/build/autoconf/compile +0 -143
  253. data/ext/libarchive-2.8.4/build/autoconf/config.guess +0 -1502
  254. data/ext/libarchive-2.8.4/build/autoconf/config.sub +0 -1708
  255. data/ext/libarchive-2.8.4/build/autoconf/depcomp +0 -630
  256. data/ext/libarchive-2.8.4/build/autoconf/install-sh +0 -291
  257. data/ext/libarchive-2.8.4/build/autoconf/ltmain.sh +0 -8406
  258. data/ext/libarchive-2.8.4/build/autoconf/missing +0 -376
  259. data/ext/libarchive-2.8.4/config.h.in +0 -772
  260. data/ext/libarchive-2.8.4/configure +0 -17916
  261. data/ext/libarchive-2.8.4/libarchive/archive.h +0 -741
  262. data/ext/libarchive-2.8.4/libarchive/archive_entry.c +0 -2202
  263. data/ext/libarchive-2.8.4/libarchive/archive_hash.h +0 -281
  264. data/ext/libarchive-2.8.4/libarchive/archive_read.c +0 -1249
  265. data/ext/libarchive-2.8.4/libarchive/archive_read_disk.c +0 -198
  266. data/ext/libarchive-2.8.4/libarchive/archive_read_disk_entry_from_file.c +0 -570
  267. data/ext/libarchive-2.8.4/libarchive/archive_read_open_filename.c +0 -272
  268. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_cpio.c +0 -777
  269. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_mtree.c +0 -1304
  270. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_zip.c +0 -903
  271. data/ext/libarchive-2.8.4/libarchive/archive_string.c +0 -453
  272. data/ext/libarchive-2.8.4/libarchive/archive_string.h +0 -148
  273. data/ext/libarchive-2.8.4/libarchive/archive_util.c +0 -391
  274. data/ext/libarchive-2.8.4/libarchive/archive_write.c +0 -466
  275. data/ext/libarchive-2.8.4/libarchive/archive_write_disk.c +0 -2628
  276. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_bzip2.c +0 -408
  277. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_gzip.c +0 -477
  278. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_none.c +0 -257
  279. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_program.c +0 -347
  280. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_xz.c +0 -438
  281. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio.c +0 -344
  282. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio_newc.c +0 -295
  283. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_mtree.c +0 -1050
  284. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_zip.c +0 -667
  285. data/ext/libarchive-2.8.4/libarchive/config_freebsd.h +0 -154
  286. data/ext/libarchive-2.8.4/libarchive/filter_fork_windows.c +0 -113
  287. data/ext/zlib-1.2.5/Makefile.in +0 -257
  288. data/ext/zlib-1.2.5/configure +0 -596
  289. data/ext/zlib-1.2.5/crc32.c +0 -442
  290. data/ext/zlib-1.2.5/crc32.h +0 -441
  291. data/ext/zlib-1.2.5/example.c +0 -565
  292. data/ext/zlib-1.2.5/gzread.c +0 -653
  293. data/ext/zlib-1.2.5/gzwrite.c +0 -531
  294. data/ext/zlib-1.2.5/minigzip.c +0 -440
  295. data/ext/zlib-1.2.5/uncompr.c +0 -59
@@ -0,0 +1,534 @@
1
+ /*-
2
+ * Copyright (c) 2014 Michihiro NAKAJIMA
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions
7
+ * are met:
8
+ * 1. Redistributions of source code must retain the above copyright
9
+ * notice, this list of conditions and the following disclaimer.
10
+ * 2. Redistributions in binary form must reproduce the above copyright
11
+ * notice, this list of conditions and the following disclaimer in the
12
+ * documentation and/or other materials provided with the distribution.
13
+ *
14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ */
25
+
26
+ #include "archive_platform.h"
27
+
28
+ #ifdef HAVE_STRING_H
29
+ #include <string.h>
30
+ #endif
31
+ #include "archive.h"
32
+ #include "archive_cryptor_private.h"
33
+
34
+ /*
35
+ * On systems that do not support any recognized crypto libraries,
36
+ * this file will normally define no usable symbols.
37
+ *
38
+ * But some compilers and linkers choke on empty object files, so
39
+ * define a public symbol that will always exist. This could
40
+ * be removed someday if this file gains another always-present
41
+ * symbol definition.
42
+ */
43
+ int __libarchive_cryptor_build_hack(void) {
44
+ return 0;
45
+ }
46
+
47
+ #ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
48
+
49
+ static int
50
+ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
51
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
52
+ size_t derived_key_len)
53
+ {
54
+ CCKeyDerivationPBKDF(kCCPBKDF2, (const char *)pw,
55
+ pw_len, salt, salt_len, kCCPRFHmacAlgSHA1, rounds,
56
+ derived_key, derived_key_len);
57
+ return 0;
58
+ }
59
+
60
+ #elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
61
+ #ifdef _MSC_VER
62
+ #pragma comment(lib, "Bcrypt.lib")
63
+ #endif
64
+
65
+ static int
66
+ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
67
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
68
+ size_t derived_key_len)
69
+ {
70
+ NTSTATUS status;
71
+ BCRYPT_ALG_HANDLE hAlg;
72
+
73
+ status = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_SHA1_ALGORITHM,
74
+ MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG);
75
+ if (!BCRYPT_SUCCESS(status))
76
+ return -1;
77
+
78
+ status = BCryptDeriveKeyPBKDF2(hAlg,
79
+ (PUCHAR)(uintptr_t)pw, (ULONG)pw_len,
80
+ (PUCHAR)(uintptr_t)salt, (ULONG)salt_len, rounds,
81
+ (PUCHAR)derived_key, (ULONG)derived_key_len, 0);
82
+
83
+ BCryptCloseAlgorithmProvider(hAlg, 0);
84
+
85
+ return (BCRYPT_SUCCESS(status)) ? 0: -1;
86
+ }
87
+
88
+ #elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_PKCS5_H)
89
+
90
+ static int
91
+ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
92
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
93
+ size_t derived_key_len)
94
+ {
95
+ mbedtls_md_context_t ctx;
96
+ const mbedtls_md_info_t *info;
97
+ int ret;
98
+
99
+ mbedtls_md_init(&ctx);
100
+ info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA1);
101
+ if (info == NULL) {
102
+ mbedtls_md_free(&ctx);
103
+ return (-1);
104
+ }
105
+ ret = mbedtls_md_setup(&ctx, info, 1);
106
+ if (ret != 0) {
107
+ mbedtls_md_free(&ctx);
108
+ return (-1);
109
+ }
110
+ ret = mbedtls_pkcs5_pbkdf2_hmac(&ctx, (const unsigned char *)pw,
111
+ pw_len, salt, salt_len, rounds, derived_key_len, derived_key);
112
+
113
+ mbedtls_md_free(&ctx);
114
+ return (ret);
115
+ }
116
+
117
+ #elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_PBKDF2_H)
118
+
119
+ static int
120
+ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
121
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
122
+ size_t derived_key_len) {
123
+ pbkdf2_hmac_sha1((unsigned)pw_len, (const uint8_t *)pw, rounds,
124
+ salt_len, salt, derived_key_len, derived_key);
125
+ return 0;
126
+ }
127
+
128
+ #elif defined(HAVE_LIBCRYPTO) && defined(HAVE_PKCS5_PBKDF2_HMAC_SHA1)
129
+
130
+ static int
131
+ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
132
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
133
+ size_t derived_key_len) {
134
+
135
+ PKCS5_PBKDF2_HMAC_SHA1(pw, pw_len, salt, salt_len, rounds,
136
+ derived_key_len, derived_key);
137
+ return 0;
138
+ }
139
+
140
+ #else
141
+
142
+ /* Stub */
143
+ static int
144
+ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
145
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
146
+ size_t derived_key_len) {
147
+ (void)pw; /* UNUSED */
148
+ (void)pw_len; /* UNUSED */
149
+ (void)salt; /* UNUSED */
150
+ (void)salt_len; /* UNUSED */
151
+ (void)rounds; /* UNUSED */
152
+ (void)derived_key; /* UNUSED */
153
+ (void)derived_key_len; /* UNUSED */
154
+ return -1; /* UNSUPPORTED */
155
+ }
156
+
157
+ #endif
158
+
159
+ #ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
160
+ # if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
161
+ # define kCCAlgorithmAES kCCAlgorithmAES128
162
+ # endif
163
+
164
+ static int
165
+ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
166
+ {
167
+ CCCryptorStatus r;
168
+
169
+ ctx->key_len = key_len;
170
+ memcpy(ctx->key, key, key_len);
171
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
172
+ ctx->encr_pos = AES_BLOCK_SIZE;
173
+ r = CCCryptorCreateWithMode(kCCEncrypt, kCCModeECB, kCCAlgorithmAES,
174
+ ccNoPadding, NULL, key, key_len, NULL, 0, 0, 0, &ctx->ctx);
175
+ return (r == kCCSuccess)? 0: -1;
176
+ }
177
+
178
+ static int
179
+ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
180
+ {
181
+ CCCryptorRef ref = ctx->ctx;
182
+ CCCryptorStatus r;
183
+
184
+ r = CCCryptorReset(ref, NULL);
185
+ if (r != kCCSuccess && r != kCCUnimplemented)
186
+ return -1;
187
+ r = CCCryptorUpdate(ref, ctx->nonce, AES_BLOCK_SIZE, ctx->encr_buf,
188
+ AES_BLOCK_SIZE, NULL);
189
+ return (r == kCCSuccess)? 0: -1;
190
+ }
191
+
192
+ static int
193
+ aes_ctr_release(archive_crypto_ctx *ctx)
194
+ {
195
+ memset(ctx->key, 0, ctx->key_len);
196
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
197
+ return 0;
198
+ }
199
+
200
+ #elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
201
+
202
+ static int
203
+ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
204
+ {
205
+ BCRYPT_ALG_HANDLE hAlg;
206
+ BCRYPT_KEY_HANDLE hKey;
207
+ DWORD keyObj_len, aes_key_len;
208
+ PBYTE keyObj;
209
+ ULONG result;
210
+ NTSTATUS status;
211
+ BCRYPT_KEY_LENGTHS_STRUCT key_lengths;
212
+
213
+ ctx->hAlg = NULL;
214
+ ctx->hKey = NULL;
215
+ ctx->keyObj = NULL;
216
+ switch (key_len) {
217
+ case 16: aes_key_len = 128; break;
218
+ case 24: aes_key_len = 192; break;
219
+ case 32: aes_key_len = 256; break;
220
+ default: return -1;
221
+ }
222
+ status = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_AES_ALGORITHM,
223
+ MS_PRIMITIVE_PROVIDER, 0);
224
+ if (!BCRYPT_SUCCESS(status))
225
+ return -1;
226
+ status = BCryptGetProperty(hAlg, BCRYPT_KEY_LENGTHS, (PUCHAR)&key_lengths,
227
+ sizeof(key_lengths), &result, 0);
228
+ if (!BCRYPT_SUCCESS(status)) {
229
+ BCryptCloseAlgorithmProvider(hAlg, 0);
230
+ return -1;
231
+ }
232
+ if (key_lengths.dwMinLength > aes_key_len
233
+ || key_lengths.dwMaxLength < aes_key_len) {
234
+ BCryptCloseAlgorithmProvider(hAlg, 0);
235
+ return -1;
236
+ }
237
+ status = BCryptGetProperty(hAlg, BCRYPT_OBJECT_LENGTH, (PUCHAR)&keyObj_len,
238
+ sizeof(keyObj_len), &result, 0);
239
+ if (!BCRYPT_SUCCESS(status)) {
240
+ BCryptCloseAlgorithmProvider(hAlg, 0);
241
+ return -1;
242
+ }
243
+ keyObj = (PBYTE)HeapAlloc(GetProcessHeap(), 0, keyObj_len);
244
+ if (keyObj == NULL) {
245
+ BCryptCloseAlgorithmProvider(hAlg, 0);
246
+ return -1;
247
+ }
248
+ status = BCryptSetProperty(hAlg, BCRYPT_CHAINING_MODE,
249
+ (PUCHAR)BCRYPT_CHAIN_MODE_ECB, sizeof(BCRYPT_CHAIN_MODE_ECB), 0);
250
+ if (!BCRYPT_SUCCESS(status)) {
251
+ BCryptCloseAlgorithmProvider(hAlg, 0);
252
+ HeapFree(GetProcessHeap(), 0, keyObj);
253
+ return -1;
254
+ }
255
+ status = BCryptGenerateSymmetricKey(hAlg, &hKey,
256
+ keyObj, keyObj_len,
257
+ (PUCHAR)(uintptr_t)key, (ULONG)key_len, 0);
258
+ if (!BCRYPT_SUCCESS(status)) {
259
+ BCryptCloseAlgorithmProvider(hAlg, 0);
260
+ HeapFree(GetProcessHeap(), 0, keyObj);
261
+ return -1;
262
+ }
263
+
264
+ ctx->hAlg = hAlg;
265
+ ctx->hKey = hKey;
266
+ ctx->keyObj = keyObj;
267
+ ctx->keyObj_len = keyObj_len;
268
+ ctx->encr_pos = AES_BLOCK_SIZE;
269
+
270
+ return 0;
271
+ }
272
+
273
+ static int
274
+ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
275
+ {
276
+ NTSTATUS status;
277
+ ULONG result;
278
+
279
+ status = BCryptEncrypt(ctx->hKey, (PUCHAR)ctx->nonce, AES_BLOCK_SIZE,
280
+ NULL, NULL, 0, (PUCHAR)ctx->encr_buf, AES_BLOCK_SIZE,
281
+ &result, 0);
282
+ return BCRYPT_SUCCESS(status) ? 0 : -1;
283
+ }
284
+
285
+ static int
286
+ aes_ctr_release(archive_crypto_ctx *ctx)
287
+ {
288
+
289
+ if (ctx->hAlg != NULL) {
290
+ BCryptCloseAlgorithmProvider(ctx->hAlg, 0);
291
+ ctx->hAlg = NULL;
292
+ BCryptDestroyKey(ctx->hKey);
293
+ ctx->hKey = NULL;
294
+ HeapFree(GetProcessHeap(), 0, ctx->keyObj);
295
+ ctx->keyObj = NULL;
296
+ }
297
+ memset(ctx, 0, sizeof(*ctx));
298
+ return 0;
299
+ }
300
+
301
+ #elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_AES_H)
302
+
303
+ static int
304
+ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
305
+ {
306
+ mbedtls_aes_init(&ctx->ctx);
307
+ ctx->key_len = key_len;
308
+ memcpy(ctx->key, key, key_len);
309
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
310
+ ctx->encr_pos = AES_BLOCK_SIZE;
311
+ return 0;
312
+ }
313
+
314
+ static int
315
+ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
316
+ {
317
+ if (mbedtls_aes_setkey_enc(&ctx->ctx, ctx->key,
318
+ ctx->key_len * 8) != 0)
319
+ return (-1);
320
+ if (mbedtls_aes_crypt_ecb(&ctx->ctx, MBEDTLS_AES_ENCRYPT, ctx->nonce,
321
+ ctx->encr_buf) != 0)
322
+ return (-1);
323
+ return 0;
324
+ }
325
+
326
+ static int
327
+ aes_ctr_release(archive_crypto_ctx *ctx)
328
+ {
329
+ mbedtls_aes_free(&ctx->ctx);
330
+ memset(ctx, 0, sizeof(*ctx));
331
+ return 0;
332
+ }
333
+
334
+ #elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H)
335
+
336
+ static int
337
+ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
338
+ {
339
+ ctx->key_len = key_len;
340
+ memcpy(ctx->key, key, key_len);
341
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
342
+ ctx->encr_pos = AES_BLOCK_SIZE;
343
+ memset(&ctx->ctx, 0, sizeof(ctx->ctx));
344
+ return 0;
345
+ }
346
+
347
+ static int
348
+ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
349
+ {
350
+ #if NETTLE_VERSION_MAJOR < 3
351
+ aes_set_encrypt_key(&ctx->ctx, ctx->key_len, ctx->key);
352
+ aes_encrypt(&ctx->ctx, AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
353
+ #else
354
+ switch(ctx->key_len) {
355
+ case AES128_KEY_SIZE:
356
+ aes128_set_encrypt_key(&ctx->ctx.c128, ctx->key);
357
+ aes128_encrypt(&ctx->ctx.c128, AES_BLOCK_SIZE, ctx->encr_buf,
358
+ ctx->nonce);
359
+ break;
360
+ case AES192_KEY_SIZE:
361
+ aes192_set_encrypt_key(&ctx->ctx.c192, ctx->key);
362
+ aes192_encrypt(&ctx->ctx.c192, AES_BLOCK_SIZE, ctx->encr_buf,
363
+ ctx->nonce);
364
+ break;
365
+ case AES256_KEY_SIZE:
366
+ aes256_set_encrypt_key(&ctx->ctx.c256, ctx->key);
367
+ aes256_encrypt(&ctx->ctx.c256, AES_BLOCK_SIZE, ctx->encr_buf,
368
+ ctx->nonce);
369
+ break;
370
+ default:
371
+ return -1;
372
+ break;
373
+ }
374
+ #endif
375
+ return 0;
376
+ }
377
+
378
+ static int
379
+ aes_ctr_release(archive_crypto_ctx *ctx)
380
+ {
381
+ memset(ctx, 0, sizeof(*ctx));
382
+ return 0;
383
+ }
384
+
385
+ #elif defined(HAVE_LIBCRYPTO)
386
+
387
+ static int
388
+ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
389
+ {
390
+ if ((ctx->ctx = EVP_CIPHER_CTX_new()) == NULL)
391
+ return -1;
392
+
393
+ switch (key_len) {
394
+ case 16: ctx->type = EVP_aes_128_ecb(); break;
395
+ case 24: ctx->type = EVP_aes_192_ecb(); break;
396
+ case 32: ctx->type = EVP_aes_256_ecb(); break;
397
+ default: ctx->type = NULL; return -1;
398
+ }
399
+
400
+ ctx->key_len = key_len;
401
+ memcpy(ctx->key, key, key_len);
402
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
403
+ ctx->encr_pos = AES_BLOCK_SIZE;
404
+ return 0;
405
+ }
406
+
407
+ static int
408
+ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
409
+ {
410
+ int outl = 0;
411
+ int r;
412
+
413
+ r = EVP_EncryptInit_ex(ctx->ctx, ctx->type, NULL, ctx->key, NULL);
414
+ if (r == 0)
415
+ return -1;
416
+ r = EVP_EncryptUpdate(ctx->ctx, ctx->encr_buf, &outl, ctx->nonce,
417
+ AES_BLOCK_SIZE);
418
+ if (r == 0 || outl != AES_BLOCK_SIZE)
419
+ return -1;
420
+ return 0;
421
+ }
422
+
423
+ static int
424
+ aes_ctr_release(archive_crypto_ctx *ctx)
425
+ {
426
+ EVP_CIPHER_CTX_free(ctx->ctx);
427
+ memset(ctx->key, 0, ctx->key_len);
428
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
429
+ return 0;
430
+ }
431
+
432
+ #else
433
+
434
+ #define ARCHIVE_CRYPTOR_STUB
435
+ /* Stub */
436
+ static int
437
+ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
438
+ {
439
+ (void)ctx; /* UNUSED */
440
+ (void)key; /* UNUSED */
441
+ (void)key_len; /* UNUSED */
442
+ return -1;
443
+ }
444
+
445
+ static int
446
+ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
447
+ {
448
+ (void)ctx; /* UNUSED */
449
+ return -1;
450
+ }
451
+
452
+ static int
453
+ aes_ctr_release(archive_crypto_ctx *ctx)
454
+ {
455
+ (void)ctx; /* UNUSED */
456
+ return 0;
457
+ }
458
+
459
+ #endif
460
+
461
+ #ifdef ARCHIVE_CRYPTOR_STUB
462
+ static int
463
+ aes_ctr_update(archive_crypto_ctx *ctx, const uint8_t * const in,
464
+ size_t in_len, uint8_t * const out, size_t *out_len)
465
+ {
466
+ (void)ctx; /* UNUSED */
467
+ (void)in; /* UNUSED */
468
+ (void)in_len; /* UNUSED */
469
+ (void)out; /* UNUSED */
470
+ (void)out_len; /* UNUSED */
471
+ aes_ctr_encrypt_counter(ctx); /* UNUSED */ /* Fix unused function warning */
472
+ return -1;
473
+ }
474
+
475
+ #else
476
+ static void
477
+ aes_ctr_increase_counter(archive_crypto_ctx *ctx)
478
+ {
479
+ uint8_t *const nonce = ctx->nonce;
480
+ int j;
481
+
482
+ for (j = 0; j < 8; j++) {
483
+ if (++nonce[j])
484
+ break;
485
+ }
486
+ }
487
+
488
+ static int
489
+ aes_ctr_update(archive_crypto_ctx *ctx, const uint8_t * const in,
490
+ size_t in_len, uint8_t * const out, size_t *out_len)
491
+ {
492
+ uint8_t *const ebuf = ctx->encr_buf;
493
+ unsigned pos = ctx->encr_pos;
494
+ unsigned max = (unsigned)((in_len < *out_len)? in_len: *out_len);
495
+ unsigned i;
496
+
497
+ for (i = 0; i < max; ) {
498
+ if (pos == AES_BLOCK_SIZE) {
499
+ aes_ctr_increase_counter(ctx);
500
+ if (aes_ctr_encrypt_counter(ctx) != 0)
501
+ return -1;
502
+ while (max -i >= AES_BLOCK_SIZE) {
503
+ for (pos = 0; pos < AES_BLOCK_SIZE; pos++)
504
+ out[i+pos] = in[i+pos] ^ ebuf[pos];
505
+ i += AES_BLOCK_SIZE;
506
+ aes_ctr_increase_counter(ctx);
507
+ if (aes_ctr_encrypt_counter(ctx) != 0)
508
+ return -1;
509
+ }
510
+ pos = 0;
511
+ if (i >= max)
512
+ break;
513
+ }
514
+ out[i] = in[i] ^ ebuf[pos++];
515
+ i++;
516
+ }
517
+ ctx->encr_pos = pos;
518
+ *out_len = i;
519
+
520
+ return 0;
521
+ }
522
+ #endif /* ARCHIVE_CRYPTOR_STUB */
523
+
524
+
525
+ const struct archive_cryptor __archive_cryptor =
526
+ {
527
+ &pbkdf2_sha1,
528
+ &aes_ctr_init,
529
+ &aes_ctr_update,
530
+ &aes_ctr_release,
531
+ &aes_ctr_init,
532
+ &aes_ctr_update,
533
+ &aes_ctr_release,
534
+ };
@@ -0,0 +1,188 @@
1
+ /*-
2
+ * Copyright (c) 2014 Michihiro NAKAJIMA
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions
7
+ * are met:
8
+ * 1. Redistributions of source code must retain the above copyright
9
+ * notice, this list of conditions and the following disclaimer.
10
+ * 2. Redistributions in binary form must reproduce the above copyright
11
+ * notice, this list of conditions and the following disclaimer in the
12
+ * documentation and/or other materials provided with the distribution.
13
+ *
14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ */
25
+
26
+ #ifndef ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
27
+ #define ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
28
+
29
+ #ifndef __LIBARCHIVE_BUILD
30
+ #error This header is only to be used internally to libarchive.
31
+ #endif
32
+ /*
33
+ * On systems that do not support any recognized crypto libraries,
34
+ * the archive_cryptor.c file will normally define no usable symbols.
35
+ *
36
+ * But some compilers and linkers choke on empty object files, so
37
+ * define a public symbol that will always exist. This could
38
+ * be removed someday if this file gains another always-present
39
+ * symbol definition.
40
+ */
41
+ int __libarchive_cryptor_build_hack(void);
42
+
43
+ #ifdef __APPLE__
44
+ # include <AvailabilityMacros.h>
45
+ # if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
46
+ # define ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
47
+ # endif
48
+ #endif
49
+
50
+ #ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
51
+ #include <CommonCrypto/CommonCryptor.h>
52
+ #include <CommonCrypto/CommonKeyDerivation.h>
53
+ #define AES_BLOCK_SIZE 16
54
+ #define AES_MAX_KEY_SIZE kCCKeySizeAES256
55
+
56
+ typedef struct {
57
+ CCCryptorRef ctx;
58
+ uint8_t key[AES_MAX_KEY_SIZE];
59
+ unsigned key_len;
60
+ uint8_t nonce[AES_BLOCK_SIZE];
61
+ uint8_t encr_buf[AES_BLOCK_SIZE];
62
+ unsigned encr_pos;
63
+ } archive_crypto_ctx;
64
+
65
+ #elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
66
+ #include <bcrypt.h>
67
+
68
+ /* Common in other bcrypt implementations, but missing from VS2008. */
69
+ #ifndef BCRYPT_SUCCESS
70
+ #define BCRYPT_SUCCESS(r) ((NTSTATUS)(r) == STATUS_SUCCESS)
71
+ #endif
72
+
73
+ #define AES_MAX_KEY_SIZE 32
74
+ #define AES_BLOCK_SIZE 16
75
+ typedef struct {
76
+ BCRYPT_ALG_HANDLE hAlg;
77
+ BCRYPT_KEY_HANDLE hKey;
78
+ PBYTE keyObj;
79
+ DWORD keyObj_len;
80
+ uint8_t nonce[AES_BLOCK_SIZE];
81
+ uint8_t encr_buf[AES_BLOCK_SIZE];
82
+ unsigned encr_pos;
83
+ } archive_crypto_ctx;
84
+
85
+ #elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_AES_H)
86
+ #include <mbedtls/aes.h>
87
+ #include <mbedtls/md.h>
88
+ #include <mbedtls/pkcs5.h>
89
+
90
+ #define AES_MAX_KEY_SIZE 32
91
+ #define AES_BLOCK_SIZE 16
92
+
93
+ typedef struct {
94
+ mbedtls_aes_context ctx;
95
+ uint8_t key[AES_MAX_KEY_SIZE];
96
+ unsigned key_len;
97
+ uint8_t nonce[AES_BLOCK_SIZE];
98
+ uint8_t encr_buf[AES_BLOCK_SIZE];
99
+ unsigned encr_pos;
100
+ } archive_crypto_ctx;
101
+
102
+ #elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H)
103
+ #if defined(HAVE_NETTLE_PBKDF2_H)
104
+ #include <nettle/pbkdf2.h>
105
+ #endif
106
+ #include <nettle/aes.h>
107
+ #include <nettle/version.h>
108
+
109
+ typedef struct {
110
+ #if NETTLE_VERSION_MAJOR < 3
111
+ struct aes_ctx ctx;
112
+ #else
113
+ union {
114
+ struct aes128_ctx c128;
115
+ struct aes192_ctx c192;
116
+ struct aes256_ctx c256;
117
+ } ctx;
118
+ #endif
119
+ uint8_t key[AES_MAX_KEY_SIZE];
120
+ unsigned key_len;
121
+ uint8_t nonce[AES_BLOCK_SIZE];
122
+ uint8_t encr_buf[AES_BLOCK_SIZE];
123
+ unsigned encr_pos;
124
+ } archive_crypto_ctx;
125
+
126
+ #elif defined(HAVE_LIBCRYPTO)
127
+ #include "archive_openssl_evp_private.h"
128
+ #define AES_BLOCK_SIZE 16
129
+ #define AES_MAX_KEY_SIZE 32
130
+
131
+ typedef struct {
132
+ EVP_CIPHER_CTX *ctx;
133
+ const EVP_CIPHER *type;
134
+ uint8_t key[AES_MAX_KEY_SIZE];
135
+ unsigned key_len;
136
+ uint8_t nonce[AES_BLOCK_SIZE];
137
+ uint8_t encr_buf[AES_BLOCK_SIZE];
138
+ unsigned encr_pos;
139
+ } archive_crypto_ctx;
140
+
141
+ #else
142
+
143
+ #define AES_BLOCK_SIZE 16
144
+ #define AES_MAX_KEY_SIZE 32
145
+ typedef int archive_crypto_ctx;
146
+
147
+ #endif
148
+
149
+ /* defines */
150
+ #define archive_pbkdf2_sha1(pw, pw_len, salt, salt_len, rounds, dk, dk_len)\
151
+ __archive_cryptor.pbkdf2sha1(pw, pw_len, salt, salt_len, rounds, dk, dk_len)
152
+
153
+ #define archive_decrypto_aes_ctr_init(ctx, key, key_len) \
154
+ __archive_cryptor.decrypto_aes_ctr_init(ctx, key, key_len)
155
+ #define archive_decrypto_aes_ctr_update(ctx, in, in_len, out, out_len) \
156
+ __archive_cryptor.decrypto_aes_ctr_update(ctx, in, in_len, out, out_len)
157
+ #define archive_decrypto_aes_ctr_release(ctx) \
158
+ __archive_cryptor.decrypto_aes_ctr_release(ctx)
159
+
160
+ #define archive_encrypto_aes_ctr_init(ctx, key, key_len) \
161
+ __archive_cryptor.encrypto_aes_ctr_init(ctx, key, key_len)
162
+ #define archive_encrypto_aes_ctr_update(ctx, in, in_len, out, out_len) \
163
+ __archive_cryptor.encrypto_aes_ctr_update(ctx, in, in_len, out, out_len)
164
+ #define archive_encrypto_aes_ctr_release(ctx) \
165
+ __archive_cryptor.encrypto_aes_ctr_release(ctx)
166
+
167
+ /* Minimal interface to cryptographic functionality for internal use in
168
+ * libarchive */
169
+ struct archive_cryptor
170
+ {
171
+ /* PKCS5 PBKDF2 HMAC-SHA1 */
172
+ int (*pbkdf2sha1)(const char *pw, size_t pw_len, const uint8_t *salt,
173
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
174
+ size_t derived_key_len);
175
+ /* AES CTR mode(little endian version) */
176
+ int (*decrypto_aes_ctr_init)(archive_crypto_ctx *, const uint8_t *, size_t);
177
+ int (*decrypto_aes_ctr_update)(archive_crypto_ctx *, const uint8_t *,
178
+ size_t, uint8_t *, size_t *);
179
+ int (*decrypto_aes_ctr_release)(archive_crypto_ctx *);
180
+ int (*encrypto_aes_ctr_init)(archive_crypto_ctx *, const uint8_t *, size_t);
181
+ int (*encrypto_aes_ctr_update)(archive_crypto_ctx *, const uint8_t *,
182
+ size_t, uint8_t *, size_t *);
183
+ int (*encrypto_aes_ctr_release)(archive_crypto_ctx *);
184
+ };
185
+
186
+ extern const struct archive_cryptor __archive_cryptor;
187
+
188
+ #endif