diff options
Diffstat (limited to 'src/identity/identity_api.c')
-rw-r--r-- | src/identity/identity_api.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 693d4392e..5d17ac5d5 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -392,6 +392,7 @@ handle_identity_update (void *cls, | |||
392 | return; | 392 | return; |
393 | } | 393 | } |
394 | ego = GNUNET_new (struct GNUNET_IDENTITY_Ego); | 394 | ego = GNUNET_new (struct GNUNET_IDENTITY_Ego); |
395 | ego->pub_initialized = GNUNET_NO; | ||
395 | ego->pk = um->private_key; | 396 | ego->pk = um->private_key; |
396 | ego->name = GNUNET_strdup (str); | 397 | ego->name = GNUNET_strdup (str); |
397 | ego->id = id; | 398 | ego->id = id; |
@@ -607,11 +608,11 @@ void | |||
607 | GNUNET_IDENTITY_ego_get_public_key (struct GNUNET_IDENTITY_Ego *ego, | 608 | GNUNET_IDENTITY_ego_get_public_key (struct GNUNET_IDENTITY_Ego *ego, |
608 | struct GNUNET_CRYPTO_EcdsaPublicKey *pk) | 609 | struct GNUNET_CRYPTO_EcdsaPublicKey *pk) |
609 | { | 610 | { |
610 | if (! ego->pub_initialized) | 611 | if (GNUNET_NO == ego->pub_initialized) |
611 | { | 612 | { |
612 | GNUNET_CRYPTO_ecdsa_key_get_public (&ego->pk, | 613 | GNUNET_CRYPTO_ecdsa_key_get_public (&ego->pk, |
613 | &ego->pub); | 614 | &ego->pub); |
614 | ego->pub_initialized = true; | 615 | ego->pub_initialized = GNUNET_YES; |
615 | } | 616 | } |
616 | *pk = ego->pub; | 617 | *pk = ego->pub; |
617 | } | 618 | } |
@@ -714,6 +715,7 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, | |||
714 | * | 715 | * |
715 | * @param h identity service to use | 716 | * @param h identity service to use |
716 | * @param name desired name | 717 | * @param name desired name |
718 | * @param privkey desired private key or NULL to create one | ||
717 | * @param cont function to call with the result (will only be called once) | 719 | * @param cont function to call with the result (will only be called once) |
718 | * @param cont_cls closure for @a cont | 720 | * @param cont_cls closure for @a cont |
719 | * @return handle to abort the operation | 721 | * @return handle to abort the operation |
@@ -721,6 +723,7 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, | |||
721 | struct GNUNET_IDENTITY_Operation * | 723 | struct GNUNET_IDENTITY_Operation * |
722 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, | 724 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, |
723 | const char *name, | 725 | const char *name, |
726 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey, | ||
724 | GNUNET_IDENTITY_CreateContinuation cont, | 727 | GNUNET_IDENTITY_CreateContinuation cont, |
725 | void *cont_cls) | 728 | void *cont_cls) |
726 | { | 729 | { |
@@ -745,7 +748,10 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, | |||
745 | env = GNUNET_MQ_msg_extra (crm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE); | 748 | env = GNUNET_MQ_msg_extra (crm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE); |
746 | crm->name_len = htons (slen); | 749 | crm->name_len = htons (slen); |
747 | crm->reserved = htons (0); | 750 | crm->reserved = htons (0); |
748 | GNUNET_CRYPTO_ecdsa_key_create (&crm->private_key); | 751 | if (NULL == privkey) |
752 | GNUNET_CRYPTO_ecdsa_key_create (&crm->private_key); | ||
753 | else | ||
754 | crm->private_key = *privkey; | ||
749 | op->pk = crm->private_key; | 755 | op->pk = crm->private_key; |
750 | GNUNET_memcpy (&crm[1], name, slen); | 756 | GNUNET_memcpy (&crm[1], name, slen); |
751 | GNUNET_MQ_send (h->mq, env); | 757 | GNUNET_MQ_send (h->mq, env); |