summaryrefslogtreecommitdiff
path: root/app-crypt/libscrypt
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-11-28 02:00:16 +0000
committerV3n3RiX <venerix@koprulu.sector>2024-11-28 02:00:16 +0000
commita2148b9fab4c83209816a49f091d70873b19881d (patch)
treeaeeaea24918f3a0df7fc0e4e013c68df40469897 /app-crypt/libscrypt
parentead7697a01fd631b56240b2d58aedd98ba7f92d3 (diff)
gentoo auto-resync : 28:11:2024 - 02:00:16
Diffstat (limited to 'app-crypt/libscrypt')
-rw-r--r--app-crypt/libscrypt/Manifest2
-rw-r--r--app-crypt/libscrypt/files/libscrypt-1.22-aliasing.patch309
-rw-r--r--app-crypt/libscrypt/libscrypt-1.22-r3.ebuild37
3 files changed, 348 insertions, 0 deletions
diff --git a/app-crypt/libscrypt/Manifest b/app-crypt/libscrypt/Manifest
index 54f19f96acb8..8380777cf565 100644
--- a/app-crypt/libscrypt/Manifest
+++ b/app-crypt/libscrypt/Manifest
@@ -1,6 +1,8 @@
+AUX libscrypt-1.22-aliasing.patch 8753 BLAKE2B 3bb7c36cee79fed3959e84fe9a35ed0f5952b6ba26385b1366d0f273327e932a068145a101256ef94d3faacc98972e9fdecbb5baddf082ed6724b1e242c04314 SHA512 886f33ff25892a7b72e3cb8497a423160f3d2087c21c99bace9268f758d9c74593616a767cb75f3f8b83b0dfcb22dbd6d2715e5c96dc4f75ea1b82f3e0383eb9
AUX libscrypt-1.22-no-clobber-fortify-source.patch 438 BLAKE2B e5089a6532f054447cd5161a8b7dbdfb32a432527b7702ce265d8c1bac76b8549d6adfcc6157e890bde4e0c9551d78f2d0aff24ea7ab989423a3716e65fcb334 SHA512 cbb9c1d6608c562c298abe5989d31b6b49f63e4640e271b93031d35fd749427182bafae64a75b6effc4e7143ae9f2867f3772090ec503f7c8073a3c10b53949f
DIST libscrypt-1.22.tar.gz 19495 BLAKE2B 2c04b91dc48e807223a3433739deb31186efc1b4066cb57e3db835b68de4d08b9586d0a686d5f0f4c119582e82823fbf0556944c190d586664cc4d6f014ad5ab SHA512 3c01fd76441bdf7c90fa17534bfdda9e279469676359172eda7f7683ca65a7aae576a87d07125ce38598ef3fd2755547d53417132b9159a2b211898f70c80f51
EBUILD libscrypt-1.22-r1.ebuild 714 BLAKE2B 2059031221c9ace3a5fcb8e3f4632869078b1fbeba2101fcb68816434f43f1856edc073973ad3691aa17998c14c96ff84a29a794491fb60734c08004a2648a5b SHA512 d432ffdf0f3da3105c21de0de925169d60faf4af8ca760c2415b123241434758b7a47bd80b42e1bac53130386845401f5ffd88250786beb3926eb861f05999ea
EBUILD libscrypt-1.22-r2.ebuild 810 BLAKE2B c293491b3d8f1088de1a7f243e3c15e79db72eff273fb0312eb1981fa97f5b872e3799355333a101f36aa5acaad62c427bcae4f9c20aed9ead93653268379fa4 SHA512 43352d147b73beb6b8edac61a6ea8aaf4162a35d0789cf7635ae404bfd72cd48035c419c6ae12e6f33f2e5b1fd85c41871fdc458d3471f9715ad7d97f6c0305f
+EBUILD libscrypt-1.22-r3.ebuild 851 BLAKE2B e05805ddac1283b3b6938570db46d5ed46614a08bd7c6be88fad4be992ee7ab56a85ce8291c6fce4fdfa517f6affecef2ccf8235d2b3ac5bb279161b005e0116 SHA512 8be7476ebc9e003e433564e65759ddea3f2af137d49348d2a8336730e38a35ff1d683207079bba0cf2b6d257105b2d5e518e4dfc04c7fbd1b05acbf4f0c7dc8f
EBUILD libscrypt-1.22.ebuild 651 BLAKE2B 5450158a061a864f203f10da091136f0aaaab11eecb3fe6f0c9b94cecfda50e0549ad88b6f498309ed4e16d813822e6a326655964a2b965e44e3712c63bcd45a SHA512 8fd7aa25a3662c4fe46a03641636d5b1fc5afd1f81f533ea77ace70880e4c1ac3329d21b0ef452256a3fc75bd387310a832fa79caf96f38e2d9dce5a7f11fa6b
MISC metadata.xml 256 BLAKE2B 0583a0f48ddab7dd1ff43587374095c077c0d5afc7134fda41a688d537250f7b9942cf538518c890f3cb175c8c8f7dd170bc3a54ff717129ac16c2531bd48d56 SHA512 db3da96ac2e1680073a199ced5f81dd8b9f17954fef1cfd5b52a626f90a02024f7fcb9eaf4433194d0b6596c22553d5aec1695234a23f3a9d6fcb3e12c6c128f
diff --git a/app-crypt/libscrypt/files/libscrypt-1.22-aliasing.patch b/app-crypt/libscrypt/files/libscrypt-1.22-aliasing.patch
new file mode 100644
index 000000000000..770358b90e6f
--- /dev/null
+++ b/app-crypt/libscrypt/files/libscrypt-1.22-aliasing.patch
@@ -0,0 +1,309 @@
+https://bugs.gentoo.org/931556
+https://gcc.gnu.org/PR117800
+https://github.com/technion/libscrypt/issues/60
+https://github.com/technion/libscrypt/pull/62
+
+From 1c20db581099de69d3f8ce8e06981e7c7e14f2e4 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Wed, 27 Nov 2024 03:07:57 +0000
+Subject: [PATCH 1/3] sysendian.h: fix aliasing violations
+
+Accessing a e.g. uint32_t as uint8_t is an aliasing violation. The
+helpers here are nearly idiomatic for avoiding that anyway, so fix
+them up accordingly.
+--- a/sysendian.h
++++ b/sysendian.h
+@@ -49,95 +49,77 @@
+ #endif
+
+ static INLINE uint32_t
+-be32dec(const void *pp)
++be32dec(const unsigned char* p)
+ {
+- const uint8_t *p = (uint8_t const *)pp;
+-
+- return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
+- ((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
++ return ((uint32_t)p[0] << 24) | ((uint32_t)p[1] << 16) | ((uint32_t)p[2] << 8) |
++ ((uint32_t)p[3] << 0);
+ }
+
+ static INLINE void
+-be32enc(void *pp, uint32_t x)
++be32enc(unsigned char* p, const uint32_t x)
+ {
+- uint8_t * p = (uint8_t *)pp;
+-
+- p[3] = x & 0xff;
+- p[2] = (x >> 8) & 0xff;
+- p[1] = (x >> 16) & 0xff;
+- p[0] = (x >> 24) & 0xff;
++ p[0] = (x >> 24);
++ p[1] = (x >> 16);
++ p[2] = (x >> 8);
++ p[3] = (x >> 0);
+ }
+
+ static INLINE uint64_t
+-be64dec(const void *pp)
++be64dec(const unsigned char* p)
+ {
+- const uint8_t *p = (uint8_t const *)pp;
+-
+- return ((uint64_t)(p[7]) + ((uint64_t)(p[6]) << 8) +
+- ((uint64_t)(p[5]) << 16) + ((uint64_t)(p[4]) << 24) +
+- ((uint64_t)(p[3]) << 32) + ((uint64_t)(p[2]) << 40) +
+- ((uint64_t)(p[1]) << 48) + ((uint64_t)(p[0]) << 56));
++ return ((uint64_t)p[0] << 0) | ((uint64_t)p[1] << 8) | ((uint64_t)p[2] << 16) |
++ ((uint64_t)p[3] << 24) | ((uint64_t)p[4] << 32) | ((uint64_t)p[5] << 40) |
++ ((uint64_t)p[6] << 48) | ((uint64_t)p[7] << 56);
+ }
+
+ static INLINE void
+-be64enc(void *pp, uint64_t x)
++be64enc(unsigned char* p, const uint64_t x)
+ {
+- uint8_t * p = (uint8_t *)pp;
+-
+- p[7] = x & 0xff;
+- p[6] = (x >> 8) & 0xff;
+- p[5] = (x >> 16) & 0xff;
+- p[4] = (x >> 24) & 0xff;
+- p[3] = (x >> 32) & 0xff;
+- p[2] = (x >> 40) & 0xff;
+- p[1] = (x >> 48) & 0xff;
+- p[0] = (x >> 56) & 0xff;
++ p[0] = (x >> 56);
++ p[1] = (x >> 48);
++ p[2] = (x >> 40);
++ p[3] = (x >> 32);
++ p[4] = (x >> 24);
++ p[5] = (x >> 16);
++ p[6] = (x >> 8);
++ p[7] = (x >> 0);
+ }
+
+ static INLINE uint32_t
+-le32dec(const void *pp)
++le32dec(const unsigned char* p)
+ {
+- const uint8_t *p = (uint8_t const *)pp;
+-
+- return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) +
+- ((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24));
++ return ((uint32_t)p[0] << 0) | ((uint32_t)p[1] << 8) | ((uint32_t)p[2] << 16) |
++ ((uint32_t)p[3] << 24);
+ }
+
+ static INLINE void
+-le32enc(void *pp, uint32_t x)
++le32enc(unsigned char* p, const uint32_t x)
+ {
+- uint8_t * p = (uint8_t *)pp;
+-
+- p[0] = x & 0xff;
+- p[1] = (x >> 8) & 0xff;
+- p[2] = (x >> 16) & 0xff;
+- p[3] = (x >> 24) & 0xff;
++ p[0] = (x >> 0);
++ p[1] = (x >> 8);
++ p[2] = (x >> 16);
++ p[3] = (x >> 24);
+ }
+
+ static INLINE uint64_t
+-le64dec(const void *pp)
++le64dec(const unsigned char* p)
+ {
+- const uint8_t *p = (uint8_t const *)pp;
+-
+- return ((uint64_t)(p[0]) + ((uint64_t)(p[1]) << 8) +
+- ((uint64_t)(p[2]) << 16) + ((uint64_t)(p[3]) << 24) +
+- ((uint64_t)(p[4]) << 32) + ((uint64_t)(p[5]) << 40) +
+- ((uint64_t)(p[6]) << 48) + ((uint64_t)(p[7]) << 56));
++ return ((uint64_t)p[0] << 0) | ((uint64_t)p[1] << 8) | ((uint64_t)p[2] << 16) |
++ ((uint64_t)p[3] << 24) | ((uint64_t)p[4] << 32) | ((uint64_t)p[5] << 40) |
++ ((uint64_t)p[6] << 48) | ((uint64_t)p[7] << 56);
+ }
+
+ static INLINE void
+-le64enc(void *pp, uint64_t x)
++le64enc(unsigned char* p, const uint64_t x)
+ {
+- uint8_t * p = (uint8_t *)pp;
+-
+- p[0] = x & 0xff;
+- p[1] = (x >> 8) & 0xff;
+- p[2] = (x >> 16) & 0xff;
+- p[3] = (x >> 24) & 0xff;
+- p[4] = (x >> 32) & 0xff;
+- p[5] = (x >> 40) & 0xff;
+- p[6] = (x >> 48) & 0xff;
+- p[7] = (x >> 56) & 0xff;
++ p[0] = (x >> 0);
++ p[1] = (x >> 8);
++ p[2] = (x >> 16);
++ p[3] = (x >> 24);
++ p[4] = (x >> 32);
++ p[5] = (x >> 40);
++ p[6] = (x >> 48);
++ p[7] = (x >> 56);
+ }
+ #endif /* !HAVE_SYS_ENDIAN_H */
+
+
+From da48d4408fb5364ab20ef98696bb5b0f0388f6f9 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Wed, 27 Nov 2024 03:09:46 +0000
+Subject: [PATCH 2/3] b64: fix -Wold-style-definition
+
+Drop K&R decls. Most of the codebase uses ISO decls anyway.
+--- a/b64.c
++++ b/b64.c
+@@ -120,11 +120,7 @@ static const char Pad64 = '=';
+ */
+
+ int
+-libscrypt_b64_encode(src, srclength, target, targsize)
+- unsigned char const *src;
+- size_t srclength;
+- char *target;
+- size_t targsize;
++libscrypt_b64_encode(unsigned char const *src, size_t srclength, char *target, size_t targsize)
+ {
+ size_t datalength = 0;
+ unsigned char input[3];
+@@ -184,10 +180,7 @@ libscrypt_b64_encode(src, srclength, target, targsize)
+ */
+
+ int
+-libscrypt_b64_decode(src, target, targsize)
+- char const *src;
+- unsigned char *target;
+- size_t targsize;
++libscrypt_b64_decode(char const *src, unsigned char *target, size_t targsize)
+ {
+ int state, ch;
+ unsigned int tarindex;
+
+From 7b574b9c517a3d1f9bd0e265a5f287155293cb85 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Wed, 27 Nov 2024 03:48:29 +0000
+Subject: [PATCH 3/3] crypto_scrypt-nosse: fix aliasing violations
+
+blkcpy was accessing memory as size_t* where it started as uint32_t*
+which is an aliasing violation. But just replace it with memcpy rather
+than reinventing the wheel.
+
+It turns out this got fixed in scrypt a while ago, so let's do the same
+fix as they did: https://github.com/Tarsnap/scrypt/commit/209fd279c9357010d1dabd446c458dfeb9820e6c.
+
+Closes: https://github.com/technion/libscrypt/issues/60
+--- a/crypto_scrypt-nosse.c
++++ b/crypto_scrypt-nosse.c
+@@ -41,35 +41,19 @@
+
+ #include "libscrypt.h"
+
+-static void blkcpy(void *, void *, size_t);
+-static void blkxor(void *, void *, size_t);
++static void blkxor(uint32_t * dest, uint32_t * src, size_t len);
+ static void salsa20_8(uint32_t[16]);
+ static void blockmix_salsa8(uint32_t *, uint32_t *, uint32_t *, size_t);
+-static uint64_t integerify(void *, size_t);
++static uint64_t integerify(uint32_t * B, size_t r);
+ static void smix(uint8_t *, size_t, uint64_t, uint32_t *, uint32_t *);
+
+ static void
+-blkcpy(void * dest, void * src, size_t len)
++blkxor(uint32_t * dest, uint32_t * src, size_t len)
+ {
+- size_t * D = dest;
+- size_t * S = src;
+- size_t L = len / sizeof(size_t);
+ size_t i;
+
+- for (i = 0; i < L; i++)
+- D[i] = S[i];
+-}
+-
+-static void
+-blkxor(void * dest, void * src, size_t len)
+-{
+- size_t * D = dest;
+- size_t * S = src;
+- size_t L = len / sizeof(size_t);
+- size_t i;
+-
+- for (i = 0; i < L; i++)
+- D[i] ^= S[i];
++ for (i = 0; i < len / 4; i++)
++ dest[i] ^= src[i];
+ }
+
+ /**
+@@ -82,7 +66,7 @@ salsa20_8(uint32_t B[16])
+ uint32_t x[16];
+ size_t i;
+
+- blkcpy(x, B, 64);
++ memcpy(x, B, 64);
+ for (i = 0; i < 8; i += 2) {
+ #define R(a,b) (((a) << (b)) | ((a) >> (32 - (b))))
+ /* Operate on columns. */
+@@ -128,7 +112,7 @@ blockmix_salsa8(uint32_t * Bin, uint32_t * Bout, uint32_t * X, size_t r)
+ size_t i;
+
+ /* 1: X <-- B_{2r - 1} */
+- blkcpy(X, &Bin[(2 * r - 1) * 16], 64);
++ memcpy(X, &Bin[(2 * r - 1) * 16], 64);
+
+ /* 2: for i = 0 to 2r - 1 do */
+ for (i = 0; i < 2 * r; i += 2) {
+@@ -138,7 +122,7 @@ blockmix_salsa8(uint32_t * Bin, uint32_t * Bout, uint32_t * X, size_t r)
+
+ /* 4: Y_i <-- X */
+ /* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */
+- blkcpy(&Bout[i * 8], X, 64);
++ memcpy(&Bout[i * 8], X, 64);
+
+ /* 3: X <-- H(X \xor B_i) */
+ blkxor(X, &Bin[i * 16 + 16], 64);
+@@ -146,7 +130,7 @@ blockmix_salsa8(uint32_t * Bin, uint32_t * Bout, uint32_t * X, size_t r)
+
+ /* 4: Y_i <-- X */
+ /* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */
+- blkcpy(&Bout[i * 8 + r * 16], X, 64);
++ memcpy(&Bout[i * 8 + r * 16], X, 64);
+ }
+ }
+
+@@ -155,10 +139,9 @@ blockmix_salsa8(uint32_t * Bin, uint32_t * Bout, uint32_t * X, size_t r)
+ * Return the result of parsing B_{2r-1} as a little-endian integer.
+ */
+ static uint64_t
+-integerify(void * B, size_t r)
++integerify(uint32_t * B, size_t r)
+ {
+- uint32_t * X = (void *)((uintptr_t)(B) + (2 * r - 1) * 64);
+-
++ const uint32_t * X = B + (2 * r - 1) * 16;
+ return (((uint64_t)(X[1]) << 32) + X[0]);
+ }
+
+@@ -187,13 +170,13 @@ smix(uint8_t * B, size_t r, uint64_t N, uint32_t * V, uint32_t * XY)
+ /* 2: for i = 0 to N - 1 do */
+ for (i = 0; i < N; i += 2) {
+ /* 3: V_i <-- X */
+- blkcpy(&V[i * (32 * r)], X, 128 * r);
++ memcpy(&V[i * (32 * r)], X, 128 * r);
+
+ /* 4: X <-- H(X) */
+ blockmix_salsa8(X, Y, Z, r);
+
+ /* 3: V_i <-- X */
+- blkcpy(&V[(i + 1) * (32 * r)], Y, 128 * r);
++ memcpy(&V[(i + 1) * (32 * r)], Y, 128 * r);
+
+ /* 4: X <-- H(X) */
+ blockmix_salsa8(Y, X, Z, r);
diff --git a/app-crypt/libscrypt/libscrypt-1.22-r3.ebuild b/app-crypt/libscrypt/libscrypt-1.22-r3.ebuild
new file mode 100644
index 000000000000..14c7fa33ed18
--- /dev/null
+++ b/app-crypt/libscrypt/libscrypt-1.22-r3.ebuild
@@ -0,0 +1,37 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit toolchain-funcs
+
+DESCRIPTION="Shared library to implement the scrypt algorithm"
+HOMEPAGE="https://github.com/technion/libscrypt"
+SRC_URI="https://github.com/technion/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="BSD-2"
+SLOT="0"
+KEYWORDS="amd64 arm arm64 ~hppa ~mips ppc ppc64 ~riscv sparc x86"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-1.22-no-clobber-fortify-source.patch
+ "${FILESDIR}"/${PN}-1.22-aliasing.patch
+)
+
+src_prepare() {
+ sed -i -e "s|ar rcs|$(tc-getAR) rcs|g" Makefile || die
+ default
+}
+
+src_configure() {
+ export PREFIX="${EPREFIX}"/usr
+ export LIBDIR=${PREFIX}/$(get_libdir)
+ export CFLAGS_EXTRA="${CFLAGS}"
+ export LDFLAGS_EXTRA="${LDFLAGS}"
+ unset CFLAGS
+ unset LDFLAGS
+}
+
+src_compile() {
+ emake CC="$(tc-getCC)"
+}