/**
* Overall size of the signature data.
*/
- uint16_t size;
+ uint16_t size GNUNET_PACKED;
/**
* S-expression, padded with zeros.
/**
* Size of the encoding, in network byte order.
*/
- uint16_t size;
+ uint16_t size GNUNET_PACKED;
/**
* Actual length of the q-point binary encoding.
*/
- uint16_t len;
+ uint16_t len GNUNET_PACKED;
/**
* 0-padded q-point in binary encoding (GCRYPT_MPI_FMT_USG).
GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename);
+/**
+ * Create a new private key by reading our peer's key from
+ * the file specified in the configuration.
+ *
+ * @return new private key, NULL on error (for example,
+ * permission denied)
+ */
+struct GNUNET_CRYPTO_EccPrivateKey *
+GNUNET_CRYPTO_ecc_key_create_from_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+
/**
* Handle to cancel private key generation and state for the
* key generation operation.
}
+/**
+ * Create a new private key by reading our peer's key from
+ * the file specified in the configuration.
+ *
+ * @return new private key, NULL on error (for example,
+ * permission denied)
+ */
+struct GNUNET_CRYPTO_EccPrivateKey *
+GNUNET_CRYPTO_ecc_key_create_from_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ struct GNUNET_CRYPTO_EccPrivateKey *pk;
+ char *fn;
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", "PRIVATE_KEY", &fn))
+ return NULL;
+ pk = GNUNET_CRYPTO_ecc_key_create_from_file (fn);
+ GNUNET_free (fn);
+ return pk;
+}
+
+
/**
* Setup a key file for a peer given the name of the
* configuration file (!). This function is used so that
{
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_CRYPTO_EccPrivateKey *pk;
- char *fn;
cfg = GNUNET_CONFIGURATION_create ();
(void) GNUNET_CONFIGURATION_load (cfg, cfg_name);
- if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", "PRIVATE_KEY", &fn))
- {
- pk = GNUNET_CRYPTO_ecc_key_create_from_file (fn);
- if (NULL != pk)
- GNUNET_CRYPTO_ecc_key_free (pk);
- GNUNET_free (fn);
- }
+ pk = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg);
+ if (NULL != pk)
+ GNUNET_CRYPTO_ecc_key_free (pk);
GNUNET_CONFIGURATION_destroy (cfg);
}
{
struct GNUNET_CRYPTO_EccPrivateKey *my_private_key;
struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key;
- char *keyfile;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", "PRIVATE_KEY",
- &keyfile))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Lacking key configuration settings.\n"));
- return GNUNET_SYSERR;
- }
- if (NULL == (my_private_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile)))
+ if (NULL == (my_private_key = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Could not access hostkey file `%s'.\n"), keyfile);
- GNUNET_free (keyfile);
+ _("Could not load peer's private key\n"));
return GNUNET_SYSERR;
}
- GNUNET_free (keyfile);
GNUNET_CRYPTO_ecc_key_get_public (my_private_key, &my_public_key);
GNUNET_CRYPTO_ecc_key_free (my_private_key);
GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), &dst->hashPubKey);