diff options
-rw-r--r-- | src/conversation/test_conversation_api.c | 4 | ||||
-rw-r--r-- | src/conversation/test_conversation_api_reject.c | 4 | ||||
-rw-r--r-- | src/conversation/test_conversation_api_twocalls.c | 4 | ||||
-rw-r--r-- | src/identity/gnunet-identity.c | 42 | ||||
-rw-r--r-- | src/identity/identity_api.c | 7 | ||||
-rw-r--r-- | src/identity/plugin_rest_identity.c | 21 | ||||
-rw-r--r-- | src/identity/test_identity.c | 2 | ||||
-rw-r--r-- | src/identity/test_identity_defaults.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_identity_service.h | 2 | ||||
-rw-r--r-- | src/revocation/test_revocation.c | 2 |
10 files changed, 74 insertions, 16 deletions
diff --git a/src/conversation/test_conversation_api.c b/src/conversation/test_conversation_api.c index 2b717367a..dbb742d91 100644 --- a/src/conversation/test_conversation_api.c +++ b/src/conversation/test_conversation_api.c | |||
@@ -402,7 +402,7 @@ namestore_put_cont (void *cls, int32_t success, const char *emsg) | |||
402 | GNUNET_assert (GNUNET_YES == success); | 402 | GNUNET_assert (GNUNET_YES == success); |
403 | GNUNET_assert (NULL == emsg); | 403 | GNUNET_assert (NULL == emsg); |
404 | GNUNET_assert (NULL == op); | 404 | GNUNET_assert (NULL == op); |
405 | op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, NULL); | 405 | op = GNUNET_IDENTITY_create (id, "caller-ego", NULL, &caller_ego_create_cont, NULL); |
406 | } | 406 | } |
407 | 407 | ||
408 | 408 | ||
@@ -483,7 +483,7 @@ run (void *cls, | |||
483 | cfg = c; | 483 | cfg = c; |
484 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); | 484 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); |
485 | id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); | 485 | id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); |
486 | op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL); | 486 | op = GNUNET_IDENTITY_create (id, "phone-ego", NULL, &phone_ego_create_cont, NULL); |
487 | ns = GNUNET_NAMESTORE_connect (cfg); | 487 | ns = GNUNET_NAMESTORE_connect (cfg); |
488 | } | 488 | } |
489 | 489 | ||
diff --git a/src/conversation/test_conversation_api_reject.c b/src/conversation/test_conversation_api_reject.c index 62e4109b0..855b21fd7 100644 --- a/src/conversation/test_conversation_api_reject.c +++ b/src/conversation/test_conversation_api_reject.c | |||
@@ -255,7 +255,7 @@ namestore_put_cont (void *cls, int32_t success, const char *emsg) | |||
255 | GNUNET_assert (GNUNET_YES == success); | 255 | GNUNET_assert (GNUNET_YES == success); |
256 | GNUNET_assert (NULL == emsg); | 256 | GNUNET_assert (NULL == emsg); |
257 | GNUNET_assert (NULL == op); | 257 | GNUNET_assert (NULL == op); |
258 | op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, NULL); | 258 | op = GNUNET_IDENTITY_create (id, "caller-ego", NULL, &caller_ego_create_cont, NULL); |
259 | } | 259 | } |
260 | 260 | ||
261 | 261 | ||
@@ -336,7 +336,7 @@ run (void *cls, | |||
336 | cfg = c; | 336 | cfg = c; |
337 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); | 337 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); |
338 | id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); | 338 | id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); |
339 | op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL); | 339 | op = GNUNET_IDENTITY_create (id, "phone-ego", NULL, &phone_ego_create_cont, NULL); |
340 | ns = GNUNET_NAMESTORE_connect (cfg); | 340 | ns = GNUNET_NAMESTORE_connect (cfg); |
341 | } | 341 | } |
342 | 342 | ||
diff --git a/src/conversation/test_conversation_api_twocalls.c b/src/conversation/test_conversation_api_twocalls.c index fab49f7d7..6d434a3e1 100644 --- a/src/conversation/test_conversation_api_twocalls.c +++ b/src/conversation/test_conversation_api_twocalls.c | |||
@@ -524,7 +524,7 @@ namestore_put_cont (void *cls, int32_t success, const char *emsg) | |||
524 | GNUNET_assert (GNUNET_YES == success); | 524 | GNUNET_assert (GNUNET_YES == success); |
525 | GNUNET_assert (NULL == emsg); | 525 | GNUNET_assert (NULL == emsg); |
526 | GNUNET_assert (NULL == op); | 526 | GNUNET_assert (NULL == op); |
527 | op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, NULL); | 527 | op = GNUNET_IDENTITY_create (id, "caller-ego", NULL, &caller_ego_create_cont, NULL); |
528 | } | 528 | } |
529 | 529 | ||
530 | 530 | ||
@@ -613,7 +613,7 @@ run (void *cls, | |||
613 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); | 613 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); |
614 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 614 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
615 | id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); | 615 | id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); |
616 | op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL); | 616 | op = GNUNET_IDENTITY_create (id, "phone-ego", NULL, &phone_ego_create_cont, NULL); |
617 | ns = GNUNET_NAMESTORE_connect (cfg); | 617 | ns = GNUNET_NAMESTORE_connect (cfg); |
618 | } | 618 | } |
619 | 619 | ||
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c index fd73048c4..cf44afd1f 100644 --- a/src/identity/gnunet-identity.c +++ b/src/identity/gnunet-identity.c | |||
@@ -76,6 +76,11 @@ static char *create_ego; | |||
76 | static char *delete_ego; | 76 | static char *delete_ego; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * -P option | ||
80 | */ | ||
81 | static char *privkey_ego; | ||
82 | |||
83 | /** | ||
79 | * -s option. | 84 | * -s option. |
80 | */ | 85 | */ |
81 | static char *set_ego; | 86 | static char *set_ego; |
@@ -101,6 +106,11 @@ static struct GNUNET_IDENTITY_Operation *create_op; | |||
101 | static struct GNUNET_IDENTITY_Operation *delete_op; | 106 | static struct GNUNET_IDENTITY_Operation *delete_op; |
102 | 107 | ||
103 | /** | 108 | /** |
109 | * Private key from command line option, or NULL. | ||
110 | */ | ||
111 | struct GNUNET_CRYPTO_EcdsaPrivateKey pk; | ||
112 | |||
113 | /** | ||
104 | * Value to return from #main(). | 114 | * Value to return from #main(). |
105 | */ | 115 | */ |
106 | static int global_ret; | 116 | static int global_ret; |
@@ -390,11 +400,28 @@ run (void *cls, | |||
390 | &delete_finished, | 400 | &delete_finished, |
391 | &delete_op); | 401 | &delete_op); |
392 | if (NULL != create_ego) | 402 | if (NULL != create_ego) |
393 | create_op = | 403 | { |
394 | GNUNET_IDENTITY_create (sh, | 404 | if (NULL != privkey_ego) |
395 | create_ego, | 405 | { |
396 | &create_finished, | 406 | GNUNET_STRINGS_string_to_data (privkey_ego, |
397 | &create_op); | 407 | strlen (privkey_ego), |
408 | &pk, | ||
409 | sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey)); | ||
410 | create_op = | ||
411 | GNUNET_IDENTITY_create (sh, | ||
412 | create_ego, | ||
413 | &pk, | ||
414 | &create_finished, | ||
415 | &create_op); | ||
416 | } | ||
417 | else | ||
418 | create_op = | ||
419 | GNUNET_IDENTITY_create (sh, | ||
420 | create_ego, | ||
421 | NULL, | ||
422 | &create_finished, | ||
423 | &create_op); | ||
424 | } | ||
398 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 425 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
399 | NULL); | 426 | NULL); |
400 | test_finished (); | 427 | test_finished (); |
@@ -422,6 +449,11 @@ main (int argc, char *const *argv) | |||
422 | "NAME", | 449 | "NAME", |
423 | gettext_noop ("delete ego NAME "), | 450 | gettext_noop ("delete ego NAME "), |
424 | &delete_ego), | 451 | &delete_ego), |
452 | GNUNET_GETOPT_option_string ('P', | ||
453 | "privkey", | ||
454 | "PRIVATE_KEY", | ||
455 | gettext_noop ("set the private key for the identity to PRIVATE_KEY (use together with -C)"), | ||
456 | &privkey_ego), | ||
425 | GNUNET_GETOPT_option_flag ('d', | 457 | GNUNET_GETOPT_option_flag ('d', |
426 | "display", | 458 | "display", |
427 | gettext_noop ("display all egos"), | 459 | gettext_noop ("display all egos"), |
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, | |||
715 | * | 715 | * |
716 | * @param h identity service to use | 716 | * @param h identity service to use |
717 | * @param name desired name | 717 | * @param name desired name |
718 | * @param privkey desired private key or NULL to create one | ||
718 | * @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) |
719 | * @param cont_cls closure for @a cont | 720 | * @param cont_cls closure for @a cont |
720 | * @return handle to abort the operation | 721 | * @return handle to abort the operation |
@@ -722,6 +723,7 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, | |||
722 | struct GNUNET_IDENTITY_Operation * | 723 | struct GNUNET_IDENTITY_Operation * |
723 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, | 724 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, |
724 | const char *name, | 725 | const char *name, |
726 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey, | ||
725 | GNUNET_IDENTITY_CreateContinuation cont, | 727 | GNUNET_IDENTITY_CreateContinuation cont, |
726 | void *cont_cls) | 728 | void *cont_cls) |
727 | { | 729 | { |
@@ -746,7 +748,10 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, | |||
746 | 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); |
747 | crm->name_len = htons (slen); | 749 | crm->name_len = htons (slen); |
748 | crm->reserved = htons (0); | 750 | crm->reserved = htons (0); |
749 | 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; | ||
750 | op->pk = crm->private_key; | 755 | op->pk = crm->private_key; |
751 | GNUNET_memcpy (&crm[1], name, slen); | 756 | GNUNET_memcpy (&crm[1], name, slen); |
752 | GNUNET_MQ_send (h->mq, env); | 757 | GNUNET_MQ_send (h->mq, env); |
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c index ef01cc578..009a01f16 100644 --- a/src/identity/plugin_rest_identity.c +++ b/src/identity/plugin_rest_identity.c | |||
@@ -57,7 +57,7 @@ | |||
57 | #define GNUNET_REST_IDENTITY_PARAM_PUBKEY "pubkey" | 57 | #define GNUNET_REST_IDENTITY_PARAM_PUBKEY "pubkey" |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Parameter public key | 60 | * Parameter private key |
61 | */ | 61 | */ |
62 | #define GNUNET_REST_IDENTITY_PARAM_PRIVKEY "privkey" | 62 | #define GNUNET_REST_IDENTITY_PARAM_PRIVKEY "privkey" |
63 | 63 | ||
@@ -990,6 +990,9 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, | |||
990 | json_t *data_js; | 990 | json_t *data_js; |
991 | json_error_t err; | 991 | json_error_t err; |
992 | char *egoname; | 992 | char *egoname; |
993 | char *privkey; | ||
994 | struct GNUNET_CRYPTO_EcdsaPrivateKey pk; | ||
995 | struct GNUNET_CRYPTO_EcdsaPrivateKey *pk_ptr; | ||
993 | int json_unpack_state; | 996 | int json_unpack_state; |
994 | char term_data[handle->data_size + 1]; | 997 | char term_data[handle->data_size + 1]; |
995 | 998 | ||
@@ -1016,8 +1019,11 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, | |||
1016 | return; | 1019 | return; |
1017 | } | 1020 | } |
1018 | json_unpack_state = 0; | 1021 | json_unpack_state = 0; |
1022 | privkey = NULL; | ||
1019 | json_unpack_state = | 1023 | json_unpack_state = |
1020 | json_unpack (data_js, "{s:s!}", GNUNET_REST_IDENTITY_PARAM_NAME, &egoname); | 1024 | json_unpack (data_js, "{s:s, s?:s!}", |
1025 | GNUNET_REST_IDENTITY_PARAM_NAME, &egoname, | ||
1026 | GNUNET_REST_IDENTITY_PARAM_PRIVKEY, &privkey); | ||
1021 | if (0 != json_unpack_state) | 1027 | if (0 != json_unpack_state) |
1022 | { | 1028 | { |
1023 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); | 1029 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); |
@@ -1054,10 +1060,21 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, | |||
1054 | } | 1060 | } |
1055 | } | 1061 | } |
1056 | handle->name = GNUNET_strdup (egoname); | 1062 | handle->name = GNUNET_strdup (egoname); |
1063 | if (NULL != privkey) | ||
1064 | { | ||
1065 | GNUNET_STRINGS_string_to_data (privkey, | ||
1066 | strlen (privkey), | ||
1067 | &pk, | ||
1068 | sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey)); | ||
1069 | pk_ptr = &pk; | ||
1070 | } | ||
1071 | else | ||
1072 | pk_ptr = NULL; | ||
1057 | json_decref (data_js); | 1073 | json_decref (data_js); |
1058 | handle->response_code = MHD_HTTP_CREATED; | 1074 | handle->response_code = MHD_HTTP_CREATED; |
1059 | handle->op = GNUNET_IDENTITY_create (handle->identity_handle, | 1075 | handle->op = GNUNET_IDENTITY_create (handle->identity_handle, |
1060 | handle->name, | 1076 | handle->name, |
1077 | pk_ptr, | ||
1061 | &do_finished_create, | 1078 | &do_finished_create, |
1062 | handle); | 1079 | handle); |
1063 | } | 1080 | } |
diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c index aaa435d4f..37eeab238 100644 --- a/src/identity/test_identity.c +++ b/src/identity/test_identity.c | |||
@@ -279,7 +279,7 @@ run (void *cls, | |||
279 | GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); | 279 | GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); |
280 | h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL); | 280 | h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL); |
281 | CHECK (NULL != h); | 281 | CHECK (NULL != h); |
282 | op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL); | 282 | op = GNUNET_IDENTITY_create (h, "test-id", NULL, &create_cb, NULL); |
283 | } | 283 | } |
284 | 284 | ||
285 | 285 | ||
diff --git a/src/identity/test_identity_defaults.c b/src/identity/test_identity_defaults.c index 1dd05f1b9..53eec1252 100644 --- a/src/identity/test_identity_defaults.c +++ b/src/identity/test_identity_defaults.c | |||
@@ -266,7 +266,7 @@ run_set (void *cls, | |||
266 | GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); | 266 | GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); |
267 | h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL); | 267 | h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL); |
268 | CHECK (NULL != h); | 268 | CHECK (NULL != h); |
269 | op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL); | 269 | op = GNUNET_IDENTITY_create (h, "test-id", NULL, &create_cb, NULL); |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index 81af671e2..f4e653598 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h | |||
@@ -233,6 +233,7 @@ typedef void | |||
233 | * | 233 | * |
234 | * @param id identity service to use | 234 | * @param id identity service to use |
235 | * @param name desired name | 235 | * @param name desired name |
236 | * @param privkey desired private key or NULL to create one | ||
236 | * @param cont function to call with the result (will only be called once) | 237 | * @param cont function to call with the result (will only be called once) |
237 | * @param cont_cls closure for @a cont | 238 | * @param cont_cls closure for @a cont |
238 | * @return handle to abort the operation | 239 | * @return handle to abort the operation |
@@ -240,6 +241,7 @@ typedef void | |||
240 | struct GNUNET_IDENTITY_Operation * | 241 | struct GNUNET_IDENTITY_Operation * |
241 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, | 242 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, |
242 | const char *name, | 243 | const char *name, |
244 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey, | ||
243 | GNUNET_IDENTITY_CreateContinuation cont, | 245 | GNUNET_IDENTITY_CreateContinuation cont, |
244 | void *cont_cls); | 246 | void *cont_cls); |
245 | 247 | ||
diff --git a/src/revocation/test_revocation.c b/src/revocation/test_revocation.c index f193d5f6c..1c2efa60f 100644 --- a/src/revocation/test_revocation.c +++ b/src/revocation/test_revocation.c | |||
@@ -237,10 +237,12 @@ identity_completion_cb (void *cls, | |||
237 | fprintf (stderr, "All peers connected @ IDENTITY ...\n"); | 237 | fprintf (stderr, "All peers connected @ IDENTITY ...\n"); |
238 | testpeers[0].create_id_op = GNUNET_IDENTITY_create (testpeers[0].idh, | 238 | testpeers[0].create_id_op = GNUNET_IDENTITY_create (testpeers[0].idh, |
239 | "client", | 239 | "client", |
240 | NULL, | ||
240 | &identity_create_cb, | 241 | &identity_create_cb, |
241 | &testpeers[0]); | 242 | &testpeers[0]); |
242 | testpeers[1].create_id_op = GNUNET_IDENTITY_create (testpeers[1].idh, | 243 | testpeers[1].create_id_op = GNUNET_IDENTITY_create (testpeers[1].idh, |
243 | "toberevoked", | 244 | "toberevoked", |
245 | NULL, | ||
244 | &identity_create_cb, | 246 | &identity_create_cb, |
245 | &testpeers[1]); | 247 | &testpeers[1]); |
246 | } | 248 | } |