diff options
Diffstat (limited to '')
-rw-r--r-- | libbb/pw_encrypt_yes.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libbb/pw_encrypt_yes.c b/libbb/pw_encrypt_yes.c new file mode 100644 index 000000000..50bd06418 --- /dev/null +++ b/libbb/pw_encrypt_yes.c | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * Utility routines. | ||
3 | * | ||
4 | * Copyright (C) 2025 by Denys Vlasenko <vda.linux@googlemail.com> | ||
5 | * | ||
6 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
7 | */ | ||
8 | #include "yescrypt/alg-yescrypt.h" | ||
9 | |||
10 | static char * | ||
11 | yes_crypt(const char *passwd, const char *salt_data) | ||
12 | { | ||
13 | /* prefix, '$', hash, NUL */ | ||
14 | char buf[YESCRYPT_PREFIX_LEN + 1 + YESCRYPT_HASH_LEN + 1]; | ||
15 | char *retval; | ||
16 | |||
17 | retval = yescrypt_r( | ||
18 | (const uint8_t *)passwd, strlen(passwd), | ||
19 | (const uint8_t *)salt_data, | ||
20 | buf, sizeof(buf)); | ||
21 | /* The returned value is either buf[], or NULL on error */ | ||
22 | |||
23 | return xstrdup(retval); | ||
24 | } | ||