git.fiddlerwoaroof.com
Browse code

Add base32 codecto Makefile, reformat

Ed Langley authored on 07/06/2017 16:20:00
Showing 4 changed files
... ...
@@ -4,7 +4,7 @@ LDFLAGS = -lpam @LIBS@
4 4
 
5 5
 INTEGRATION_OBJS = sys_syslog.o sys_fstream.o sys_unistd.o sys_pwd.o sys_pam.o \
6 6
                    sys_stdlib.o sys_time.o
7
-OBJS = dual_control.o request.o validator.o conversation.o user.o token.o logger.o session.o installer.o system.o generator.o
7
+OBJS = dual_control.o request.o validator.o conversation.o user.o token.o logger.o session.o installer.o system.o generator.o base32.o
8 8
 TEST_SOURCES := $(wildcard *_test.cc)
9 9
 TESTS := $(patsubst %.cc,%.out,$(TEST_SOURCES))
10 10
 TESTRUNS := $(patsubst %.out,RUN_%,$(TESTS))
... ...
@@ -75,7 +75,8 @@ private:
75 75
 
76 76
     unsigned long truncate (const std::string &mac) const
77 77
     {
78
-        uint8_t offset = static_cast<uint8_t > (mac[19]) & static_cast<uint8_t> (0x0f);
78
+        uint8_t offset = static_cast<uint8_t > (mac[19]) & static_cast<uint8_t>
79
+                         (0x0f);
79 80
 
80 81
         std::string  offsetBytes = mac.substr (offset, 4);
81 82
 
... ...
@@ -86,9 +87,11 @@ private:
86 87
                       size_t data_size, const int digits=6) const
87 88
     {
88 89
         // TODO: see if I can use sha256/etc. with google auth...
89
-        unsigned char *digest = HMAC (EVP_sha1(), key.c_str(), key.size(), data, data_size, NULL, NULL);
90
+        unsigned char *digest = HMAC (EVP_sha1(), key.c_str(), key.size(), data,
91
+                                      data_size, NULL, NULL);
90 92
 
91
-        std::string digest_s = std::string (reinterpret_cast<const char *> (digest), 20); //TODO: use vectors
93
+        std::string digest_s = std::string (reinterpret_cast<const char *> (digest),
94
+                                            20); //TODO: use vectors
92 95
 
93 96
         unsigned long result = truncate (digest_s) % ipow (10,digits);
94 97
 
... ...
@@ -125,3 +128,4 @@ totp_generator::totp_generator (
125 128
     delegate_ (std::make_shared<token_generator_impl> (clock, key_c,
126 129
                code_digits))
127 130
 {}
131
+
... ...
@@ -43,7 +43,7 @@ public:
43 43
     std::string generate_token () const
44 44
     {
45 45
         return delegate_->generate_token();
46
-    };
46
+    }
47 47
 
48 48
     totp_generator (delegate delegate_) :
49 49
         delegate_ (delegate_)
... ...
@@ -55,3 +55,4 @@ public:
55 55
 };
56 56
 
57 57
 #endif
58
+
... ...
@@ -195,3 +195,4 @@ int main (int argc, char *argv[])
195 195
 {
196 196
     return !run_tests();
197 197
 }
198
+