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,343 @@
1
+ .\" Written and revised by Solar Designer <solar at openwall.com> in 2000-2024.
2
+ .\" Revised by Zack Weinberg <zackw at panix.com> in 2017.
3
+ .\" Converted to mdoc format by Zack Weinberg in 2018.
4
+ .\"
5
+ .\" No copyright is claimed, and this man page is hereby placed in the public
6
+ .\" domain. In case this attempt to disclaim copyright and place the man page
7
+ .\" in the public domain is deemed null and void, then the man page is
8
+ .\" Copyright 2000-2011 Solar Designer, 2017 Zack Weinberg, and it is
9
+ .\" hereby released to the 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
+ .Dd March 27, 2024
17
+ .Dt CRYPT 5
18
+ .Os "Openwall Project"
19
+ .Sh NAME
20
+ .Nm crypt
21
+ .Nd storage format for hashed passphrases and available hashing methods
22
+ .Sh DESCRIPTION
23
+ The hashing methods implemented by
24
+ .Xr crypt 3
25
+ are designed only to process user passphrases for storage and authentication;
26
+ they are not suitable for use as general-purpose cryptographic hashes.
27
+ .Pp
28
+ Passphrase hashing is not a replacement for strong passphrases.
29
+ It is always possible
30
+ for an attacker with access to the hashed passphrases
31
+ to guess and check possible cleartext passphrases.
32
+ However, with a strong hashing method,
33
+ guessing will be too slow for the attacker
34
+ to discover a strong passphrase.
35
+ .Pp
36
+ Most of the hashing methods use a
37
+ .Dq salt
38
+ to perturb the hash function,
39
+ so that the same passphrase may produce many possible hashes.
40
+ Newer methods accept longer salt strings.
41
+ The salt should be chosen at random for each user.
42
+ Salt defeats a number of attacks:
43
+ .Bl -enum
44
+ .It
45
+ It is not possible to hash a passphrase once
46
+ and then test it against each account's stored hash;
47
+ the hash calculation must be repeated for each account.
48
+ .It
49
+ It is not possible to tell whether two accounts use the same passphrase
50
+ without successfully guessing one of the phrases.
51
+ .It
52
+ Tables of precalculated hashes of commonly used passphrases
53
+ must have an entry for each possible salt,
54
+ which makes them impractically large.
55
+ .El
56
+ .Pp
57
+ Most of the hashing methods are also deliberately engineered to be slow;
58
+ they use many iterations of an underlying cryptographic primitive
59
+ to increase the cost of each guess.
60
+ The newer hashing methods allow the number of iterations to be adjusted,
61
+ using the
62
+ .Dq processing cost
63
+ parameter to
64
+ .Xr crypt_gensalt 3 .
65
+ For memory-hard hashing methods such as yescrypt,
66
+ this parameter also adjusts the amount of memory needed to compute a hash.
67
+ Having this configurable makes it possible to keep password guessing attacks
68
+ against the hashes slow and costly as hardware improves.
69
+ .Sh FORMAT OF HASHED PASSPHRASES
70
+ All of the hashing methods supported by
71
+ .Xr crypt 3
72
+ produce a hashed passphrase which consists of four components:
73
+ .Ar prefix ,
74
+ .Ar options ,
75
+ .Ar salt ,
76
+ and
77
+ .Ar hash .
78
+ The prefix controls which hashing method is to be used, and is the
79
+ appropriate string to pass to
80
+ .Xr crypt_gensalt 3
81
+ to select that method.
82
+ The contents of
83
+ .Ar options ,
84
+ .Ar salt ,
85
+ and
86
+ .Ar hash
87
+ are up to the method.
88
+ Depending on the method, the
89
+ .Ar prefix
90
+ and
91
+ .Ar options
92
+ components may be empty.
93
+ .Pp
94
+ The
95
+ .Fa setting
96
+ argument to
97
+ .Xr crypt 3
98
+ must begin with the first three components of a valid hashed passphrase,
99
+ but anything after that is ignored.
100
+ This makes authentication simple:
101
+ hash the input passphrase using the stored hashed passphrase as the setting,
102
+ and then compare the result to the stored hashed passphrase.
103
+ .Pp
104
+ Hashed passphrases are always entirely printable ASCII,
105
+ and do not contain any whitespace
106
+ or the characters
107
+ .Sq Li \&: ,
108
+ .Sq Li \&; ,
109
+ .Sq Li \&* ,
110
+ .Sq Li \&! ,
111
+ or
112
+ .Sq Li \&\e .
113
+ (These characters are used as delimiters and special markers in the
114
+ .Xr passwd 5
115
+ and
116
+ .Xr shadow 5
117
+ files.)
118
+ .Pp
119
+ The syntax of each component of a hashed passphrase
120
+ is up to the hashing method.
121
+ .Sq Li \&$
122
+ characters usually delimit components,
123
+ and the salt and hash are usually encoded as numerals in base 64.
124
+ The details of this base-64 encoding vary among hashing methods.
125
+ The common
126
+ .Dq base64
127
+ encoding specified by RFC 4648 is usually
128
+ .Em not
129
+ used.
130
+ .Sh AVAILABLE HASHING METHODS
131
+ This is a list of
132
+ .Em all
133
+ the hashing methods supported by
134
+ .Xr crypt 3 ,
135
+ roughly in decreasing order of strength.
136
+ Many of the older methods
137
+ are now considered too weak to use for new passphrases.
138
+ The hashed passphrase format is expressed
139
+ with extended regular expressions (see
140
+ .Xr regex 7 )
141
+ and does not show the division into prefix, options, salt, and hash.
142
+ .de hash
143
+ .Bl -tag -width 2n
144
+ .It Sy Prefix
145
+ .\" mandoc bug: .Qq comes out with curly quotes.
146
+ .\" mandoc bug: .Li is hyperlinked to itself for no apparent reason.
147
+ .Bf Li
148
+ "\\$1"
149
+ .Ef
150
+ .if "\\$1"" (empty string)
151
+ .It Sy Hashed passphrase format
152
+ .\" mandoc bug: .Li is hyperlinked to itself for no apparent reason.
153
+ .Bf -literal
154
+ \&\\$2
155
+ .Ef
156
+ .It Sy Maximum passphrase length
157
+ .ie "\\$3"unlimited" unlimited
158
+ .el \\$3 characters
159
+ .if "\\$4"7" (ignores 8th bit)
160
+ .It Sy Hash size
161
+ \\$6 bits
162
+ .if !"\\$5"\\$6" \{\
163
+ .It Sy Effective key size
164
+ \&\\$5 bits
165
+ .\}
166
+ .It Sy Salt size
167
+ \\$7 bits
168
+ .It Sy Processing cost parameter
169
+ \\$8
170
+ .El
171
+ ..
172
+ .Ss yescrypt
173
+ yescrypt is a scalable passphrase hashing scheme designed by Solar Designer,
174
+ which is based on Colin Percival's scrypt.
175
+ While yescrypt's strength against password guessing attacks comes from its
176
+ algorithm design, its cryptographic security is guaranteed by its use of
177
+ SHA-256 on the outer layer.
178
+ The SHA-256 hash function has been published by NIST in FIPS PUB 180-2
179
+ (and its subsequent revisions such as FIPS PUB 180-4)
180
+ and by the IETF as RFC 4634 (and subsequently RFC 6234).
181
+ Recommended for new hashes.
182
+ .hash "$y$" "\e$y\e$[./A-Za-z0-9]+\e$[./A-Za-z0-9]{,86}\e$[./A-Za-z0-9]{43}" unlimited 8 256 256 "up to 512 (128+ recommended)" "1 to 11 (logarithmic, also affects memory usage)"
183
+ .Ss gost-yescrypt
184
+ gost-yescrypt uses the output from yescrypt as an input message to HMAC with
185
+ the GOST R 34.11-2012 (Streebog) hash function with a 256-bit digest.
186
+ Thus, yescrypt's cryptographic properties are superseded by those of the GOST
187
+ hash function.
188
+ This hashing method is useful in applications that need modern passphrase
189
+ hashing, but have to rely on GOST algorithms.
190
+ The GOST R 34.11-2012 (Streebog) hash function has been published by the IETF
191
+ as RFC 6986.
192
+ Acceptable for new hashes where required.
193
+ .hash "$gy$" "\e$gy\e$[./A-Za-z0-9]+\e$[./A-Za-z0-9]{,86}\e$[./A-Za-z0-9]{43}" unlimited 8 256 256 "up to 512 (128+ recommended)" "1 to 11 (logarithmic, also affects memory usage)"
194
+ .Ss sm3-yescrypt
195
+ sm3-yescrypt uses the output from yescrypt as an input message to HMAC with
196
+ the ShangMi 3 hash function with a 256-bit digest.
197
+ Thus, yescrypt's cryptographic properties are superseded by those of the
198
+ ShangMi 3 hash function.
199
+ This hashing method is useful in applications that need modern passphrase
200
+ hashing, but have to rely on algorithms approved by the Chinese Office of
201
+ State Commercial Cryptography Administration (OSCCA).
202
+ The ShangMi 3 hash function has been published in Part 3: "Dedicated
203
+ hash-functions" of the ISO/IEC 10118-3:2018.
204
+ Acceptable for new hashes where required.
205
+ .hash "$sm3y$" "\e$sm3y\e$[./A-Za-z0-9]+\e$[./A-Za-z0-9]{,86}\e$[./A-Za-z0-9]{43}" unlimited 8 256 256 "up to 512 (128+ recommended)" "1 to 11 (logarithmic, also affects memory usage)"
206
+ .Ss scrypt
207
+ scrypt is a password-based key derivation function created by Colin Percival,
208
+ originally for the Tarsnap online backup service.
209
+ The algorithm was specifically designed to make it costly to perform
210
+ large-scale custom hardware attacks by requiring large amounts of memory.
211
+ In 2016, the scrypt algorithm was published by IETF as RFC 7914.
212
+ .hash "$7$" "\e$7\e$[./A-Za-z0-9]{11,97}\e$[./A-Za-z0-9]{43}" unlimited 8 256 256 "up to 512 (128+ recommended)" "6 to 11 (logarithmic, also affects memory usage)"
213
+ .Ss bcrypt
214
+ A hash based on the Blowfish block cipher,
215
+ modified to have an extra-expensive key schedule.
216
+ Originally developed by Niels Provos and David Mazieres for OpenBSD
217
+ and also supported on recent versions of FreeBSD and NetBSD,
218
+ on Solaris 10 and newer, and on several GNU/*/Linux distributions.
219
+ .hash "$2b$" "\e$2[abxy]\e$[0-9]{2}\e$[./A-Za-z0-9]{53}" 72 8 184 184 128 "4 to 31 (logarithmic)"
220
+ .Pp
221
+ The alternative prefix "$2y$" is equivalent to "$2b$".
222
+ It exists for historical reasons only.
223
+ The alternative prefixes "$2a$" and "$2x$"
224
+ provide bug-compatibility with crypt_blowfish 1.0.4 and earlier,
225
+ which incorrectly processed characters with the 8th bit set.
226
+ .Ss sha512crypt
227
+ A hash based on SHA-2 with 512-bit output,
228
+ originally developed by Ulrich Drepper for GNU libc.
229
+ Supported on Linux but not common elsewhere.
230
+ Acceptable for new hashes.
231
+ The default processing cost parameter is 5000,
232
+ which is too low for modern hardware.
233
+ .hash "$6$" "\e$6\e$(rounds=[1-9][0-9]+\e$)?[^$:\(rsn]{1,16}\e$[./0-9A-Za-z]{86}" unlimited 8 512 512 "6 to 96" "1000 to 999,999,999"
234
+ .Ss sha256crypt
235
+ A hash based on SHA-2 with 256-bit output,
236
+ originally developed by Ulrich Drepper for GNU libc.
237
+ Supported on Linux but not common elsewhere.
238
+ Acceptable for new hashes.
239
+ The default processing cost parameter is 5000,
240
+ which is too low for modern hardware.
241
+ .hash "$5$" "\e$5\e$(rounds=[1-9][0-9]+\e$)?[^$:\(rsn]{1,16}\e$[./0-9A-Za-z]{43}" unlimited 8 256 256 "6 to 96" "1000 to 999,999,999"
242
+ .Ss sm3crypt
243
+ A hash based on the ShangMi 3 hash function
244
+ with 256-bit output, that uses the same design as
245
+ sha256crypt and/or sha512crypt.
246
+ Supported on EulerOS, Kylin, openEuler, and openKylin,
247
+ but not common elsewhere.
248
+ Acceptable for new hashes where required.
249
+ The default processing cost parameter is 5000,
250
+ which is too low for modern hardware.
251
+ .hash "$sm3$" "\e$sm3\e$(rounds=[1-9][0-9]+\e$)?[^$:\(rsn]{1,16}\e$[./0-9A-Za-z]{86}" unlimited 8 256 256 "6 to 96" "1000 to 999,999,999"
252
+ .Ss sha1crypt
253
+ A hash based on HMAC-SHA1.
254
+ Originally developed by Simon Gerraty for NetBSD.
255
+ Not as weak as the DES-based hashes below,
256
+ but SHA-1 is so cheap on modern hardware
257
+ that it should not be used for new hashes.
258
+ .hash "$sha1" "\e$sha1\e$[1-9][0-9]+\e$[./0-9A-Za-z]{1,64}\e$[./0-9A-Za-z]{8,64}[./0-9A-Za-z]{32}" unlimited 8 160 160 "6 to 384" "4 to 4,294,967,295"
259
+ .Ss SunMD5
260
+ A hash based on the MD5 algorithm,
261
+ originally developed by Alec David Muffett for Solaris.
262
+ Not adopted elsewhere, to our knowledge.
263
+ Not as weak as the DES-based hashes below,
264
+ but MD5 is so cheap on modern hardware
265
+ that it should not be used for new hashes.
266
+ .hash "$md5" "\e$md5(,rounds=[1-9][0-9]+)?\e$[./0-9A-Za-z]{8}\e${1,2}[./0-9A-Za-z]{22}" unlimited 8 128 128 48 "4096 to 4,294,963,199"
267
+ .Ss md5crypt
268
+ A hash based on the MD5 algorithm, originally developed by
269
+ Poul-Henning Kamp for FreeBSD.
270
+ Supported on most free Unixes and newer versions of Solaris.
271
+ Not as weak as the DES-based hashes below,
272
+ but MD5 is so cheap on modern hardware
273
+ that it should not be used for new hashes.
274
+ Processing cost is not adjustable.
275
+ .hash "$1$" "\e$1\e$[^$:\(rsn]{1,8}\e$[./0-9A-Za-z]{22}" unlimited 8 128 128 "6 to 48" 1000
276
+ .Ss bsdicrypt (BSDI extended DES)
277
+ An extension of traditional DES,
278
+ which eliminates the length limit,
279
+ increases the salt size,
280
+ and makes the time cost tunable.
281
+ It originates with BSDI BSD/OS
282
+ and is also available on at least NetBSD, OpenBSD, and FreeBSD
283
+ due to the use of David Burren's FreeSec library.
284
+ It is much better than traditional DES and bigcrypt,
285
+ but still should not be used for new hashes.
286
+ .hash _ "_[./0-9A-Za-z]{19}" unlimited 7 "up to 56" 64 24 "1 to 16,777,215 (must be odd)"
287
+ .Ss descrypt (Traditional DES)
288
+ The original hashing method from Unix V7, based on the DES block cipher.
289
+ Because DES is cheap on modern hardware,
290
+ because there are only 4096 possible salts and 2**56 distinct passphrases,
291
+ which it truncates to 8 characters,
292
+ it is feasible to discover
293
+ .Em any
294
+ passphrase hashed with this method.
295
+ It should only be used if you absolutely have to generate hashes
296
+ that will work on an old operating system that supports nothing else.
297
+ .hash "" "[./0-9A-Za-z]{13}" 8 7 "up to 56" 64 12 25
298
+ .Ss bigcrypt
299
+ A weak extension of traditional DES,
300
+ available on some commercial Unixes.
301
+ All it does is raise the length limit from 8 to 128 characters,
302
+ and it does this in a crude way that allows attackers to
303
+ guess chunks of a long passphrase separately and in parallel,
304
+ which may make guessing even easier than for traditional DES above.
305
+ It should not be used for new hashes.
306
+ .hash "" "[./0-9A-Za-z]{13,178}" 128 7 "up to 56" "up to 1024" 12 25
307
+ .Ss NT
308
+ The hashing method used for network authentication
309
+ in some versions of the SMB/CIFS protocol.
310
+ Available, for cross-compatibility's sake, on FreeBSD.
311
+ Based on MD4.
312
+ Has no salt or tunable cost parameter.
313
+ It is so weak that almost
314
+ .Em any
315
+ human-chosen passphrase hashed with this method is guessable.
316
+ It should only be used if you absolutely have to generate hashes
317
+ that will work on an old operating system that supports nothing else.
318
+ .hash "$3$" "\e$3\e$\e$[0-9a-f]{32}" unlimited 8 256 256 0 1
319
+ .Sh SEE ALSO
320
+ .Xr crypt 3 ,
321
+ .Xr crypt_gensalt 3 ,
322
+ .Xr getpwent 3 ,
323
+ .Xr passwd 5 ,
324
+ .Xr shadow 5 ,
325
+ .Xr pam 8
326
+ .Rs
327
+ .%A Niels Provos
328
+ .%A David Mazieres
329
+ .%T A Future-Adaptable Password Scheme
330
+ .%B Proceedings of the 1999 USENIX Annual Technical Conference
331
+ .%D June 1999
332
+ .%U https://www.usenix.org/events/usenix99/provos.html
333
+ .Re
334
+ .Rs
335
+ .%A Robert Morris
336
+ .%A Ken Thompson
337
+ .%T Password Security: A Case History
338
+ .%J Communications of the ACM
339
+ .%V 22
340
+ .%N 11
341
+ .%D 1979
342
+ .%U http://wolfram.schneider.org/bsd/7thEdManVol2/password/password.pdf
343
+ .Re
@@ -0,0 +1,106 @@
1
+ .\" Written by Zack Weinberg <zackw at panix.com> in 2018.
2
+ .\"
3
+ .\" To the extent possible under law, the authors have waived
4
+ .\" all copyright and related or neighboring rights to this work.
5
+ .\" See https://creativecommons.org/publicdomain/zero/1.0/ for further
6
+ .\" details.
7
+ .\"
8
+ .Dd November 8, 2018
9
+ .Dt CRYPT_CHECKSALT 3
10
+ .Os "libxcrypt"
11
+ .Sh NAME
12
+ .Nm crypt_checksalt
13
+ .Nd validate a crypt setting string
14
+ .Sh LIBRARY
15
+ .Lb libcrypt
16
+ .Sh SYNOPSIS
17
+ .In crypt.h
18
+ .Ft int
19
+ .Fo crypt_checksalt
20
+ .Fa "const char *setting"
21
+ .Fc
22
+ .Sh DESCRIPTION
23
+ .Nm
24
+ checks the
25
+ .Ar setting
26
+ string against the system configuration
27
+ and reports whether the hashing method and parameters it specifies
28
+ are acceptable.
29
+ It is intended to be used by programs
30
+ such as
31
+ .Xr login 1
32
+ to determine whether the user's passphrase should be re-hashed
33
+ using the currently preferred hashing method.
34
+ .Sh RETURN VALUES
35
+ The return value is 0 if there is nothing wrong with this setting.
36
+ Otherwise, it is one of the following constants:
37
+ .Bl -tag -width 4n
38
+ .It Dv CRYPT_SALT_OK
39
+ .Ar setting
40
+ is a fully correct setting string.
41
+ This constant is guaranteed to equal 0.
42
+ .It Dv CRYPT_SALT_INVALID
43
+ .Ar setting
44
+ is not a valid setting string; either it specifies a hashing method
45
+ that is not known to this version of libxcrypt,
46
+ or it specifies invalid parameters for the method.
47
+ .It Dv CRYPT_SALT_METHOD_DISABLED (Not implemented, yet)
48
+ .Ar setting
49
+ specifies a hashing method that is no longer allowed to be used at all;
50
+ .Nm crypt
51
+ will fail if passed this
52
+ .Ar setting .
53
+ Manual intervention will be required to reactivate the user's account.
54
+ .It Dv CRYPT_SALT_METHOD_LEGACY
55
+ .Ar setting
56
+ specifies a hashing method that is no longer considered strong enough
57
+ for use with new passphrases.
58
+ .Nm crypt
59
+ will still authenticate a passphrase against this setting,
60
+ but if authentication succeeds,
61
+ the passphrase should be re-hashed using the currently preferred method.
62
+ .It Dv CRYPT_SALT_TOO_CHEAP (Not implemented, yet)
63
+ .Ar setting
64
+ specifies cost parameters that are considered too cheap for use with
65
+ new passphrases.
66
+ .Nm crypt
67
+ will still authenticate a passphrase against this setting,
68
+ but if authentication succeeds,
69
+ the passphrase should be re-hashed using the currently preferred method.
70
+ .El
71
+ .Sh FEATURE TEST MACROS
72
+ .In crypt.h
73
+ will define the macro
74
+ .Dv CRYPT_CHECKSALT_AVAILABLE
75
+ if
76
+ .Nm
77
+ is available in the current version of libxcrypt.
78
+ .Sh BUGS
79
+ Since full configurability is not yet implemented, the current
80
+ implementation will only ever return
81
+ .Nm CRYPT_SALT_OK (0)
82
+ or
83
+ .Nm CRYPT_SALT_INVALID
84
+ when invoked.
85
+ .Sh PORTABILITY NOTES
86
+ The function
87
+ .Nm
88
+ is not part of any standard.
89
+ It was added to libxcrypt in version 4.3.0.
90
+ .Sh ATTRIBUTES
91
+ For an explanation of the terms used in this section, see
92
+ .Xr attributes 7 .
93
+ .TS
94
+ allbox;
95
+ lb lb lb
96
+ l l l.
97
+ Interface Attribute Value
98
+ T{
99
+ .Nm
100
+ T} Thread safety MT-Safe
101
+ .TE
102
+ .sp
103
+ .Sh SEE ALSO
104
+ .Xr crypt 3 ,
105
+ .Xr crypt_gensalt 3 ,
106
+ .Xr crypt 5