]> git.ipfire.org Git - thirdparty/shadow.git/commit
libmisc/salt.c: Sanitize code. 361/head
authorBjörn Esser <besser82@fedoraproject.org>
Mon, 14 Jun 2021 21:28:28 +0000 (23:28 +0200)
committerBjörn Esser <besser82@fedoraproject.org>
Tue, 22 Jun 2021 20:03:21 +0000 (22:03 +0200)
commit14b108728a5d55c3d478a170c39f0e2ffd4de1b0
treef9c59c1f992ce9a26aa2ecc5b3d181b62076a817
parentdbfad7d1c9a031b5db33e1695da4a1c03a4494ea
libmisc/salt.c: Sanitize code.

* Move all pre-processor defines to the top of the file.
* Unify the gensalt() function to be useable for all supported
  hash methods.
* Drop the gensalt_{b,yes}crypt() functions in favor of the
  previous change.
* Refactor the functions converting the rounds number into
  a string for use with the crypt() function, to not require
  any static buffer anymore.
* Clarify the comment about how crypt_make_salt() chooses the used
  hash method from the settings in the login.defs file.
* Use memset() to fill static buffers with zero before using them.
* Use a fixed amount of 16 random base64-chars for the
  sha{256,512}crypt hash methods, which is effectively still less
  than the recommendation from NIST (>= 128 bits), but the maximum
  those methods can effectively use (approx. 90 bits).
* Rename ROUNDS_{MIN,MAX} to SHA_ROUNDS_{MIN,MAX}.
* Bugfixes in the logic of setting rounds in BCRYPT_salt_rounds().
* Likewise for YESCRYPT_salt_cost().
* Fix formatting and white-space errors.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
libmisc/salt.c