21 Commits

Author SHA1 Message Date
Milan Broz
1e441bf75c Use #if for rest of defines. 2025-01-27 11:05:08 +00:00
Milan Broz
36574dd114 Avoid if (not NULL) free().
This fixes some COdeQL warnings.
2025-01-16 15:54:09 +01:00
Milan Broz
c3972372b1 argon2: Avoid unitialized warning in cppcheck
Thsi patch avoids this cppcheck warning:

Error: CPPCHECK_WARNING (CWE-457): [#def1]
cryptsetup-main/lib/crypto_backend/argon2/blake2/blake2b.c:369: warning[uninitvar]: Uninitialized variable: out_buffer

It is a false positive, but wiping buffer is cheap a and similar approach is used
in other Argon2 implementations (OpenSSL).
2024-11-08 19:51:14 +00:00
Milan Broz
46289f92ff argon2: Avoid cppcheck integer oveflow warning
This patch avoid warning in constant-time base64 function:

Error: CPPCHECK_WARNING (CWE-190): [#def2]
cryptsetup-main/lib/crypto_backend/argon2/encoding.c:86: error[integerOverflow]: Signed integer overflow for expression ''0'-52'.

The (x + ('0' - 52)) can be rewritten to (x - (52 - '0')) with the same effect.
Similar solution used in https://github.com/pornin/CTTK/blob/master/src/base64.c
2024-11-08 19:51:14 +00:00
Daniel Zatovic
114a13af84 Add support for meson build system.
For now, let's keep support for both - autotools and meson.
2023-03-03 13:49:47 +00:00
Alex Xu (Hello71)
46efbc0a36 argon2: Don't call _endthreadex/pthread_exit
Returning from the thread creation function is documented to be a valid
way of exiting a thread on both Windows and pthread systems. Removing
the explicit call avoids the need to install libgcc_s.so in initramfs
for glibc systems, and slightly reduces code size.

Upstream: https://github.com/P-H-C/phc-winner-argon2/pull/331
2022-01-28 15:06:08 +00:00
Milan Broz
a76310b53f Do not try to set compiler optimization flag if wipe is implemented in libc.
If zeroing memory is implemented through libc call (like memset_bzero),
compiler should never remove such call. It is not needed to set O0
optimization flag explicitly.

Various checkers like annocheck causes problems with these flags,
just remove it where it makes no sense.

(Moreover, we use the same pattern without compiler magic
in crypt_backend_memzero() already.)
2021-09-20 17:42:20 +02:00
Milan Broz
413b484774 Add some fixes and workarounds for gcc-11 static analyzer.
Not everything is a real bug (false positive rate is very high here),
but the code is actually more readable.
2021-05-18 17:28:47 +02:00
Francesco Turco
a491b938ba use HTTPS for URLs 2020-07-04 16:43:23 +02:00
Milan Broz
238b18b8ac Upstream fixes to bundled Argon2 code.
Wait for already running threads if a thread creation failed.
Use explicit_bzero() on recent glibc versions.
(Without fixed logic, we have already macro definition through automake.)

Fixes #444.
2019-03-13 08:26:40 +01:00
Milan Broz
4e1c62d7f1 Ignore false positive Coverity warning for string length. 2018-12-04 12:57:08 +01:00
Rafael Fontenelle
f35ec9771e Fix typos
A bunch of typos reported by codespell, most of them comments in the code
2018-07-21 07:24:25 -03:00
Ondrej Kozina
b2a1728201 Fix bundled argon2 distcheck errors. 2018-07-18 11:57:43 +02:00
Milan Broz
d3460b6cf5 Fix internal bundled Argon2 build. 2018-07-07 11:06:54 +02:00
Milan Broz
ba384d15d2 Add optimized Argon2 SSE code.
Note: it is always better to use external libargon2 library.

Unfortunately, until Argon2 is in generic crypto libraries,
we must sometimes use bundled version just for bureaucratic reasons.

Let's include optimized variant of reference implementation as well.

Note, this code will not add any SSE compiler switches.

If --enable-internal-sse-argon2 option is used, it checks if current
compilation flags support simple SSE progam and if so, it use
the optimized variant.
(Not tested for AVX optimizations; it expects that SSE is enabled as well.)
2018-07-07 10:36:49 +02:00
Milan Broz
2f38ade0e0 Update Argon2 header to match upstream. 2018-07-07 10:35:23 +02:00
Milan Broz
180d96234e Fix another compiler warnings with extra flags. 2018-01-20 21:17:10 +01:00
Milan Broz
7ba4ca1854 Add bundled lib README to package. 2017-12-07 12:15:55 +01:00
Milan Broz
f507d16baa Update bundled Argon2 source. 2017-11-14 12:07:53 +01:00
Milan Broz
d77bbe93c1 Use non-recursive automake.
This change also causes that now binaries and libraries are placed in
build root directory.

Now we can use subdir-objects for automake.
2017-10-12 11:48:17 +02:00
Milan Broz
09d14a0b6c Add Argon2 bundled library to crypto backend.
The Argon2i/id is a password hashing function that
won Password Hashing Competiton.

It will be (optionally) used in LUKS2 for passworrd-based
key derivation.

We have to bundle code for now (similar PBKDF2 years ago)
because there is yet no usable implementation in common
crypto libraries.
(Once there is native implementation, cryptsetup
will switch to the crypto library version.)

For now, we use reference (not optimized but portable) implementation.

This patch contains bundled Argon2 algorithm library copied from
  https://github.com/P-H-C/phc-winner-argon2

For more info see Password Hashing Competition site:
  https://password-hashing.net/
and draft of RFC document
  https://datatracker.ietf.org/doc/draft-irtf-cfrg-argon2/

Signed-off-by: Milan Broz <gmazyland@gmail.com>
2017-08-06 21:13:12 +02:00