diff options
author | irungentoo <irungentoo@gmail.com> | 2014-07-30 10:29:46 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-07-30 10:29:46 -0400 |
commit | 07ddbb8858c06b6a717c4d3dd78953645a487dac (patch) | |
tree | d7d0725b184d071afab3d3da3ba8f3f3dacd854b | |
parent | 9a74e5d0581e2ce954e365aec470551785dbb844 (diff) |
Added function to get public and private key from Tox object.
-rw-r--r-- | toxcore/tox.c | 14 | ||||
-rw-r--r-- | toxcore/tox.h | 4 |
2 files changed, 18 insertions, 0 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index 1b6597ba..3c5db1e3 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -481,6 +481,20 @@ void tox_set_nospam(Tox *tox, uint32_t nospam) | |||
481 | set_nospam(&(m->fr), nospam); | 481 | set_nospam(&(m->fr), nospam); |
482 | } | 482 | } |
483 | 483 | ||
484 | /* Copy the public and secret key from the Tox object. | ||
485 | public_key and secret_key must be 32 bytes big. | ||
486 | if the pointer is NULL, no data will be copied to it.*/ | ||
487 | void tox_get_keys(Tox *tox, uint8_t *public_key, uint8_t *secret_key) | ||
488 | { | ||
489 | Messenger *m = tox; | ||
490 | |||
491 | if (public_key) | ||
492 | memcpy(public_key, m->net_crypto->self_public_key, crypto_box_PUBLICKEYBYTES); | ||
493 | |||
494 | if (secret_key) | ||
495 | memcpy(secret_key, m->net_crypto->self_secret_key, crypto_box_SECRETKEYBYTES); | ||
496 | } | ||
497 | |||
484 | /**********GROUP CHAT FUNCTIONS: WARNING Group chats will be rewritten so this might change ************/ | 498 | /**********GROUP CHAT FUNCTIONS: WARNING Group chats will be rewritten so this might change ************/ |
485 | 499 | ||
486 | /* Set the callback for group invites. | 500 | /* Set the callback for group invites. |
diff --git a/toxcore/tox.h b/toxcore/tox.h index 14426f31..39beb004 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -361,6 +361,10 @@ void tox_callback_connection_status(Tox *tox, void (*function)(Tox *tox, int32_t | |||
361 | uint32_t tox_get_nospam(const Tox *tox); | 361 | uint32_t tox_get_nospam(const Tox *tox); |
362 | void tox_set_nospam(Tox *tox, uint32_t nospam); | 362 | void tox_set_nospam(Tox *tox, uint32_t nospam); |
363 | 363 | ||
364 | /* Copy the public and secret key from the Tox object. | ||
365 | public_key and secret_key must be 32 bytes big. | ||
366 | if the pointer is NULL, no data will be copied to it.*/ | ||
367 | void tox_get_keys(Tox *tox, uint8_t *public_key, uint8_t *secret_key); | ||
364 | 368 | ||
365 | /**********GROUP CHAT FUNCTIONS: WARNING Group chats will be rewritten so this might change ************/ | 369 | /**********GROUP CHAT FUNCTIONS: WARNING Group chats will be rewritten so this might change ************/ |
366 | 370 | ||