#include "messenger_api_message.h"
#include "gnunet_common.h"
#include "gnunet_messenger_service.h"
#include "gnunet_signatures.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_MessageSignature |
struct | GNUNET_MESSENGER_ShortMessage |
Macros | |
#define | member_size(type, member) sizeof(((type*) NULL)->member) |
#define | max(x, y) (x > y? x : y) |
#define | min(x, y) (x < y? x : y) |
#define | encode_step_ext(dst, offset, src, size) |
#define | encode_step(dst, offset, src) |
#define | encode_step_key(dst, offset, src, length) |
#define | encode_step_signature(dst, offset, src, length) |
#define | decode_step_ext(src, offset, dst, size) |
#define | decode_step(src, offset, dst) |
#define | decode_step_malloc(src, offset, dst, size, zero) |
#define | decode_step_key(src, offset, dst, length) |
Typedefs | |
typedef uint32_t | kind_t |
Functions | |
struct GNUNET_MESSENGER_Message * | create_message (enum GNUNET_MESSENGER_MessageKind kind) |
Creates and allocates a new message with a specific kind. More... | |
struct GNUNET_MESSENGER_Message * | copy_message (const struct GNUNET_MESSENGER_Message *message) |
Creates and allocates a copy of a given message. More... | |
void | copy_message_header (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_MESSENGER_MessageHeader *header) |
Copy message header details from another message to a given message. More... | |
static void | destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, struct GNUNET_MESSENGER_MessageBody *body) |
void | cleanup_message (struct GNUNET_MESSENGER_Message *message) |
Frees the messages body memory. More... | |
void | destroy_message (struct GNUNET_MESSENGER_Message *message) |
Destroys a message and frees its memory fully. More... | |
enum GNUNET_GenericReturnValue | is_message_session_bound (const struct GNUNET_MESSENGER_Message *message) |
Returns if the message should be bound to a member session. More... | |
static void | fold_short_message (const struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_ShortMessage *shortened) |
static void | unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, struct GNUNET_MESSENGER_Message *message) |
static uint16_t | get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind) |
uint16_t | get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind, enum GNUNET_GenericReturnValue include_header) |
Returns the minimal size in bytes to encode a message of a specific kind. More... | |
static uint16_t | get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body) |
uint16_t | get_message_size (const struct GNUNET_MESSENGER_Message *message, enum GNUNET_GenericReturnValue include_header) |
Returns the exact size in bytes to encode a given message. More... | |
static uint16_t | get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, enum GNUNET_GenericReturnValue include_body) |
static uint16_t | calc_usual_padding () |
static uint16_t | calc_padded_length (uint16_t length) |
static void | encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body, uint16_t length, char *buffer, uint16_t offset) |
void | encode_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, enum GNUNET_GenericReturnValue include_header) |
Encodes a given message into a buffer of a maximal length in bytes. More... | |
static void | encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, char *buffer) |
static uint16_t | decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, struct GNUNET_MESSENGER_MessageBody *body, uint16_t length, const char *buffer, uint16_t offset) |
enum GNUNET_GenericReturnValue | decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, enum GNUNET_GenericReturnValue include_header, uint16_t *padding) |
Decodes a message from a given buffer of a maximal length in bytes. More... | |
static enum GNUNET_GenericReturnValue | decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, const char *buffer) |
void | hash_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, struct GNUNET_HashCode *hash) |
Calculates a hash of a given buffer with a length in bytes from a message. More... | |
void | sign_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_PrivateKey *key) |
Signs the hash of a message with a given private key and writes the signature into the buffer as well. More... | |
void | sign_message_by_peer (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Signs the hash of a message with the peer identity of a given config and writes the signature into the buffer as well. More... | |
enum GNUNET_GenericReturnValue | verify_message (const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_PublicKey *key) |
Verifies the signature of a given message and its hash with a specific public key. More... | |
enum GNUNET_GenericReturnValue | verify_message_by_peer (const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_PeerIdentity *identity) |
Verifies the signature of a given message and its hash with a specific peer's identity. More... | |
enum GNUNET_GenericReturnValue | encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PublicKey *key) |
Encrypts a message using a given public key and replaces its body and kind with the now private encrypted message. More... | |
enum GNUNET_GenericReturnValue | decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PrivateKey *key) |
Decrypts a private message using a given private key and replaces its body and kind with the inner encrypted message. More... | |
struct GNUNET_MESSENGER_Message * | transcribe_message (const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PublicKey *key) |
Transcribes a message as a new transcript message using a given public key from the recipient of the encrypted message content. More... | |
enum GNUNET_GenericReturnValue | read_transcript_message (struct GNUNET_MESSENGER_Message *message) |
Read the original message from a transcript message and replaces its body and kind with the inner encrypted message. More... | |
struct GNUNET_MQ_Envelope * | pack_message (struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, const GNUNET_MESSENGER_SignFunction sign, enum GNUNET_MESSENGER_PackMode mode, const void *cls) |
Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_PACK_MODE_ENVELOPE. More... | |
enum GNUNET_GenericReturnValue | is_peer_message (const struct GNUNET_MESSENGER_Message *message) |
Returns whether a specific kind of message can be sent by the service without usage of a clients private key. More... | |
enum GNUNET_GenericReturnValue | is_service_message (const struct GNUNET_MESSENGER_Message *message) |
Returns whether a specific kind of message contains service critical information. More... | |
enum GNUNET_GenericReturnValue | filter_message_sending (const struct GNUNET_MESSENGER_Message *message) |
Returns whether a specific kind of message should be sent by a client. More... | |
const struct GNUNET_ShortHashCode * | get_message_discourse (const struct GNUNET_MESSENGER_Message *message) |
Returns the discourse hash of a message depending on its kind. More... | |
Variables | |
const uint16_t | encryption_overhead |
Definition at line 283 of file messenger_api_message.c.
#define max | ( | x, | |
y | |||
) | (x > y? x : y) |
Definition at line 495 of file messenger_api_message.c.
#define min | ( | x, | |
y | |||
) | (x < y? x : y) |
Definition at line 525 of file messenger_api_message.c.
#define encode_step_ext | ( | dst, | |
offset, | |||
src, | |||
size | |||
) |
#define encode_step | ( | dst, | |
offset, | |||
src | |||
) |
Definition at line 532 of file messenger_api_message.c.
#define encode_step_key | ( | dst, | |
offset, | |||
src, | |||
length | |||
) |
Definition at line 536 of file messenger_api_message.c.
#define encode_step_signature | ( | dst, | |
offset, | |||
src, | |||
length | |||
) |
Definition at line 546 of file messenger_api_message.c.
#define decode_step_ext | ( | src, | |
offset, | |||
dst, | |||
size | |||
) |
Definition at line 768 of file messenger_api_message.c.
#define decode_step | ( | src, | |
offset, | |||
dst | |||
) |
Definition at line 773 of file messenger_api_message.c.
Definition at line 777 of file messenger_api_message.c.
#define decode_step_key | ( | src, | |
offset, | |||
dst, | |||
length | |||
) |
Definition at line 783 of file messenger_api_message.c.
typedef uint32_t kind_t |
Definition at line 364 of file messenger_api_message.c.
struct GNUNET_MESSENGER_Message * create_message | ( | enum GNUNET_MESSENGER_MessageKind | kind | ) |
Creates and allocates a new message with a specific kind.
[in] | kind | Kind of message |
Definition at line 48 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessagePrivate::data, GNUNET_MESSENGER_MessageTranscript::data, GNUNET_MESSENGER_MessageTalk::data, GNUNET_MESSENGER_MessageBody::file, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_TICKET, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_new, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageTicket::identifier, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageTranscript::length, GNUNET_MESSENGER_MessageTalk::length, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageTag::tag, GNUNET_MESSENGER_MessageBody::tag, GNUNET_MESSENGER_MessageBody::talk, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, GNUNET_MESSENGER_MessageBody::ticket, GNUNET_MESSENGER_MessageBody::transcript, and GNUNET_MESSENGER_MessageFile::uri.
Referenced by create_message_connection(), create_message_delete(), create_message_id(), create_message_info(), create_message_join(), create_message_key(), create_message_leave(), create_message_merge(), create_message_miss(), create_message_name(), create_message_peer(), create_message_request(), create_message_subscribe(), get_store_message(), and transcribe_message().
struct GNUNET_MESSENGER_Message * copy_message | ( | const struct GNUNET_MESSENGER_Message * | message | ) |
Creates and allocates a copy of a given message.
[in] | message | Message |
Definition at line 93 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessagePrivate::data, GNUNET_MESSENGER_MessageTranscript::data, GNUNET_MESSENGER_MessageTalk::data, GNUNET_MESSENGER_MessageBody::file, GNUNET_assert, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_TICKET, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_new, GNUNET_strdup, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageTicket::identifier, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageTranscript::length, GNUNET_MESSENGER_MessageTalk::length, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageTag::tag, GNUNET_MESSENGER_MessageBody::tag, GNUNET_MESSENGER_MessageBody::talk, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, GNUNET_MESSENGER_MessageBody::ticket, GNUNET_MESSENGER_MessageBody::transcript, and GNUNET_MESSENGER_MessageFile::uri.
Referenced by enqueue_message_control(), forward_tunnel_message(), GNUNET_MESSENGER_send_message(), handle_private_message(), handle_room_message(), handle_transcript_message(), handle_tunnel_message(), and send_srv_handle_message().
void copy_message_header | ( | struct GNUNET_MESSENGER_Message * | message, |
const struct GNUNET_MESSENGER_MessageHeader * | header | ||
) |
Copy message header details from another message to a given message.
[in,out] | message | Message |
[in] | header | Message header |
Definition at line 161 of file messenger_api_message.c.
References GNUNET_assert, GNUNET_memcpy, GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::kind.
Referenced by handle_room_message(), and handle_transcript_message().
|
static |
Definition at line 178 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessagePrivate::data, GNUNET_MESSENGER_MessageTranscript::data, GNUNET_MESSENGER_MessageTalk::data, GNUNET_MESSENGER_MessageBody::file, GNUNET_assert, GNUNET_free, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_TICKET, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_MESSENGER_MessageTicket::identifier, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageTag::tag, GNUNET_MESSENGER_MessageBody::tag, GNUNET_MESSENGER_MessageBody::talk, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, GNUNET_MESSENGER_MessageBody::ticket, GNUNET_MESSENGER_MessageBody::transcript, and GNUNET_MESSENGER_MessageFile::uri.
Referenced by cleanup_message(), destroy_message(), encrypt_message(), and unfold_short_message().
void cleanup_message | ( | struct GNUNET_MESSENGER_Message * | message | ) |
Frees the messages body memory.
[in,out] | message | Message |
Definition at line 224 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, destroy_message_body(), GNUNET_assert, GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::kind.
Referenced by check_recv_message(), check_send_message(), handle_recv_message(), handle_send_message(), and handle_tunnel_message().
void destroy_message | ( | struct GNUNET_MESSENGER_Message * | message | ) |
Destroys a message and frees its memory fully.
[in,out] | message | Message |
Definition at line 233 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, destroy_message_body(), GNUNET_assert, GNUNET_free, GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::kind.
Referenced by clear_queue_messages(), create_message_peer(), dequeue_from_messages(), dequeue_message_from_room(), destroy_message_control(), enqueue_to_messages(), forward_tunnel_message(), get_store_message(), handle_delete_message(), handle_discourse_subscription(), handle_private_message(), handle_transcript_message(), iterate_destroy_message(), iterate_destroy_messages(), iterate_destroy_subscription(), iterate_flag_for_cleanup_discourse_message(), keep_subscription_alive(), send_message_to_room_with_key(), send_tunnel_message(), task_message_control(), and update_room_message().
enum GNUNET_GenericReturnValue is_message_session_bound | ( | const struct GNUNET_MESSENGER_Message * | message | ) |
Returns if the message should be bound to a member session.
[in] | message | Message |
Definition at line 244 of file messenger_api_message.c.
References GNUNET_assert, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_NAME, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::kind.
Referenced by enqueue_message_to_room(), and update_member_session_history().
|
static |
Definition at line 260 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_ShortMessage::body, GNUNET_memcpy, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, and GNUNET_MESSENGER_ShortMessage::kind.
Referenced by encrypt_message(), and transcribe_message().
|
static |
Definition at line 271 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_ShortMessage::body, destroy_message_body(), GNUNET_memcpy, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, and GNUNET_MESSENGER_ShortMessage::kind.
Referenced by decrypt_message(), encrypt_message(), and read_transcript_message().
|
static |
Definition at line 286 of file messenger_api_message.c.
References GNUNET_MESSENGER_MessageConnection::amount, GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageBody::connection, GNUNET_MESSENGER_MessageDelete::delay, GNUNET_MESSENGER_MessageBody::deletion, GNUNET_MESSENGER_MessageSubscribe::discourse, GNUNET_MESSENGER_MessageTalk::discourse, GNUNET_MESSENGER_MessageInvite::door, GNUNET_MESSENGER_MessageBody::file, GNUNET_MESSENGER_MessageConnection::flags, GNUNET_MESSENGER_MessageSubscribe::flags, GNUNET_MESSENGER_KIND_CONNECTION, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_KIND_SUBSCRIBE, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MessageFile::hash, GNUNET_MESSENGER_MessageDelete::hash, GNUNET_MESSENGER_MessageTranscript::hash, GNUNET_MESSENGER_MessageTag::hash, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, GNUNET_MESSENGER_MessageBody::info, GNUNET_MESSENGER_MessageBody::invite, GNUNET_MESSENGER_MessageInvite::key, GNUNET_MESSENGER_MessageFile::key, GNUNET_MESSENGER_MessagePrivate::key, member_size, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageInfo::messenger_version, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessageFile::name, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageMiss::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_MessageMerge::previous, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageBody::request, GNUNET_MESSENGER_MessageBody::subscribe, GNUNET_MESSENGER_MessageBody::tag, GNUNET_MESSENGER_MessageBody::talk, GNUNET_MESSENGER_MessageSubscribe::time, and GNUNET_MESSENGER_MessageBody::transcript.
Referenced by get_message_kind_size(), and get_short_message_size().
uint16_t get_message_kind_size | ( | enum GNUNET_MESSENGER_MessageKind | kind, |
enum GNUNET_GenericReturnValue | include_header | ||
) |
Returns the minimal size in bytes to encode a message of a specific kind.
[in] | kind | Kind of message |
[in] | include_header | Flag to include header |
Definition at line 367 of file messenger_api_message.c.
References get_message_body_kind_size(), GNUNET_YES, GNUNET_MESSENGER_Message::header, member_size, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageHeader::sender_id, and GNUNET_MESSENGER_MessageHeader::timestamp.
Referenced by calc_usual_padding(), check_recv_message(), check_send_message(), check_tunnel_message(), decode_message(), get_message_size(), and get_store_message().
|
static |
Definition at line 388 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageBody::file, GNUNET_CRYPTO_public_key_get_length(), GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_TICKET, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_MESSENGER_MessageTicket::identifier, GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageTranscript::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageTranscript::length, GNUNET_MESSENGER_MessageTalk::length, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageTag::tag, GNUNET_MESSENGER_MessageBody::tag, GNUNET_MESSENGER_MessageBody::talk, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, GNUNET_MESSENGER_MessageBody::ticket, GNUNET_MESSENGER_MessageBody::transcript, and GNUNET_MESSENGER_MessageFile::uri.
Referenced by get_message_size(), and get_short_message_size().
uint16_t get_message_size | ( | const struct GNUNET_MESSENGER_Message * | message, |
enum GNUNET_GenericReturnValue | include_header | ||
) |
Returns the exact size in bytes to encode a given message.
[in] | message | Message |
[in] | include_header | Flag to include header |
Definition at line 437 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, get_message_body_size(), get_message_kind_size(), GNUNET_assert, GNUNET_CRYPTO_signature_get_length(), GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, and GNUNET_MESSENGER_MessageHeader::signature.
Referenced by iterate_save_messages(), notify_srv_handle_message(), pack_message(), and send_message_to_room().
|
static |
Definition at line 458 of file messenger_api_message.c.
References GNUNET_MESSENGER_ShortMessage::body, get_message_body_kind_size(), get_message_body_size(), GNUNET_YES, and GNUNET_MESSENGER_ShortMessage::kind.
Referenced by decode_short_message(), encrypt_message(), and transcribe_message().
|
static |
Definition at line 475 of file messenger_api_message.c.
References get_message_kind_size(), GNUNET_MESSENGER_KIND_MAX, GNUNET_MESSENGER_PADDING_MIN, and GNUNET_YES.
Referenced by calc_padded_length().
|
static |
Definition at line 498 of file messenger_api_message.c.
References calc_usual_padding(), GNUNET_MESSENGER_MAX_MESSAGE_SIZE, GNUNET_MESSENGER_PADDING_LEVEL0, GNUNET_MESSENGER_PADDING_LEVEL1, GNUNET_MESSENGER_PADDING_LEVEL2, GNUNET_MESSENGER_PADDING_MIN, and max.
Referenced by encrypt_message(), and pack_message().
|
static |
Definition at line 557 of file messenger_api_message.c.
References GNUNET_MESSENGER_MessageConnection::amount, GNUNET_MESSENGER_MessageBody::connection, GNUNET_MESSENGER_MessagePrivate::data, GNUNET_MESSENGER_MessageTranscript::data, GNUNET_MESSENGER_MessageTalk::data, GNUNET_MESSENGER_MessageDelete::delay, GNUNET_MESSENGER_MessageBody::deletion, GNUNET_MESSENGER_MessageSubscribe::discourse, GNUNET_MESSENGER_MessageTalk::discourse, GNUNET_MESSENGER_MessageInvite::door, encode_step, encode_step_ext, encode_step_key, GNUNET_MESSENGER_MessageBody::file, GNUNET_MESSENGER_MessageConnection::flags, GNUNET_MESSENGER_MessageSubscribe::flags, GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_block(), GNUNET_htobe32, GNUNET_memcpy, GNUNET_MESSENGER_KIND_CONNECTION, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_KIND_SUBSCRIBE, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_TICKET, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MessageFile::hash, GNUNET_MESSENGER_MessageDelete::hash, GNUNET_MESSENGER_MessageTranscript::hash, GNUNET_MESSENGER_MessageTag::hash, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, GNUNET_MESSENGER_MessageTicket::identifier, GNUNET_MESSENGER_MessageBody::info, GNUNET_MESSENGER_MessageBody::invite, GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageInvite::key, GNUNET_MESSENGER_MessageFile::key, GNUNET_MESSENGER_MessagePrivate::key, GNUNET_MESSENGER_MessageTranscript::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageInfo::messenger_version, min, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageFile::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageMiss::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_MessageMerge::previous, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageBody::request, GNUNET_MESSENGER_MessageBody::subscribe, GNUNET_MESSENGER_MessageTag::tag, GNUNET_MESSENGER_MessageBody::tag, GNUNET_MESSENGER_MessageBody::talk, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, GNUNET_MESSENGER_MessageBody::ticket, GNUNET_MESSENGER_MessageSubscribe::time, GNUNET_MESSENGER_MessageBody::transcript, and GNUNET_MESSENGER_MessageFile::uri.
Referenced by encode_message(), and encode_short_message().
void encode_message | ( | const struct GNUNET_MESSENGER_Message * | message, |
uint16_t | length, | ||
char * | buffer, | ||
enum GNUNET_GenericReturnValue | include_header | ||
) |
Encodes a given message into a buffer of a maximal length in bytes.
[in] | message | Message |
[in] | length | Maximal length to encode |
[out] | buffer | Buffer |
[in] | include_header | Flag to include header |
Definition at line 709 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, encode_message_body(), encode_step, encode_step_signature, GNUNET_assert, GNUNET_htobe32, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_MessageHeader::signature, and GNUNET_MESSENGER_MessageHeader::timestamp.
Referenced by iterate_save_messages(), notify_srv_handle_message(), pack_message(), and send_message_to_room().
|
static |
Definition at line 742 of file messenger_api_message.c.
References GNUNET_MESSENGER_ShortMessage::body, encode_message_body(), encode_step, GNUNET_assert, GNUNET_CRYPTO_hash(), GNUNET_htobe32, GNUNET_memcpy, and GNUNET_MESSENGER_ShortMessage::kind.
Referenced by encrypt_message(), and transcribe_message().
|
static |
Definition at line 796 of file messenger_api_message.c.
References GNUNET_MESSENGER_MessageConnection::amount, GNUNET_MESSENGER_MessageBody::connection, GNUNET_MESSENGER_MessagePrivate::data, GNUNET_MESSENGER_MessageTranscript::data, GNUNET_MESSENGER_MessageTalk::data, decode_step, decode_step_ext, decode_step_key, decode_step_malloc, GNUNET_MESSENGER_MessageDelete::delay, GNUNET_MESSENGER_MessageBody::deletion, GNUNET_MESSENGER_MessageSubscribe::discourse, GNUNET_MESSENGER_MessageTalk::discourse, GNUNET_MESSENGER_MessageInvite::door, GNUNET_MESSENGER_MessageBody::file, GNUNET_MESSENGER_MessageConnection::flags, GNUNET_MESSENGER_MessageSubscribe::flags, GNUNET_assert, GNUNET_be32toh, GNUNET_memcpy, GNUNET_MESSENGER_KIND_CONNECTION, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_KIND_SUBSCRIBE, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_TICKET, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MessageFile::hash, GNUNET_MESSENGER_MessageDelete::hash, GNUNET_MESSENGER_MessageTranscript::hash, GNUNET_MESSENGER_MessageTag::hash, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, GNUNET_MESSENGER_MessageTicket::identifier, GNUNET_MESSENGER_MessageBody::info, GNUNET_MESSENGER_MessageBody::invite, GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageInvite::key, GNUNET_MESSENGER_MessageFile::key, GNUNET_MESSENGER_MessagePrivate::key, GNUNET_MESSENGER_MessageTranscript::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageTranscript::length, GNUNET_MESSENGER_MessageTalk::length, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageInfo::messenger_version, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageFile::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageMiss::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_MessageMerge::previous, GNUNET_MESSENGER_MessageBody::privacy, GNUNET_MESSENGER_MessageBody::request, GNUNET_MESSENGER_MessageBody::subscribe, GNUNET_MESSENGER_MessageTag::tag, GNUNET_MESSENGER_MessageBody::tag, GNUNET_MESSENGER_MessageBody::talk, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, GNUNET_MESSENGER_MessageBody::ticket, GNUNET_MESSENGER_MessageSubscribe::time, GNUNET_MESSENGER_MessageBody::transcript, and GNUNET_MESSENGER_MessageFile::uri.
Referenced by decode_message(), and decode_short_message().
enum GNUNET_GenericReturnValue decode_message | ( | struct GNUNET_MESSENGER_Message * | message, |
uint16_t | length, | ||
const char * | buffer, | ||
enum GNUNET_GenericReturnValue | include_header, | ||
uint16_t * | padding | ||
) |
Decodes a message from a given buffer of a maximal length in bytes.
If the buffer is too small for a message of its decoded kind the function fails with resulting GNUNET_NO after decoding only the messages header.
On success the function returns GNUNET_YES.
[out] | message | Message |
[in] | length | Maximal length to decode |
[in] | buffer | Buffer |
[in] | include_header | Flag to include header |
[out] | padding | Padding |
Definition at line 970 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, decode_message_body(), decode_step, get_message_kind_size(), GNUNET_assert, GNUNET_be32toh, GNUNET_CRYPTO_read_signature_from_buffer(), GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageHeader::previous, result, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_MessageHeader::signature, and GNUNET_MESSENGER_MessageHeader::timestamp.
Referenced by check_recv_message(), check_send_message(), check_tunnel_message(), get_store_message(), handle_recv_message(), handle_send_message(), and handle_tunnel_message().
|
static |
Definition at line 1036 of file messenger_api_message.c.
References GNUNET_MESSENGER_ShortMessage::body, decode_message_body(), decode_step, get_short_message_size(), GNUNET_assert, GNUNET_be32toh, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_cmp(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO, GNUNET_YES, and GNUNET_MESSENGER_ShortMessage::kind.
Referenced by decrypt_message(), and read_transcript_message().
void hash_message | ( | const struct GNUNET_MESSENGER_Message * | message, |
uint16_t | length, | ||
const char * | buffer, | ||
struct GNUNET_HashCode * | hash | ||
) |
Calculates a hash of a given buffer with a length in bytes from a message.
[in] | message | Message |
[in] | length | Length of buffer |
[in] | buffer | Buffer |
[out] | hash | Hash |
Definition at line 1080 of file messenger_api_message.c.
References GNUNET_assert, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_signature_get_length(), GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::signature.
Referenced by check_tunnel_message(), get_store_message(), handle_tunnel_message(), pack_message(), and send_message_to_room().
void sign_message | ( | struct GNUNET_MESSENGER_Message * | message, |
uint16_t | length, | ||
char * | buffer, | ||
const struct GNUNET_HashCode * | hash, | ||
const struct GNUNET_CRYPTO_PrivateKey * | key | ||
) |
Signs the hash of a message with a given private key and writes the signature into the buffer as well.
[in,out] | message | Message |
[in] | length | Length of buffer |
[out] | buffer | Buffer |
[in] | hash | Hash of message |
[in] | key | Private key |
Definition at line 1096 of file messenger_api_message.c.
References encode_step_signature, GNUNET_assert, GNUNET_CRYPTO_sign, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, GNUNET_MESSENGER_MessageSignature::hash, GNUNET_MESSENGER_Message::header, key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_MESSENGER_MessageSignature::purpose, GNUNET_MESSENGER_MessageHeader::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, and GNUNET_CRYPTO_Signature::type.
Referenced by send_message_to_room().
void sign_message_by_peer | ( | struct GNUNET_MESSENGER_Message * | message, |
uint16_t | length, | ||
char * | buffer, | ||
const struct GNUNET_HashCode * | hash, | ||
const struct GNUNET_CONFIGURATION_Handle * | cfg | ||
) |
Signs the hash of a message with the peer identity of a given config and writes the signature into the buffer as well.
[in,out] | message | Message |
[in] | length | Length of buffer |
[out] | buffer | Buffer |
[in] | hash | Hash of message |
[in] | cfg | Peer configuration |
Definition at line 1127 of file messenger_api_message.c.
References cfg, encode_step_signature, GNUNET_assert, GNUNET_CRYPTO_sign_by_peer_identity(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_PUBLIC_KEY_TYPE_EDDSA, GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, GNUNET_MESSENGER_MessageSignature::hash, GNUNET_MESSENGER_Message::header, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_MESSENGER_MessageSignature::purpose, GNUNET_MESSENGER_MessageHeader::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, and GNUNET_CRYPTO_Signature::type.
Referenced by sign_srv_room_message_by_peer().
enum GNUNET_GenericReturnValue verify_message | ( | const struct GNUNET_MESSENGER_Message * | message, |
const struct GNUNET_HashCode * | hash, | ||
const struct GNUNET_CRYPTO_PublicKey * | key | ||
) |
Verifies the signature of a given message and its hash with a specific public key.
The function returns GNUNET_OK if the signature was valid, otherwise GNUNET_SYSERR.
[in] | message | Message |
[in] | hash | Hash of message |
[in] | key | Public key |
Definition at line 1159 of file messenger_api_message.c.
References GNUNET_assert, GNUNET_CRYPTO_signature_verify, GNUNET_memcpy, GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, GNUNET_SYSERR, GNUNET_MESSENGER_MessageSignature::hash, GNUNET_MESSENGER_Message::header, key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_MESSENGER_MessageSignature::purpose, GNUNET_MESSENGER_MessageHeader::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, and GNUNET_CRYPTO_Signature::type.
Referenced by verify_member_session_as_sender().
enum GNUNET_GenericReturnValue verify_message_by_peer | ( | const struct GNUNET_MESSENGER_Message * | message, |
const struct GNUNET_HashCode * | hash, | ||
const struct GNUNET_PeerIdentity * | identity | ||
) |
Verifies the signature of a given message and its hash with a specific peer's identity.
The function returns GNUNET_OK if the signature was valid, otherwise GNUNET_SYSERR.
[in] | message | Message |
[in] | hash | Hash of message |
[in] | identity | Peer identity |
Definition at line 1182 of file messenger_api_message.c.
References GNUNET_assert, GNUNET_CRYPTO_verify_peer_identity(), GNUNET_memcpy, GNUNET_PUBLIC_KEY_TYPE_EDDSA, GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, GNUNET_SYSERR, GNUNET_MESSENGER_MessageSignature::hash, GNUNET_MESSENGER_Message::header, identity, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_MESSENGER_MessageSignature::purpose, GNUNET_MESSENGER_MessageHeader::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, and GNUNET_CRYPTO_Signature::type.
Referenced by get_store_peer_of(), and verify_store_peer().
enum GNUNET_GenericReturnValue encrypt_message | ( | struct GNUNET_MESSENGER_Message * | message, |
const struct GNUNET_CRYPTO_PublicKey * | key | ||
) |
Encrypts a message using a given public key and replaces its body and kind with the now private encrypted message.
The function returns GNUNET_YES if the operation succeeded, otherwise GNUNET_NO.
[in,out] | message | Message |
[in] | key | Public key |
Definition at line 1206 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_ShortMessage::body, calc_padded_length(), cleanup(), data, GNUNET_MESSENGER_MessagePrivate::data, destroy_message_body(), encode_short_message(), encryption_overhead, fold_short_message(), get_short_message_size(), GNUNET_assert, GNUNET_CRYPTO_hpke_pk_to_x25519(), GNUNET_CRYPTO_hpke_seal_oneshot(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Message::header, is_service_message(), key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_ShortMessage::kind, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageBody::privacy, result, and unfold_short_message().
Referenced by dequeue_message_from_room(), and send_message_to_room_with_key().
enum GNUNET_GenericReturnValue decrypt_message | ( | struct GNUNET_MESSENGER_Message * | message, |
const struct GNUNET_CRYPTO_PrivateKey * | key | ||
) |
Decrypts a private message using a given private key and replaces its body and kind with the inner encrypted message.
The function returns GNUNET_YES if the operation succeeded, otherwise GNUNET_NO.
[in,out] | message | Message |
[in] | key | Private key |
Definition at line 1267 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, cleanup(), data, GNUNET_MESSENGER_MessagePrivate::data, decode_short_message(), encryption_overhead, GNUNET_assert, GNUNET_CRYPTO_hpke_open_oneshot(), GNUNET_CRYPTO_hpke_sk_to_x25519(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_NO, GNUNET_OK, GNUNET_YES, key, GNUNET_MESSENGER_MessagePrivate::length, GNUNET_MESSENGER_MessageBody::privacy, result, and unfold_short_message().
Referenced by handle_private_message().
struct GNUNET_MESSENGER_Message * transcribe_message | ( | const struct GNUNET_MESSENGER_Message * | message, |
const struct GNUNET_CRYPTO_PublicKey * | key | ||
) |
Transcribes a message as a new transcript message using a given public key from the recipient of the encrypted message content.
[in] | message | Message |
[in] | key | Public key |
Definition at line 1333 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, create_message(), GNUNET_MESSENGER_MessageTranscript::data, encode_short_message(), fold_short_message(), get_short_message_size(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_YES, is_service_message(), key, GNUNET_MESSENGER_MessageTranscript::key, GNUNET_MESSENGER_MessageTranscript::length, and GNUNET_MESSENGER_MessageBody::transcript.
Referenced by send_message_to_room_with_key().
enum GNUNET_GenericReturnValue read_transcript_message | ( | struct GNUNET_MESSENGER_Message * | message | ) |
Read the original message from a transcript message and replaces its body and kind with the inner encrypted message.
The function returns GNUNET_YES if the operation succeeded, otherwise GNUNET_NO.
[in,out] | transcript | Message transcript |
Definition at line 1374 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageTranscript::data, decode_short_message(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageTranscript::length, GNUNET_MESSENGER_MessageBody::transcript, and unfold_short_message().
Referenced by handle_transcript_message().
struct GNUNET_MQ_Envelope * pack_message | ( | struct GNUNET_MESSENGER_Message * | message, |
struct GNUNET_HashCode * | hash, | ||
const GNUNET_MESSENGER_SignFunction | sign, | ||
enum GNUNET_MESSENGER_PackMode | mode, | ||
const void * | cls | ||
) |
Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_PACK_MODE_ENVELOPE.
Independent of the mode the message will be hashed if hash is not NULL and it will be signed if the sign function is not NULL.
[out] | message | Message |
[out] | hash | Hash of message |
[in] | sign | Function to sign |
[in] | mode | Mode of packing |
[in,out] | cls | Closure for signing |
Definition at line 1402 of file messenger_api_message.c.
References calc_padded_length(), encode_message(), env, get_message_size(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_MESSAGE_TYPE_CADET_CLI, GNUNET_MESSENGER_PACK_MODE_ENVELOPE, GNUNET_MQ_msg_extra, GNUNET_sh2s(), GNUNET_YES, hash_message(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, mode, and GNUNET_MESSENGER_MessageHeader::sender_id.
Referenced by forward_tunnel_message(), iterate_send_room_message(), and pack_srv_room_message().
enum GNUNET_GenericReturnValue is_peer_message | ( | const struct GNUNET_MESSENGER_Message * | message | ) |
Returns whether a specific kind of message can be sent by the service without usage of a clients private key.
The function returns GNUNET_YES if the kind of message can be signed via a peer's identity, otherwise GNUNET_NO.
[in] | message | Message |
Definition at line 1452 of file messenger_api_message.c.
References GNUNET_assert, GNUNET_MESSENGER_KIND_CONNECTION, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_PEER, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, and GNUNET_MESSENGER_MessageHeader::kind.
Referenced by callback_found_message(), callback_room_handle_message(), enqueue_message_control(), filter_message_sending(), get_store_member_of(), get_store_peer_of(), handle_room_messages(), is_service_message(), notify_about_members(), notify_srv_handle_message(), pack_srv_room_message(), process_message_control(), and task_message_control().
enum GNUNET_GenericReturnValue is_service_message | ( | const struct GNUNET_MESSENGER_Message * | message | ) |
Returns whether a specific kind of message contains service critical information.
That kind of information should not be encrypted via private messages for example to guarantee the service to work properly. The function returns GNUNET_YES if the kind of message needs to be transferred accessible to all peers and their running service. It returns GNUNET_NO if the message can be encrypted to specific subgroups of members without issues. If the kind of message is unknown it returns GNUNET_SYSERR.
[in] | message | Message |
Definition at line 1471 of file messenger_api_message.c.
References GNUNET_assert, GNUNET_MESSENGER_KIND_CONNECTION, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_KIND_SUBSCRIBE, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_TICKET, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Message::header, is_peer_message(), and GNUNET_MESSENGER_MessageHeader::kind.
Referenced by encrypt_message(), and transcribe_message().
enum GNUNET_GenericReturnValue filter_message_sending | ( | const struct GNUNET_MESSENGER_Message * | message | ) |
Returns whether a specific kind of message should be sent by a client.
The function returns GNUNET_YES or GNUNET_NO for recommendations and GNUNET_SYSERR for specific kinds of messages which should not be sent manually at all.
[in] | message | Message |
Definition at line 1529 of file messenger_api_message.c.
References GNUNET_assert, GNUNET_MESSENGER_KIND_CONNECTION, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_KIND_SUBSCRIBE, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_TICKET, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Message::header, is_peer_message(), and GNUNET_MESSENGER_MessageHeader::kind.
Referenced by check_send_message(), and GNUNET_MESSENGER_send_message().
const struct GNUNET_ShortHashCode * get_message_discourse | ( | const struct GNUNET_MESSENGER_Message * | message | ) |
Returns the discourse hash of a message depending on its kind.
If a message contains a discourse hash it will not be stored locally on peers.
[in] | message | Message |
Definition at line 1587 of file messenger_api_message.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageSubscribe::discourse, GNUNET_MESSENGER_MessageTalk::discourse, GNUNET_assert, GNUNET_MESSENGER_KIND_SUBSCRIBE, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageBody::subscribe, and GNUNET_MESSENGER_MessageBody::talk.
Referenced by handle_message_control(), iterate_flag_for_cleanup_discourse_message(), put_store_message(), send_message_to_room(), and update_message_state().
const uint16_t encryption_overhead |
Definition at line 32 of file messenger_api_message.c.
Referenced by decrypt_message(), and encrypt_message().