logrotate: enable selinux support
[buildroot-gz.git] / package / tegrarcm / 0001-Don-t-assume-cryptopp-is-system-wide-installed.patch
blob3c738d86a470728e389df39528eebb440686c877
1 From 5ea6b3859ebe16ff47856b58262b14463e119c13 Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Tue, 19 Apr 2016 22:14:42 +0200
4 Subject: [PATCH] Don't assume cryptopp is system-wide installed
6 The current build system adds "-isystem /usr/include/$(CRYPTOLIB)" to
7 AM_CPPFLAGS, but this is wrong because cryptopp might not be installed
8 in this location. Instead, the build system should simply include
9 <cryptopp/...> or <crypto++/...> and rely on the compiler include
10 path.
12 The tricky part is that it can be <cryptopp/...> or <crypto++/...>. To
13 solve this, we use a solution similar to the one used in
14 https://github.com/bingmann/crypto-speedtest/blob/master/m4/cryptopp.m4
15 and
16 https://github.com/bingmann/crypto-speedtest/blob/master/src/speedtest_cryptopp.cpp:
17 the configure script fills in a variable called
18 CRYPTOLIB_HEADER_PREFIX, and we use that in the C++ code to include
19 the right header file.
21 It is worth mentioning that doing #include
22 <CRYPTOLIB_HEADER_PREFIX/foobar.h> doesn't work, and we have to use an
23 intermediate #define'd constant to overcome this C preprocessor
24 limitation.
26 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
27 Submitted upstream at https://github.com/NVIDIA/tegrarcm/pull/2
28 ---
29 configure.ac | 1 +
30 src/Makefile.am | 2 +-
31 src/aes-cmac.cpp | 28 +++++++++++++++++-----------
32 3 files changed, 19 insertions(+), 12 deletions(-)
34 diff --git a/configure.ac b/configure.ac
35 index 943654f..620e158 100644
36 --- a/configure.ac
37 +++ b/configure.ac
38 @@ -33,6 +33,7 @@ AC_LINK_IFELSE(
39 [AC_MSG_ERROR([libcrypto++/libcryptopp is not installed.])])]
41 AC_SUBST(CRYPTOLIB)
42 +AC_DEFINE_UNQUOTED([CRYPTOLIB_HEADER_PREFIX], [$CRYPTOLIB], [Location of cryptolib header])
43 LDFLAGS=$SAVED_LDFLAGS
44 AC_LANG(C)
46 diff --git a/src/Makefile.am b/src/Makefile.am
47 index 3dad0e6..35a606f 100644
48 --- a/src/Makefile.am
49 +++ b/src/Makefile.am
50 @@ -1,5 +1,5 @@
51 AM_CFLAGS = -Wall -std=c99
52 -AM_CPPFLAGS = -isystem /usr/include/$(CRYPTOLIB) $(LIBUSB_CFLAGS)
53 +AM_CPPFLAGS = $(LIBUSB_CFLAGS)
55 bin_PROGRAMS = tegrarcm
56 tegrarcm_SOURCES = \
57 diff --git a/src/aes-cmac.cpp b/src/aes-cmac.cpp
58 index 24c89f8..da8be5a 100644
59 --- a/src/aes-cmac.cpp
60 +++ b/src/aes-cmac.cpp
61 @@ -26,6 +26,9 @@
62 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 +#include "config.h"
68 #include <iostream>
69 using std::cout;
70 using std::cerr;
71 @@ -40,26 +43,29 @@ using std::string;
72 #include <cstdlib>
73 using std::exit;
75 -#include "cryptlib.h"
76 -using CryptoPP::Exception;
77 +#define CRYPTOPP_INCLUDE_CRYPTLIB <CRYPTOLIB_HEADER_PREFIX/cryptlib.h>
78 +#define CRYPTOPP_INCLUDE_CMAC <CRYPTOLIB_HEADER_PREFIX/cmac.h>
79 +#define CRYPTOPP_INCLUDE_AES <CRYPTOLIB_HEADER_PREFIX/aes.h>
80 +#define CRYPTOPP_INCLUDE_HEX <CRYPTOLIB_HEADER_PREFIX/hex.h>
81 +#define CRYPTOPP_INCLUDE_FILTERS <CRYPTOLIB_HEADER_PREFIX/filters.h>
82 +#define CRYPTOPP_INCLUDE_SECBLOCK <CRYPTOLIB_HEADER_PREFIX/secblock.h>
84 -#include "cmac.h"
85 -using CryptoPP::CMAC;
86 +#include CRYPTOPP_INCLUDE_CRYPTLIB
87 +#include CRYPTOPP_INCLUDE_CMAC
88 +#include CRYPTOPP_INCLUDE_AES
89 +#include CRYPTOPP_INCLUDE_HEX
90 +#include CRYPTOPP_INCLUDE_FILTERS
91 +#include CRYPTOPP_INCLUDE_SECBLOCK
93 -#include "aes.h"
94 +using CryptoPP::Exception;
95 +using CryptoPP::CMAC;
96 using CryptoPP::AES;
98 -#include "hex.h"
99 using CryptoPP::HexEncoder;
100 using CryptoPP::HexDecoder;
102 -#include "filters.h"
103 using CryptoPP::StringSink;
104 using CryptoPP::StringSource;
105 using CryptoPP::HashFilter;
106 using CryptoPP::HashVerificationFilter;
108 -#include "secblock.h"
109 using CryptoPP::SecByteBlock;
111 extern "C" int cmac_hash(const unsigned char *msg, int len, unsigned char *cmac_buf)
113 2.6.4