xcrypt 0.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 (199) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +106 -0
  3. data/ext/libxcrypt/AUTHORS +38 -0
  4. data/ext/libxcrypt/COPYING.LIB +502 -0
  5. data/ext/libxcrypt/ChangeLog +239 -0
  6. data/ext/libxcrypt/INSTALL +380 -0
  7. data/ext/libxcrypt/LICENSING +152 -0
  8. data/ext/libxcrypt/Makefile.am +704 -0
  9. data/ext/libxcrypt/Makefile.in +4110 -0
  10. data/ext/libxcrypt/NEWS +630 -0
  11. data/ext/libxcrypt/README +1 -0
  12. data/ext/libxcrypt/README.md +179 -0
  13. data/ext/libxcrypt/THANKS +13 -0
  14. data/ext/libxcrypt/TODO +1 -0
  15. data/ext/libxcrypt/TODO.md +100 -0
  16. data/ext/libxcrypt/aclocal.m4 +2617 -0
  17. data/ext/libxcrypt/autogen.sh +33 -0
  18. data/ext/libxcrypt/autom4te.cache/output.0 +19884 -0
  19. data/ext/libxcrypt/autom4te.cache/output.1 +19884 -0
  20. data/ext/libxcrypt/autom4te.cache/output.2 +19884 -0
  21. data/ext/libxcrypt/autom4te.cache/output.3 +19885 -0
  22. data/ext/libxcrypt/autom4te.cache/requests +714 -0
  23. data/ext/libxcrypt/autom4te.cache/traces.0 +4088 -0
  24. data/ext/libxcrypt/autom4te.cache/traces.1 +1060 -0
  25. data/ext/libxcrypt/autom4te.cache/traces.2 +4088 -0
  26. data/ext/libxcrypt/autom4te.cache/traces.3 +1060 -0
  27. data/ext/libxcrypt/build-aux/ci/ci-log-dependency-versions +79 -0
  28. data/ext/libxcrypt/build-aux/ci/ci-log-logfiles +22 -0
  29. data/ext/libxcrypt/build-aux/ci/clang-gcov-wrapper +2 -0
  30. data/ext/libxcrypt/build-aux/ci/configure-wrapper +10 -0
  31. data/ext/libxcrypt/build-aux/ci/summarize-coverage +24 -0
  32. data/ext/libxcrypt/build-aux/m4/ax_append_compile_flags.m4 +46 -0
  33. data/ext/libxcrypt/build-aux/m4/ax_append_flag.m4 +50 -0
  34. data/ext/libxcrypt/build-aux/m4/ax_check_compile_flag.m4 +53 -0
  35. data/ext/libxcrypt/build-aux/m4/ax_check_vscript.m4 +142 -0
  36. data/ext/libxcrypt/build-aux/m4/ax_gcc_func_attribute.m4 +246 -0
  37. data/ext/libxcrypt/build-aux/m4/ax_require_defined.m4 +37 -0
  38. data/ext/libxcrypt/build-aux/m4/ax_valgrind_check.m4 +239 -0
  39. data/ext/libxcrypt/build-aux/m4/libtool.m4 +8488 -0
  40. data/ext/libxcrypt/build-aux/m4/ltoptions.m4 +467 -0
  41. data/ext/libxcrypt/build-aux/m4/ltsugar.m4 +124 -0
  42. data/ext/libxcrypt/build-aux/m4/ltversion.m4 +24 -0
  43. data/ext/libxcrypt/build-aux/m4/lt~obsolete.m4 +99 -0
  44. data/ext/libxcrypt/build-aux/m4/pkg_compat.m4 +88 -0
  45. data/ext/libxcrypt/build-aux/m4/zw_alignment.m4 +90 -0
  46. data/ext/libxcrypt/build-aux/m4/zw_automodern.m4 +307 -0
  47. data/ext/libxcrypt/build-aux/m4/zw_detect_asan.m4 +24 -0
  48. data/ext/libxcrypt/build-aux/m4/zw_endianness.m4 +152 -0
  49. data/ext/libxcrypt/build-aux/m4/zw_ld_wrap.m4 +47 -0
  50. data/ext/libxcrypt/build-aux/m4/zw_prog_perl.m4 +40 -0
  51. data/ext/libxcrypt/build-aux/m4/zw_simple_warnings.m4 +150 -0
  52. data/ext/libxcrypt/build-aux/m4/zw_static_assert.m4 +68 -0
  53. data/ext/libxcrypt/build-aux/m4-autogen/compile +364 -0
  54. data/ext/libxcrypt/build-aux/m4-autogen/config.guess +1815 -0
  55. data/ext/libxcrypt/build-aux/m4-autogen/config.sub +2354 -0
  56. data/ext/libxcrypt/build-aux/m4-autogen/depcomp +792 -0
  57. data/ext/libxcrypt/build-aux/m4-autogen/install-sh +541 -0
  58. data/ext/libxcrypt/build-aux/m4-autogen/ltmain.sh +11524 -0
  59. data/ext/libxcrypt/build-aux/m4-autogen/missing +236 -0
  60. data/ext/libxcrypt/build-aux/m4-autogen/test-driver +160 -0
  61. data/ext/libxcrypt/build-aux/scripts/BuildCommon.pm +712 -0
  62. data/ext/libxcrypt/build-aux/scripts/check-perlcritic-config +76 -0
  63. data/ext/libxcrypt/build-aux/scripts/compute-symver-floor +116 -0
  64. data/ext/libxcrypt/build-aux/scripts/expand-selected-hashes +80 -0
  65. data/ext/libxcrypt/build-aux/scripts/gen-crypt-h +131 -0
  66. data/ext/libxcrypt/build-aux/scripts/gen-crypt-hashes-h +141 -0
  67. data/ext/libxcrypt/build-aux/scripts/gen-crypt-symbol-vers-h +150 -0
  68. data/ext/libxcrypt/build-aux/scripts/gen-libcrypt-map +67 -0
  69. data/ext/libxcrypt/build-aux/scripts/move-if-change +84 -0
  70. data/ext/libxcrypt/build-aux/scripts/skip-if-exec-format-error +78 -0
  71. data/ext/libxcrypt/codecov.yml +4 -0
  72. data/ext/libxcrypt/config.h.in +303 -0
  73. data/ext/libxcrypt/configure +19885 -0
  74. data/ext/libxcrypt/configure.ac +549 -0
  75. data/ext/libxcrypt/doc/crypt.3 +512 -0
  76. data/ext/libxcrypt/doc/crypt.5 +343 -0
  77. data/ext/libxcrypt/doc/crypt_checksalt.3 +106 -0
  78. data/ext/libxcrypt/doc/crypt_gensalt.3 +285 -0
  79. data/ext/libxcrypt/doc/crypt_gensalt_ra.3 +1 -0
  80. data/ext/libxcrypt/doc/crypt_gensalt_rn.3 +1 -0
  81. data/ext/libxcrypt/doc/crypt_preferred_method.3 +68 -0
  82. data/ext/libxcrypt/doc/crypt_r.3 +1 -0
  83. data/ext/libxcrypt/doc/crypt_ra.3 +1 -0
  84. data/ext/libxcrypt/doc/crypt_rn.3 +1 -0
  85. data/ext/libxcrypt/lib/alg-des-tables.c +3858 -0
  86. data/ext/libxcrypt/lib/alg-des.c +269 -0
  87. data/ext/libxcrypt/lib/alg-des.h +74 -0
  88. data/ext/libxcrypt/lib/alg-gost3411-2012-const.h +313 -0
  89. data/ext/libxcrypt/lib/alg-gost3411-2012-core.c +238 -0
  90. data/ext/libxcrypt/lib/alg-gost3411-2012-core.h +51 -0
  91. data/ext/libxcrypt/lib/alg-gost3411-2012-hmac.c +78 -0
  92. data/ext/libxcrypt/lib/alg-gost3411-2012-hmac.h +46 -0
  93. data/ext/libxcrypt/lib/alg-gost3411-2012-precalc.h +1426 -0
  94. data/ext/libxcrypt/lib/alg-gost3411-2012-ref.h +67 -0
  95. data/ext/libxcrypt/lib/alg-hmac-sha1.c +140 -0
  96. data/ext/libxcrypt/lib/alg-hmac-sha1.h +35 -0
  97. data/ext/libxcrypt/lib/alg-md4.c +270 -0
  98. data/ext/libxcrypt/lib/alg-md4.h +43 -0
  99. data/ext/libxcrypt/lib/alg-md5.c +291 -0
  100. data/ext/libxcrypt/lib/alg-md5.h +43 -0
  101. data/ext/libxcrypt/lib/alg-sha1.c +288 -0
  102. data/ext/libxcrypt/lib/alg-sha1.h +34 -0
  103. data/ext/libxcrypt/lib/alg-sha256.c +630 -0
  104. data/ext/libxcrypt/lib/alg-sha256.h +123 -0
  105. data/ext/libxcrypt/lib/alg-sha512.c +311 -0
  106. data/ext/libxcrypt/lib/alg-sha512.h +81 -0
  107. data/ext/libxcrypt/lib/alg-sm3-hmac.c +113 -0
  108. data/ext/libxcrypt/lib/alg-sm3-hmac.h +42 -0
  109. data/ext/libxcrypt/lib/alg-sm3.c +449 -0
  110. data/ext/libxcrypt/lib/alg-sm3.h +63 -0
  111. data/ext/libxcrypt/lib/alg-yescrypt-common.c +713 -0
  112. data/ext/libxcrypt/lib/alg-yescrypt-opt.c +1568 -0
  113. data/ext/libxcrypt/lib/alg-yescrypt-platform.c +106 -0
  114. data/ext/libxcrypt/lib/alg-yescrypt.h +360 -0
  115. data/ext/libxcrypt/lib/byteorder.h +164 -0
  116. data/ext/libxcrypt/lib/crypt-bcrypt.c +1061 -0
  117. data/ext/libxcrypt/lib/crypt-des-obsolete.c +215 -0
  118. data/ext/libxcrypt/lib/crypt-des.c +491 -0
  119. data/ext/libxcrypt/lib/crypt-gensalt-static.c +40 -0
  120. data/ext/libxcrypt/lib/crypt-gost-yescrypt.c +182 -0
  121. data/ext/libxcrypt/lib/crypt-md5.c +232 -0
  122. data/ext/libxcrypt/lib/crypt-nthash.c +134 -0
  123. data/ext/libxcrypt/lib/crypt-obsolete.h +40 -0
  124. data/ext/libxcrypt/lib/crypt-pbkdf1-sha1.c +260 -0
  125. data/ext/libxcrypt/lib/crypt-port.h +514 -0
  126. data/ext/libxcrypt/lib/crypt-scrypt.c +247 -0
  127. data/ext/libxcrypt/lib/crypt-sha256.c +308 -0
  128. data/ext/libxcrypt/lib/crypt-sha512.c +323 -0
  129. data/ext/libxcrypt/lib/crypt-sm3-yescrypt.c +189 -0
  130. data/ext/libxcrypt/lib/crypt-sm3.c +308 -0
  131. data/ext/libxcrypt/lib/crypt-static.c +44 -0
  132. data/ext/libxcrypt/lib/crypt-sunmd5.c +314 -0
  133. data/ext/libxcrypt/lib/crypt-yescrypt.c +177 -0
  134. data/ext/libxcrypt/lib/crypt.c +421 -0
  135. data/ext/libxcrypt/lib/crypt.h.in +249 -0
  136. data/ext/libxcrypt/lib/gen-des-tables.c +363 -0
  137. data/ext/libxcrypt/lib/hashes.conf +59 -0
  138. data/ext/libxcrypt/lib/libcrypt.map.in +48 -0
  139. data/ext/libxcrypt/lib/libcrypt.minver +97 -0
  140. data/ext/libxcrypt/lib/libxcrypt.pc.in +15 -0
  141. data/ext/libxcrypt/lib/util-base64.c +26 -0
  142. data/ext/libxcrypt/lib/util-gensalt-sha.c +88 -0
  143. data/ext/libxcrypt/lib/util-get-random-bytes.c +154 -0
  144. data/ext/libxcrypt/lib/util-make-failure-token.c +48 -0
  145. data/ext/libxcrypt/lib/util-xbzero.c +43 -0
  146. data/ext/libxcrypt/lib/util-xstrcpy.c +42 -0
  147. data/ext/libxcrypt/lib/xcrypt.h.in +58 -0
  148. data/ext/libxcrypt/libxcrypt.spec.rpkg +481 -0
  149. data/ext/libxcrypt/rpkg.conf +2 -0
  150. data/ext/libxcrypt/rpkg.macros +86 -0
  151. data/ext/libxcrypt/test/TestCommon.pm +326 -0
  152. data/ext/libxcrypt/test/alg-des.c +80 -0
  153. data/ext/libxcrypt/test/alg-gost3411-2012-hmac.c +90 -0
  154. data/ext/libxcrypt/test/alg-gost3411-2012.c +191 -0
  155. data/ext/libxcrypt/test/alg-hmac-sha1.c +187 -0
  156. data/ext/libxcrypt/test/alg-md4.c +111 -0
  157. data/ext/libxcrypt/test/alg-md5.c +134 -0
  158. data/ext/libxcrypt/test/alg-pbkdf-hmac-sha256.c +269 -0
  159. data/ext/libxcrypt/test/alg-sha1.c +111 -0
  160. data/ext/libxcrypt/test/alg-sha256.c +141 -0
  161. data/ext/libxcrypt/test/alg-sha512.c +170 -0
  162. data/ext/libxcrypt/test/alg-sm3-hmac.c +149 -0
  163. data/ext/libxcrypt/test/alg-sm3.c +168 -0
  164. data/ext/libxcrypt/test/alg-yescrypt.c +466 -0
  165. data/ext/libxcrypt/test/badsalt.c +726 -0
  166. data/ext/libxcrypt/test/badsetting.c +350 -0
  167. data/ext/libxcrypt/test/byteorder.c +254 -0
  168. data/ext/libxcrypt/test/checksalt.c +265 -0
  169. data/ext/libxcrypt/test/compile-strong-alias.c +43 -0
  170. data/ext/libxcrypt/test/crypt-badargs.c +392 -0
  171. data/ext/libxcrypt/test/crypt-gost-yescrypt.c +149 -0
  172. data/ext/libxcrypt/test/crypt-nested-call.c +180 -0
  173. data/ext/libxcrypt/test/crypt-sm3-yescrypt.c +149 -0
  174. data/ext/libxcrypt/test/crypt-too-long-phrase.c +157 -0
  175. data/ext/libxcrypt/test/des-cases.h +196 -0
  176. data/ext/libxcrypt/test/des-obsolete.c +206 -0
  177. data/ext/libxcrypt/test/des-obsolete_r.c +207 -0
  178. data/ext/libxcrypt/test/explicit-bzero.c +334 -0
  179. data/ext/libxcrypt/test/gensalt-bcrypt_x.c +54 -0
  180. data/ext/libxcrypt/test/gensalt-extradata.c +246 -0
  181. data/ext/libxcrypt/test/gensalt-nested-call.c +126 -0
  182. data/ext/libxcrypt/test/gensalt-nthash.c +65 -0
  183. data/ext/libxcrypt/test/gensalt.c +599 -0
  184. data/ext/libxcrypt/test/getrandom-fallbacks.c +295 -0
  185. data/ext/libxcrypt/test/getrandom-interface.c +211 -0
  186. data/ext/libxcrypt/test/ka-table-gen.py +945 -0
  187. data/ext/libxcrypt/test/ka-table.inc +5849 -0
  188. data/ext/libxcrypt/test/ka-tester.c +240 -0
  189. data/ext/libxcrypt/test/preferred-method.c +133 -0
  190. data/ext/libxcrypt/test/short-outbuf.c +119 -0
  191. data/ext/libxcrypt/test/special-char-salt.c +1160 -0
  192. data/ext/libxcrypt/test/symbols-compat.pl +137 -0
  193. data/ext/libxcrypt/test/symbols-renames.pl +107 -0
  194. data/ext/libxcrypt/test/symbols-static.pl +87 -0
  195. data/ext/xcrypt/xcrypt.c +9 -0
  196. data/lib/xcrypt/ffi.rb +76 -0
  197. data/lib/xcrypt/version.rb +5 -0
  198. data/lib/xcrypt.rb +89 -0
  199. metadata +267 -0
@@ -0,0 +1,48 @@
1
+ # This file is processed by gen-libcrypt-map to produce the versions
2
+ # map file for libxcrypt.
3
+ # symbol default_version compat_version [compat_version ...]
4
+
5
+ # Actively supported POSIX interfaces; in GNU libc since 2.0
6
+ crypt XCRYPT_2.0 GLIBC_2.0
7
+ crypt_r XCRYPT_2.0 GLIBC_2.0
8
+
9
+ # Actively supported Openwall extensions; never actually added to
10
+ # upstream GNU libc, but present in at least Openwall, ALT, and SUSE
11
+ # Linux distributions with one or more of these symbol versions
12
+ crypt_rn XCRYPT_2.0 GLIBC_2.0:owl:suse GLIBC_2.2.1:alt
13
+ crypt_gensalt XCRYPT_2.0 GLIBC_2.0:owl:suse GLIBC_2.2.1:alt OW_CRYPT_1.0:suse
14
+ crypt_gensalt_rn XCRYPT_2.0 GLIBC_2.0:owl:suse GLIBC_2.2.1:alt OW_CRYPT_1.0:suse
15
+
16
+ crypt_ra XCRYPT_2.0 GLIBC_2.0:owl:suse GLIBC_2.2.2:alt
17
+ crypt_gensalt_ra XCRYPT_2.0 GLIBC_2.0:owl:suse GLIBC_2.2.2:alt OW_CRYPT_1.0:suse
18
+
19
+ # Actively supported interfaces from libxcrypt.
20
+ crypt_checksalt XCRYPT_4.3
21
+ crypt_preferred_method XCRYPT_4.4
22
+
23
+ # Interfaces for code compatibility with libxcrypt v3.1.1 and earlier.
24
+ # No longer available to new binaries. Include in version-script, only
25
+ # if one of the compatibility interfaces is enabled.
26
+ crypt_gensalt_r - XCRYPT_2.0:alt:glibc:owl:suse:yes
27
+ xcrypt - XCRYPT_2.0:alt:glibc:owl:suse:yes
28
+ xcrypt_r - XCRYPT_2.0:alt:glibc:owl:suse:yes
29
+ xcrypt_gensalt - XCRYPT_2.0:alt:glibc:owl:suse:yes
30
+ xcrypt_gensalt_r - XCRYPT_2.0:alt:glibc:owl:suse:yes
31
+
32
+ # Deprecated interfaces, POSIX and otherwise; also present in GNU libc
33
+ # since 2.0
34
+ encrypt - GLIBC_2.0
35
+ encrypt_r - GLIBC_2.0
36
+ setkey - GLIBC_2.0
37
+ setkey_r - GLIBC_2.0
38
+ fcrypt - GLIBC_2.0
39
+
40
+ # This determines the ordering of the version chain. Each symbol
41
+ # version that appears above must also appear in this list, and to
42
+ # simplify gen-libcrypt-map, so must all of the versions listed in
43
+ # libcrypt.minver. The ordering is left to right, top to bottom.
44
+ %chain GLIBC_2.0 GLIBC_2.2 GLIBC_2.2.1 GLIBC_2.2.2 GLIBC_2.2.5 GLIBC_2.2.6
45
+ %chain GLIBC_2.3 GLIBC_2.4 GLIBC_2.12 GLIBC_2.16 GLIBC_2.17 GLIBC_2.18
46
+ %chain GLIBC_2.21 GLIBC_2.27 GLIBC_2.29 GLIBC_2.32 GLIBC_2.33 GLIBC_2.35
47
+ %chain GLIBC_2.36 GLIBC_2.38
48
+ %chain OW_CRYPT_1.0 XCRYPT_2.0 XCRYPT_4.3 XCRYPT_4.4
@@ -0,0 +1,97 @@
1
+ # This file defines the minimum symbol version number used by the
2
+ # system-provided libcrypt, for each CPU and OS where libxcrypt can be
3
+ # binary backward compatible with it. See also lib/libcrypt.map.in,
4
+ # build-aux/scripts/compute-symver-floor, and
5
+ # build-aux/scripts/gen-libcrypt-map.
6
+ #
7
+ # Lines in this file that start with '#' are comments; # is not
8
+ # otherwise significant. Blank lines are ignored. All other lines
9
+ # must have three or four columns: VERSION, SYSTEM, CPU_FAMILY,
10
+ # and PREPROCESSOR_CHECK, in that order.
11
+ #
12
+ # VERSION is the minimum symbol version to use on hosts where SYSTEM
13
+ # and CPU_FAMILY match autoconf's $host_os and $host_cpu values,
14
+ # respectively, when interpreted as (Perl) regexes. There is an implicit
15
+ # ^ at the beginning of each regex (that is, they must match starting
16
+ # at the beginning of the string) but there is no implicit $ at the end
17
+ # (that is, they do not have to match the entire string). Use '.'
18
+ # to accept any string.
19
+ #
20
+ # If there is anything more on the line after the CPU_FAMILY field,
21
+ # all of it is taken as a preprocessor #if expression which must be
22
+ # true for this line's version number to be used. The macros defined
23
+ # in <limits.h> are available to this expression. This mechanism is
24
+ # for subarchitectures that do not change $host_cpu, e.g. x32 (I wish
25
+ # they wouldn't do that...)
26
+ #
27
+ # The symbol version XCRYPT_2.0 is special; if this file selects that
28
+ # version as the minimum for some platform, configure will
29
+ # automatically switch into --disable-obsolete-api mode. This is used
30
+ # for platforms where either we have not yet implemented binary
31
+ # backward compatibility with the system-provided libcrypt, or we know
32
+ # there is no system-provided libcrypt to be compatible with.
33
+ #
34
+ # The symbol version ERROR is special; if this file selects that
35
+ # version as the minimum for some platform, configuration will fail.
36
+ # This is used for platforms where we know we ought to support
37
+ # backward binary compatibility and the library shouldn't be allowed
38
+ # to be used until someone's set this up properly.
39
+ #
40
+ # More specific regexes must be sorted below less specific ones, and
41
+ # empty PREPROCESSOR_CHECK must be sorted below non-empty. If neither
42
+ # constraint applies, sort entries in descending order of symbol
43
+ # version within one SYSTEM, and in alphabetical order of CPU_FAMILY
44
+ # within each symbol version.
45
+ #
46
+ # Future cleanup: the ERROR lines for 'gnu*', 'kfreebsd*gnu*', and
47
+ # 'linux*gnu*' can be removed once GNU libc stops shipping libcrypt.
48
+ # It will be correct to use XCRYPT_2.0 as the minimum symbol version
49
+ # for any platform added to glibc after that release.
50
+
51
+ #VERSION SYSTEM CPU_FAMILY PREPROCESSOR_CHECK
52
+
53
+ # GNU Hurd
54
+ GLIBC_2.38 gnu x86_64
55
+ GLIBC_2.2.6 gnu i[3-9]86
56
+ ERROR gnu .
57
+
58
+ # FreeBSD kernel with GNU libc
59
+ GLIBC_2.3 kfreebsd.*gnu x86_64 !(defined __x86_64__ && ULONG_MAX == UINT_MAX) /* not x32 */
60
+ GLIBC_2.3 kfreebsd.*gnu i[3-9]86
61
+ ERROR kfreebsd.*gnu .
62
+
63
+ # Linux with GNU libc
64
+ GLIBC_2.36 linux.*gnu loongarch64 __WORDSIZE == 64 && ULONG_MAX != UINT_MAX /* lp64* ABI */
65
+ GLIBC_2.35 linux.*gnu or1k
66
+ GLIBC_2.33 linux.*gnu riscv32
67
+ GLIBC_2.32 linux.*gnu arc
68
+ GLIBC_2.29 linux.*gnu csky
69
+ GLIBC_2.27 linux.*gnu riscv64
70
+ GLIBC_2.21 linux.*gnu nios2
71
+ GLIBC_2.18 linux.*gnu microblaze
72
+ GLIBC_2.17 linux.*gnu aarch64
73
+ GLIBC_2.17 linux.*gnu powerpc64le
74
+ GLIBC_2.16 linux.*gnu x86_64 defined __x86_64__ && ULONG_MAX == UINT_MAX /* x32 */
75
+ GLIBC_2.12 linux.*gnu tilegx
76
+ GLIBC_2.12 linux.*gnu tilepro
77
+ GLIBC_2.4 linux.*gnu arm
78
+ GLIBC_2.4 linux.*gnu m68k defined __mcoldfire__
79
+ GLIBC_2.3 linux.*gnu powerpc64
80
+ GLIBC_2.2.5 linux.*gnu x86_64 defined __x86_64__ && ULONG_MAX != UINT_MAX /* 64 */
81
+ GLIBC_2.2 linux.*gnu s390x
82
+ GLIBC_2.0 linux.*gnu alpha
83
+ GLIBC_2.0 linux.*gnu e2k
84
+ GLIBC_2.0 linux.*gnu hppa
85
+ GLIBC_2.0 linux.*gnu i[3-9]86
86
+ GLIBC_2.0 linux.*gnu ia64
87
+ GLIBC_2.0 linux.*gnu m68k
88
+ GLIBC_2.0 linux.*gnu mips
89
+ GLIBC_2.0 linux.*gnu powerpc
90
+ GLIBC_2.0 linux.*gnu s390
91
+ GLIBC_2.0 linux.*gnu sh
92
+ GLIBC_2.0 linux.*gnu sparc
93
+ GLIBC_2.0 linux.*gnu x86_64
94
+ ERROR linux.*gnu .
95
+
96
+ # Other systems.
97
+ XCRYPT_2.0 . .
@@ -0,0 +1,15 @@
1
+ #############################################
2
+ ##### Pkg-Config file for libxcrypt #####
3
+ #############################################
4
+
5
+ prefix=@prefix@
6
+ exec_prefix=${prefix}
7
+
8
+ libdir=@libdir@
9
+ includedir=@includedir@
10
+
11
+ Name: @PACKAGE@
12
+ Version: @VERSION@
13
+ Description: Extended crypt library for DES, MD5, Blowfish and others
14
+ Libs: -L${libdir} -lcrypt
15
+ Cflags: -I${includedir}
@@ -0,0 +1,26 @@
1
+ /* Copyright (C) 2018-2021 Björn Esser <besser82@fedoraproject.org>
2
+ *
3
+ * Redistribution and use in source and binary forms, with or without
4
+ * modification, are permitted.
5
+ *
6
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
10
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
12
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
15
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16
+ * SUCH DAMAGE.
17
+ */
18
+
19
+ /* Base64-related utility functions and data. */
20
+
21
+ #include "crypt-port.h"
22
+
23
+ const unsigned char ascii64[65] =
24
+ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
25
+ /* 0000000000111111111122222222223333333333444444444455555555556666 */
26
+ /* 0123456789012345678901234567890123456789012345678901234567890123 */
@@ -0,0 +1,88 @@
1
+ /*
2
+ * Written by Solar Designer and placed in the public domain.
3
+ * See crypt-bcrypt.c for more information.
4
+ *
5
+ * This file contains setting-string generation code shared among the
6
+ * MD5, SHA256, and SHA512 hash algorithms, which use very similar
7
+ * setting formats. Setting-string generation for bcrypt and DES is
8
+ * entirely in crypt-bcrypt.c and crypt-des.c respectively.
9
+ */
10
+
11
+ #include "crypt-port.h"
12
+
13
+ #include <errno.h>
14
+ #include <stdio.h>
15
+
16
+ #if INCLUDE_md5crypt || INCLUDE_sha256crypt || INCLUDE_sha512crypt || INCLUDE_sm3crypt
17
+
18
+ void
19
+ gensalt_sha_rn (const char *tag, size_t maxsalt, unsigned long defcount,
20
+ unsigned long mincount, unsigned long maxcount,
21
+ unsigned long count,
22
+ const uint8_t *rbytes, size_t nrbytes,
23
+ uint8_t *output, size_t output_size)
24
+ {
25
+ /* We will use more rbytes if available, but at least this much is
26
+ required. */
27
+ if (nrbytes < 3)
28
+ {
29
+ errno = EINVAL;
30
+ return;
31
+ }
32
+
33
+ if (count == 0)
34
+ count = defcount;
35
+ if (count < mincount)
36
+ count = mincount;
37
+ if (count > maxcount)
38
+ count = maxcount;
39
+
40
+ /* Compute how much space we need. */
41
+ size_t output_len = 8; /* $x$ssss\0 */
42
+ if (count != defcount)
43
+ {
44
+ output_len += 9; /* rounds=1$ */
45
+ for (unsigned long ceiling = 10; ceiling < count; ceiling *= 10)
46
+ output_len += 1;
47
+ }
48
+ if (output_size < output_len)
49
+ {
50
+ errno = ERANGE;
51
+ return;
52
+ }
53
+
54
+ size_t written;
55
+ if (count == defcount)
56
+ {
57
+ written = (size_t) snprintf ((char *)output, output_size, "$%s$", tag);
58
+ }
59
+ else
60
+ written = (size_t) snprintf ((char *)output, output_size,
61
+ "$%s$rounds=%lu$", tag, count);
62
+
63
+ /* The length calculation above should ensure that this is always true. */
64
+ assert (written + 5 < output_size);
65
+
66
+ size_t used_rbytes = 0;
67
+ while (written + 5 < output_size &&
68
+ used_rbytes + 3 < nrbytes &&
69
+ (used_rbytes * 4 / 3) < maxsalt)
70
+ {
71
+ unsigned long value =
72
+ ((unsigned long) (unsigned char) rbytes[used_rbytes + 0] << 0) |
73
+ ((unsigned long) (unsigned char) rbytes[used_rbytes + 1] << 8) |
74
+ ((unsigned long) (unsigned char) rbytes[used_rbytes + 2] << 16);
75
+
76
+ output[written + 0] = ascii64[value & 0x3f];
77
+ output[written + 1] = ascii64[(value >> 6) & 0x3f];
78
+ output[written + 2] = ascii64[(value >> 12) & 0x3f];
79
+ output[written + 3] = ascii64[(value >> 18) & 0x3f];
80
+
81
+ written += 4;
82
+ used_rbytes += 3;
83
+ }
84
+
85
+ output[written] = '\0';
86
+ }
87
+
88
+ #endif
@@ -0,0 +1,154 @@
1
+ /* Retrieval of cryptographically random bytes from the operating system.
2
+ *
3
+ * Written by Zack Weinberg <zackw at panix.com> in 2017.
4
+ *
5
+ * No copyright is claimed, and the software is hereby placed in the public
6
+ * domain. In case this attempt to disclaim copyright and place the software
7
+ * in the public domain is deemed null and void, then the software is
8
+ * Copyright (c) 2017 Zack Weinberg and it is hereby released to the
9
+ * general public under the following terms:
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without
12
+ * modification, are permitted.
13
+ *
14
+ * There's ABSOLUTELY NO WARRANTY, express or implied.
15
+ */
16
+
17
+ #include "crypt-port.h"
18
+
19
+ #include <errno.h>
20
+ #include <stdlib.h>
21
+
22
+ #ifdef HAVE_FCNTL_H
23
+ #include <fcntl.h>
24
+ #endif
25
+ #ifdef HAVE_SYS_RANDOM_H
26
+ #include <sys/random.h>
27
+ #endif
28
+ #ifdef HAVE_SYS_SYSCALL_H
29
+ #include <sys/syscall.h>
30
+ #endif
31
+ #ifdef HAVE_SYS_STAT_H
32
+ #include <sys/stat.h>
33
+ #endif
34
+
35
+ /* If we have O_CLOEXEC, we use it, but if we don't, we don't worry
36
+ about it. */
37
+ #ifndef O_CLOEXEC
38
+ #define O_CLOEXEC 0
39
+ #endif
40
+
41
+ /* There is no universally portable way to access a system CSPRNG.
42
+ If the C library provides any of the following functions, we try them,
43
+ in order of preference: arc4random_buf, getentropy, getrandom.
44
+ If none of those are available or they don't work, we attempt to
45
+ make direct system calls for getentropy and getrandom. If *that*
46
+ doesn't work, we try opening and reading /dev/urandom.
47
+
48
+ This function returns true if the exact number of requested bytes
49
+ was successfully read, false otherwise; if it returns false, errno
50
+ has been set. It may block. It cannot be used to read more than
51
+ 256 bytes at a time (this is a limitation inherited from
52
+ getentropy() and enforced regardless of the actual back-end in use).
53
+
54
+ If we fall all the way back to /dev/urandom, we open and close it on
55
+ each call. */
56
+
57
+ bool
58
+ get_random_bytes(void *buf, size_t buflen)
59
+ {
60
+ if (buflen == 0)
61
+ return true;
62
+
63
+ /* Some, but not all, of the primitives below are limited to
64
+ producing no more than 256 bytes of random data. Impose this
65
+ constraint on our callers regardless of which primitive is
66
+ actually used. */
67
+ if (buflen > 256)
68
+ {
69
+ errno = EIO;
70
+ return false;
71
+ }
72
+
73
+ /* To eliminate the possibility of one of the primitives below failing
74
+ with EFAULT, force a crash now if the buffer is unwritable. */
75
+ explicit_bzero (buf, buflen);
76
+
77
+ #ifdef HAVE_ARC4RANDOM_BUF
78
+ /* arc4random_buf, if it exists, can never fail. */
79
+ arc4random_buf (buf, buflen);
80
+ return true;
81
+
82
+ #else /* no arc4random_buf */
83
+
84
+ #ifdef HAVE_GETENTROPY
85
+ /* getentropy may exist but lack kernel support. */
86
+ static bool getentropy_doesnt_work;
87
+ if (!getentropy_doesnt_work)
88
+ {
89
+ if (!getentropy (buf, buflen))
90
+ return true;
91
+ getentropy_doesnt_work = true;
92
+ }
93
+ #endif
94
+
95
+ #ifdef HAVE_GETRANDOM
96
+ /* Likewise getrandom. */
97
+ static bool getrandom_doesnt_work;
98
+ if (!getrandom_doesnt_work)
99
+ {
100
+ if ((size_t)getrandom (buf, buflen, 0) == buflen)
101
+ return true;
102
+ getrandom_doesnt_work = true;
103
+ }
104
+ #endif
105
+
106
+ /* If we can make arbitrary syscalls, try getentropy and getrandom
107
+ again that way. */
108
+ #ifdef HAVE_SYSCALL
109
+ #ifdef SYS_getentropy
110
+ static bool sys_getentropy_doesnt_work;
111
+ if (!sys_getentropy_doesnt_work)
112
+ {
113
+ if (!syscall (SYS_getentropy, buf, buflen))
114
+ return true;
115
+ sys_getentropy_doesnt_work = true;
116
+ }
117
+ #endif
118
+
119
+ #ifdef SYS_getrandom
120
+ static bool sys_getrandom_doesnt_work;
121
+ if (!sys_getrandom_doesnt_work)
122
+ {
123
+ if ((size_t)syscall (SYS_getrandom, buf, buflen, 0) == buflen)
124
+ return true;
125
+ sys_getrandom_doesnt_work = true;
126
+ }
127
+ #endif
128
+ #endif
129
+
130
+ #if defined HAVE_SYS_STAT_H && defined HAVE_FCNTL_H && defined HAVE_UNISTD_H
131
+ /* Try reading from /dev/urandom. */
132
+ static bool dev_urandom_doesnt_work;
133
+ if (!dev_urandom_doesnt_work)
134
+ {
135
+ int fd = open ("/dev/urandom", O_RDONLY|O_CLOEXEC);
136
+ if (fd == -1)
137
+ dev_urandom_doesnt_work = true;
138
+ else
139
+ {
140
+ ssize_t nread = read (fd, buf, buflen);
141
+ if (nread < 0 || (size_t)nread < buflen)
142
+ dev_urandom_doesnt_work = true;
143
+
144
+ close(fd);
145
+ return !dev_urandom_doesnt_work;
146
+ }
147
+ }
148
+ #endif
149
+
150
+ /* if we get here, we're just completely hosed */
151
+ errno = ENOSYS;
152
+ return false;
153
+ #endif /* no arc4random_buf */
154
+ }
@@ -0,0 +1,48 @@
1
+ /* Copyright (C) 2018-2019 Björn Esser <besser82@fedoraproject.org>
2
+ *
3
+ * Redistribution and use in source and binary forms, with or without
4
+ * modification, are permitted.
5
+ *
6
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
10
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
12
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
15
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16
+ * SUCH DAMAGE.
17
+ */
18
+
19
+ #include "crypt-port.h"
20
+
21
+ /* Fill the output buffer with a failure token. */
22
+ void
23
+ make_failure_token (const char *setting, char *output, int size)
24
+ {
25
+ if (size >= 3)
26
+ {
27
+ char token[3] = "*0";
28
+
29
+ if (setting && setting[0] == '*' && setting[1] == '0')
30
+ token[1] = '1';
31
+
32
+ output[0] = token[0];
33
+ output[1] = token[1];
34
+ output[2] = '\0';
35
+ }
36
+
37
+ /* If there's not enough space for the full failure token, do the
38
+ best we can. */
39
+ else if (size == 2)
40
+ {
41
+ output[0] = '*';
42
+ output[1] = '\0';
43
+ }
44
+ else if (size == 1)
45
+ {
46
+ output[0] = '\0';
47
+ }
48
+ }
@@ -0,0 +1,43 @@
1
+ /* Copyright (C) 2018-2019 Björn Esser <besser82@fedoraproject.org>
2
+ *
3
+ * Redistribution and use in source and binary forms, with or without
4
+ * modification, are permitted.
5
+ *
6
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
10
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
12
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
15
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16
+ * SUCH DAMAGE.
17
+ */
18
+
19
+ #include "crypt-port.h"
20
+
21
+ #if INCLUDE_explicit_bzero
22
+ /* As long as this function is defined in a translation unit all by
23
+ itself, and we aren't doing LTO, it would be enough for it to just
24
+ call memset. While compiling _this_ translation unit, the compiler
25
+ has no information about what the callers do with the buffer, so it
26
+ cannot eliminate the memset. While compiling code that _calls_
27
+ this function, the compiler doesn't know what it does, so it cannot
28
+ eliminate the call (if it has special knowledge of a function with
29
+ this name, we would hope that it knows _not_ to optimize it out!)
30
+
31
+ However, in anticipation of doing LTO on this library one day, we
32
+ add two more defensive measures, when we know how: the function is
33
+ marked no-inline, and there is a no-op assembly insert immediately
34
+ after the memset call, declared to read the memory that the memset
35
+ writes. */
36
+
37
+ NO_INLINE void
38
+ explicit_bzero (void *s, size_t len)
39
+ {
40
+ s = memset (s, 0, len);
41
+ asm volatile ("" : : "g" (s) : "memory");
42
+ }
43
+ #endif
@@ -0,0 +1,42 @@
1
+ /* Copyright (C) 2018-2019 Björn Esser <besser82@fedoraproject.org>
2
+ *
3
+ * Redistribution and use in source and binary forms, with or without
4
+ * modification, are permitted.
5
+ *
6
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
10
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
12
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
15
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16
+ * SUCH DAMAGE.
17
+ */
18
+
19
+ /* Simple commonly used helper functions. */
20
+
21
+ #include "crypt-port.h"
22
+
23
+ #include <stdlib.h>
24
+
25
+ /* Provide a safe way to copy strings with the guarantee src,
26
+ including its terminating '\0', will fit d_size bytes.
27
+ The trailing bytes of d_size will be filled with '\0'.
28
+ dst and src must not be NULL. Returns strlen (src). */
29
+ size_t
30
+ strcpy_or_abort (void *dst, size_t d_size, const void *src)
31
+ {
32
+ assert (dst != NULL);
33
+ assert (src != NULL);
34
+ size_t s_size = strlen ((const char *)src);
35
+ assert (d_size > s_size);
36
+ if (!(d_size > s_size)) /* for NDEBUG builds */
37
+ abort();
38
+
39
+ memcpy (dst, src, s_size);
40
+ memset (((char *)dst) + s_size, 0, d_size - s_size);
41
+ return s_size;
42
+ }
@@ -0,0 +1,58 @@
1
+ /* libxcrypt interfaces for code compatibility.
2
+
3
+ Copyright (C) 2018 Björn Esser <besser82@fedoraproject.org>
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted.
7
+
8
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
9
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
10
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
11
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
12
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
13
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
14
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
15
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
16
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
17
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
18
+ SUCH DAMAGE. */
19
+
20
+ #ifndef _XCRYPT_H
21
+ #define _XCRYPT_H 1
22
+
23
+ #include <crypt.h>
24
+
25
+ @BEGIN_DECLS@
26
+
27
+ /* For backward compatibility with older versions (v3.1.1 and earlier)
28
+ of libcrypt, this header declares xcrypt, xcrypt_r, xcrypt_gensalt,
29
+ and xcrypt_gensalt_r as alternative names for crypt, crypt_r,
30
+ crypt_gensalt, and crypt_gensalt_rn, respectively. If glibc's
31
+ <sys/cdefs.h> macro __REDIRECT_NTH (which declares an alternative
32
+ name at the object-file level) is available, we use it. */
33
+ #ifdef __REDIRECT_NTH
34
+ extern char * __REDIRECT_NTH (xcrypt, (const char *__phrase,
35
+ const char *__setting), crypt);
36
+
37
+ extern char * __REDIRECT_NTH (xcrypt_r, (const char *__phrase,
38
+ const char *__setting,
39
+ struct crypt_data *__restrict __data), crypt_r);
40
+
41
+ extern char * __REDIRECT_NTH (xcrypt_gensalt, (const char *__prefix,
42
+ unsigned long __count, const char *__rbytes,
43
+ int __nrbytes), crypt_gensalt);
44
+
45
+ extern char * __REDIRECT_NTH (xcrypt_gensalt_r, (const char *__prefix,
46
+ unsigned long __count, const char *__rbytes,
47
+ int __nrbytes, char *__output,
48
+ int __output_size), crypt_gensalt_rn);
49
+ #else
50
+ # define xcrypt crypt
51
+ # define xcrypt_r crypt_r
52
+ # define xcrypt_gensalt crypt_gensalt
53
+ # define xcrypt_gensalt_r crypt_gensalt_rn
54
+ #endif
55
+
56
+ @END_DECLS@
57
+
58
+ #endif /* xcrypt.h */