77 Commits

Author SHA1 Message Date
Marco d'Itri
59a8760c31
Update the text of the GPL 2026-02-16 02:46:44 +01:00
Marco d'Itri
db1c3e143d
mkpasswd: rename bcrypt-a and gost-yescrypt
Let's use the same names listed in libxcrypt's crypt(5).

I highly doubt that anybody uses these names, so I am not adding
compatibility aliases.
2026-02-16 02:46:44 +01:00
Marco d'Itri
9d8f93b3c2
mkpasswd: support the Chinese algorithms 2026-02-16 02:46:44 +01:00
Marco d'Itri
15883e61b2
mkpasswd: move the "national" algorithms
Keep them around the end of the list because they should never be
selected automatically or preferred.
2026-02-16 02:46:44 +01:00
Marco d'Itri
6e74da05d1
mkpasswd: use readpassphrase(3) if available 2025-06-21 01:34:43 +02:00
Marco d'Itri
8a3bbc2473 Suppress the "unused parameter" warning in get_random_bytes() 2024-02-24 17:08:17 +01:00
Marco d'Itri
8079ab6f52 Remove the copyright years from the sources files 2023-12-10 12:08:46 +01:00
Marco d'Itri
114b9d2fd9 mkpasswd: prevent using two unitialized variables 2023-10-08 22:58:27 +02:00
Petr Menšík
6761f80395 Add SPDX license identifiers to code files
Change manual pages word to recognize it by licensecheck tool.
2023-07-22 17:38:06 +02:00
Marco d'Itri
c58b75e0a9 Fix some signedness-related warnings 2022-12-28 20:40:13 +01:00
Marco d'Itri
05c68ae9f0 mkpasswd: add some comments 2022-01-06 16:09:42 +01:00
Marco d'Itri
fb5cc7f4ef mkpasswd: allow providing a partial salt string
To support commands like:

  mkpasswd --method=yescrypt abc 'j9T$NLTnlHlt6cj0lkSizrMNN.'
  mkpasswd --method=sha-256  abc 'rounds=3000$NhJ78pg4LKwQ9cOJ$'
2022-01-06 16:04:42 +01:00
Marco d'Itri
6520b68285 Update the copyright year 2021-02-16 01:53:41 +01:00
Marco d'Itri
aea6650cfc mkpasswd: support raw $salt$ prefixes
If the salt provided to the program starts with '$' then it will be
passed straight to crypt(3) without any checks.
2019-12-31 02:36:51 +01:00
Marco d'Itri
38cab73d18 mkpasswd: support setting the rounds number for *scrypt
It is not practical to support for these functions passing straight to
crypt(3) an user-provided salt string because the salt field in the
hashed password also contains the rounds number encoded as base64.
See yescrypt_encode_params_r in the libxcrypt source for details.
2019-12-31 01:56:56 +01:00
Marco d'Itri
467f8e9935 mkpasswd: replace md5 with md5crypt in the documentation 2019-12-30 06:05:58 +01:00
Marco d'Itri
4f1ddfa66e mkpasswd: ignore a 0-bytes salt parameter
This also prevents a segmentation fault when
CRYPT_GENSALT_IMPLEMENTS_DEFAULT_PREFIX is used.

Closes #81 from Github.
2019-12-30 05:59:36 +01:00
Marco d'Itri
19eb4fa5ef mkpasswd: move a forgotten comment to the right place 2019-07-18 04:47:38 +02:00
Marco d'Itri
a0c0bf7144 Split the help messages in multiple strings
To help translators.
2019-06-24 05:07:43 +02:00
Marco d'Itri
2b78ca68df mkpasswd: support the "gost-yescrypt" hash 2019-06-23 15:40:12 +02:00
Marco d'Itri
830c3e3a7c Update the copyright year everywhere 2019-06-23 15:40:12 +02:00
Marco d'Itri
4d24d493ff mkpasswd: implement a generic way to provide the hash type 2018-10-14 03:41:14 +02:00
Marco d'Itri
88a7462301 mkpasswd: support the other hash types in libxcrypt
Among them scrypt and bcrypt.
2018-10-14 03:19:48 +02:00
Marco d'Itri
4362ef1fc4 mkpasswd: reorder the hash types
From the most secure to the less, accordingly to libxcrypt's crypt(5).
2018-10-14 02:33:13 +02:00
Marco d'Itri
b91c9057da mkpasswd: correctly print the available methods as columns 2018-10-14 01:14:09 +02:00
Marco d'Itri
b2ae96cf3f mkpasswd: adopt the John the Ripper naming of hash types
And add hidden compatibility aliases for the old ones.
(Except than the bcrypt variants, since there is no proof that anybody
ever used this program for them.)

See https://github.com/besser82/libxcrypt/pull/26 for more information.
2018-10-10 01:12:27 +02:00
Marco d'Itri
ae31f61a34 mkpasswd: include crypt.h on Solaris 2018-09-20 00:18:06 +02:00
Marco d'Itri
d4d7cd1096 mkpasswd: fix rounds support for bcrypt 2x and 2y 2018-09-20 00:18:06 +02:00
Marco d'Itri
3197cb7db4 mkpasswd: support letting crypt_gensalt decide the prefix
If crypt_gensalt (as implemented by Solaris and modern versions of
libxcrypt) is passed a NULL prefix then it will decide by itself which
algorithm should be used by default.
2018-09-20 00:18:06 +02:00
Marco d'Itri
61f4e5d64c mkpasswd: simplify a check for errors
salt is a const char *, so we know that it cannot be modified as a side
effect.
2018-09-16 03:36:38 +02:00
Marco d'Itri
c1cb4b2ca0 mkpasswd: update the libowcrypt Makefile section
Distributions which have crypt_gensalt in libowcrypt now should define
a HAVE_LIBOWCRYPT=1 Makefile variable.
2018-09-16 03:36:38 +02:00
Marco d'Itri
44775cb342 mkpasswd: rename HAVE_XCRYPT to HAVE_XCRYPT_H 2018-09-16 03:36:38 +02:00
Marco d'Itri
7a325d277c mkpasswd: ifdef out the entropy gathering code on Solaris 2018-09-16 03:35:38 +02:00
Marco d'Itri
19e44ac2ec mkpasswd: let crypt_gensalt collect entropy by itself
Let crypt_gensalt(3) collect entropy by itself instead of having
mkpasswd provide it.
This is supported by the libxcrypt implementation of crypt_gensalt(3).
2018-09-16 03:35:38 +02:00
Marco d'Itri
8392fd349d mkpasswd: use perror with crypt and crypt_gensalt
Only some implementations of crypt(3) set errno on errors.
2018-09-12 02:26:55 +02:00
Marco d'Itri
fbeb327936 mkpasswd: update the copyright year 2018-05-25 01:44:38 +02:00
Marco d'Itri
fdd5a596b0 mkpasswd: support passwords of arbitrary length
Closes: #899254
2018-05-22 05:04:54 +02:00
Marco d'Itri
a9f59fdd52 Update the copyright years 2018-01-13 01:15:48 +01:00
Petr Písař
50b57a6fb7 Remove unused variables in get_random_bytes()
If getentropy() is available, GCC warns about unsused variables:

mkpasswd.c: In function ‘get_random_bytes’:
mkpasswd.c:369:13: warning: unused variable ‘bytes_read’ [-Wunused-variable]
     ssize_t bytes_read;
             ^~~~~~~~~~
mkpasswd.c:368:9: warning: unused variable ‘fd’ [-Wunused-variable]
     int fd;
         ^~

This patch fixes it.
2017-12-27 03:09:58 +01:00
Marco d'Itri
6557a52b3e mkpasswd: use getentropy(2) on recent Linux 2017-12-10 17:14:26 +01:00
Marco d'Itri
182fdaaaaa mkpasswd: refactoring 2017-12-10 17:13:03 +01:00
Andreas Stieger
a786e83add fix FSF address in mkpasswd.c 2017-08-22 16:59:53 +02:00
Marco d'Itri
fb823a251a Annotate more functions with NORETURN
Contributed by Sami Kerola.
Closes #48 from Github.
2017-02-26 23:33:01 +01:00
Marco d'Itri
5e33209e13 Fix minor compiler warnings
Fix a lot of minor compiler warnings with no practical effect.
Contributed by Sami Kerola.
2017-02-26 23:12:47 +01:00
Marco d'Itri
a4815eb370 BSD portability fixes 2017-02-26 14:13:27 +01:00
Marco d'Itri
4ac83a5f49 mkpasswd: fix compile time error with HAVE_ARC4RANDOM_BUF
Patch from MacPorts.
2017-02-26 04:29:11 +01:00
Marco d'Itri
3b38b4fd1d mkpasswd: define _DEFAULT_SOURCE
Since glibc 2.20 it replaces the deprecated _BSD_SOURCE macro.
2016-03-28 18:37:43 +02:00
Marco d'Itri
09d4a0fe88 mkpasswd: exit if crypt_gensalt on Solaris fails 2015-03-23 04:31:02 +01:00
Marco d'Itri
4fa1cd69e4 mkpasswd: use arc4random_buf where available 2014-12-26 19:55:51 +01:00
Marco d'Itri
b207df0805 mkpasswd: support OpenBSD's new hash 2b 2014-12-26 19:55:51 +01:00