GNUNET_assert (GNUNET_YES == success);
GNUNET_assert (NULL == emsg);
GNUNET_assert (NULL == op);
- op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, NULL);
+ op = GNUNET_IDENTITY_create (id, "caller-ego", NULL, &caller_ego_create_cont, NULL);
}
cfg = c;
GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL);
id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL);
- op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL);
+ op = GNUNET_IDENTITY_create (id, "phone-ego", NULL, &phone_ego_create_cont, NULL);
ns = GNUNET_NAMESTORE_connect (cfg);
}
GNUNET_assert (GNUNET_YES == success);
GNUNET_assert (NULL == emsg);
GNUNET_assert (NULL == op);
- op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, NULL);
+ op = GNUNET_IDENTITY_create (id, "caller-ego", NULL, &caller_ego_create_cont, NULL);
}
cfg = c;
GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL);
id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL);
- op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL);
+ op = GNUNET_IDENTITY_create (id, "phone-ego", NULL, &phone_ego_create_cont, NULL);
ns = GNUNET_NAMESTORE_connect (cfg);
}
GNUNET_assert (GNUNET_YES == success);
GNUNET_assert (NULL == emsg);
GNUNET_assert (NULL == op);
- op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, NULL);
+ op = GNUNET_IDENTITY_create (id, "caller-ego", NULL, &caller_ego_create_cont, NULL);
}
timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL);
GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL);
- op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL);
+ op = GNUNET_IDENTITY_create (id, "phone-ego", NULL, &phone_ego_create_cont, NULL);
ns = GNUNET_NAMESTORE_connect (cfg);
}
*/
static char *delete_ego;
+/**
+ * -P option
+ */
+static char *privkey_ego;
+
/**
* -s option.
*/
*/
static struct GNUNET_IDENTITY_Operation *delete_op;
+/**
+ * Private key from command line option, or NULL.
+ */
+struct GNUNET_CRYPTO_EcdsaPrivateKey pk;
+
/**
* Value to return from #main().
*/
&delete_finished,
&delete_op);
if (NULL != create_ego)
- create_op =
- GNUNET_IDENTITY_create (sh,
- create_ego,
- &create_finished,
- &create_op);
+ {
+ if (NULL != privkey_ego)
+ {
+ GNUNET_STRINGS_string_to_data (privkey_ego,
+ strlen (privkey_ego),
+ &pk,
+ sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey));
+ create_op =
+ GNUNET_IDENTITY_create (sh,
+ create_ego,
+ &pk,
+ &create_finished,
+ &create_op);
+ }
+ else
+ create_op =
+ GNUNET_IDENTITY_create (sh,
+ create_ego,
+ NULL,
+ &create_finished,
+ &create_op);
+ }
GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
NULL);
test_finished ();
"NAME",
gettext_noop ("delete ego NAME "),
&delete_ego),
+ GNUNET_GETOPT_option_string ('P',
+ "privkey",
+ "PRIVATE_KEY",
+ gettext_noop ("set the private key for the identity to PRIVATE_KEY (use together with -C)"),
+ &privkey_ego),
GNUNET_GETOPT_option_flag ('d',
"display",
gettext_noop ("display all egos"),
*
* @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
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)
{
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);
#define GNUNET_REST_IDENTITY_PARAM_PUBKEY "pubkey"
/**
- * Parameter public key
+ * Parameter private key
*/
#define GNUNET_REST_IDENTITY_PARAM_PRIVKEY "privkey"
json_t *data_js;
json_error_t err;
char *egoname;
+ char *privkey;
+ struct GNUNET_CRYPTO_EcdsaPrivateKey pk;
+ struct GNUNET_CRYPTO_EcdsaPrivateKey *pk_ptr;
int json_unpack_state;
char term_data[handle->data_size + 1];
return;
}
json_unpack_state = 0;
+ privkey = NULL;
json_unpack_state =
- json_unpack (data_js, "{s:s!}", GNUNET_REST_IDENTITY_PARAM_NAME, &egoname);
+ json_unpack (data_js, "{s:s, s?:s!}",
+ GNUNET_REST_IDENTITY_PARAM_NAME, &egoname,
+ GNUNET_REST_IDENTITY_PARAM_PRIVKEY, &privkey);
if (0 != json_unpack_state)
{
handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
}
}
handle->name = GNUNET_strdup (egoname);
+ if (NULL != privkey)
+ {
+ GNUNET_STRINGS_string_to_data (privkey,
+ strlen (privkey),
+ &pk,
+ sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey));
+ pk_ptr = &pk;
+ }
+ else
+ pk_ptr = NULL;
json_decref (data_js);
handle->response_code = MHD_HTTP_CREATED;
handle->op = GNUNET_IDENTITY_create (handle->identity_handle,
handle->name,
+ pk_ptr,
&do_finished_create,
handle);
}
GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL);
CHECK (NULL != h);
- op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL);
+ op = GNUNET_IDENTITY_create (h, "test-id", NULL, &create_cb, NULL);
}
GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL);
CHECK (NULL != h);
- op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL);
+ op = GNUNET_IDENTITY_create (h, "test-id", NULL, &create_cb, NULL);
}
*
* @param id 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
struct GNUNET_IDENTITY_Operation *
GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
const char *name,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey,
GNUNET_IDENTITY_CreateContinuation cont,
void *cont_cls);
fprintf (stderr, "All peers connected @ IDENTITY ...\n");
testpeers[0].create_id_op = GNUNET_IDENTITY_create (testpeers[0].idh,
"client",
+ NULL,
&identity_create_cb,
&testpeers[0]);
testpeers[1].create_id_op = GNUNET_IDENTITY_create (testpeers[1].idh,
"toberevoked",
+ NULL,
&identity_create_cb,
&testpeers[1]);
}