dev-libs/crypto++ pull crypto++-5.6.1-r3 from Gentoo

This updates the ebuild for libcrypto++ to the latest revision
from Gentoo portage.  This is necessary to pick up a build fix
for gcc >= 4.7.

BUG=None
TEST=emerged with "sudo -E emerge dev-libs/crypto++" in chroot

Change-Id: I7947bd0211d9b6a27d181b822c442c38fa3c8050
Signed-off-by: Allen Martin <amartin@nvidia.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/39216
Reviewed-by: Andrew Chew <achew@nvidia.com>
Reviewed-by: Rhyland Klein <rklein@nvidia.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Allen Martin 2012-12-04 16:13:49 -08:00 committed by Gerrit
parent e7ee95c835
commit c42a70782b
4 changed files with 343 additions and 0 deletions

View File

@ -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/crypto++/crypto++-5.6.1-r3.ebuild,v 1.3 2012/11/04 19:41:44 c1pher Exp $
EAPI="3"
inherit eutils flag-o-matic multilib toolchain-funcs
DESCRIPTION="Crypto++ is a C++ class library of cryptographic schemes"
HOMEPAGE="http://cryptopp.com"
SRC_URI="mirror://sourceforge/cryptopp/cryptopp${PV//.}.zip"
LICENSE="cryptopp"
SLOT="0"
KEYWORDS="alpha amd64 hppa ppc ppc64 sparc x86"
IUSE=""
DEPEND="app-arch/unzip
sys-devel/libtool"
RDEPEND=""
S="${WORKDIR}"
src_prepare() {
epatch \
"${FILESDIR}"/${PF}-fix_build_system.patch \
"${FILESDIR}"/${P}-rijndael.patch \
"${FILESDIR}"/${P}-gcc-4.7.patch
}
src_compile() {
# Higher optimizations cause problems.
replace-flags -O? -O1
filter-flags -fomit-frame-pointer
emake -f GNUmakefile CXX="$(tc-getCXX)" CXXFLAGS="${CXXFLAGS}" \
LIBDIR="$(get_libdir)" || die "emake failed"
}
src_test() {
# Ensure that all test vectors have Unix line endings.
local file
for file in TestVectors/*; do
edos2unix ${file}
done
if ! emake CXX="$(tc-getCXX)" CXXFLAGS="${CXXFLAGS}" test; then
eerror "Crypto++ self-tests failed."
eerror "Try to remove some optimization flags and reemerge Crypto++."
die "emake test failed"
fi
}
src_install() {
emake DESTDIR="${D}" LIBDIR="$(get_libdir)" install \
|| die "emake install failed"
}

View File

@ -0,0 +1,120 @@
https://bugs.gentoo.org/403197
http://sourceforge.net/apps/trac/cryptopp/ticket/14
http://sourceforge.net/apps/trac/cryptopp/attachment/ticket/14/gcc4.7.diff
diff --git a/algebra.cpp b/algebra.cpp
index 78c3947..d4bfc57 100644
--- a/algebra.cpp
+++ b/algebra.cpp
@@ -58,7 +58,7 @@ template <class T> const T& AbstractEuclideanDomain<T>::Gcd(const Element &a, co
Element g[3]={b, a};
unsigned int i0=0, i1=1, i2=2;
- while (!Equal(g[i1], this->Identity()))
+ while (!this->Equal(g[i1], this->Identity()))
{
g[i2] = Mod(g[i0], g[i1]);
unsigned int t = i0; i0 = i1; i1 = i2; i2 = t;
@@ -74,7 +74,7 @@ template <class T> const typename QuotientRing<T>::Element& QuotientRing<T>::Mul
Element y;
unsigned int i0=0, i1=1, i2=2;
- while (!Equal(g[i1], Identity()))
+ while (!this->Equal(g[i1], Identity()))
{
// y = g[i0] / g[i1];
// g[i2] = g[i0] % g[i1];
diff --git a/eccrypto.cpp b/eccrypto.cpp
index fd8462f..922104c 100644
--- a/eccrypto.cpp
+++ b/eccrypto.cpp
@@ -435,7 +435,7 @@ template <class EC> void DL_GroupParameters_EC<EC>::Initialize(const OID &oid)
StringSource ssG(param.g, true, new HexDecoder);
Element G;
bool result = GetCurve().DecodePoint(G, ssG, (size_t)ssG.MaxRetrievable());
- SetSubgroupGenerator(G);
+ this->SetSubgroupGenerator(G);
assert(result);
StringSource ssN(param.n, true, new HexDecoder);
@@ -591,7 +591,7 @@ bool DL_GroupParameters_EC<EC>::ValidateElement(unsigned int level, const Elemen
if (level >= 2 && pass)
{
const Integer &q = GetSubgroupOrder();
- Element gq = gpc ? gpc->Exponentiate(this->GetGroupPrecomputation(), q) : ExponentiateElement(g, q);
+ Element gq = gpc ? gpc->Exponentiate(this->GetGroupPrecomputation(), q) : this->ExponentiateElement(g, q);
pass = pass && IsIdentity(gq);
}
return pass;
@@ -629,7 +629,7 @@ void DL_PublicKey_EC<EC>::BERDecodePublicKey(BufferedTransformation &bt, bool pa
typename EC::Point P;
if (!this->GetGroupParameters().GetCurve().DecodePoint(P, bt, size))
BERDecodeError();
- SetPublicElement(P);
+ this->SetPublicElement(P);
}
template <class EC>
diff --git a/eccrypto.h b/eccrypto.h
index b359e03..3530455 100644
--- a/eccrypto.h
+++ b/eccrypto.h
@@ -43,7 +43,7 @@ public:
void Initialize(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k = Integer::Zero())
{
this->m_groupPrecomputation.SetCurve(ec);
- SetSubgroupGenerator(G);
+ this->SetSubgroupGenerator(G);
m_n = n;
m_k = k;
}
@@ -145,9 +145,9 @@ public:
typedef typename EC::Point Element;
void Initialize(const DL_GroupParameters_EC<EC> &params, const Element &Q)
- {this->AccessGroupParameters() = params; SetPublicElement(Q);}
+ {this->AccessGroupParameters() = params; this->SetPublicElement(Q);}
void Initialize(const EC &ec, const Element &G, const Integer &n, const Element &Q)
- {this->AccessGroupParameters().Initialize(ec, G, n); SetPublicElement(Q);}
+ {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPublicElement(Q);}
// X509PublicKey
void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
@@ -166,9 +166,9 @@ public:
void Initialize(const EC &ec, const Element &G, const Integer &n, const Integer &x)
{this->AccessGroupParameters().Initialize(ec, G, n); this->SetPrivateExponent(x);}
void Initialize(RandomNumberGenerator &rng, const DL_GroupParameters_EC<EC> &params)
- {GenerateRandom(rng, params);}
+ {this->GenerateRandom(rng, params);}
void Initialize(RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n)
- {GenerateRandom(rng, DL_GroupParameters_EC<EC>(ec, G, n));}
+ {this->GenerateRandom(rng, DL_GroupParameters_EC<EC>(ec, G, n));}
// PKCS8PrivateKey
void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
diff --git a/panama.cpp b/panama.cpp
index 09b1708..a1a37d6 100644
--- a/panama.cpp
+++ b/panama.cpp
@@ -422,7 +422,7 @@ void PanamaHash<B>::TruncatedFinal(byte *hash, size_t size)
{
this->ThrowIfInvalidTruncatedSize(size);
- PadLastBlock(this->BLOCKSIZE, 0x01);
+ this->PadLastBlock(this->BLOCKSIZE, 0x01);
HashEndianCorrectedBlock(this->m_data);
diff --git a/secblock.h b/secblock.h
index 24b9fc0..40cce33 100644
--- a/secblock.h
+++ b/secblock.h
@@ -88,7 +88,7 @@ public:
pointer allocate(size_type n, const void * = NULL)
{
- CheckSize(n);
+ this->CheckSize(n);
if (n == 0)
return NULL;

View File

@ -0,0 +1,152 @@
--- GNUmakefile
+++ GNUmakefile
@@ -1,3 +1,5 @@
+LIBTOOL = libtool
+LIBDIR = lib
CXXFLAGS = -DNDEBUG -g -O2
#CXXFLAGS = -g
# -fPIC is supported. Please report any breakage of -fPIC as a bug.
@@ -7,8 +9,9 @@
# LDFLAGS += -Wl,--gc-sections
ARFLAGS = -cr # ar needs the dash on OpenBSD
RANLIB = ranlib
-CP = cp
+LN_S = ln -s
MKDIR = mkdir
+INSTALL = install
EGREP = egrep
UNAME = $(shell uname)
ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")
@@ -77,8 +80,11 @@
CXXFLAGS += -pipe
endif
+THREAD_LIBS =
+
ifeq ($(UNAME),Linux)
LDFLAGS += -pthread
+THREAD_LIBS += -lpthread
ifneq ($(shell uname -i | $(EGREP) -c "(_64|d64)"),0)
M32OR64 = -m64
endif
@@ -99,8 +105,6 @@
ifeq ($(UNAME),SunOS)
LDLIBS += -lnsl -lsocket
M32OR64 = -m$(shell isainfo -b)
-endif
-
ifneq ($(IS_SUN_CC),0) # override flags for CC Sun C++ compiler
CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef $(M32OR64)
LDFLAGS =
@@ -114,52 +118,52 @@
CXXFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
endif
endif
+endif
SRCS = $(wildcard *.cpp)
ifeq ($(SRCS),) # workaround wildcard function bug in GNU Make 3.77
SRCS = $(shell echo *.cpp)
endif
-OBJS = $(SRCS:.cpp=.o)
-# test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
-TESTOBJS = bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o
+OBJS = $(SRCS:.cpp=.lo)
+# test.lo needs to be after bench.lo for cygwin 1.1.4 (possible ld bug?)
+TESTOBJS = bench.lo bench2.lo test.lo validat1.lo validat2.lo validat3.lo adhoc.lo datatest.lo regtest.lo fipsalgt.lo dlltest.lo
LIBOBJS = $(filter-out $(TESTOBJS),$(OBJS))
DLLSRCS = algebra.cpp algparam.cpp asn.cpp basecode.cpp cbcmac.cpp channels.cpp cryptlib.cpp des.cpp dessp.cpp dh.cpp dll.cpp dsa.cpp ec2n.cpp eccrypto.cpp ecp.cpp eprecomp.cpp files.cpp filters.cpp fips140.cpp fipstest.cpp gf2n.cpp gfpcrypt.cpp hex.cpp hmac.cpp integer.cpp iterhash.cpp misc.cpp modes.cpp modexppc.cpp mqueue.cpp nbtheory.cpp oaep.cpp osrng.cpp pch.cpp pkcspad.cpp pubkey.cpp queue.cpp randpool.cpp rdtables.cpp rijndael.cpp rng.cpp rsa.cpp sha.cpp simple.cpp skipjack.cpp strciphr.cpp trdlocal.cpp
-DLLOBJS = $(DLLSRCS:.cpp=.export.o)
-LIBIMPORTOBJS = $(LIBOBJS:.o=.import.o)
-TESTIMPORTOBJS = $(TESTOBJS:.o=.import.o)
-DLLTESTOBJS = dlltest.dllonly.o
+DLLOBJS = $(DLLSRCS:.cpp=.export.lo)
+LIBIMPORTOBJS = $(LIBOBJS:.lo=.import.lo)
+TESTIMPORTOBJS = $(TESTOBJS:.lo=.import.lo)
+DLLTESTOBJS = dlltest.dllonly.lo
-all: cryptest.exe
+all: libcrypto++.la
-test: cryptest.exe
- ./cryptest.exe v
+test: cryptest
+ ./cryptest v
clean:
- $(RM) cryptest.exe libcryptopp.a $(LIBOBJS) $(TESTOBJS) cryptopp.dll libcryptopp.dll.a libcryptopp.import.a cryptest.import.exe dlltest.exe $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
+ $(RM) -f .libs cryptest libcrypto++.* libcryptopp.* $(LIBOBJS) $(TESTOBJS) cryptopp.dll cryptest.import dlltest $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
install:
- $(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin
- $(CP) *.h $(PREFIX)/include/cryptopp
- $(CP) *.a $(PREFIX)/lib
- $(CP) *.so $(PREFIX)/lib
- $(CP) *.exe $(PREFIX)/bin
-
-libcryptopp.a: $(LIBOBJS)
- $(AR) $(ARFLAGS) $@ $(LIBOBJS)
- $(RANLIB) $@
+ $(MKDIR) -p $(DESTDIR)$(PREFIX)/include/crypto++ $(DESTDIR)$(PREFIX)/$(LIBDIR)
+ $(INSTALL) -m 644 *.h $(DESTDIR)$(PREFIX)/include/crypto++
+ $(LN_S) crypto++ $(DESTDIR)$(PREFIX)/include/cryptopp
+ $(LIBTOOL) --mode=install $(INSTALL) libcrypto++.la $(DESTDIR)$(PREFIX)/$(LIBDIR)
+ $(LN_S) libcrypto++.a $(DESTDIR)$(PREFIX)/$(LIBDIR)/libcryptopp.a
+ $(LN_S) libcrypto++.so.0.0.0 $(DESTDIR)$(PREFIX)/$(LIBDIR)/libcryptopp.so
+ $(LN_S) libcrypto++.so.0.0.0 $(DESTDIR)$(PREFIX)/$(LIBDIR)/libcryptopp.so.0
+ $(LN_S) libcrypto++.so.0.0.0 $(DESTDIR)$(PREFIX)/$(LIBDIR)/libcryptopp.so.0.0.0
-libcryptopp.so: $(LIBOBJS)
- $(CXX) -shared -o $@ $(LIBOBJS)
+libcrypto++.la: $(LIBOBJS)
+ $(LIBTOOL) --tag=CXX --mode=link $(CXX) $(LDFLAGS) -rpath $(PREFIX)/$(LIBDIR) -o $@ $(LIBOBJS) $(THREAD_LIBS)
-cryptest.exe: libcryptopp.a $(TESTOBJS)
- $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS)
+cryptest: libcrypto++.la $(TESTOBJS)
+ $(LIBTOOL) --tag=CXX --mode=link $(CXX) $(LDFLAGS) -o $@ $(TESTOBJS) -L. -lcrypto++ $(LDLIBS) $(THREAD_LIBS)
nolib: $(OBJS) # makes it faster to test changes
- $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
+ $(LIBTOOL) --tag=CXX --mode=link $(CXX) -o ct $(LDFLAGS) $(OBJS) $(LDLIBS) $(THREAD_LIBS)
-dll: cryptest.import.exe dlltest.exe
+dll: cryptest.import dlltest
cryptopp.dll: $(DLLOBJS)
$(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
@@ -168,10 +172,10 @@
$(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
$(RANLIB) $@
-cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
+cryptest.import: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
$(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
-dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
+dlltest: cryptopp.dll $(DLLTESTOBJS)
$(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
adhoc.cpp: adhoc.cpp.proto
@@ -181,14 +185,14 @@
touch adhoc.cpp
endif
-%.dllonly.o : %.cpp
+%.dllonly.lo : %.cpp
$(CXX) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $@
-%.import.o : %.cpp
+%.import.lo : %.cpp
$(CXX) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $@
-%.export.o : %.cpp
+%.export.lo : %.cpp
$(CXX) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $@
-%.o : %.cpp
- $(CXX) $(CXXFLAGS) -c $<
+%.lo : %.cpp
+ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(CXXFLAGS) -c $<

View File

@ -0,0 +1,14 @@
--- rijndael.cpp 2010-08-06 18:46:22.000000000 +0200
+++ rijndael.cpp2 2011-12-27 16:10:52.606933355 +0100
@@ -349,7 +349,11 @@
void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
{
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) || CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
+#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
if (HasSSE2())
+#else
+ if (HasAESNI())
+#endif
{
Rijndael::Enc::AdvancedProcessBlocks(inBlock, xorBlock, outBlock, 16, 0);
return;