GNUnet 0.26.2-16-ge86b66bd5
 
Loading...
Searching...
No Matches
messenger_api_message_kind.c File Reference
#include "messenger_api_message_kind.h"
#include "gnunet_common.h"
#include "gnunet_util_lib.h"
#include "messenger_api_message.h"
#include <string.h>
Include dependency graph for messenger_api_message_kind.c:

Go to the source code of this file.

Functions

struct GNUNET_MESSENGER_Messagecreate_message_join (const struct GNUNET_CRYPTO_BlindablePrivateKey *key, const struct GNUNET_CRYPTO_HpkePublicKey *hpke_key)
 Creates and allocates a new join message containing the clients public key.
 
struct GNUNET_MESSENGER_Messagecreate_message_leave (void)
 Creates and allocates a new leave message.
 
struct GNUNET_MESSENGER_Messagecreate_message_name (const char *name)
 Creates and allocates a new name message containing the name to change to.
 
struct GNUNET_MESSENGER_Messagecreate_message_key (const struct GNUNET_CRYPTO_BlindablePrivateKey *key, const struct GNUNET_CRYPTO_HpkePublicKey *hpke_key)
 Creates and allocates a new key message containing the public key to change to derived from its private counterpart.
 
struct GNUNET_MESSENGER_Messagecreate_message_id (const struct GNUNET_ShortHashCode *unique_id)
 Creates and allocates a new id message containing the unique member id to change to.
 
struct GNUNET_MESSENGER_Messagecreate_message_request (const struct GNUNET_HashCode *hash)
 Creates and allocates a new request message containing the hash of a missing message.
 
struct GNUNET_MESSENGER_Messagecreate_message_deletion (const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 Creates and allocates a new deletion message containing the hash of a message to delete after a specific delay.
 
struct GNUNET_MESSENGER_Messagecreate_message_subscription (const struct GNUNET_ShortHashCode *discourse, const struct GNUNET_TIME_Relative time, uint32_t flags)
 Creates and allocates a new subscribe message for a subscription of a given discourse with a specific time window and flags.
 
struct GNUNET_MESSENGER_Messagecreate_message_announcement (const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_CRYPTO_EcdhePrivateKey *private_key, const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key, const struct GNUNET_TIME_Relative timeout)
 Creates and allocates a new announcement message for an announcement of a given epoch or group under an identifier using a specific private_key and shared_key until a given timeout.
 
struct GNUNET_MESSENGER_Messagecreate_message_appeal (const struct GNUNET_HashCode *event, const struct GNUNET_CRYPTO_EcdhePrivateKey *private_key, const struct GNUNET_TIME_Relative timeout)
 Creates and allocates a new appeal message for an epoch announcement using a specific private_key to receive access before a given timeout.
 
struct GNUNET_MESSENGER_Messagecreate_message_access (const struct GNUNET_HashCode *event, const struct GNUNET_CRYPTO_EcdhePublicKey *public_key, const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key)
 Creates and allocates a new access message to grant access to the shared_key of an announced epoch or group depending on target event encrypting the shared key for a specific public_key.
 
struct GNUNET_MESSENGER_Messagecreate_message_revolution (const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key)
 Creates and allocates a new revolution message for an announced epoch or group selected by its identifier which is using a specific shared_key.
 
struct GNUNET_MESSENGER_Messagecreate_message_group (const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_HashCode *initiator, const struct GNUNET_HashCode *partner, const struct GNUNET_TIME_Relative timeout)
 Creates and allocates a new group message to propose a group formation between an initiator subgroup and another partner subgroup until a given timeout to improve further epoch key exchange.
 
struct GNUNET_MESSENGER_Messagecreate_message_authorization (const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_HashCode *event, const struct GNUNET_CRYPTO_SymmetricSessionKey *group_key, const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key)
 Creates and allocates a new authorization message to grant access to the shared_key of a specific group selected via its identifier following an announcement or a group formation event encrypting the shared key for a specific established group_key of selected group.
 

Function Documentation

◆ create_message_join()

struct GNUNET_MESSENGER_Message * create_message_join ( const struct GNUNET_CRYPTO_BlindablePrivateKey key,
const struct GNUNET_CRYPTO_HpkePublicKey hpke_key 
)

Creates and allocates a new join message containing the clients public key.

(all values are stored as copy)

The message also include the public hpke_key to receive encrypted messages using hybrid public key encryption.

Parameters
[in]keyPrivate key
[in]hpke_keyPublic key for HPKE
Returns
New message

Definition at line 34 of file messenger_api_message_kind.c.

36{
37 struct GNUNET_MESSENGER_Message *message;
38
39 if (! key)
40 return NULL;
41
43
44 if (! message)
45 return NULL;
46
47 memset (&(message->body.leave.epoch), 0,
48 sizeof (struct GNUNET_HashCode));
49
51 key, &(message->body.join.key)));
52
53 GNUNET_memcpy (&(message->body.join.hpke_key), hpke_key,
54 sizeof (message->body.join.hpke_key));
55
56 return message;
57}
struct GNUNET_HashCode key
The key used in the DHT.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_key_get_public(const struct GNUNET_CRYPTO_BlindablePrivateKey *privkey, struct GNUNET_CRYPTO_BlindablePublicKey *key)
Retrieves the public key representation of a private key.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
struct GNUNET_MESSENGER_Message * create_message(enum GNUNET_MESSENGER_MessageKind kind)
Creates and allocates a new message with a specific kind.
A 512-bit hashcode.
struct GNUNET_MESSENGER_MessageLeave leave
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_CRYPTO_BlindablePublicKey key
The senders blindable public key to verify its signatures.
struct GNUNET_CRYPTO_HpkePublicKey hpke_key
The senders HPKE public key to encrypt private messages with.
struct GNUNET_HashCode epoch
The previous epoch the message was sent from.
struct GNUNET_MESSENGER_MessageBody body
Body.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_MessageLeave::epoch, GNUNET_assert, GNUNET_CRYPTO_blindable_key_get_public(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_JOIN, GNUNET_OK, GNUNET_MESSENGER_MessageJoin::hpke_key, GNUNET_MESSENGER_MessageBody::join, key, GNUNET_MESSENGER_MessageJoin::key, and GNUNET_MESSENGER_MessageBody::leave.

Referenced by handle_member_id().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_leave()

struct GNUNET_MESSENGER_Message * create_message_leave ( void  )

Creates and allocates a new leave message.

Returns
New message

Definition at line 61 of file messenger_api_message_kind.c.

62{
63 struct GNUNET_MESSENGER_Message *message;
64
66
67 if (! message)
68 return NULL;
69
70 memset (&(message->body.leave.epoch), 0,
71 sizeof (struct GNUNET_HashCode));
72
73 return message;
74}
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_MessageLeave::epoch, GNUNET_MESSENGER_KIND_LEAVE, and GNUNET_MESSENGER_MessageBody::leave.

Referenced by GNUNET_MESSENGER_close_room().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_name()

struct GNUNET_MESSENGER_Message * create_message_name ( const char *  name)

Creates and allocates a new name message containing the name to change to.

(all values are stored as copy)

Parameters
[in]nameNew name
Returns
New message

Definition at line 78 of file messenger_api_message_kind.c.

79{
80 struct GNUNET_MESSENGER_Message *message;
81
82 if (! name)
83 return NULL;
84
86
87 if (! message)
88 return NULL;
89
90 message->body.name.name = GNUNET_strdup (name);
91 return message;
92}
static char * name
Name (label) of the records to list.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
struct GNUNET_MESSENGER_MessageName name
char * name
The new name which replaces the current senders name.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_KIND_NAME, GNUNET_strdup, name, GNUNET_MESSENGER_MessageName::name, and GNUNET_MESSENGER_MessageBody::name.

Referenced by iterate_send_name_to_room().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_key()

struct GNUNET_MESSENGER_Message * create_message_key ( const struct GNUNET_CRYPTO_BlindablePrivateKey key,
const struct GNUNET_CRYPTO_HpkePublicKey hpke_key 
)

Creates and allocates a new key message containing the public key to change to derived from its private counterpart.

(all values are stored as copy)

The message also include the public hpke_key to receive encrypted messages using hybrid public key encryption.

Parameters
[in]keyPrivate key
[in]hpke_keyPublic key for HPKE
Returns
New message

Definition at line 96 of file messenger_api_message_kind.c.

98{
99 struct GNUNET_MESSENGER_Message *message;
100
101 if (! key)
102 return NULL;
103
105
106 if (! message)
107 return NULL;
108
110 key, &(message->body.key.key)));
111
112 GNUNET_memcpy (&(message->body.join.hpke_key), hpke_key,
113 sizeof (message->body.key.hpke_key));
114
115 return message;
116}
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
struct GNUNET_MESSENGER_MessageKey key
struct GNUNET_CRYPTO_BlindablePublicKey key
The new blindable public key which replaces the current senders public key.
struct GNUNET_CRYPTO_HpkePublicKey hpke_key
The new HPKE public key which replaces the current senders HPKE public key.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_assert, GNUNET_CRYPTO_blindable_key_get_public(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_KEY, GNUNET_OK, GNUNET_MESSENGER_MessageJoin::hpke_key, GNUNET_MESSENGER_MessageKey::hpke_key, GNUNET_MESSENGER_MessageBody::join, key, GNUNET_MESSENGER_MessageKey::key, and GNUNET_MESSENGER_MessageBody::key.

Referenced by iterate_send_key_to_room().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_id()

struct GNUNET_MESSENGER_Message * create_message_id ( const struct GNUNET_ShortHashCode unique_id)

Creates and allocates a new id message containing the unique member id to change to.

(all values are stored as copy)

Parameters
[in]unique_idUnique member id
Returns
New message

Definition at line 120 of file messenger_api_message_kind.c.

121{
122 struct GNUNET_MESSENGER_Message *message;
123
124 if (! unique_id)
125 return NULL;
126
128
129 if (! message)
130 return NULL;
131
132 GNUNET_memcpy (&(message->body.id.id), unique_id,
133 sizeof(struct GNUNET_ShortHashCode));
134
135 return message;
136}
@ GNUNET_MESSENGER_KIND_ID
The id kind.
struct GNUNET_MESSENGER_MessageId id
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.
A 256-bit hashcode.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_MessageId::id, and GNUNET_MESSENGER_MessageBody::id.

Referenced by handle_member_id().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_request()

struct GNUNET_MESSENGER_Message * create_message_request ( const struct GNUNET_HashCode hash)

Creates and allocates a new request message containing the hash of a missing message.

(all values are stored as copy)

Parameters
[in]hashHash of message
Returns
New message

Definition at line 140 of file messenger_api_message_kind.c.

141{
142 struct GNUNET_MESSENGER_Message *message;
143
144 if (! hash)
145 return NULL;
146
147 {
148 struct GNUNET_HashCode zero;
149 memset (&zero, 0, sizeof(zero));
150
151 if (0 == GNUNET_CRYPTO_hash_cmp (hash, &zero))
152 return NULL;
153 }
154
156
157 if (! message)
158 return NULL;
159
160 GNUNET_memcpy (&(message->body.request.hash), hash, sizeof(struct
162
163 return message;
164}
static const struct GNUNET_CRYPTO_BlindablePrivateKey zero
Public key of all zeros.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
struct GNUNET_MESSENGER_MessageRequest request
struct GNUNET_HashCode hash
The hash of the requested message.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_CRYPTO_hash_cmp(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MessageBody::request, and zero.

Referenced by handle_miss_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_deletion()

struct GNUNET_MESSENGER_Message * create_message_deletion ( const struct GNUNET_HashCode hash,
const struct GNUNET_TIME_Relative  delay 
)

Creates and allocates a new deletion message containing the hash of a message to delete after a specific delay.

(all values are stored as copy)

Parameters
[in]hashHash of message
[in]delayDelay of deletion
Returns
New message

Definition at line 168 of file messenger_api_message_kind.c.

170{
171 struct GNUNET_MESSENGER_Message *message;
172
173 if (! hash)
174 return NULL;
175
177
178 if (! message)
179 return NULL;
180
181 GNUNET_memcpy (&(message->body.deletion.hash), hash, sizeof(struct
183 message->body.deletion.delay = GNUNET_TIME_relative_hton (delay);
184
185 return message;
186}
@ GNUNET_MESSENGER_KIND_DELETION
The deletion kind.
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition time.c:616
struct GNUNET_MESSENGER_MessageDeletion deletion
struct GNUNET_HashCode hash
The hash of the message to delete.
struct GNUNET_TIME_RelativeNBO delay
The delay of the delete operation to get processed.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_MessageDeletion::delay, GNUNET_MESSENGER_MessageBody::deletion, GNUNET_memcpy, GNUNET_MESSENGER_KIND_DELETION, GNUNET_TIME_relative_hton(), and GNUNET_MESSENGER_MessageDeletion::hash.

Referenced by delete_room_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_subscription()

struct GNUNET_MESSENGER_Message * create_message_subscription ( const struct GNUNET_ShortHashCode discourse,
const struct GNUNET_TIME_Relative  time,
uint32_t  flags 
)

Creates and allocates a new subscribe message for a subscription of a given discourse with a specific time window and flags.

(all values are stored as copy)

Parameters
[in]discourseDiscourse
[in]timeTime of subscription
[in]flagsSubscription flags
Returns
New message

Definition at line 190 of file messenger_api_message_kind.c.

193{
194 struct GNUNET_MESSENGER_Message *message;
195
196 if (! discourse)
197 return NULL;
198
200
201 if (! message)
202 return NULL;
203
204 GNUNET_memcpy (&(message->body.subscription.discourse), discourse,
205 sizeof (struct GNUNET_ShortHashCode));
206
208 message->body.subscription.flags = flags;
209
210 return message;
211}
@ GNUNET_MESSENGER_KIND_SUBSCRIBTION
The subscription kind.
struct GNUNET_MESSENGER_MessageSubscribtion subscription
uint32_t flags
The flags about the subscription to a discourse.
struct GNUNET_TIME_RelativeNBO time
The time window of the subscription.
struct GNUNET_ShortHashCode discourse
The hash of the discourse to subscription.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_MessageSubscribtion::discourse, GNUNET_MESSENGER_MessageSubscribtion::flags, GNUNET_memcpy, GNUNET_MESSENGER_KIND_SUBSCRIBTION, GNUNET_TIME_relative_hton(), GNUNET_MESSENGER_MessageBody::subscription, and GNUNET_MESSENGER_MessageSubscribtion::time.

Referenced by handle_discourse_subscription().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_announcement()

struct GNUNET_MESSENGER_Message * create_message_announcement ( const union GNUNET_MESSENGER_EpochIdentifier identifier,
const struct GNUNET_CRYPTO_EcdhePrivateKey private_key,
const struct GNUNET_CRYPTO_SymmetricSessionKey shared_key,
const struct GNUNET_TIME_Relative  timeout 
)

Creates and allocates a new announcement message for an announcement of a given epoch or group under an identifier using a specific private_key and shared_key until a given timeout.

Parameters
[in]identifierEpoch identifier
[in]private_keyPrivate key
[in]shared_keyShared key
[in]timeoutTimeout
Returns
New message

Definition at line 215 of file messenger_api_message_kind.c.

222{
223 struct GNUNET_MESSENGER_Message *message;
224
225 if ((! identifier) || (! private_key) || (! shared_key))
226 return NULL;
227
229
230 if (! message)
231 return NULL;
232
233 GNUNET_memcpy (&(message->body.announcement.identifier), identifier,
234 sizeof (message->body.announcement.identifier));
235
237 private_key, &(message->body.announcement.key));
238
242
244
245 sign_message_by_key (message, shared_key);
246
247 return message;
248}
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition gnunet-arm.c:118
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
void GNUNET_CRYPTO_ecdhe_key_get_public(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Extract the public key for the given private key.
Definition crypto_ecc.c:217
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
#define GNUNET_MESSENGER_EPOCH_NONCE_BYTES
@ GNUNET_MESSENGER_KIND_ANNOUNCEMENT
The announcement kind.
void sign_message_by_key(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_SymmetricSessionKey *key)
Signs the message body via it's own hmac with a specific shared key.
uint8_t nonce[sizeof(struct GNUNET_ShortHashCode)]
union GNUNET_MESSENGER_EpochNonce nonce
The nonce of the announcement.
struct GNUNET_TIME_RelativeNBO timeout
The timeout of the announcement.
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the announcement in an epoch.
struct GNUNET_CRYPTO_EcdhePublicKey key
The public key to appeal access.
struct GNUNET_MESSENGER_MessageAnnouncement announcement
struct GNUNET_MESSENGER_EpochNonceData data

References GNUNET_MESSENGER_MessageBody::announcement, GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_EpochNonce::data, GNUNET_CRYPTO_ecdhe_key_get_public(), GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_block(), GNUNET_memcpy, GNUNET_MESSENGER_EPOCH_NONCE_BYTES, GNUNET_MESSENGER_KIND_ANNOUNCEMENT, GNUNET_TIME_relative_hton(), GNUNET_MESSENGER_MessageAnnouncement::identifier, GNUNET_MESSENGER_MessageAnnouncement::key, GNUNET_MESSENGER_EpochNonceData::nonce, GNUNET_MESSENGER_MessageAnnouncement::nonce, sign_message_by_key(), timeout, and GNUNET_MESSENGER_MessageAnnouncement::timeout.

Referenced by send_epoch_announcement(), and send_epoch_group_announcement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_appeal()

struct GNUNET_MESSENGER_Message * create_message_appeal ( const struct GNUNET_HashCode event,
const struct GNUNET_CRYPTO_EcdhePrivateKey private_key,
const struct GNUNET_TIME_Relative  timeout 
)

Creates and allocates a new appeal message for an epoch announcement using a specific private_key to receive access before a given timeout.

Parameters
[in]eventHash of announcement event
[in]private_keyPrivate key
[in]timeoutTimeout
Returns
New message

Definition at line 252 of file messenger_api_message_kind.c.

255{
256 struct GNUNET_MESSENGER_Message *message;
257
258 if ((! event) || (! private_key))
259 return NULL;
260
262
263 if (! message)
264 return NULL;
265
266 GNUNET_memcpy (&(message->body.appeal.event), event,
267 sizeof (message->body.appeal.event));
268
270 private_key, &(message->body.appeal.key));
271
273
274 return message;
275}
@ GNUNET_MESSENGER_KIND_APPEAL
The appeal kind.
struct GNUNET_CRYPTO_EcdhePublicKey key
The public key to receive access.
struct GNUNET_TIME_RelativeNBO timeout
The timeout of the appeal.
struct GNUNET_HashCode event
The hash of the linked announcement message event.
struct GNUNET_MESSENGER_MessageAppeal appeal

References GNUNET_MESSENGER_MessageBody::appeal, GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_MessageAppeal::event, GNUNET_CRYPTO_ecdhe_key_get_public(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_APPEAL, GNUNET_TIME_relative_hton(), GNUNET_MESSENGER_MessageAppeal::key, timeout, and GNUNET_MESSENGER_MessageAppeal::timeout.

Referenced by send_epoch_announcement_appeal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_access()

struct GNUNET_MESSENGER_Message * create_message_access ( const struct GNUNET_HashCode event,
const struct GNUNET_CRYPTO_EcdhePublicKey public_key,
const struct GNUNET_CRYPTO_SymmetricSessionKey shared_key 
)

Creates and allocates a new access message to grant access to the shared_key of an announced epoch or group depending on target event encrypting the shared key for a specific public_key.

Parameters
[in]eventHash of appeal or group formation event
[in]public_keyPublic key
[in]shared_keyShared key
Returns
New message

Definition at line 279 of file messenger_api_message_kind.c.

283{
284 struct GNUNET_MESSENGER_Message *message;
285 struct GNUNET_CRYPTO_HpkePublicKey public_hpke;
286
287 if ((! event) || (! public_key) || (! shared_key))
288 return NULL;
289
291
292 if (! message)
293 return NULL;
294
295 GNUNET_memcpy (&public_hpke.ecdhe_key,
296 public_key,
297 sizeof *public_key);
298 if (GNUNET_OK != GNUNET_CRYPTO_hpke_seal_oneshot (&public_hpke,
299 (const uint8_t*)
300 "messenger",
301 strlen ("messenger"),
302 NULL,
303 0,
304 (const uint8_t*) shared_key,
305 sizeof (*shared_key),
306 message->body.access.key,
307 NULL))
308 {
309 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Encrypting key failed!\n");
310
311 destroy_message (message);
312 return NULL;
313 }
314
315 GNUNET_memcpy (&(message->body.access.event), event,
316 sizeof (message->body.access.event));
317
318 sign_message_by_key (message, shared_key);
319
320 return message;
321}
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_seal_oneshot(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const uint8_t *info, size_t info_len, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *ct, unsigned long long *ct_len)
RFC9180 HPKE encryption.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_MESSENGER_KIND_ACCESS
The access kind.
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
A public key used for encryption.
struct GNUNET_HashCode event
The hash of the linked announcement or group message event.
uint8_t key[sizeof(struct GNUNET_CRYPTO_SymmetricSessionKey)+16+sizeof(struct GNUNET_CRYPTO_HpkeEncapsulation)]
The encrypted group or epoch key.
struct GNUNET_MESSENGER_MessageAccess access

References GNUNET_MESSENGER_MessageBody::access, GNUNET_MESSENGER_Message::body, create_message(), destroy_message(), GNUNET_CRYPTO_HpkePublicKey::ecdhe_key, GNUNET_MESSENGER_MessageAccess::event, GNUNET_CRYPTO_hpke_seal_oneshot(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcpy, GNUNET_MESSENGER_KIND_ACCESS, GNUNET_OK, GNUNET_MESSENGER_MessageAccess::key, and sign_message_by_key().

Referenced by send_epoch_announcement_access(), and send_epoch_group_access().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_revolution()

struct GNUNET_MESSENGER_Message * create_message_revolution ( const union GNUNET_MESSENGER_EpochIdentifier identifier,
const struct GNUNET_CRYPTO_SymmetricSessionKey shared_key 
)

Creates and allocates a new revolution message for an announced epoch or group selected by its identifier which is using a specific shared_key.

Parameters
[in]identifierEpoch identifier
[in]shared_keyShared key
Returns
New message

Definition at line 325 of file messenger_api_message_kind.c.

329{
330 struct GNUNET_MESSENGER_Message *message;
331
332 if ((! identifier) || (! shared_key))
333 return NULL;
334
336
337 if (! message)
338 return NULL;
339
340 GNUNET_memcpy (&(message->body.revolution.identifier), identifier,
341 sizeof (message->body.revolution.identifier));
342
344 message->body.revolution.nonce.data.nonce,
346
347 sign_message_by_key (message, shared_key);
348
349 return message;
350}
@ GNUNET_MESSENGER_KIND_REVOLUTION
The revolution kind.
struct GNUNET_MESSENGER_MessageRevolution revolution
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the announcement in an epoch.
union GNUNET_MESSENGER_EpochNonce nonce
The nonce of the revolution.

References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_EpochNonce::data, GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_block(), GNUNET_memcpy, GNUNET_MESSENGER_EPOCH_NONCE_BYTES, GNUNET_MESSENGER_KIND_REVOLUTION, GNUNET_MESSENGER_MessageRevolution::identifier, GNUNET_MESSENGER_EpochNonceData::nonce, GNUNET_MESSENGER_MessageRevolution::nonce, GNUNET_MESSENGER_MessageBody::revolution, and sign_message_by_key().

Referenced by send_epoch_announcement_revolution(), and send_epoch_group_revolution().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_group()

struct GNUNET_MESSENGER_Message * create_message_group ( const union GNUNET_MESSENGER_EpochIdentifier identifier,
const struct GNUNET_HashCode initiator,
const struct GNUNET_HashCode partner,
const struct GNUNET_TIME_Relative  timeout 
)

Creates and allocates a new group message to propose a group formation between an initiator subgroup and another partner subgroup until a given timeout to improve further epoch key exchange.

Parameters
[in]identifierGroup identifier
[in]initiatorInitiator group identifier
[in]partnerPartner group identifier
[in]timeoutTimeout
Returns
New message

Definition at line 354 of file messenger_api_message_kind.c.

358{
359 struct GNUNET_MESSENGER_Message *message;
360
361 if ((! identifier) || (! initiator) || (! partner) ||
362 (! identifier->code.group_bit))
363 return NULL;
364
366
367 if (! message)
368 return NULL;
369
370 GNUNET_memcpy (&(message->body.group.identifier), identifier,
371 sizeof (message->body.group.identifier));
372 GNUNET_memcpy (&(message->body.group.initiator), initiator,
373 sizeof (message->body.group.initiator));
374 GNUNET_memcpy (&(message->body.group.partner), partner,
375 sizeof (message->body.group.partner));
376
378
379 return message;
380}
@ GNUNET_MESSENGER_KIND_GROUP
The group kind.
struct GNUNET_MESSENGER_MessageGroup group
struct GNUNET_TIME_RelativeNBO timeout
The timeout of the group formation.
struct GNUNET_HashCode initiator
The hash of the initiator group announcement.
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the group in an epoch.
struct GNUNET_HashCode partner
The hash of the partner group announcement.
struct GNUNET_MESSENGER_EpochIdentifierCode code

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochIdentifier::code, create_message(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_GROUP, GNUNET_TIME_relative_hton(), GNUNET_MESSENGER_MessageBody::group, GNUNET_MESSENGER_EpochIdentifierCode::group_bit, GNUNET_MESSENGER_MessageGroup::identifier, GNUNET_MESSENGER_MessageGroup::initiator, GNUNET_MESSENGER_MessageGroup::partner, timeout, and GNUNET_MESSENGER_MessageGroup::timeout.

Referenced by send_epoch_group().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_message_authorization()

struct GNUNET_MESSENGER_Message * create_message_authorization ( const union GNUNET_MESSENGER_EpochIdentifier identifier,
const struct GNUNET_HashCode event,
const struct GNUNET_CRYPTO_SymmetricSessionKey group_key,
const struct GNUNET_CRYPTO_SymmetricSessionKey shared_key 
)

Creates and allocates a new authorization message to grant access to the shared_key of a specific group selected via its identifier following an announcement or a group formation event encrypting the shared key for a specific established group_key of selected group.

Parameters
[in]identifierGroup identifier
[in]eventHash of announcement or group formation event
[in]group_keyEstablished group key
[in]shared_keyShared key
Returns
New message

Definition at line 384 of file messenger_api_message_kind.c.

391{
392 struct GNUNET_MESSENGER_Message *message;
394
395 if ((! identifier) || (! event) || (! group_key) || (! shared_key))
396 return NULL;
397
399
400 if (! message)
401 return NULL;
402
403 GNUNET_CRYPTO_symmetric_derive_iv (&iv, group_key,
404 event, sizeof (*event),
405 identifier, sizeof (*identifier),
406 NULL);
407
408 if (-1 == GNUNET_CRYPTO_symmetric_encrypt (shared_key,
410 group_key,
411 &iv,
412 message->body.authorization.key))
413 {
414 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Encrypting key failed!\n");
415
416 destroy_message (message);
417 return NULL;
418 }
419
420 GNUNET_memcpy (&(message->body.authorization.identifier), identifier,
421 sizeof (message->body.authorization.identifier));
422 GNUNET_memcpy (&(message->body.authorization.event), event,
423 sizeof (message->body.authorization.event));
424
425 sign_message_by_key (message, shared_key);
426
427 return message;
428}
ssize_t GNUNET_CRYPTO_symmetric_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Encrypt a block using a symmetric sessionkey.
void GNUNET_CRYPTO_symmetric_derive_iv(struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, const void *salt, size_t salt_len,...)
Derive an IV.
#define GNUNET_MESSENGER_AUTHORIZATION_KEY_BYTES
@ GNUNET_MESSENGER_KIND_AUTHORIZATION
The authorization kind.
struct GNUNET_HashCode event
The hash of the linked group message event.
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the group in an epoch.
uint8_t key[sizeof(struct GNUNET_CRYPTO_SymmetricSessionKey)]
The encrypted group or epoch key.
struct GNUNET_MESSENGER_MessageAuthorization authorization

References GNUNET_MESSENGER_MessageBody::authorization, GNUNET_MESSENGER_Message::body, create_message(), destroy_message(), GNUNET_MESSENGER_MessageAuthorization::event, GNUNET_CRYPTO_symmetric_derive_iv(), GNUNET_CRYPTO_symmetric_encrypt(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcpy, GNUNET_MESSENGER_AUTHORIZATION_KEY_BYTES, GNUNET_MESSENGER_KIND_AUTHORIZATION, GNUNET_MESSENGER_MessageAuthorization::identifier, GNUNET_MESSENGER_MessageAuthorization::key, and sign_message_by_key().

Referenced by send_epoch_announcement_authorization(), and send_epoch_group_authorization().

Here is the call graph for this function:
Here is the caller graph for this function: