summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-07-07 04:57:16 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-07-07 04:57:16 +0200
commite2091c98425e2e1615db7dcad9556c928ea5123d (patch)
tree5051444182c778bf7dc24d7f3300af8c09175374 /libbb
parenta2a5db41a3ace98e7eff53aca231053be7717c66 (diff)
libbb: add two more forgotten source files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/hash_sha256_block.c19
-rw-r--r--libbb/pw_encrypt_yes.c24
2 files changed, 43 insertions, 0 deletions
diff --git a/libbb/hash_sha256_block.c b/libbb/hash_sha256_block.c
new file mode 100644
index 000000000..3c4366321
--- /dev/null
+++ b/libbb/hash_sha256_block.c
@@ -0,0 +1,19 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 2025 Denys Vlasenko
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+//kbuild:lib-y += hash_sha256_block.o
+#include "libbb.h"
+
+void FAST_FUNC
+sha256_block(const void *in, size_t len, uint8_t hash[32])
+{
+ sha256_ctx_t ctx;
+ sha256_begin(&ctx);
+ sha256_hash(&ctx, in, len);
+ sha256_end(&ctx, hash);
+}
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 @@
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 2025 by Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+#include "yescrypt/alg-yescrypt.h"
+
+static char *
+yes_crypt(const char *passwd, const char *salt_data)
+{
+ /* prefix, '$', hash, NUL */
+ char buf[YESCRYPT_PREFIX_LEN + 1 + YESCRYPT_HASH_LEN + 1];
+ char *retval;
+
+ retval = yescrypt_r(
+ (const uint8_t *)passwd, strlen(passwd),
+ (const uint8_t *)salt_data,
+ buf, sizeof(buf));
+ /* The returned value is either buf[], or NULL on error */
+
+ return xstrdup(retval);
+}