summaryrefslogtreecommitdiff
path: root/libs/libaxolotl/src/signal_protocol.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libaxolotl/src/signal_protocol.h')
-rw-r--r--libs/libaxolotl/src/signal_protocol.h44
1 files changed, 39 insertions, 5 deletions
diff --git a/libs/libaxolotl/src/signal_protocol.h b/libs/libaxolotl/src/signal_protocol.h
index e2ff5d6812..4e71355c2e 100644
--- a/libs/libaxolotl/src/signal_protocol.h
+++ b/libs/libaxolotl/src/signal_protocol.h
@@ -103,6 +103,15 @@ signal_buffer *signal_buffer_create(const uint8_t *data, size_t len);
signal_buffer *signal_buffer_copy(const signal_buffer *buffer);
/**
+ * Create a copy of an existing buffer.
+ *
+ * @param buffer the existing buffer to copy
+ * @param n the maximum number of bytes to copy
+ * @return pointer to the updated buffer, or 0 on failure
+ */
+signal_buffer *signal_buffer_n_copy(const signal_buffer *buffer, size_t n);
+
+/**
* Append the provided data to an existing buffer.
* Note: The underlying buffer is only expanded by an amount sufficient
* to hold the data being appended. There is no additional reserved space
@@ -125,12 +134,21 @@ signal_buffer *signal_buffer_append(signal_buffer *buffer, const uint8_t *data,
uint8_t *signal_buffer_data(signal_buffer *buffer);
/**
+ * Gets the data pointer for the buffer.
+ * This can be used to read and write data stored in the buffer.
+ *
+ * @param buffer pointer to the buffer instance
+ * @return data pointer
+ */
+const uint8_t *signal_buffer_const_data(const signal_buffer *buffer);
+
+/**
* Gets the length of the data stored within the buffer.
*
* @param buffer pointer to the buffer instance
* @return data length
*/
-size_t signal_buffer_len(signal_buffer *buffer);
+size_t signal_buffer_len(const signal_buffer *buffer);
/**
* Compare two buffers.
@@ -400,10 +418,14 @@ typedef struct signal_protocol_session_store {
* @param record pointer to a freshly allocated buffer containing the
* serialized session record. Unset if no record was found.
* The Signal Protocol library is responsible for freeing this buffer.
+ * @param user_record pointer to a freshly allocated buffer containing
+ * application specific data stored alongside the serialized session
+ * record. If no such data exists, then this pointer may be left unset.
+ * The Signal Protocol library is responsible for freeing this buffer.
* @param address the address of the remote client
* @return 1 if the session was loaded, 0 if the session was not found, negative on failure
*/
- int (*load_session_func)(signal_buffer **record, const signal_protocol_address *address, void *user_data);
+ int (*load_session_func)(signal_buffer **record, signal_buffer **user_record, const signal_protocol_address *address, void *user_data);
/**
* Returns all known devices with active sessions for a recipient
@@ -423,9 +445,13 @@ typedef struct signal_protocol_session_store {
* @param record pointer to a buffer containing the serialized session
* record for the remote client
* @param record_len length of the serialized session record
+ * @param user_record pointer to a buffer containing application specific
+ * data to be stored alongside the serialized session record for the
+ * remote client. If no such data exists, then this pointer will be null.
+ * @param user_record_len length of the application specific data
* @return 0 on success, negative on failure
*/
- int (*store_session_func)(const signal_protocol_address *address, uint8_t *record, size_t record_len, void *user_data);
+ int (*store_session_func)(const signal_protocol_address *address, uint8_t *record, size_t record_len, uint8_t *user_record, size_t user_record_len, void *user_data);
/**
* Determine whether there is a committed session record for a
@@ -640,9 +666,13 @@ typedef struct signal_protocol_sender_key_store {
* @param sender_key_name the (groupId + senderId + deviceId) tuple
* @param record pointer to a buffer containing the serialized record
* @param record_len length of the serialized record
+ * @param user_record pointer to a buffer containing application specific
+ * data to be stored alongside the serialized record. If no such
+ * data exists, then this pointer will be null.
+ * @param user_record_len length of the application specific data
* @return 0 on success, negative on failure
*/
- int (*store_sender_key)(const signal_protocol_sender_key_name *sender_key_name, uint8_t *record, size_t record_len, void *user_data);
+ int (*store_sender_key)(const signal_protocol_sender_key_name *sender_key_name, uint8_t *record, size_t record_len, uint8_t *user_record, size_t user_record_len, void *user_data);
/**
* Returns a copy of the sender key record corresponding to the
@@ -651,10 +681,14 @@ typedef struct signal_protocol_sender_key_store {
* @param record pointer to a newly allocated buffer containing the record,
* if found. Unset if no record was found.
* The Signal Protocol library is responsible for freeing this buffer.
+ * @param user_record pointer to a newly allocated buffer containing
+ * application-specific data stored alongside the record. If no such
+ * data exists, then this pointer may be left unset.
+ * The Signal Protocol library is responsible for freeing this buffer.
* @param sender_key_name the (groupId + senderId + deviceId) tuple
* @return 1 if the record was loaded, 0 if the record was not found, negative on failure
*/
- int (*load_sender_key)(signal_buffer **record, const signal_protocol_sender_key_name *sender_key_name, void *user_data);
+ int (*load_sender_key)(signal_buffer **record, signal_buffer **user_record, const signal_protocol_sender_key_name *sender_key_name, void *user_data);
/**
* Function called to perform cleanup when the data store context is being