aboutsummaryrefslogtreecommitdiffstats
path: root/argon2/hash.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-05-14 19:46:14 +0200
committerMattias Andrée <m@maandree.se>2026-05-14 19:46:14 +0200
commit5660c556a06916c2f1e004f7f8d5e368b3a88e25 (patch)
tree562217dbfa5f33ee7a73f6bdfc3b67dc9245b4d9 /argon2/hash.c
parentFix test bug only found with musl+clang (diff)
downloadlibrecrypt-5660c556a06916c2f1e004f7f8d5e368b3a88e25.tar.gz
librecrypt-5660c556a06916c2f1e004f7f8d5e368b3a88e25.tar.bz2
librecrypt-5660c556a06916c2f1e004f7f8d5e368b3a88e25.tar.xz
Clean up
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'argon2/hash.c')
-rw-r--r--argon2/hash.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/argon2/hash.c b/argon2/hash.c
index 313eea0..fd4609a 100644
--- a/argon2/hash.c
+++ b/argon2/hash.c
@@ -125,7 +125,7 @@ librecrypt__argon2__hash(char *restrict out_buffer, size_t size, const char *phr
if (libar2_hash(scratch ? scratch : out_buffer, REMOVE_CONST(phrase), len, &params, &ctx))
goto fail;
if (scratch && out_buffer)
- memcpy(out_buffer, scratch, params.hashlen < size ? params.hashlen : size);
+ memcpy(out_buffer, scratch, MIN(params.hashlen, size));
/* same rationale as for `ctx.autoerase_salt = 1;` */
if (scratch) {
@@ -190,7 +190,7 @@ check(const char *phrase, const char *settings, const char *hash, size_t hashlen
for (i = 1u; i <= hashlen * 2u; i++) {
memset(buf, 0, sizeof(buf));
EXPECT(librecrypt__argon2__hash(buf, i, phrase, len, settings, prefix, NULL) == 0);
- EXPECT(!memcmp(expected, buf, i < hashlen ? i : hashlen));
+ EXPECT(!memcmp(expected, buf, MIN(i, hashlen)));
}
}