Browse code
Review and cleanup TODOs
Ed Langley authored on 14/06/2017 17:59:27
Showing 6 changed files
Showing 6 changed files
... | ... |
@@ -192,7 +192,6 @@ public: |
192 | 192 |
|
193 | 193 |
std::vector<uint8_t> decode (std::string input) const override |
194 | 194 |
{ |
195 |
- //TODO: where to pad input to required size? |
|
196 | 195 |
auto lookup_table = construct_lookup_table(); |
197 | 196 |
auto input_size = calculate_decoded_size (input); |
198 | 197 |
|
... | ... |
@@ -201,6 +200,7 @@ public: |
201 | 200 |
unsigned long long bits_written = 0; |
202 | 201 |
|
203 | 202 |
for (std::string::size_type idx = 0; idx < input.size(); idx++) { |
203 |
+ // TODO: fail on invalid input |
|
204 | 204 |
uint8_t val = lookup_table[input[idx]]; |
205 | 205 |
|
206 | 206 |
uint8_t start_bit = bits_written % 8; |
... | ... |
@@ -43,7 +43,6 @@ dual_control initialize() |
43 | 43 |
fstreams fstreams (fstreams::create()); |
44 | 44 |
sys_time time (sys_time::get()); |
45 | 45 |
int code_digits = 6; |
46 |
- //TODO: have generator take the key after construction |
|
47 | 46 |
totp_generator generator = totp_generator (time, code_digits); |
48 | 47 |
tokens tokens (tokens::create (fstreams, generator)); |
49 | 48 |
validator validator (validator::create (directory, tokens)); |
... | ... |
@@ -173,8 +173,7 @@ int int_precomputed() |
173 | 173 |
|
174 | 174 |
// then |
175 | 175 |
check (actual.size() == 6, "size is wrong"); |
176 |
- check (actual == expected, |
|
177 |
- "precomputed value failed to match"); // TODO: Does == work for std::string like I want it to? |
|
176 |
+ check (actual == expected, "precomputed value failed to match"); |
|
178 | 177 |
succeed(); |
179 | 178 |
} |
180 | 179 |
|
... | ... |
@@ -47,11 +47,11 @@ public: |
47 | 47 |
user user (found_user[0]); |
48 | 48 |
|
49 | 49 |
std::string key_string = tokens_.ensure_key (user); |
50 |
+ // TODO: use vectors in generator input instead of strings to avoid this nonsense |
|
50 | 51 |
std::vector<uint8_t> key = base32().decode (key_string); |
51 | 52 |
std::string decoded_key (key.begin(), key.end()); |
52 | 53 |
std::string token = generator_.generate_token (decoded_key); |
53 | 54 |
|
54 |
- // TODO: fix generator input |
|
55 | 55 |
return {key_string, token}; |
56 | 56 |
} |
57 | 57 |
}; |
... | ... |
@@ -21,6 +21,7 @@ |
21 | 21 |
#include "test_util.h" |
22 | 22 |
#include "generator.h" |
23 | 23 |
|
24 |
+// TODO: audit usage of 'token', sometimes it should be 'key' |
|
24 | 25 |
class mock_tokens : public tokens_ifc |
25 | 26 |
{ |
26 | 27 |
public: |
... | ... |
@@ -190,9 +191,6 @@ int unistd_does_not_find_user_name_empty_string_case() |
190 | 191 |
std::tie (actual_key, actual_token) = installer.install_key(); |
191 | 192 |
|
192 | 193 |
//then |
193 |
- // TODO: rethink this... |
|
194 |
- check (test_tokens->captured_token == "", |
|
195 |
- "should not have installed a token"); |
|
196 | 194 |
check (actual_key == "", |
197 | 195 |
"should not have installed a token"); |
198 | 196 |
check (actual_token == "", |
... | ... |
@@ -31,7 +31,8 @@ private: |
31 | 31 |
totp_generator generator_; |
32 | 32 |
random_source rand_; |
33 | 33 |
public: |
34 |
- tokens_impl (const fstreams &fstreams, const totp_generator generator, const random_source rand) : |
|
34 |
+ tokens_impl (const fstreams &fstreams, const totp_generator generator, |
|
35 |
+ const random_source rand) : |
|
35 | 36 |
fstreams_ (fstreams), generator_ (generator), rand_ (rand) {} |
36 | 37 |
std::string token (const user &user) const override |
37 | 38 |
{ |
... | ... |
@@ -67,7 +68,6 @@ private: |
67 | 68 |
std::string file_path = get_key_path (user); |
68 | 69 |
fstreams::pstream stream (fstreams_.open_fstream (file_path)); |
69 | 70 |
|
70 |
- // TODO: ignore newlines |
|
71 | 71 |
std::vector<char> line_v (16); |
72 | 72 |
stream->read (line_v.data(), line_v.size()); |
73 | 73 |
|
... | ... |
@@ -84,7 +84,7 @@ public: |
84 | 84 |
base32 codec; |
85 | 85 |
// get randomness |
86 | 86 |
int length = 10; |
87 |
- std::vector<uint8_t> random_bytes (rand_.get_random_bytes(length)); |
|
87 |
+ std::vector<uint8_t> random_bytes (rand_.get_random_bytes (length)); |
|
88 | 88 |
// base32encode it |
89 | 89 |
std::string key = codec.encode (random_bytes); |
90 | 90 |
return key; |
... | ... |
@@ -118,3 +118,4 @@ tokens tokens::create (const fstreams &fstreams, |
118 | 118 |
return tokens (tokens::delegate |
119 | 119 |
(new tokens_impl (fstreams, generator, rand))); |
120 | 120 |
} |
121 |
+ |