aboutsummaryrefslogtreecommitdiffstats
path: root/src/inexact.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/inexact.c')
-rw-r--r--src/inexact.c27
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;