diff options
author | ben | 2019-05-28 17:08:37 +0200 |
---|---|---|
committer | ben | 2019-05-28 17:08:37 +0200 |
commit | e0f4163c7e783bca7a38a344a8201c4889eccdb7 (patch) | |
tree | 5820b795c9bf7b9e16e3aaea04ac435987ea8265 /src/inexact.c | |
parent | c814f3c1c2970773ebc10876882776bd10febf0f (diff) | |
download | inexact-e0f4163c7e783bca7a38a344a8201c4889eccdb7.tar.gz inexact-e0f4163c7e783bca7a38a344a8201c4889eccdb7.tar.bz2 inexact-e0f4163c7e783bca7a38a344a8201c4889eccdb7.tar.xz |
[FIX] Windows and Mac OS X compatibility.beta_1.02
Diffstat (limited to 'src/inexact.c')
-rw-r--r-- | src/inexact.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/inexact.c b/src/inexact.c index 2f51d30..1992e17 100644 --- a/src/inexact.c +++ b/src/inexact.c @@ -100,7 +100,6 @@ int generate_keys(const char *seckey_filename, const char *pubkey_filename, memcpy(privatekey_buffer + sizeof(curve25519_key), publickey, sizeof(curve25519_key)); } else { - struct chacha20_drng *drng; int ret = drng_chacha20_init(&drng); if (ret) { printf("Chacha20 allocation failed: %d\n", ret); @@ -431,13 +430,13 @@ int get_pubkey(const char *keyfile, unsigned char *pkey) { const size_t file_data_len = 45; unsigned char *file_data = malloc(file_data_len); + int exitcode = 1; + if (file_data == NULL) { printf("Malloc failed\n"); goto exit; } - int exitcode = 1; - fs = fopen(keyfile, "rb"); if (fs == NULL) { printf("key file opening failed: %s.\n", strerror(errno)); @@ -774,14 +773,6 @@ int get_symmetrickeys(unsigned char *salt_out, unsigned char *seckey_out, int exitcode = 1; - password = malloc(password_maxlen); - password_verif = malloc(password_maxlen); - - if (password == NULL || password_verif == NULL) { - printf("Malloc failed\n"); - goto exit; - } - int ret = drng_chacha20_init(&drng); if (ret) { printf("Chacha20 allocation failed: %d\n", ret); @@ -792,6 +783,14 @@ int get_symmetrickeys(unsigned char *salt_out, unsigned char *seckey_out, goto exit; } + password = malloc(password_maxlen); + password_verif = malloc(password_maxlen); + + if (password == NULL || password_verif == NULL) { + printf("Malloc failed\n"); + goto exit; + } + password_out = readpassphrase("Password : ", password, password_maxlen, 0); if (password_out != password) { printf("password input failed.\n"); @@ -817,9 +816,9 @@ int get_symmetrickeys(unsigned char *salt_out, unsigned char *seckey_out, goto exit; } - int a2res = - argon2id_hash_raw(t_cost, m_cost, parallelism, password, password_len, - salt_out, salt_len, seckey_out, sizeof(curve25519_key)); + int a2res = argon2id_hash_raw(t_cost, m_cost, parallelism, password, + password_len, salt_out, salt_len, seckey_out, + sizeof(curve25519_key)); if (a2res != ARGON2_OK) { printf("argon2 failed."); goto exit; |