summaryrefslogtreecommitdiff
path: root/src/identity/identity_api.c
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-05-25 21:38:58 +0200
committerjospaeth <spaethj@in.tum.de>2020-05-25 21:38:58 +0200
commita32de45ceffeb69038ecfa7b963f30b7fed83a41 (patch)
tree76a39adcf7163c71e470b7c5bf4357dd5471cf9c /src/identity/identity_api.c
parent19cd0e6d0eca5192a9c8f4f005abd85d531949f1 (diff)
add option to create identity from private keyspaeth/import_identity
Diffstat (limited to 'src/identity/identity_api.c')
-rw-r--r--src/identity/identity_api.c7
1 files changed, 6 insertions, 1 deletions
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);