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 | |
parent | c814f3c1c2970773ebc10876882776bd10febf0f (diff) | |
download | inexact-beta_1.02.tar.gz inexact-beta_1.02.tar.bz2 inexact-beta_1.02.tar.xz |
[FIX] Windows and Mac OS X compatibility.beta_1.02
-rw-r--r-- | src/chacha20_drng.c | 6 | ||||
-rw-r--r-- | src/inexact.c | 27 | ||||
-rw-r--r-- | src/main.c | 1 |
3 files changed, 15 insertions, 19 deletions
diff --git a/src/chacha20_drng.c b/src/chacha20_drng.c index 9180557..3c46706 100644 --- a/src/chacha20_drng.c +++ b/src/chacha20_drng.c @@ -483,11 +483,7 @@ static int drng_chacha20_rng_selftest(struct chacha20_drng *drng) static void drng_chacha20_dealloc(struct chacha20_drng *drng) { memset_secure(drng, 0, sizeof(*drng)); -#ifdef _WIN32 - _aligned_free(drng); -#else free(drng); -#endif } /** @@ -595,7 +591,7 @@ int drng_chacha20_reseed(struct chacha20_drng *drng, const uint8_t *inbuf, DSO_PUBLIC void drng_chacha20_destroy(struct chacha20_drng *drng) { - drng_chacha20_dealloc(drng); + drng_chacha20_dealloc(drng); } DSO_PUBLIC 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; @@ -434,6 +434,7 @@ int main(int argc, char *argv[]) { unsigned char *secretkey = malloc(32); unsigned char *publickey = malloc(32); unsigned char *salt = malloc(32); + if (secretkey == NULL || publickey == NULL || salt == NULL) { printf("Malloc failed\n"); exitcode = 1; |