From 8e8959829d942ff11e1db055b79079eb5c856335 Mon Sep 17 00:00:00 2001 From: Christoph Weiss Date: Thu, 26 Nov 2015 16:00:25 +0100 Subject: add cryptopp (https://www.cryptopp.com/) --- index.html | 4 ++++ src/cryptopp-1-fixes.patch | 18 ++++++++++++++++++ src/cryptopp-test.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/cryptopp.mk | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 src/cryptopp-1-fixes.patch create mode 100644 src/cryptopp-test.cpp create mode 100644 src/cryptopp.mk diff --git a/index.html b/index.html index a7408ef..a439671 100644 --- a/index.html +++ b/index.html @@ -1197,6 +1197,10 @@ local-pkg-list: $(LOCAL_PKG_LIST) CppUnit + cryptopp + Crypto++ Library + + crystalhd Broadcom Crystal HD Headers diff --git a/src/cryptopp-1-fixes.patch b/src/cryptopp-1-fixes.patch new file mode 100644 index 0000000..ac4bdbd --- /dev/null +++ b/src/cryptopp-1-fixes.patch @@ -0,0 +1,18 @@ +This file is part of MXE. +See index.html for further information. + +Fix broken Makefile, add relevant object files and don't use -DCRYPTOPP_EXPORTS + +diff -ur a/GNUmakefile b/GNUmakefile +--- a/GNUmakefile 2015-11-22 22:17:59.000000000 +0100 ++++ b/GNUmakefile 2015-11-29 13:04:15.587252779 +0100 +@@ -255,8 +255,7 @@ + LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS)) + + # List cryptlib.cpp first in an attempt to tame C++ static initialization problems +-DLLSRCS := cryptlib.cpp algebra.cpp algparam.cpp asn.cpp basecode.cpp cbcmac.cpp channels.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) ++DLLOBJS := cryptlib.o cpu.o hex.o serpent.o randpool.o sharkbox.o blowfish.o files.o seal.o gzip.o fips140.o eprecomp.o dsa.o dll.o md2.o fipstest.o rc5.o mars.o osrng.o queue.o xtrcrypt.o gf256.o vmac.o authenc.o default.o idea.o squaretb.o pkcspad.o emsa2.o sha.o network.o eax.o tea.o square.o dessp.o crc.o elgamal.o zlib.o ida.o dh2.o camellia.o strciphr.o ecp.o marss.o adler32.o wait.o iterhash.o safer.o base32.o rc2.o polynomi.o oaep.o gf2n.o zinflate.o shark.o xtr.o shacal2.o cmac.o eccrypto.o rdrand.o ripemd.o gcm.o pubkey.o basecode.o trdlocal.o salsa.o esign.o luc.o hrtimer.o ttmac.o cbcmac.o mqv.o dh.o md4.o whrlpool.o rw.o cast.o asn.o tiger.o rng.o pssr.o misc.o mqueue.o algparam.o base64.o zdeflate.o channels.o ccm.o des.o blumshub.o ec2n.o casts.o gfpcrypt.o gost.o algebra.o rijndael.o modes.o sha3.o panama.o nbtheory.o md5.o socketft.o twofish.o tigertab.o tftables.o rsa.o rdtables.o sosemanuk.o 3way.o gf2_32.o rabin.o bfinit.o filters.o integer.o seed.o rc6.o wake.o skipjack.o arc4.o hmac.o winpipes.o + + # Import lib testing + LIBIMPORTOBJS := $(LIBOBJS:.o=.import.o) diff --git a/src/cryptopp-test.cpp b/src/cryptopp-test.cpp new file mode 100644 index 0000000..0d6ec48 --- /dev/null +++ b/src/cryptopp-test.cpp @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() { + { + CryptoPP::SHA512 sha2; + unsigned char digest[CryptoPP::SHA512::DIGESTSIZE]; + sha2.Final(digest); + } + + { + std::string data; + const CryptoPP::SecByteBlock key; + const CryptoPP::SecByteBlock iv; + + CryptoPP::SecByteBlock ret(0, CryptoPP::AES::MAX_KEYLENGTH); + CryptoPP::StringSource(data, true, new CryptoPP::HashFilter(*(new CryptoPP::SHA3_512), new CryptoPP::ArraySink(ret, CryptoPP::AES::MAX_KEYLENGTH))); + CryptoPP::GCM< CryptoPP::AES, CryptoPP::GCM_64K_Tables >::Encryption pwenc; + pwenc.SetKeyWithIV(key.data(), key.size(), iv.data(), iv.size()); + std::string cipher; + CryptoPP::StringSource(data, true, new CryptoPP::AuthenticatedEncryptionFilter(pwenc, new CryptoPP::StringSink(cipher), false, 16)); + } + + { + const CryptoPP::SecByteBlock key; + const CryptoPP::SecByteBlock iv; + CryptoPP::GCM< CryptoPP::AES, CryptoPP::GCM_64K_Tables >::Decryption pwdec; + pwdec.SetKeyWithIV(key.data(), key.size(), iv.data(), iv.size()); + } + + { + CryptoPP::SecByteBlock ret(0, CryptoPP::AES::BLOCKSIZE); + std::string str; + CryptoPP::StringSource(str, true, new CryptoPP::Base64Decoder(new CryptoPP::ArraySink(ret, CryptoPP::AES::BLOCKSIZE))); + } + + return 0; +} diff --git a/src/cryptopp.mk b/src/cryptopp.mk new file mode 100644 index 0000000..d05597b --- /dev/null +++ b/src/cryptopp.mk @@ -0,0 +1,37 @@ +# This file is part of MXE. +# See index.html for further information. + +PKG := cryptopp +$(PKG)_IGNORE := +$(PKG)_VERSION := 5.6.3 +$(PKG)_CHECKSUM := 9390670a14170dd0f48a6b6b06f74269ef4b056d4718a1a329f6f6069dc957c9 +$(PKG)_SUBDIR := +$(PKG)_VERSIONF := $(shell echo $($(PKG)_VERSION) | tr -d .) +$(PKG)_FILE := $(PKG)$($(PKG)_VERSIONF).zip +$(PKG)_URL := $(SOURCEFORGE_MIRROR)/cryptopp/$($(PKG)_FILE) +$(PKG)_URL_2 := https://www.cryptopp.com/$($(PKG)_FILE) +$(PKG)_DEPS := gcc + +define $(PKG)_UPDATE + $(WGET) -q -O- 'https://www.cryptopp.com/' | \ + $(SED) -n 's,Crypto++ Library \([0-9]\.[0-9]\.[0-9]\).*,\1,p' +endef + +define $(PKG)_BUILD + cp '$(1)'config.recommend '$(1)'config.h + $(MAKE) -C '$(1)' -j '$(JOBS)' -f GNUmakefile \ + CC=$(TARGET)-gcc \ + CXX=$(TARGET)-g++ \ + RANLIB=$(TARGET)-ranlib \ + AR=$(TARGET)-ar \ + LD=$(TARGET)-ld \ + CXXFLAGS='-DNDEBUG -O3 -mtune=native -pipe' \ + $(if $(BUILD_STATIC),libcryptopp.a,cryptopp.dll) + + $(INSTALL) -d '$(PREFIX)'/$(TARGET)/include/cryptopp + $(INSTALL) '$(1)'*.h '$(PREFIX)'/$(TARGET)/include/cryptopp + $(INSTALL) '$(1)'$(if $(BUILD_STATIC),libcryptopp.a,libcryptopp.dll.a) '$(PREFIX)'/$(TARGET)/lib + $(if $(BUILD_STATIC),,$(INSTALL) '$(1)'cryptopp.dll '$(PREFIX)'/$(TARGET)/bin) + + $(TARGET)-g++ -w $(2).cpp -o '$(PREFIX)'/$(TARGET)/bin/test-cryptopp.exe -lcryptopp +endef -- cgit v0.12