Skip to content

Commit

Permalink
better configuration of crypto++ library
Browse files Browse the repository at this point in the history
This fixes issues on unixes without /usr/include/crypto++ and makes use of
pkgconfig to configure the package correctly.
  • Loading branch information
exaexa committed Jan 13, 2016
1 parent abf0ea2 commit dbce46b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
4 changes: 2 additions & 2 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ echo "noinst_HEADERS = `find src/ -type f -name \*.h |tr \"\n\" \" \" `" >>$OUT
echo "${NAME}_CPPFLAGS = -I\$(srcdir)/$i/ ${COMMON_CPPFLAGS}" >>$OUT
echo "${NAME}_CFLAGS = ${COMMON_CFLAGS}" >>$OUT
echo "${NAME}_CXXFLAGS = ${COMMON_CXXFLAGS}" >>$OUT
echo "${NAME}_LDFLAGS = ${COMMON_LDFLAGS}" >>$OUT
echo "${NAME}_LDADD = -lgmp -lfftw3 -lm @CRYPTOPP_LIBS@ ${COMMON_LDADD} " >>$OUT
echo "${NAME}_LDFLAGS = ${COMMON_LDFLAGS} \$(CRYPTOPP_CFLAGS) " >>$OUT
echo "${NAME}_LDADD = -lgmp -lfftw3 -lm \$(CRYPTOPP_LIBS) ${COMMON_LDADD} " >>$OUT

libtoolize --force && aclocal && autoconf && automake --add-missing

12 changes: 10 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ AC_ARG_WITH([cryptopp],
#and check crypto++
if test "$WITH_CRYPTOPP" = "yes"; then

PKG_CHECK_MODULES([CRYPTOPP],[libcrypto++])

#crypto++ headers are either in include/crypto++ or include/cryptopp,
#the information is otherwise unavailable from standard configuration
#means. Please report/add more tests if you encounter distros that
#place them elsewhere.
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([crypto++/sha.h crypto++/tiger.h crypto++/ripemd.h], , AC_MSG_ERROR([Codecrypt requires Crypto++]))
AC_CHECK_HEADER([crypto++/config.h],
AC_DEFINE([CRYPTOPP_DIR_PLUS], [1]),
AC_DEFINE([CRYPTOPP_DIR_PLUS], [0])
)
AC_LANG_POP([C++])

AC_DEFINE([HAVE_CRYPTOPP], [1])
AC_SUBST([CRYPTOPP_LIBS], [-lcryptopp])
else
AC_DEFINE([HAVE_CRYPTOPP], [0])
fi
Expand Down
9 changes: 7 additions & 2 deletions src/rmd_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@

#if HAVE_CRYPTOPP==1

#include "sha_hash.h"
#include <crypto++/ripemd.h>
#include "hash.h"
#if CRYPTOPP_DIR_PLUS
# include <crypto++/ripemd.h>
#else
# include <cryptopp/ripemd.h>
#endif


//it's used just like SHA, so create it from SHA
class rmd128hash : public shahash<CryptoPP::RIPEMD128> {};
Expand Down
7 changes: 5 additions & 2 deletions src/sha_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
#if HAVE_CRYPTOPP==1

#include "hash.h"

#include <crypto++/sha.h>
#if CRYPTOPP_DIR_PLUS
# include <crypto++/sha.h>
#else
# include <cryptopp/sha.h>
#endif

template <class shatype>
class shahash : public hash_func
Expand Down
9 changes: 7 additions & 2 deletions src/tiger_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@

#if HAVE_CRYPTOPP==1

#include "sha_hash.h"
#include <crypto++/tiger.h>
#include "hash.h"

#if CRYPTOPP_DIR_PLUS
# include <crypto++/tiger.h>
#else
# include <cryptopp/tiger.h>
#endif

//it's used just like SHA, so create it from SHA
class tiger192hash : public shahash<CryptoPP::Tiger> {};
Expand Down

0 comments on commit dbce46b

Please sign in to comment.