GNUNET_CRYPTO_eddsa_key_create (void);
+/**
+ * @ingroup crypto
+ * Create a new private key. Clear with #GNUNET_CRYPTO_ecdhe_key_clear().
+ *
+ * @param[out] pk set to fresh private key;
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
+ */
+int
+GNUNET_CRYPTO_ecdhe_key_create2 (struct GNUNET_CRYPTO_EcdhePrivateKey *pk);
+
+
/**
* @ingroup crypto
* Create a new private key. Caller must free return value.
GNUNET_CRYPTO_ecdhe_key_create ()
{
struct GNUNET_CRYPTO_EcdhePrivateKey *priv;
+
+ priv = GNUNET_new (struct GNUNET_CRYPTO_EcdhePrivateKey);
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_ecdhe_key_create2 (priv))
+ {
+ GNUNET_free (priv);
+ return NULL;
+ }
+ return priv;
+}
+
+
+/**
+ * @ingroup crypto
+ * Create a new private key. Clear with #GNUNET_CRYPTO_ecdhe_key_clear().
+ *
+ * @param[out] pk set to fresh private key;
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
+ */
+int
+GNUNET_CRYPTO_ecdhe_key_create2 (struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
+{
gcry_sexp_t priv_sexp;
gcry_sexp_t s_keyparam;
gcry_mpi_t d;
"(flags eddsa no-keytest)))")))
{
LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc);
- return NULL;
+ return GNUNET_SYSERR;
}
if (0 != (rc = gcry_pk_genkey (&priv_sexp, s_keyparam)))
{
LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_genkey", rc);
gcry_sexp_release (s_keyparam);
- return NULL;
+ return GNUNET_SYSERR;
}
gcry_sexp_release (s_keyparam);
#if EXTRA_CHECKS
{
LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc);
gcry_sexp_release (priv_sexp);
- return NULL;
+ return GNUNET_SYSERR;
}
#endif
if (0 != (rc = key_from_sexp (&d, priv_sexp, "private-key", "d")))
{
LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "key_from_sexp", rc);
gcry_sexp_release (priv_sexp);
- return NULL;
+ return GNUNET_SYSERR;
}
gcry_sexp_release (priv_sexp);
- priv = GNUNET_new (struct GNUNET_CRYPTO_EcdhePrivateKey);
- GNUNET_CRYPTO_mpi_print_unsigned (priv->d, sizeof (priv->d), d);
+ GNUNET_CRYPTO_mpi_print_unsigned (pk->d, sizeof (pk->d), d);
gcry_mpi_release (d);
- return priv;
+ return GNUNET_OK;
}