Go to the source code of this file.
Macros | |
#define | GNUNET_MESSENGER_MAX_MESSAGE_SIZE |
#define | GNUNET_MESSENGER_PADDING_MIN (sizeof(uint16_t) + sizeof(char)) |
#define | GNUNET_MESSENGER_PADDING_LEVEL0 (512) |
#define | GNUNET_MESSENGER_PADDING_LEVEL1 (4096) |
#define | GNUNET_MESSENGER_PADDING_LEVEL2 (32768) |
Typedefs | |
typedef void(* | GNUNET_MESSENGER_SignFunction) (const void *cls, struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash) |
Enumerations | |
enum | GNUNET_MESSENGER_PackMode { GNUNET_MESSENGER_PACK_MODE_ENVELOPE = 0x1 , GNUNET_MESSENGER_PACK_MODE_UNKNOWN = 0x0 } |
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... | |
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... | |
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... | |
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... | |
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... | |
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... | |
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... | |
#define GNUNET_MESSENGER_MAX_MESSAGE_SIZE |
Definition at line 33 of file messenger_api_message.h.
#define GNUNET_MESSENGER_PADDING_MIN (sizeof(uint16_t) + sizeof(char)) |
Definition at line 36 of file messenger_api_message.h.
#define GNUNET_MESSENGER_PADDING_LEVEL0 (512) |
Definition at line 37 of file messenger_api_message.h.
#define GNUNET_MESSENGER_PADDING_LEVEL1 (4096) |
Definition at line 38 of file messenger_api_message.h.
#define GNUNET_MESSENGER_PADDING_LEVEL2 (32768) |
Definition at line 39 of file messenger_api_message.h.
typedef void(* GNUNET_MESSENGER_SignFunction) (const void *cls, struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash) |
Definition at line 281 of file messenger_api_message.h.
Enumerator | |
---|---|
GNUNET_MESSENGER_PACK_MODE_ENVELOPE | |
GNUNET_MESSENGER_PACK_MODE_UNKNOWN |
Definition at line 289 of file messenger_api_message.h.
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().
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().
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().
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().
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().
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().
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().