diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/auditor/taler-auditor-httpd.c | 11 | ||||
-rw-r--r-- | src/auditor/taler-auditor-sign.c | 30 | ||||
-rw-r--r-- | src/exchange-tools/key-helper.c | 19 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_bank_admin_add_incoming.c | 12 |
4 files changed, 31 insertions, 41 deletions
diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index 627950aed..d326f0f62 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -479,7 +479,7 @@ auditor_serve_process_config (void) { /* Fall back to trying to read private key */ char *auditor_key_file; - struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_priv; + struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, @@ -495,8 +495,10 @@ auditor_serve_process_config (void) "AUDITOR_PRIV_FILE"); return GNUNET_SYSERR; } - eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (auditor_key_file); - if (NULL == eddsa_priv) + if (GNUNET_OK != + GNUNET_CRYPTO_eddsa_key_from_file (auditor_key_file, + GNUNET_NO, + &eddsa_priv)) { /* Both failed, complain! */ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, @@ -509,9 +511,8 @@ auditor_serve_process_config (void) return 1; } GNUNET_free (auditor_key_file); - GNUNET_CRYPTO_eddsa_key_get_public (eddsa_priv, + GNUNET_CRYPTO_eddsa_key_get_public (&eddsa_priv, &auditor_pub.eddsa_pub); - GNUNET_free (eddsa_priv); } return GNUNET_OK; } diff --git a/src/auditor/taler-auditor-sign.c b/src/auditor/taler-auditor-sign.c index e8491fabe..7dd7605fb 100644 --- a/src/auditor/taler-auditor-sign.c +++ b/src/auditor/taler-auditor-sign.c @@ -186,7 +186,7 @@ main (int argc, GNUNET_GETOPT_option_verbose (&verbose), GNUNET_GETOPT_OPTION_END }; - struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_priv; + struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; struct TALER_AuditorSignatureP *sigs; struct TALER_AuditorPublicKeyP apub; struct GNUNET_DISK_FileHandle *fh; @@ -239,20 +239,17 @@ main (int argc, "Auditor URL not given in neither configuration nor command-line\n"); return 1; } - if (GNUNET_YES != - GNUNET_DISK_file_test (auditor_key_file)) - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Auditor private key `%s' does not exist yet, creating it!\n", - auditor_key_file); - eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (auditor_key_file); - if (NULL == eddsa_priv) + if (GNUNET_SYSERR == + GNUNET_CRYPTO_eddsa_key_from_file (auditor_key_file, + GNUNET_YES, + &eddsa_priv)) { fprintf (stderr, - "Failed to initialize auditor key from file `%s'\n", + "Failed to initialize auditor private key from file `%s'\n", auditor_key_file); return 1; } - GNUNET_CRYPTO_eddsa_key_get_public (eddsa_priv, + GNUNET_CRYPTO_eddsa_key_get_public (&eddsa_priv, &apub.eddsa_pub); fh = GNUNET_DISK_file_open (exchange_request_file, GNUNET_DISK_OPEN_READ, @@ -263,7 +260,6 @@ main (int argc, "Failed to open file `%s': %s\n", exchange_request_file, strerror (errno)); - GNUNET_free (eddsa_priv); return 1; } if (GNUNET_OK != @@ -275,7 +271,6 @@ main (int argc, exchange_request_file, strerror (errno)); GNUNET_DISK_file_close (fh); - GNUNET_free (eddsa_priv); return 1; } if (0 != (in_size % sizeof (struct TALER_DenominationKeyValidityPS))) @@ -284,7 +279,6 @@ main (int argc, "Input file size of file `%s' is invalid\n", exchange_request_file); GNUNET_DISK_file_close (fh); - GNUNET_free (eddsa_priv); return 1; } dki_len = in_size / sizeof (struct TALER_DenominationKeyValidityPS); @@ -293,7 +287,6 @@ main (int argc, fprintf (stderr, "Failed to produce auditor signature, denomination list is empty.\n"); GNUNET_DISK_file_close (fh); - GNUNET_free (eddsa_priv); return 2; } if (NULL == @@ -302,7 +295,6 @@ main (int argc, fprintf (stderr, "Failed to initialize auditor database plugin.\n"); GNUNET_DISK_file_close (fh); - GNUNET_free (eddsa_priv); return 3; } @@ -326,7 +318,6 @@ main (int argc, TALER_AUDITORDB_plugin_unload (adb); GNUNET_DISK_file_close (fh); GNUNET_free (dki); - GNUNET_free (eddsa_priv); return 1; } GNUNET_DISK_file_close (fh); @@ -350,7 +341,7 @@ main (int argc, kv.denom_hash = dk->denom_hash; /* Finally sign ... */ - GNUNET_CRYPTO_eddsa_sign (eddsa_priv, + GNUNET_CRYPTO_eddsa_sign (&eddsa_priv, &kv, &sigs[i].eddsa_sig); } @@ -362,7 +353,6 @@ main (int argc, TALER_AUDITORDB_plugin_unload (adb); GNUNET_free (dki); GNUNET_free (sigs); - GNUNET_free (eddsa_priv); return 1; } @@ -375,7 +365,6 @@ main (int argc, TALER_AUDITORDB_plugin_unload (adb); GNUNET_free (dki); GNUNET_free (sigs); - GNUNET_free (eddsa_priv); return 3; } @@ -396,7 +385,6 @@ main (int argc, TALER_AUDITORDB_plugin_unload (adb); GNUNET_free (dki); GNUNET_free (sigs); - GNUNET_free (eddsa_priv); return 3; } for (unsigned int i = 0; i<dki_len; i++) @@ -416,7 +404,6 @@ main (int argc, TALER_AUDITORDB_plugin_unload (adb); GNUNET_free (dki); GNUNET_free (sigs); - GNUNET_free (eddsa_priv); return 3; } } @@ -443,7 +430,6 @@ main (int argc, } GNUNET_free (sigs); GNUNET_free (dki); - GNUNET_free (eddsa_priv); return 0; } diff --git a/src/exchange-tools/key-helper.c b/src/exchange-tools/key-helper.c index 281202bd7..0e3c0a2bb 100644 --- a/src/exchange-tools/key-helper.c +++ b/src/exchange-tools/key-helper.c @@ -60,21 +60,24 @@ get_and_check_master_key (const struct GNUNET_CONFIGURATION_Handle *cfg, "Exchange master private key `%s' does not exist yet, creating it!\n", fn); { - struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_priv; + int ret; - eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (fn); - if (NULL == eddsa_priv) + ret = GNUNET_CRYPTO_eddsa_key_from_file (fn, + GNUNET_YES, + &master_priv->eddsa_priv); + if (GNUNET_OK != ret) { fprintf (stderr, - "Failed to initialize master key from file `%s'\n", - fn); + "Failed to initialize master key from file `%s': %s\n", + fn, + (GNUNET_NO == ret) + ? "file exists" + : "could not create file"); GNUNET_free (fn); return GNUNET_SYSERR; } - master_priv->eddsa_priv = *eddsa_priv; - GNUNET_CRYPTO_eddsa_key_get_public (eddsa_priv, + GNUNET_CRYPTO_eddsa_key_get_public (&master_priv->eddsa_priv, &mpub); - GNUNET_free (eddsa_priv); } /* Check our key matches that in the configuration */ diff --git a/src/testing/testing_api_cmd_bank_admin_add_incoming.c b/src/testing/testing_api_cmd_bank_admin_add_incoming.c index 6ab287f66..2399825d9 100644 --- a/src/testing/testing_api_cmd_bank_admin_add_incoming.c +++ b/src/testing/testing_api_cmd_bank_admin_add_incoming.c @@ -304,7 +304,6 @@ admin_add_incoming_run (void *cls, { char *section; char *keys; - struct GNUNET_CRYPTO_EddsaPrivateKey *priv; struct GNUNET_CONFIGURATION_Handle *cfg; GNUNET_assert (NULL != fts->config_filename); @@ -336,21 +335,22 @@ admin_add_incoming_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - priv = GNUNET_CRYPTO_eddsa_key_create_from_file (keys); - GNUNET_free (keys); - if (NULL == priv) + if (GNUNET_OK != + GNUNET_CRYPTO_eddsa_key_from_file (keys, + GNUNET_NO, + &fts->reserve_priv.eddsa_priv)) { GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, section, "TIP_RESERVE_PRIV_FILENAME", "Failed to read private key"); GNUNET_free (section); + GNUNET_free (keys); TALER_TESTING_interpreter_fail (is); return; } - fts->reserve_priv.eddsa_priv = *priv; + GNUNET_free (keys); GNUNET_free (section); - GNUNET_free (priv); GNUNET_CONFIGURATION_destroy (cfg); } else |