Skip to content

Commit

Permalink
beecrypt: new, 4.2.1
Browse files Browse the repository at this point in the history
Track patches at AOSC-Tracking/beecrypt @ aosc/v4.2.1
(HEAD: 8f88298a72cb4bb1d7bfbeec116df2d72371758d).
  • Loading branch information
MingcongBai committed Feb 13, 2025
1 parent aebacd5 commit 40d6c4a
Show file tree
Hide file tree
Showing 4 changed files with 236 additions and 0 deletions.
6 changes: 6 additions & 0 deletions runtime-cryptography/beecrypt/autobuild/defines
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PKGNAME=beecrypt
PKGSEC=libs
PKGDEP="gcc-runtime"
PKGDES="BeeCrypt cryptography library"

PKGPROV="libbeecrypt7_spiral libbeecrypt-dev_spiral"
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
From 01afc7f17b2a44adc02290aaac400778c080dfaf Mon Sep 17 00:00:00 2001
From: "Bernhard R. Link" <[email protected]>
Date: Sat, 17 Sep 2011 19:45:38 +0200
Subject: [PATCH 1/2] UBUNTU: fix wrong debug output on 64 bit

From Ubuntu: beecrypt 4.2.1-4

Signed-off-by: Mingcong Bai <[email protected]>
---
python/mpw-py.c | 30 +++++++++++++++---------------
python/rng-py.c | 4 ++--
2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/python/mpw-py.c b/python/mpw-py.c
index a833bbf..edb872f 100644
--- a/python/mpw-py.c
+++ b/python/mpw-py.c
@@ -332,7 +332,7 @@ static void prtmpw(const char * msg, mpwObject * x)
/*@global stderr, fileSystem @*/
/*@modifies stderr, fileSystem @*/
{
-fprintf(stderr, "%5.5s %p[%d]:\t", msg, MPW_DATA(x), MPW_SIZE(x)), mpfprintln(stderr, MPW_SIZE(x), MPW_DATA(x));
+fprintf(stderr, "%5.5s %p[%lu]:\t", msg, MPW_DATA(x), (long int)(MPW_SIZE(x))), mpfprintln(stderr, MPW_SIZE(x), MPW_DATA(x));
}

static size_t
@@ -354,7 +354,7 @@ mpsizeinbase(size_t xsize, mpw* xdata, size_t base)
res = (nbits * mp_bases[base].chars_per_bit_exactly) + 1;
}
if (_mpw_debug < -1)
-fprintf(stderr, "*** mpsizeinbase(%p[%d], %d) res %u\n", xdata, xsize, base, (unsigned)res);
+fprintf(stderr, "*** mpsizeinbase(%p[%lu], %lu) res %u\n", xdata, (unsigned long)xsize, (unsigned long)base, (unsigned)res);
return res;
}

@@ -408,7 +408,7 @@ mpstr(char * t, size_t nt, size_t size, mpw* data, mpw base)
size_t result;

if (_mpw_debug < -1)
-fprintf(stderr, "*** mpstr(%p[%d], %p[%d], %d):\t", t, nt, data, size, base), mpfprintln(stderr, size, data);
+fprintf(stderr, "*** mpstr(%p[%lu], %p[%lu], %d):\t", t, (unsigned long)nt, data, (unsigned long)size, base), mpfprintln(stderr, size, data);

mpsetx(asize, adata, size, data);

@@ -418,8 +418,8 @@ fprintf(stderr, "*** mpstr(%p[%d], %p[%d], %d):\t", t, nt, data, size, base), mp
mpndivmod(zdata, asize, adata, 1, &base, wksp);

if (_mpw_debug < -1) {
-fprintf(stderr, " a %p[%d]:\t", adata, asize), mpfprintln(stderr, asize, adata);
-fprintf(stderr, " z %p[%d]:\t", zdata, asize+1), mpfprintln(stderr, asize+1, zdata);
+fprintf(stderr, " a %p[%lu]:\t", adata, (unsigned long)asize), mpfprintln(stderr, asize, adata);
+fprintf(stderr, " z %p[%lu]:\t", zdata, (unsigned long)(asize+1)), mpfprintln(stderr, asize+1, zdata);
}
result = zdata[asize];
t[nt] = bchars[result];
@@ -461,7 +461,7 @@ mpw_format(mpwObject * z, size_t base, int addL)
}

if (_mpw_debug < -1)
-fprintf(stderr, "*** mpw_format(%p,%d,%d):\t", z, base, addL), mpfprintln(stderr, zsize, zdata);
+fprintf(stderr, "*** mpw_format(%p,%lu,%d):\t", z, (unsigned long)base, addL), mpfprintln(stderr, zsize, zdata);

assert(base >= 2 && base <= 36);

@@ -812,7 +812,7 @@ static void mpnpow_w(mpnumber* n, size_t xsize, const mpw* xdata,
size = MP_ROUND_B2W(15 * xbits);

if (_mpw_debug < 0)
-fprintf(stderr, "*** pbits %d xbits %d nsize %d size %d\n", pbits, xbits, nsize, size);
+fprintf(stderr, "*** pbits %lu xbits %lu nsize %lu size %lu\n", (unsigned long)pbits, (unsigned long)xbits, (unsigned long)nsize, (unsigned long)size);
mpnsize(n, nsize);

/* 1. Precompute odd powers of x (up to 2**K). */
@@ -1588,7 +1588,7 @@ fprintf(stderr, "sub ++: borrow\n");
}

if (_mpw_debug)
-fprintf(stderr, "*** mpw_%s %p[%d]\t", fname, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
+fprintf(stderr, "*** mpw_%s %p[%lu]\t", fname, MPW_DATA(z), (unsigned long)MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));

exit:
mpbfree(&b);
@@ -1667,7 +1667,7 @@ prtmpw("c", m);
z = mpw_FromMPW(zsize, zdata, 1);

if (_mpw_debug < 0)
-fprintf(stderr, "*** mpw_%s %p[%d]\t", fname, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
+fprintf(stderr, "*** mpw_%s %p[%lu]\t", fname, MPW_DATA(z), (unsigned long)(MPW_SIZE(z))), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));

exit:
mpbfree(&b);
@@ -1949,9 +1949,9 @@ mpw_divmod(PyObject * v, PyObject * w)
mpndivmod(zdata, asize, adata, bsize, bdata, wksp);

if (_mpw_debug < 0) {
-fprintf(stderr, " a %p[%d]:\t", adata, asize), mpfprintln(stderr, asize, adata);
-fprintf(stderr, " b %p[%d]:\t", bdata, bsize), mpfprintln(stderr, bsize, bdata);
-fprintf(stderr, " z %p[%d]:\t", zdata, zsize), mpfprintln(stderr, zsize, zdata);
+fprintf(stderr, " a %p[%lu]:\t", adata, (unsigned long)asize), mpfprintln(stderr, asize, adata);
+fprintf(stderr, " b %p[%lu]:\t", bdata, (unsigned long)bsize), mpfprintln(stderr, bsize, bdata);
+fprintf(stderr, " z %p[%lu]:\t", zdata, (unsigned long)zsize), mpfprintln(stderr, zsize, zdata);
}

zsize -= bsize;
@@ -2026,7 +2026,7 @@ mpw_neg(mpwObject * a)
}

if (z != NULL && _mpw_debug)
-fprintf(stderr, "*** mpw_neg %p[%d]\t", MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
+fprintf(stderr, "*** mpw_neg %p[%lu]\t", MPW_DATA(z), (unsigned long)(MPW_SIZE(z))), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));

return (PyObject *)z;
}
@@ -2044,7 +2044,7 @@ mpw_pos(mpwObject * a)
z = mpw_Copy(a);

if (z != NULL && _mpw_debug)
-fprintf(stderr, "*** mpw_pos %p[%d]\t", MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
+fprintf(stderr, "*** mpw_pos %p[%lu]\t", MPW_DATA(z), (unsigned long)MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));

return (PyObject *)z;
}
@@ -2061,7 +2061,7 @@ mpw_abs(mpwObject * a)
z = (mpwObject *)mpw_pos(a);

if (z != NULL && _mpw_debug)
-fprintf(stderr, "*** mpw_abs %p[%d]\t", MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
+fprintf(stderr, "*** mpw_abs %p[%lu]\t", MPW_DATA(z), (unsigned long)(MPW_SIZE(z))), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));

return (PyObject *)z;
}
diff --git a/python/rng-py.c b/python/rng-py.c
index 6252ede..a59d2d7 100644
--- a/python/rng-py.c
+++ b/python/rng-py.c
@@ -199,7 +199,7 @@ rng_Next(rngObject * s, PyObject * args)
}

if (_rng_debug)
-fprintf(stderr, "*** rng_Next(%p) %p[%d]\t", s, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
+fprintf(stderr, "*** rng_Next(%p) %p[%lu]\t", s, MPW_DATA(z), (unsigned long)(MPW_SIZE(z))), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));

return (PyObject *)z;
}
@@ -236,7 +236,7 @@ rng_Prime(rngObject * s, PyObject * args)

z = mpw_FromMPW(b->size, b->modl, 1);
if (z != NULL && _rng_debug)
-fprintf(stderr, "*** rng_Prime(%p) %p[%d]\t", s, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
+fprintf(stderr, "*** rng_Prime(%p) %p[%lu]\t", s, MPW_DATA(z), (unsigned long)(MPW_SIZE(z))), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));

return (PyObject *)z;
}
--
2.48.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From 8f88298a72cb4bb1d7bfbeec116df2d72371758d Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <[email protected]>
Date: Sat, 15 Jun 2024 22:42:33 +0200
Subject: [PATCH 2/2] OPENEMBEDDED: package/beecrypt: fix build with gcc 14

Fix the following build failure with gcc 14:

blockmode.c: In function 'blockEncryptCTR':
blockmode.c:162:42: error: implicit declaration of function 'swapu32' [-Wimplicit-function-declaration]
162 | buf[i] = swapu32(fdback[j]);
| ^~~~~~~

Fixes:
- http://autobuild.buildroot.org/results/651e0e31305b1f211071d94ea74f7b7a5793b03e

Signed-off-by: Fabrice Fontaine <[email protected]>

[Mingcong Bai: Revised to enable swapu32 definitions unconditionally.]

Link: https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/
Signed-off-by: Mingcong Bai <[email protected]>
---
include/beecrypt/endianness.h | 6 ++----
package/beecrypt/0004-beecrypt-4.2.1-c99.patch | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 4 deletions(-)
create mode 100644 package/beecrypt/0004-beecrypt-4.2.1-c99.patch

diff --git a/include/beecrypt/endianness.h b/include/beecrypt/endianness.h
index acc647a..ec6fea6 100644
--- a/include/beecrypt/endianness.h
+++ b/include/beecrypt/endianness.h
@@ -38,10 +38,8 @@ static inline uint16_t _swapu16(uint16_t n)
}
# define swapu16(n) _swap16(n)

-# ifdef __arch__swab32
-# define swap32(n) __arch__swab32(n)
-# define swapu32(n) __arch__swab32(n)
-# else
+# define swap32(n) __arch__swab32(n)
+# define swapu32(n) __arch__swab32(n)

static inline int32_t _swap32(int32_t n)
{
diff --git a/package/beecrypt/0004-beecrypt-4.2.1-c99.patch b/package/beecrypt/0004-beecrypt-4.2.1-c99.patch
new file mode 100644
index 0000000..489ce43
--- /dev/null
+++ b/package/beecrypt/0004-beecrypt-4.2.1-c99.patch
@@ -0,0 +1,17 @@
+Add missing header to fix C99 conformance in blockmode.c
+
+Upstream: https://sourceforge.net/p/beecrypt/patches/13
+Signed-off-by: Fabrice Fontaine <[email protected]>
+
+diff --git a/blockmode.c b/blockmode.c
+index 46d1fde..9998c23 100644
+--- a/blockmode.c
++++ b/blockmode.c
+@@ -29,6 +29,7 @@
+ # include "config.h"
+ #endif
+
++#include "beecrypt/endianness.h"
+ #include "beecrypt/blockmode.h"
+
+ int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
--
2.48.1

4 changes: 4 additions & 0 deletions runtime-cryptography/beecrypt/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VER=4.2.1
SRCS="tbl::https://sourceforge.net/projects/beecrypt/files/beecrypt/$VER/beecrypt-$VER.tar.gz/download"
CHKSUMS="sha256::286f1f56080d1a6b1d024003a5fa2158f4ff82cae0c6829d3c476a4b5898c55d"
CHKUPDATE="anitya::id=174"

0 comments on commit 40d6c4a

Please sign in to comment.