aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/messenger_api.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2023-10-18 13:37:38 +0200
committerMartin Schanzenbach <schanzen@gnunet.org>2023-10-18 13:37:38 +0200
commit9ef4abad615bea12d13be542b8ae5fbeb2dfee32 (patch)
tree8875a687e004d331c9ea6a1d511a328c72b88113 /src/messenger/messenger_api.c
parente95236b3ed78cd597c15f34b89385295702b627f (diff)
downloadgnunet-9ef4abad615bea12d13be542b8ae5fbeb2dfee32.tar.gz
gnunet-9ef4abad615bea12d13be542b8ae5fbeb2dfee32.zip
NEWS: Refactoring components under src/ into lib/, plugin/, cli/ and service/
This also includes a necessary API refactoring of crypto from IDENTITY to UTIL.
Diffstat (limited to 'src/messenger/messenger_api.c')
-rw-r--r--src/messenger/messenger_api.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/messenger/messenger_api.c b/src/messenger/messenger_api.c
index 610c979c4..3604d0569 100644
--- a/src/messenger/messenger_api.c
+++ b/src/messenger/messenger_api.c
@@ -105,10 +105,10 @@ check_get_key (void *cls,
105 const uint16_t length = full_length - sizeof(*msg); 105 const uint16_t length = full_length - sizeof(*msg);
106 const char *buffer = ((const char*) msg) + sizeof(*msg); 106 const char *buffer = ((const char*) msg) + sizeof(*msg);
107 107
108 struct GNUNET_IDENTITY_PublicKey pubkey; 108 struct GNUNET_CRYPTO_PublicKey pubkey;
109 size_t read; 109 size_t read;
110 if (GNUNET_SYSERR == 110 if (GNUNET_SYSERR ==
111 GNUNET_IDENTITY_read_public_key_from_buffer(buffer, length, 111 GNUNET_CRYPTO_read_public_key_from_buffer(buffer, length,
112 &pubkey, &read)) 112 &pubkey, &read))
113 return GNUNET_NO; 113 return GNUNET_NO;
114 114
@@ -124,14 +124,14 @@ handle_get_key (void *cls,
124 const uint16_t length = ntohs (msg->header.size) - sizeof(*msg); 124 const uint16_t length = ntohs (msg->header.size) - sizeof(*msg);
125 const char *buffer = ((const char*) msg) + sizeof(*msg); 125 const char *buffer = ((const char*) msg) + sizeof(*msg);
126 126
127 struct GNUNET_IDENTITY_PublicKey pubkey; 127 struct GNUNET_CRYPTO_PublicKey pubkey;
128 size_t read; 128 size_t read;
129 if (GNUNET_SYSERR == 129 if (GNUNET_SYSERR ==
130 GNUNET_IDENTITY_read_public_key_from_buffer(buffer, length, 130 GNUNET_CRYPTO_read_public_key_from_buffer(buffer, length,
131 &pubkey, &read)) 131 &pubkey, &read))
132 return; 132 return;
133 133
134 char* str = GNUNET_IDENTITY_public_key_to_string (&pubkey); 134 char* str = GNUNET_CRYPTO_public_key_to_string (&pubkey);
135 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Set key of handle: %s\n", str); 135 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Set key of handle: %s\n", str);
136 GNUNET_free(str); 136 GNUNET_free(str);
137 137
@@ -534,8 +534,8 @@ GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle,
534 return GNUNET_YES; 534 return GNUNET_YES;
535} 535}
536 536
537static const struct GNUNET_IDENTITY_PublicKey* 537static const struct GNUNET_CRYPTO_PublicKey*
538get_non_anonymous_key (const struct GNUNET_IDENTITY_PublicKey* public_key) 538get_non_anonymous_key (const struct GNUNET_CRYPTO_PublicKey* public_key)
539{ 539{
540 if (0 == GNUNET_memcmp(public_key, get_anonymous_public_key())) 540 if (0 == GNUNET_memcmp(public_key, get_anonymous_public_key()))
541 return NULL; 541 return NULL;
@@ -543,7 +543,7 @@ get_non_anonymous_key (const struct GNUNET_IDENTITY_PublicKey* public_key)
543 return public_key; 543 return public_key;
544} 544}
545 545
546const struct GNUNET_IDENTITY_PublicKey* 546const struct GNUNET_CRYPTO_PublicKey*
547GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle) 547GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle)
548{ 548{
549 if (!handle) 549 if (!handle)
@@ -688,7 +688,7 @@ GNUNET_MESSENGER_contact_get_name (const struct GNUNET_MESSENGER_Contact *contac
688 return get_contact_name (contact); 688 return get_contact_name (contact);
689} 689}
690 690
691const struct GNUNET_IDENTITY_PublicKey* 691const struct GNUNET_CRYPTO_PublicKey*
692GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact) 692GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact)
693{ 693{
694 if (!contact) 694 if (!contact)
@@ -721,12 +721,12 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
721 721
722 if (contact) 722 if (contact)
723 { 723 {
724 const struct GNUNET_IDENTITY_PublicKey *public_key = get_non_anonymous_key ( 724 const struct GNUNET_CRYPTO_PublicKey *public_key = get_non_anonymous_key (
725 get_contact_key(contact) 725 get_contact_key(contact)
726 ); 726 );
727 727
728 if (public_key) 728 if (public_key)
729 key_length = GNUNET_IDENTITY_public_key_get_length(public_key); 729 key_length = GNUNET_CRYPTO_public_key_get_length(public_key);
730 else 730 else
731 key_length = -1; 731 key_length = -1;
732 } 732 }
@@ -759,7 +759,7 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
759 char *msg_buffer = buffer + key_length; 759 char *msg_buffer = buffer + key_length;
760 760
761 if (key_length > 0) 761 if (key_length > 0)
762 GNUNET_IDENTITY_write_public_key_to_buffer(get_contact_key(contact), buffer, key_length); 762 GNUNET_CRYPTO_write_public_key_to_buffer(get_contact_key(contact), buffer, key_length);
763 763
764 encode_message (message, msg_length, msg_buffer, GNUNET_NO); 764 encode_message (message, msg_length, msg_buffer, GNUNET_NO);
765 765