From a32de45ceffeb69038ecfa7b963f30b7fed83a41 Mon Sep 17 00:00:00 2001 From: jospaeth Date: Mon, 25 May 2020 21:38:58 +0200 Subject: add option to create identity from private key --- src/identity/identity_api.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/identity/identity_api.c') diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index c2fcc5075..5d17ac5d5 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c @@ -715,6 +715,7 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, * * @param h identity service to use * @param name desired name + * @param privkey desired private key or NULL to create one * @param cont function to call with the result (will only be called once) * @param cont_cls closure for @a cont * @return handle to abort the operation @@ -722,6 +723,7 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, const char *name, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey, GNUNET_IDENTITY_CreateContinuation cont, void *cont_cls) { @@ -746,7 +748,10 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, env = GNUNET_MQ_msg_extra (crm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE); crm->name_len = htons (slen); crm->reserved = htons (0); - GNUNET_CRYPTO_ecdsa_key_create (&crm->private_key); + if (NULL == privkey) + GNUNET_CRYPTO_ecdsa_key_create (&crm->private_key); + else + crm->private_key = *privkey; op->pk = crm->private_key; GNUNET_memcpy (&crm[1], name, slen); GNUNET_MQ_send (h->mq, env); -- cgit v1.2.3