git.fiddlerwoaroof.com
Browse code

Setup Crypto++ detection; code cleanup

Ed Langley authored on 29/05/2017 17:37:18
Showing 3 changed files
... ...
@@ -14,6 +14,10 @@ MODULELIB = pam_dual_control.so
14 14
 
15 15
 UNAME_S := $(shell uname -s)
16 16
 
17
+CRYPTOPP_NAME=@CRYPTOPP_NAME@
18
+
19
+MYDEFS = @DEFS@
20
+
17 21
 .PHONY: all
18 22
 all: .depend dual_control.a dual_control
19 23
 
... ...
@@ -26,6 +26,36 @@ AC_ARG_WITH(pam-module-directory,
26 26
     PAM_MODULE_DIRECTORY="$DEFAULT_PAM_MODULE_DIRECTORY")
27 27
 AC_SUBST(PAM_MODULE_DIRECTORY)
28 28
 
29
+#check whether to build with crypto++
30
+AC_ARG_WITH([cryptopp],
31
+	AC_HELP_STRING([--with-cryptopp],[Build algorithms that need Crypto++ support]),
32
+	[WITH_CRYPTOPP=$withval],
33
+	[WITH_CRYPTOPP=yes])
34
+
35
+#and check crypto++
36
+if test "$WITH_CRYPTOPP" = "yes"; then
37
+	#crypto++ headers are either in include/crypto++ or include/cryptopp,
38
+	#the information is otherwise unavailable from standard configuration
39
+	#means. Please report/add more tests if you encounter distros that
40
+	#place them elsewhere.
41
+	AC_LANG_PUSH([C++])
42
+	AC_CHECK_HEADERS([crypto++/hex.h cryptopp/base32.h], [dualcontrol_found_cryptopp_headers=yes;break;], [echo ...])
43
+	AS_IF([test "x$dualcontrol_found_cryptopp_headers" != "xyes"], [AC_MSG_ERROR([Unable to find Crypto++])])
44
+	AC_DEFINE([HAVE_CRYPTOPP], [1])
45
+
46
+	CRYPTOPP_NAME=cryptopp
47
+	AC_CHECK_HEADER([crypto++/config.h],
48
+		CRYPTOPP_NAME=crypto++
49
+	)
50
+	AC_LANG_POP([C++])
51
+
52
+
53
+	AC_SUBST(CRYPTOPP_NAME)
54
+else
55
+	AC_DEFINE([HAVE_CRYPTOPP], [0])
56
+fi
57
+
58
+
29 59
 
30 60
 AC_CONFIG_FILES([Makefile])
31 61
 AC_OUTPUT
... ...
@@ -45,5 +75,3 @@ if test "$PAM_MODULE_DIRECTORY" = "$DEFAULT_PAM_MODULE_DIRECTORY"; then
45 75
 else
46 76
     AC_MSG_NOTICE([PAM module installation directory: $PAM_MODULE_DIRECTORY])
47 77
 fi
48
-
49
-
... ...
@@ -106,9 +106,7 @@ public:
106 106
 
107 107
     std::string generate_token () const override
108 108
     {
109
-        clock.time(nullptr);
110
-        time_t foo = 111;
111
-        const CryptoPP::Integer &time = clock.time (&foo);
109
+        const CryptoPP::Integer &time = clock.time (nullptr);
112 110
         int time_step_size = 30;
113 111
         CryptoPP::Integer current_step = time_step (time.ConvertToLong(),
114 112
                                          time_step_size);