Package init

- 初始化提交
This commit is contained in:
wangtaozhi 2023-05-17 18:12:25 +08:00
parent 30e8b6c982
commit 864168ddc4
13 changed files with 464 additions and 0 deletions

View File

@ -0,0 +1,12 @@
diff -up mhash-0.9.9.9/src/hmac_test.c.nofree mhash-0.9.9.9/src/hmac_test.c
--- mhash-0.9.9.9/src/hmac_test.c.nofree 2019-07-29 14:44:55.856345469 -0400
+++ mhash-0.9.9.9/src/hmac_test.c 2019-07-29 14:45:11.466021935 -0400
@@ -72,7 +72,7 @@ int main()
return(MUTILS_INVALID_RESULT);
}
- mutils_free(tmp);
+ /* mutils_free(tmp); */
/* Test No 2 */

119
mhash-0.9.9.9-align.patch Normal file
View File

@ -0,0 +1,119 @@
diff -up mhash-0.9.9.9/lib/stdfns.c.BAD mhash-0.9.9.9/lib/stdfns.c
--- mhash-0.9.9.9/lib/stdfns.c.BAD 2009-07-02 16:38:43.217029623 -0400
+++ mhash-0.9.9.9/lib/stdfns.c 2009-07-02 16:41:58.647120391 -0400
@@ -152,6 +152,18 @@ mutils_bzero(void *s, __const mutils_wor
}
}
+static void
+mutils_memset8(void *s, __const mutils_word8 c, __const mutils_word32 n)
+{
+ mutils_word8 *stmp = s;
+ mutils_word32 i;
+
+ for (i = 0; i < n; i++, stmp++)
+ {
+ *stmp = c;
+ }
+}
+
WIN32DLL_DEFINE
void
mutils_memset(void *s, __const mutils_word8 c, __const mutils_word32 n)
@@ -160,8 +172,7 @@ mutils_memset(void *s, __const mutils_wo
/* Sparc needs 8-bit alignment - just use standard memset */
memset(s, (int) c, (size_t) n);
#else
- mutils_word8 *stmp;
- mutils_word32 *ltmp = (mutils_word32 *) s;
+ mutils_word32 *ltmp;
mutils_word32 lump;
mutils_word32 i;
mutils_word32 words;
@@ -172,22 +183,30 @@ mutils_memset(void *s, __const mutils_wo
return;
}
+ if (n < 16)
+ {
+ return mutils_memset8(s, c, n);
+ }
+
+ /* unaligned portion at beginning */
+ remainder = (-(mutils_word32)s) & 0x3;
+ mutils_memset8(s, c, remainder);
+
+ /* aligned words in the middle */
+ ltmp = (mutils_word32 *) (s + remainder);
+
lump = (c << 24) + (c << 16) + (c << 8) + c;
- words = n >> 2;
- remainder = n - (words << 2);
+ words = (n - remainder) >> 2;
+ remainder = n - remainder - (words << 2);
for (i = 0; i < words; i++, ltmp++)
{
*ltmp = lump;
}
- stmp = (mutils_word8 *) ltmp;
-
- for (i = 0; i < remainder; i++, stmp++)
- {
- *stmp = c;
- }
+ /* unaligned portion at end */
+ return mutils_memset8(ltmp, c, remainder);
#endif
}
@@ -281,6 +300,9 @@ mutils_word32nswap(mutils_word32 *x, mut
mutils_word32 *buffer;
mutils_word32 *ptrIn;
mutils_word32 *ptrOut;
+ mutils_word8 *ptr8In;
+ mutils_word8 *ptr8Out;
+ mutils_word8 tmp8;
mutils_word32 count = n * 4;
if (destructive == MUTILS_FALSE)
@@ -301,9 +323,35 @@ mutils_word32nswap(mutils_word32 *x, mut
* data on a little-endian machine.
*/
- for (loop = 0, ptrIn = x, ptrOut = buffer; loop < n; loop++, ptrOut++, ptrIn++)
+ if ((mutils_word32)x & 0x3)
+ {
+ ptr8In = (mutils_word8 *) x;
+ ptr8Out = (mutils_word8 *) buffer;
+ for (loop = 0; loop < n; loop++)
+ {
+#ifdef WORDS_BIGENDIAN
+ tmp8 = ptr8In[0];
+ ptr8Out[0] = ptr8In[3];
+ ptr8Out[3] = tmp8;
+ tmp8 = ptr8In[1];
+ ptr8Out[1] = ptr8In[2];
+ ptr8Out[2] = tmp8;
+#else
+ ptr8Out[0] = ptr8In[0];
+ ptr8Out[1] = ptr8In[1];
+ ptr8Out[2] = ptr8In[2];
+ ptr8Out[3] = ptr8In[3];
+#endif
+ ptr8Out += 4;
+ ptr8In += 4;
+ }
+ }
+ else
{
- *ptrOut = mutils_lend32(*ptrIn);
+ for (loop = 0, ptrIn = x, ptrOut = buffer; loop < n; loop++, ptrOut++, ptrIn++)
+ {
+ *ptrOut = mutils_lend32(*ptrIn);
+ }
}
return(buffer);

View File

@ -0,0 +1,16 @@
diff -up mhash-0.9.9.9/lib/stdfns.c.BAD mhash-0.9.9.9/lib/stdfns.c
--- mhash-0.9.9.9/lib/stdfns.c.BAD 2009-07-21 12:05:40.139461097 -0400
+++ mhash-0.9.9.9/lib/stdfns.c 2009-07-21 12:06:52.151190927 -0400
@@ -378,6 +378,12 @@ mutils_memmove(void *dest, __const void
bigptr1 = (mutils_word32 *) dest;
bigptr2 = (mutils_word32 *) src;
+ /* copy byte-by-byte for small and/or unaligned copies */
+ if ((n < 16) || ((mutils_word32)dest & 0x3) || ((mutils_word32)src & 0x3))
+ {
+ return mutils_memcpy8(dest, src, n);
+ }
+
words = n >> 2;
remainder = n - (words << 2);

View File

@ -0,0 +1,75 @@
diff -up mhash-0.9.9.9/configure.in.fix-autotool-stomping mhash-0.9.9.9/configure.in
--- mhash-0.9.9.9/configure.in.fix-autotool-stomping 2007-04-04 22:22:28.000000000 -0400
+++ mhash-0.9.9.9/configure.in 2009-07-02 17:02:39.099044520 -0400
@@ -6,6 +6,7 @@ AC_CONFIG_SRCDIR([lib/mhash.c])
AM_INIT_AUTOMAKE
AC_DEFINE([MHASH_VERSION], PROGRAM_VERSION, "MHash Version")
+AC_CONFIG_HEADER([include/mutils/config.h])
AC_CONFIG_HEADER([include/mutils/mhash_config.h])
diff -up /dev/null mhash-0.9.9.9/include/mutils/config.h.in
--- /dev/null 2009-07-01 18:40:45.228272777 -0400
+++ mhash-0.9.9.9/include/mutils/config.h.in 2009-07-02 17:02:39.100044508 -0400
@@ -0,0 +1,22 @@
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Version number of package */
+#undef VERSION
+
+
diff -up mhash-0.9.9.9/include/mutils/mhash_config.h.in.fix-autotool-stomping mhash-0.9.9.9/include/mutils/mhash_config.h.in
--- mhash-0.9.9.9/include/mutils/mhash_config.h.in.fix-autotool-stomping 2008-12-07 18:33:50.000000000 -0500
+++ mhash-0.9.9.9/include/mutils/mhash_config.h.in 2009-07-02 17:04:30.453049610 -0400
@@ -181,24 +181,6 @@
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
/* Define to 1 if the C compiler supports function prototypes. */
#undef PROTOTYPES
@@ -208,9 +190,6 @@
/* dmalloc */
#undef USE_DMALLOC
-/* Version number of package */
-#undef VERSION
-
/* Define if using the dmalloc debugging malloc package */
#undef WITH_DMALLOC

View File

@ -0,0 +1,12 @@
diff -up mhash-0.9.9.9/lib/mhash.c.BAD mhash-0.9.9.9/lib/mhash.c
--- mhash-0.9.9.9/lib/mhash.c.BAD 2009-07-02 16:57:43.872049877 -0400
+++ mhash-0.9.9.9/lib/mhash.c 2009-07-02 16:58:03.909029777 -0400
@@ -719,6 +719,8 @@ WIN32DLL_DEFINE MHASH mhash_restore_stat
mutils_memcpy( &ret->state_size, &mem[pos], sizeof(ret->state_size));
pos += sizeof( ret->state_size);
+ if (ret->state)
+ mutils_free(ret->state);
ret->state = mutils_malloc(ret->state_size);
if (ret->state==NULL)
goto freeall;

View File

@ -0,0 +1,12 @@
diff -up mhash-0.9.9.9/lib/snefru.c.BAD mhash-0.9.9.9/lib/snefru.c
--- mhash-0.9.9.9/lib/snefru.c.BAD 2009-07-02 16:54:58.973279449 -0400
+++ mhash-0.9.9.9/lib/snefru.c 2009-07-02 16:55:04.609279072 -0400
@@ -859,6 +859,8 @@ static void snefru_digest(__const struct
{
mutils_word32 i;
+ if(!digest) return;
+
for (i = 0; i < len; i++, digest += 4)
{
*(mutils_word32 *)digest = mutils_bend2sys32(ctx->hash[i]);

View File

@ -0,0 +1,12 @@
diff -up mhash-0.9.9.9/lib/whirlpool.c.BAD mhash-0.9.9.9/lib/whirlpool.c
--- mhash-0.9.9.9/lib/whirlpool.c.BAD 2009-07-02 16:59:50.885279180 -0400
+++ mhash-0.9.9.9/lib/whirlpool.c 2009-07-02 17:00:12.189279257 -0400
@@ -970,6 +970,8 @@ void whirlpool_digest(__const struct whi
mutils_word8 * digest)
{
mutils_word32 i;
+
+ if(!digest) return;
/*
* return the completed message digest:
*/

View File

@ -0,0 +1,14 @@
diff -up mhash-0.9.9.9/lib/tiger.c.BAD mhash-0.9.9.9/lib/tiger.c
--- mhash-0.9.9.9/lib/tiger.c.BAD 2009-07-02 16:42:47.683029940 -0400
+++ mhash-0.9.9.9/lib/tiger.c 2009-07-02 16:43:46.085049317 -0400
@@ -252,7 +252,9 @@ void tiger_update(struct tiger_ctx *ctx,
void tiger_final(struct tiger_ctx *ctx)
{
register mutils_word64 i, j;
- mutils_word8 temp[TIGER_DATASIZE];
+ /* Force 64-bit alignment */
+ mutils_word64 temp_64bit[TIGER_DATASIZE/8];
+ mutils_word8 *temp = temp_64bit;
i = ctx->index;
#if defined(WORDS_BIGENDIAN)

View File

@ -0,0 +1,12 @@
diff -up mhash-0.9.9.9/src/keygen_test.c.BAD mhash-0.9.9.9/src/keygen_test.c
--- mhash-0.9.9.9/src/keygen_test.c.BAD 2009-07-22 18:01:59.636042665 -0400
+++ mhash-0.9.9.9/src/keygen_test.c 2009-07-22 18:04:53.608292727 -0400
@@ -121,7 +121,7 @@ int main()
mhash_keygen_ext(KEYGEN_S2K_SALTED, data, key, keysize, password, passlen);
- mutils_memset(tmp, 0, keysize * 2);
+ // mutils_memset(tmp, 0, keysize * 2);
tmp = mutils_asciify(key, keysize);

View File

@ -0,0 +1,53 @@
diff -up mhash-0.9.9.9/lib/stdfns.c.BAD mhash-0.9.9.9/lib/stdfns.c
--- mhash-0.9.9.9/lib/stdfns.c.BAD 2009-07-21 12:01:21.596191078 -0400
+++ mhash-0.9.9.9/lib/stdfns.c 2009-07-21 12:02:37.419191301 -0400
@@ -24,6 +24,7 @@
*/
#include "libdefs.h"
+#include <limits.h>
/**
* Some of these are wrappers. The idea is to eventually produce an extremely
@@ -408,11 +409,11 @@ mutils_memcmp(__const void *s1, const vo
{
return(0);
}
- return(-MAXINT);
+ return(-INT_MAX);
}
if (s2 == NULL)
{
- return(MAXINT);
+ return(INT_MAX);
}
return(memcmp(s1, s2, n));
@@ -539,11 +540,11 @@ mutils_strcmp(__const mutils_word8 *src1
{
return(0);
}
- return(-MAXINT);
+ return(-INT_MAX);
}
if (src2 == NULL)
{
- return(MAXINT);
+ return(INT_MAX);
}
return(strcmp((char *) src1, (char *) src2));
}
@@ -562,11 +563,11 @@ mutils_strncmp(__const mutils_word8 *src
{
return(0);
}
- return(-MAXINT);
+ return(-INT_MAX);
}
if (src2 == NULL)
{
- return(MAXINT);
+ return(INT_MAX);
}
return(strncmp((char *) src1, (char *) src2, n));
}

BIN
mhash-0.9.9.9.tar.bz2 Normal file

Binary file not shown.

123
mhash.spec Normal file
View File

@ -0,0 +1,123 @@
# http://sourceforge.net/projects/mhash
# As of 2007-08-18 11:03, this project is no longer under active development.
Summary: Thread-safe hash algorithms library
Name: mhash
Version: 0.9.9.9
Release: 28%{?dist}
URL: http://mhash.sourceforge.net/
License: LGPL-2.1-or-later
Source: http://downloads.sourceforge.net/mhash/mhash-%{version}.tar.bz2
Patch2: mhash-0.9.9.9-align.patch
Patch3: mhash-0.9.9.9-force64bit-tiger.patch
# Taken from Gentoo:
# http://mirror.its.uidaho.edu/pub/gentoo-portage/app-crypt/mhash/files/mhash-0.9.9-fix-snefru-segfault.patch
Patch4: mhash-0.9.9.9-fix-snefru-segfault.patch
# Taken from Gentoo:
# http://mirror.its.uidaho.edu/pub/gentoo-portage/app-crypt/mhash/files/mhash-0.9.9-fix-mem-leak.patch
Patch5: mhash-0.9.9.9-fix-mem-leak.patch
# Taken from Gentoo:
# http://mirror.its.uidaho.edu/pub/gentoo-portage/app-crypt/mhash/files/mhash-0.9.9-fix-whirlpool-segfault.patch
Patch6: mhash-0.9.9.9-fix-whirlpool-segfault.patch
# Taken from Gentoo:
# http://mirror.its.uidaho.edu/pub/gentoo-portage/app-crypt/mhash/files/mhash-0.9.9-autotools-namespace-stomping.patch
Patch7: mhash-0.9.9.9-autotools-namespace-stomping.patch
# Taken from openpkg:
# http://www.mail-archive.com/openpkg-cvs@openpkg.org/msg26353.html
Patch8: mhash-0.9.9.9-maxint.patch
# Taken from Jitesh Shah
# http://ftp.uk.linux.org/pub/armlinux/fedora/diffs-f11/mhash/0001-Alignment-fixes.patch
Patch9: mhash-0.9.9.9-alignment.patch
# Fix keygen_test
Patch10: mhash-0.9.9.9-keygen_test_fix.patch
# Fix mhash_test
# Credit to Hanno Böck back in 2015.
Patch11: mhash-0.9.9-no-free-before-use.patch
BuildRequires: make
BuildRequires: gcc
BuildRequires: autoconf, automake
Provides: libmhash = %{version}-%{release}
%description
Mhash is a free library which provides a uniform interface to a
large number of hash algorithms.
These algorithms can be used to compute checksums, message digests,
and other signatures. The HMAC support implements the basics for
message authentication, following RFC 2104. In the later versions
some key generation algorithms, which use hash algorithms, have been
added. Currently, the library supports the algorithms: ADLER32, GOST,
HAVAL256, HAVAL224, HAVAL192, HAVAL160, HAVAL128, MD5, MD4, MD2,
RIPEMD128/160/256/320, TIGER, TIGER160, TIGER128, SHA1/224/256/384/512,
Whirlpool, SNEFRU128/256, CRC32B and CRC32 checksums.
%package -n %{name}-devel
Summary: Header files and libraries for developing apps which use mhash
Requires: %{name} = %{version}-%{release}
Provides: libmhash-devel = %{version}-%{release}
%description -n %{name}-devel
This package contains the header files and libraries needed to
develop programs that use the mhash library.
%prep
%setup -q
%patch2 -p1 -b .alignment
%patch3 -p1 -b .force64bit-tiger
%patch4 -p1 -b .fix-snefru-segfault
%patch5 -p1 -b .fix-mem-leak
%patch6 -p1 -b .fix-whirlpool-segfault
%patch7 -p1 -b .fix-autotool-stomping
%patch8 -p1 -b .maxint
%patch9 -p1 -b .alignment2
%patch10 -p1 -b .fix
%patch11 -p1 -b .nofree
autoconf
%build
%configure --enable-shared %{?_with_static: --enable-static} %{!?_with_static: --disable-static}
# If this exits, the multiarch patch needs an update.
grep 'define SIZEOF_' include/mutils/mhash_config.h && exit 1
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=${RPM_BUILD_ROOT} install
# Eliminate some autoheader definitions which should not enter a public API.
# There are more which wait for a fix upstream.
sed -i 's!\(#define \(PACKAGE\|VERSION \).*\)!/* \1 */!g' ${RPM_BUILD_ROOT}%{_includedir}/mutils/mhash_config.h
%check
make check
%ldconfig_scriptlets -n %{name}
%files -n %{name}
%doc AUTHORS COPYING NEWS README THANKS TODO
%{_libdir}/*.so.*
%files -n %{name}-devel
%doc ChangeLog ./doc/*.c ./doc/skid2-authentication
%{_includedir}/*.h
%{_includedir}/mutils/
%{?_with_static: %{_libdir}/*.a}
%{_libdir}/*.so
%exclude %{_libdir}/*.la
%{_mandir}/man3/*
%changelog
* Wed May 17 2023 wangtaozhi <wangtaozhi@kylinsec.com.cn> - 0.9.9.9-28
- Package init

4
mhash.yaml Normal file
View File

@ -0,0 +1,4 @@
version_control: github
src_repo: mhash
tag_prefix: "v"
separator: "."