From 80997bf06f6b38389438ebca42733a5866f1f658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20F=C3=B6rster?= Date: Wed, 8 Aug 2012 09:19:20 +0200 Subject: [PATCH] [dev-libs/libtomcrypt] resurrect from g-x86 attic, with rsa_verify_simple.c which was rejected upstream, for StormLib --- dev-libs/libtomcrypt/Manifest | 1 + ...ypt-1.17-r2-libtool-tag-and-make-fix.patch | 37 ++++++++ .../libtomcrypt/files/rsa_verify_simple.c | 87 +++++++++++++++++++ .../libtomcrypt/libtomcrypt-1.17-r7.ebuild | 57 ++++++++++++ 4 files changed, 182 insertions(+) create mode 100644 dev-libs/libtomcrypt/Manifest create mode 100644 dev-libs/libtomcrypt/files/libtomcrypt-1.17-r2-libtool-tag-and-make-fix.patch create mode 100644 dev-libs/libtomcrypt/files/rsa_verify_simple.c create mode 100644 dev-libs/libtomcrypt/libtomcrypt-1.17-r7.ebuild diff --git a/dev-libs/libtomcrypt/Manifest b/dev-libs/libtomcrypt/Manifest new file mode 100644 index 0000000..cca3f24 --- /dev/null +++ b/dev-libs/libtomcrypt/Manifest @@ -0,0 +1 @@ +DIST crypt-1.17.tar.bz2 1599215 SHA256 e33b47d77a495091c8703175a25c8228aff043140b2554c08a3c3cd71f79d116 SHA512 9335df5ae0a2c8e33e8f03ced0cfb0a8d1ac4bccd007b74818228c3b8b232446b4425356f304a08320b75542a537a46b305b92c3011dee76dfd636497bf57af2 WHIRLPOOL 71f61a270635f5487016efbdffb5867aa880319f5ad3646f41510307925fb1f1d82d29072f8362be1a2c3b71336922cf23aec4ad1d0c7a077d5ff6e920117337 diff --git a/dev-libs/libtomcrypt/files/libtomcrypt-1.17-r2-libtool-tag-and-make-fix.patch b/dev-libs/libtomcrypt/files/libtomcrypt-1.17-r2-libtool-tag-and-make-fix.patch new file mode 100644 index 0000000..694ba25 --- /dev/null +++ b/dev-libs/libtomcrypt/files/libtomcrypt-1.17-r2-libtool-tag-and-make-fix.patch @@ -0,0 +1,37 @@ +--- a/makefile.shared 2009-03-16 11:07:19.000000000 +0100 ++++ b/makefile.shared 2009-03-16 11:30:25.000000000 +0100 +@@ -9,7 +9,7 @@ + VERSION=0:117 + + # Compiler and Linker Names +-CC=libtool --mode=compile --tag=CC gcc ++CC=libtool --mode=compile --tag CC gcc + + # ranlib tools + ifndef RANLIB +@@ -244,7 +244,7 @@ + library: $(LIBNAME) + + testprof/$(LIBTEST): +- cd testprof ; CFLAGS="$(CFLAGS)" GROUP=$(GROUP) USER=$(USER) VERSION=$(VERSION) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) make -f makefile.shared ++ cd testprof ; CFLAGS="$(CFLAGS)" GROUP=$(GROUP) USER=$(USER) VERSION=$(VERSION) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) $(MAKE) -f makefile.shared + + objs: $(OBJECTS) + +@@ -253,7 +253,7 @@ + + install: $(LIBNAME) + install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH) +- cd testprof ; CFLAGS="$(CFLAGS)" GROUP=$(GROUP) USER=$(USER) VERSION=$(VERSION) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) DESTDIR=$(DESTDIR) make -f makefile.shared install ++ cd testprof ; CFLAGS="$(CFLAGS)" GROUP=$(GROUP) USER=$(USER) VERSION=$(VERSION) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) DESTDIR=$(DESTDIR) $(MAKE) -f makefile.shared install + libtool --silent --mode=install install -c libtomcrypt.la $(DESTDIR)$(LIBPATH)/libtomcrypt.la + install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH) + install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH) +--- a/testprof/makefile.shared 2009-03-16 11:26:19.000000000 +0100 ++++ b/testprof/makefile.shared 2009-03-16 11:26:47.000000000 +0100 +@@ -1,4 +1,4 @@ +-CC=libtool --mode=compile gcc ++CC=libtool --mode=compile --tag CC gcc + + CFLAGS += -I../src/headers -I./ -Wall -W + diff --git a/dev-libs/libtomcrypt/files/rsa_verify_simple.c b/dev-libs/libtomcrypt/files/rsa_verify_simple.c new file mode 100644 index 0000000..6d8888c --- /dev/null +++ b/dev-libs/libtomcrypt/files/rsa_verify_simple.c @@ -0,0 +1,87 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ +#include "../../headers/tomcrypt.h" + +/** + @file rsa_verify_simple.c + Created by Ladislav Zezula (zezula@volny.cz) as modification + for Blizzard strong signature verification +*/ + +#ifdef LTC_MRSA + +/** + Simple RSA decryption + @param sig The signature data + @param siglen The length of the signature data (octets) + @param hash The hash of the message that was signed + @param hashlen The length of the hash of the message that was signed (octets) + @param stat [out] The result of the signature comparison, 1==valid, 0==invalid + @param key The public RSA key corresponding + @return Error code +*/ +int rsa_verify_simple(const unsigned char *sig, unsigned long siglen, + const unsigned char *hash, unsigned long hashlen, + int *stat, + rsa_key *key) +{ + unsigned long modulus_bitlen, modulus_bytelen, x; + unsigned char *tmpbuf; + int err; + + LTC_ARGCHK(sig != NULL); + LTC_ARGCHK(hash != NULL); + LTC_ARGCHK(stat != NULL); + LTC_ARGCHK(key != NULL); + + /* default to invalid */ + *stat = 0; + + /* get modulus len in bits */ + modulus_bitlen = mp_count_bits( (key->N)); + + /* outlen must be at least the size of the modulus */ + modulus_bytelen = mp_unsigned_bin_size( (key->N)); + if (modulus_bytelen != siglen) { + return CRYPT_INVALID_PACKET; + } + + /* allocate temp buffer for decoded sig */ + tmpbuf = XMALLOC(siglen); + if (tmpbuf == NULL) { + return CRYPT_MEM; + } + + /* RSA decode it */ + x = siglen; + if ((err = ltc_mp.rsa_me(sig, siglen, tmpbuf, &x, PK_PUBLIC, key)) != CRYPT_OK) { + XFREE(tmpbuf); + return err; + } + + /* make sure the output is the right size */ + if (x != siglen) { + XFREE(tmpbuf); + return CRYPT_INVALID_PACKET; + } + + /* compare the decrypted signature with the given hash */ + if(x == hashlen && XMEMCMP(tmpbuf, hash, hashlen) == 0) + *stat = 1; + +#ifdef LTC_CLEAN_STACK + zeromem(tmpbuf, siglen); +#endif + XFREE(tmpbuf); + return CRYPT_OK; +} + +#endif /* LTC_MRSA */ diff --git a/dev-libs/libtomcrypt/libtomcrypt-1.17-r7.ebuild b/dev-libs/libtomcrypt/libtomcrypt-1.17-r7.ebuild new file mode 100644 index 0000000..8de6c6f --- /dev/null +++ b/dev-libs/libtomcrypt/libtomcrypt-1.17-r7.ebuild @@ -0,0 +1,57 @@ +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-libs/libtomcrypt/libtomcrypt-1.17-r6.ebuild,v 1.2 2012/02/25 15:22:17 jer Exp $ + +EAPI="2" + +inherit flag-o-matic multilib toolchain-funcs + +DESCRIPTION="modular and portable cryptographic toolkit" +HOMEPAGE="http://libtom.org/?page=features&whatfile=crypt" +SRC_URI="http://libtom.org/files/crypt-${PV}.tar.bz2" + +LICENSE="WTFPL-2" +SLOT="0" +KEYWORDS="~amd64 ~ppc ~x86" +IUSE="doc" + +RDEPEND="dev-libs/libtommath" +DEPEND="${RDEPEND} + doc? ( virtual/latex-base app-text/ghostscript-gpl )" + +src_prepare() { + use doc || sed -i '/^install:/s:docs::' makefile + epatch "${FILESDIR}"/libtomcrypt-1.17-r2-libtool-tag-and-make-fix.patch + sed -i \ + -e "s:--mode=link gcc:--mode=link $(tc-getCC) ${LDFLAGS} --tag CC $(tc-getCC):g" \ + -e "s: gcc: $(tc-getCC):g" \ + -e "s:src/pk/rsa/rsa_verify_hash.o :src/pk/rsa/rsa_verify_hash.o src/pk/rsa/rsa_verify_simple.o :g" \ + {,testprof/}makefile.shared || die + cp "${FILESDIR}/rsa_verify_simple.c" "${S}/src/pk/rsa" +} + +src_compile() { + append-flags -DLTM_DESC + export LIBPATH="/usr/$(get_libdir)" + EXTRALIBS="-ltommath" \ + CC=$(tc-getCC) \ + IGNORE_SPEED=1 \ + emake -f makefile.shared \ + || die "emake failed" +} + +src_test() { + # Tests don't compile + true +} + +src_install() { + emake -f makefile.shared DESTDIR="${D}" install ||\ + die "emake install failed" + dodoc TODO changes || die "dodoc failed" + if use doc ; then + dodoc doc/* || die "dodoc failed" + docinto notes ; dodoc notes/* || die "dodoc failed" + docinto demos ; dodoc demos/* || die "dodoc failed" + fi +}