Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add BIP 151 support #449

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 33 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ AS_IF([test "$CXXFLAGS" = "-g -O2"] ,[AC_SUBST(CXXFLAGS, [ ])])

#build tests arg
AC_ARG_ENABLE([tests],
AC_HELP_STRING([--enable-tests],
[build with test suites @<:@default=no@:>@]),
[want_tests="$enableval"], [want_tests=no])
AC_HELP_STRING([--enable-tests],
[build with test suites @<:@default=no@:>@]),
[want_tests="$enableval"], [want_tests=no])

#build benchmarks
AC_ARG_ENABLE([benchmarks],
AC_HELP_STRING([--enable-benchmarks],
[build with benchmark suites @<:@default=no@:>@]),
[want_benchmarks=$enableval], [want_benchmarks=no])

#build debug arg
AC_ARG_ENABLE([debug],
Expand Down Expand Up @@ -166,21 +172,34 @@ AC_CONFIG_FILES(Makefile
cppForSwig/Makefile
cppForSwig/lmdb/Makefile)

AM_CONDITIONAL([BUILD_BENCH], [test x$want_benchmarks = xyes])
AM_CONDITIONAL([BUILD_TESTS], [test "x$want_tests" = "xyes"])
if test "x$want_tests" = "xyes"; then
AC_CONFIG_FILES(cppForSwig/gtest/Makefile)
fi

dnl ac_configure_args can only be set once and affects all subdirs.
dnl Place all params here.
dnl FCGI - No customs
dnl Crypto++ - No customs
dnl libchacha20poly1305 - No customs
dnl libsecp256k1 (libbtc) - --disable-shared --with-pic --with-bignum=no --enable-experimental --enable-module-ecdh
ac_configure_args="${orig_config_args} --disable-shared --with-pic --with-bignum=no --enable-experimental --enable-module-ecdh"
AC_CONFIG_SUBDIRS([cppForSwig/fcgi cppForSwig/cryptopp cppForSwig/libbtc])

AC_OUTPUT

echo " CC = $CC"
echo " CFLAGS = $CFLAGS"
echo " CPP = $CPP"
echo " CPPFLAGS = $CPPFLAGS"
echo " CXX = $CXX"
echo " CXXFLAGS = $CXXFLAGS"
echo " LDFLAGS = $LDFLAGS"
echo " LD = $LD"
echo " with tests = $want_tests"
echo " debug symbols = $want_debug"
echo " with GUI = $with_gui"
echo " Armory Autotools flags"
echo " CC = $CC"
echo " CFLAGS = $CFLAGS"
echo " CPP = $CPP"
echo " CPPFLAGS = $CPPFLAGS"
echo " CXX = $CXX"
echo " CXXFLAGS = $CXXFLAGS"
echo " LDFLAGS = $LDFLAGS"
echo " LD = $LD"
echo " ac_configure_args = $ac_configure_args"
echo " with tests = $want_tests"
echo " with benchmarks = $want_benchmarks"
echo " debug symbols = $want_debug"
echo " with GUI = $with_gui"
77 changes: 47 additions & 30 deletions cppForSwig/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
bin_PROGRAMS =
noinst_PROGRAMS =
TESTS =
BENCHMARKS =
lib_LTLIBRARIES =
MAYBE_BUILD =

if BUILD_TESTS
MAYBE_BUILD += gtest
noinst_PROGRAMS += chacha20poly1305/chacha20poly1305test
TESTS += chacha20poly1305/chacha20poly1305test
endif

if BUILD_BENCH
noinst_PROGRAMS += chacha20poly1305/chacha20poly1305bench
BENCHMARKS += chacha20poly1305/chacha20poly1305bench
endif

DIST_SUBDIRS = lmdb fcgi cryptopp
SUBDIRS = lmdb fcgi cryptopp $(MAYBE_BUILD)
DIST_SUBDIRS = lmdb fcgi cryptopp libbtc
SUBDIRS = lmdb fcgi cryptopp libbtc $(MAYBE_BUILD)

SWIG_FLAGS = -c++ -python -threads
AM_CXXFLAGS = $(CXXFLAGS) -std=c++11
Expand All @@ -20,22 +33,7 @@ if HAVE_CLANG
SWIG_FLAGS += -D__CLANG__
endif

INCLUDE_FILES = UniversalTimer.h BinaryData.h lmdb_wrapper.h \
BtcUtils.h DBUtils.h BlockObj.h BlockUtils.h EncryptionUtils.h \
BtcWallet.h LedgerEntry.h ScrAddrObj.h Blockchain.h \
BDM_mainthread.h BDM_supportClasses.h \
BlockDataViewer.h HistoryPager.h Progress.h \
txio.h TxClasses.h StoredBlockObj.h \
DatabaseBuilder.h BlockchainScanner.h BlockDataMap.h \
DataObject.h BitcoinP2p.h BDM_Server.h BDM_seder.h SocketObject.h \
FcgiMessage.h BlockDataManagerConfig.h \
Transactions.h Script.h Signer.h nodeRPC.h JSON_codec.h \
ReentrantLock.h StringSockets.h log.h OS_TranslatePath.h \
TransactionBatch.h BlockchainScanner_Super.h SigHashEnum.h TxEvalState.h \
Accounts.h Addresses.h AssetEncryption.h Assets.h \
DecryptedDataContainer.h DerviationScheme.h \
bech32/ref/c++/bech32.h bech32/ref/c++/segwit_addr.h \
SshParser.h
INCLUDE_FILES = -I. -Ibech32/ref/c++ -Ichacha20poly1305

DB_SOURCE_FILES = UniversalTimer.cpp BinaryData.cpp lmdb_wrapper.cpp \
BtcUtils.cpp DBUtils.cpp BlockObj.cpp BlockUtils.cpp EncryptionUtils.cpp \
Expand Down Expand Up @@ -64,16 +62,18 @@ CPPBLOCKUTILS_SOURCE_FILES = UniversalTimer.cpp BinaryData.cpp \
DecryptedDataContainer.cpp DerivationScheme.cpp \
bech32/ref/c++/bech32.cpp bech32/ref/c++/segwit_addr.cpp

#ArmoryDB
noinst_PROGRAMS = ArmoryDB
CHACHA20POLY1305_SOURCE_FILES = chacha20poly1305/poly1305.c \
chacha20poly1305/chacha.c chacha20poly1305/chachapoly_aead.c

ArmoryDB_SOURCES = $(INCLUDE_FILES) \
$(DB_SOURCE_FILES)
#ArmoryDB
bin_PROGRAMS += ArmoryDB
ArmoryDB_SOURCES = $(DB_SOURCE_FILES)

ArmoryDB_CXXFLAGS = $(AM_CXXFLAGS) -Ilmdb \
-Icryptopp \
-Ifcgi -Ifcgi/include \
-D__STDC_LIMIT_MACROS
ArmoryDB_CPPFLAGS = $(AM_CPPFLAGS) $(INCLUDE_FILES)

ArmoryDB_LDADD = -Llmdb -llmdb \
-Lcryptopp -lcryptopp \
Expand All @@ -84,23 +84,40 @@ ArmoryDB_LDFLAGS = -static $(LDFLAGS)

#libCppBlockUtils
if HAVE_GUI
lib_LTLIBRARIES = libCppBlockUtils.la

libCppBlockUtils_la_SOURCES = $(INCLUDE_FILES) \
$(CPPBLOCKUTILS_SOURCE_FILES) \
CppBlockUtils_wrap.cxx
lib_LTLIBRARIES += libCppBlockUtils.la
libCppBlockUtils_la_SOURCES = $(CPPBLOCKUTILS_SOURCE_FILES) \
CppBlockUtils_wrap.cxx
libCppBlockUtils_la_CPPFLAGS = $(AM_CPPFLAGS) $(INCLUDE_FILES)
libCppBlockUtils_la_CXXFLAGS = $(AM_CXXFLAGS) -Ilmdb \
-Icryptopp \
-Ilibbtc/src/secp256k1/include \
$(AX_SWIG_PYTHON_CPPFLAGS) \
$(EXTRA_PYTHON_INCLUDES) \
-D__STDC_LIMIT_MACROS

libCppBlockUtils_la_LIBADD = -Llmdb -llmdb \
./cryptopp/libcryptopp.la \
-lpthread

./libbtc/src/secp256k1/libsecp256k1.la \
-lpthread
libCppBlockUtils_la_LDFLAGS = $(LDFLAGS)

# ChaCha20Poly1305 library
lib_LTLIBRARIES += libChaCha20Poly1305.la
libChaCha20Poly1305_la_SOURCES = $(CHACHA20POLY1305_SOURCE_FILES)
libChaCha20Poly1305_la_CPPFLAGS = $(AM_CPPFLAGS) $(INCLUDE_FILES)
libChaCha20Poly1305_la_CFLAGS = $(AM_CFLAGS)

if BUILD_TESTS
chacha20poly1305test_SOURCE_FILES = $(CHACHA20POLY1305_SOURCE_FILES) chacha20poly1305/test.c
chacha20poly1305test_CPPFLAGS = $(AM_CPPFLAGS) $(INCLUDE_FILES)
chacha20poly1305test_CFLAGS = $(AM_CFLAGS)
endif

if BUILD_BENCH
chacha20poly1305bench_SOURCE_FILES = $(CHACHA20POLY1305_SOURCE_FILES) chacha20poly1305/bench.c
chacha20poly1305bench_CPPFLAGS = $(AM_CPPFLAGS) $(INCLUDE_FILES)
chacha20poly1305bench_CFLAGS = $(AM_CFLAGS)
endif

if BUILD_DARWIN
libCppBlockUtils_la_LDFLAGS += -Wl,-rpath,@executable_path/ -Wl,-rpath,@loader_path/
endif
Expand Down
43 changes: 43 additions & 0 deletions cppForSwig/chacha20poly1305/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
language: c
os:
- osx
- linux

compiler:
- clang
- gcc
- x86_64-w64-mingw32-gcc

addons:
apt:
packages:
- valgrind
- binutils-mingw-w64
- gcc-mingw-w64
- wine

before_install:
- pip install --user cpp-coveralls
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then brew install valgrind gnu-sed --default-names; fi

matrix:
fast_finish:
- true
exclude:
- os: osx
compiler: x86_64-w64-mingw32-gcc

script:
- $CC -O3 poly1305.c chacha.c chachapoly_aead.c bench.c -o bench
- rm *.o
- $CC -O0 -g poly1305.c chacha.c chachapoly_aead.c tests.c -o test
- if ( [ "${TRAVIS_OS_NAME}" == "linux" ] ) && ( [ "$CC" == "gcc" ] ); then
valgrind --track-origins=yes --leak-check=full --error-exitcode=1 ./test;
./test;
else
if ( [ "$CC" == x86_64-w64-mingw32-gcc ] ) || ( [ "$CC" == i686-w64-mingw32-gcc ] ); then
ls -la;
else
./test;
fi
fi
30 changes: 30 additions & 0 deletions cppForSwig/chacha20poly1305/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[![Build Status](https://travis-ci.org/jonasschnelli/chacha20poly1305.svg?branch=master)](https://travis-ci.org/jonasschnelli/chacha20poly1305)

chacha20/poly1305/chacha20poly1305 openssh aead
=====

Simple C module for chacha20, poly1305 and chacha20poly1305@openssh AEAD

Features:
* Simple, pure C code without any dependencies.

Performance
-----------

-

Build steps
-----------

Object code:

$ gcc -O3 -c poly1305.c chacha.c chachapoly_aead.c

Tests:

$ gcc -O3 poly1305.c chacha.c chachapoly_aead.c tests.c -o test

Benchmark:

$ gcc -O3 poly1305.c chacha.c chachapoly_aead.c bench.c -o bench

Loading