diff options
author | David Timber <mieabby@gmail.com> | 2020-08-20 12:23:35 +0930 |
---|---|---|
committer | David Timber <mieabby@gmail.com> | 2020-08-20 15:15:57 +0930 |
commit | 76d4d6b2bafada7b790e817b7324d53f3d3a0c7f (patch) | |
tree | d8b3669fa7b167fc3bf764e971fc6e70bd8d9b49 /src/proone-mask.c | |
parent | 7bd3eb3b1ad4209ac4cf4b46f849213d46bc33aa (diff) |
Progress ...
* Move DVault out of executable. Dynamically load it on startup
* Improved testing scheme
* Tidy up prne_*assert* macro series
* Protocol: store host credentials in base64 string. No mask
* Use the lock shm as a shared_global so the stats can persist
* mmap() the executable read-only for later use
Diffstat (limited to 'src/proone-mask.c')
-rw-r--r-- | src/proone-mask.c | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/src/proone-mask.c b/src/proone-mask.c deleted file mode 100644 index aa39d56..0000000 --- a/src/proone-mask.c +++ /dev/null @@ -1,101 +0,0 @@ -#include <stdio.h> -#include <stddef.h> -#include <stdint.h> -#include <stdbool.h> -#include <ctype.h> - -#include <unistd.h> -#include <fcntl.h> -#include <sys/random.h> - -#include "dvault.h" -#include "util_rt.h" - - -int main (const int argc, char **args) { - int exit_code = 0; - ssize_t fd_read_size; - size_t read_size = 0; - uint8_t salt; - prne_dvault_mask_result_t mask_result; - prne_data_type_t type; - - prne_init_dvault_mask_result(&mask_result); - - if (argc <= 1) { - fprintf(stderr, - "Usage: %s <type> [salt]\n" - "<type>: 'cstr', 'bin'\n" - "[salt]: salt hex value\n", - args[0]); - exit_code = 2; - goto END; - } - - if (argc >= 3) { - for (char *p = args[2]; *p != 0; p += 1) { - *p = (char)tolower(*p); - } - - if (sscanf(args[2], "%hhx", &salt) != 1) { - perror("parsing salt: "); - exit_code = 1; - goto END; - } - } - else { - prne_geturandom(&salt, sizeof(salt)); - } - - type = prne_data_type_fstr(args[1]); - switch (type) { - case PRNE_DATA_TYPE_BIN: - case PRNE_DATA_TYPE_CSTR: { - static const size_t buf_size = 0x0000FFFF + 1; - uint8_t buf[buf_size]; - - do { - fd_read_size = read(STDIN_FILENO, buf + read_size, buf_size - read_size); - if (fd_read_size < 0) { - perror("Error reading stdin"); - exit_code = 1; - goto END; - } - if (fd_read_size > 0) { - read_size += fd_read_size; - if (read_size >= buf_size) { - fprintf(stderr, "Error: data too large\n"); - exit_code = 1; - goto END; - } - } - } while (fd_read_size > 0); - - if (read_size == 0) { - fprintf(stderr, "Error: no data read\n"); - exit_code = 1; - goto END; - } - - mask_result = prne_dvault_mask(type, salt, read_size, buf); - if (mask_result.result == PRNE_DVAULT_MASK_OK) { - printf("(uint8_t*)\"%s\",\n", mask_result.str); - } - else { - fprintf(stderr, "Error: prne_dvault_mask() returned %d\n", (int)mask_result.result); - exit_code = 1; - goto END; - } - break; - } - default: - fprintf(stderr, "Error: unknown data type '%s'\n", args[1]); - exit_code = 2; - goto END; - } - -END: - prne_free_dvault_mask_result(&mask_result); - - return exit_code; -} |