Module C.Funcs
val inbound_group_session_size : unit -> Unsigned.size_tinbound_group_session_size ()Get the size of an inbound group session, in bytes.
val inbound_group_session : unit Ctypes_static.ptr -> Types.InboundGroupSession.t Ctypes_static.ptrinbound_group_session session key key_length message_indexInitialise an inbound group session object using the supplied memory The supplied memory should be at least olm_inbound_group_session_size() bytes.
val inbound_group_session_last_error : Types.InboundGroupSession.t Ctypes_static.ptr -> char Ctypes_static.ptrinbound_group_session_last_error sessA null terminated string describing the most recent error to happen to a group session
val clear_inbound_group_session : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.size_tclear_inbound_group_session sessClears the memory used to back this group session
val pickle_inbound_group_session_length : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.size_tpickle_inbound_group_session_length sessReturns the number of bytes needed to store an inbound group session
val pickle_inbound_group_session : Types.InboundGroupSession.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpickle_inbound_group_session sess key key_len pickled pickled_lenInitialise an inbound group session object using the supplied memory The supplied memory should be at least olm_inbound_group_session_size() bytes.
val unpickle_inbound_group_session : Types.InboundGroupSession.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tunpickle_inbound_group_session sess key key_len pickled pickled_lenLoads a group session from a pickled base64 string. Decrypts the session using the supplied key.
Returns olm_error() on failure. If the key doesn't match the one used to encrypt the account then olm_inbound_group_session_last_error() will be "BAD_ACCOUNT_KEY". If the base64 couldn't be decoded then olm_inbound_group_session_last_error() will be "INVALID_BASE64". The input pickled buffer is destroyed
val init_inbound_group_session : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tinit_inbound_group_session sess sess_key sess_key_lenReturns the number of bytes needed to store an inbound group session
val import_inbound_group_session : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_timport_inbound_group_session sess sess_key sess_key_lenImport an inbound group session, from a previous export.
Returns olm_error() on failure. On failure last_error will be set with an error code. The last_error will be:
* OLM_INVALID_BASE64 if the session_key is not valid base64 * OLM_BAD_SESSION_KEY if the session_key is invalid
val group_decrypt_max_plaintext_length : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tgroup_decrypt_max_plaintext_length sess msg msg_lenGet an upper bound on the number of bytes of plain-text the decrypt method will write for a given input message length. The actual size could be different due to padding.
The input message buffer is destroyed.
Returns olm_error() on failure.
val group_decrypt : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.uint32 Ctypes_static.ptr -> Unsigned.size_tgroup_decrypt sess msg msg_len plaintext max_plaintext_len msg_indexDecrypt a message. The input message buffer is destroyed. Returns the length of the decrypted plain-text, or olm_error() on failure.
On failure last_error will be set with an error code. The last_error will be: * OLM_OUTPUT_BUFFER_TOO_SMALL if the plain-text buffer is too small * OLM_INVALID_BASE64 if the message is not valid base-64 * OLM_BAD_MESSAGE_VERSION if the message was encrypted with an unsupported version of the protocol * OLM_BAD_MESSAGE_FORMAT if the message headers could not be decoded * OLM_BAD_MESSAGE_MAC if the message could not be verified * OLM_UNKNOWN_MESSAGE_INDEX if we do not have a session key corresponding to the message's index (ie, it was sent before the session key was shared with us)
val inbound_group_session_id_length : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.size_tinbound_group_session_id_length sessGet the number of bytes returned by olm_inbound_group_session_id()
val inbound_group_session_id : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tinbound_group_session_id sess id id_lenGet a base64-encoded identifier for this session.
Returns the length of the session id on success or olm_error() on failure. On failure last_error will be set with an error code. The last_error will be OUTPUT_BUFFER_TOO_SMALL if the id buffer was too small.
val inbound_group_session_first_known_index : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint32inbound_group_session_first_known_index sessGet the first message index we know how to decrypt.
val inbound_group_session_is_verified : Types.InboundGroupSession.t Ctypes_static.ptr -> intinbound_group_session_is_verified sessCheck if the session has been verified as a valid session.
(A session is verified either because the original session share was signed, or because we have subsequently successfully decrypted a message.)
This is mainly intended for the unit tests, currently.
val export_inbound_group_session_length : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.size_texport_inbound_group_session_length sessGet the number of bytes returned by olm_export_inbound_group_session()
val export_inbound_group_session : Types.InboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.uint32 -> Unsigned.size_texport_inbound_group_session sess key key_len msg_indexExport the base64-encoded ratchet key for this session, at the given index, in a format which can be used by olm_import_inbound_group_session
Returns the length of the ratchet key on success or olm_error() on failure. On failure last_error will be set with an error code. The last_error will be: * OUTPUT_BUFFER_TOO_SMALL if the buffer was too small * OLM_UNKNOWN_MESSAGE_INDEX if we do not have a session key corresponding to the given index (ie, it was sent before the session key was shared with us)
val outbound_group_session_size : unit -> Unsigned.size_toutbound_group_session_size ()Get the size of an outbound group session, in bytes.
val outbound_group_session : unit Ctypes_static.ptr -> Types.OutboundGroupSession.t Ctypes_static.ptroutbound_group_session memInitialise an outbound group session object using the supplied memory The supplied memory should be at least olm_outbound_group_session_size() bytes.
val outbound_group_session_last_error : Types.OutboundGroupSession.t Ctypes_static.ptr -> char Ctypes_static.ptroutbound_group_session_last_error sessA null terminated string describing the most recent error to happen to a group session
val clear_outbound_group_session : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.size_tclear_outbound_group_session sessInitialise an outbound group session object using the supplied memory The supplied memory should be at least olm_outbound_group_session_size() bytes.
val pickle_outbound_group_session_length : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.size_tpickle_outbound_group_session_length sessGet the size of an outbound group session, in bytes.
val pickle_outbound_group_session : Types.OutboundGroupSession.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpickle_outbound_group_session sess key key_len pickled pickled_lenStores a group session as a base64 string. Encrypts the session using the supplied key. Returns the length of the session on success.
Returns olm_error() on failure. If the pickle output buffer is smaller than olm_pickle_outbound_group_session_length() then olm_outbound_group_session_last_error() will be "OUTPUT_BUFFER_TOO_SMALL"
val unpickle_outbound_group_session : Types.OutboundGroupSession.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tunpickle_outbound_group_session sess key key_len pickled pickled_lenLoads a group session from a pickled base64 string. Decrypts the session using the supplied key.
Returns olm_error() on failure. If the key doesn't match the one used to encrypt the account then olm_outbound_group_session_last_error() will be "BAD_ACCOUNT_KEY". If the base64 couldn't be decoded then olm_outbound_group_session_last_error() will be "INVALID_BASE64". The input pickled buffer is destroyed
val init_outbound_group_session_random_length : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.size_tinit_outbound_group_session_random_length sessThe number of random bytes needed to create an outbound group session
val init_outbound_group_session : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tinit_outbound_group_session sess random random_lenStart a new outbound group session. Returns olm_error() on failure. On failure last_error will be set with an error code. The last_error will be NOT_ENOUGH_RANDOM if the number of random bytes was too small.
val group_encrypt_message_length : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tgroup_encrypt_message_length sess plaintext_lenThe number of bytes that will be created by encrypting a message
val group_encrypt : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tgroup_encrypt sess plaintext plaintext_len msg msg_lenEncrypt some plain-text. Returns the length of the encrypted message or olm_error() on failure. On failure last_error will be set with an error code. The last_error will be OUTPUT_BUFFER_TOO_SMALL if the output buffer is too small.
val outbound_group_session_id_length : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.size_toutbound_group_session_id_length sessGet the number of bytes returned by olm_outbound_group_session_id()
val outbound_group_session_id : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_toutbound_group_session_id sess id id_lenGet a base64-encoded identifier for this session.
Returns the length of the session id on success or olm_error() on failure. On failure last_error will be set with an error code. The last_error will be OUTPUT_BUFFER_TOO_SMALL if the id buffer was too small.
val outbound_group_session_message_index : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint32outbound_group_session_message_index sessGet the current message index for this session.
Each message is sent with an increasing index; this returns the index for the next message.
val outbound_group_session_key_length : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.size_toutbound_group_session_key_length sessGet the number of bytes returned by olm_outbound_group_session_key()
val outbound_group_session_key : Types.OutboundGroupSession.t Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_toutbound_group_session_key sess key key_lenGet the base64-encoded current ratchet key for this session.
Each message is sent with a different ratchet key. This function returns the ratchet key that will be used for the next message.
Returns the length of the ratchet key on success or olm_error() on failure. On failure last_error will be set with an error code. The last_error will be OUTPUT_BUFFER_TOO_SMALL if the buffer was too small.
val get_library_version : Unsigned.uint8 Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> Unsigned.uint8 Ctypes_static.ptr -> unitget_library_version major minor patchGet the version number of the library. Arguments will be updated if non-null.
val account : unit Ctypes_static.ptr -> Types.Account.t Ctypes_static.ptraccount memInitialise an account object using the supplied memory The supplied memory must be at least olm_account_size() bytes
val session : unit Ctypes_static.ptr -> Types.Session.t Ctypes_static.ptrsession memInitialise a session object using the supplied memory The supplied memory must be at least olm_session_size() bytes
val utility : unit Ctypes_static.ptr -> Types.Utility.t Ctypes_static.ptrutility memInitialise a utility object using the supplied memory The supplied memory must be at least olm_utility_size() bytes
val error : unit -> Unsigned.size_terror ()The value that olm will return from a function if there was an error
val account_last_error : Types.Account.t Ctypes_static.ptr -> char Ctypes_static.ptraccount_last_error accA null terminated string describing the most recent error to happen to an account
val session_last_error : Types.Session.t Ctypes_static.ptr -> char Ctypes_static.ptrsession_last_error sessA null terminated string describing the most recent error to happen to a session
val utility_last_error : Types.Utility.t Ctypes_static.ptr -> char Ctypes_static.ptrutility_last_error utilA null terminated string describing the most recent error to happen to a utility
val clear_account : Types.Account.t Ctypes_static.ptr -> Unsigned.size_tclear_account accClears the memory used to back this account
val clear_session : Types.Session.t Ctypes_static.ptr -> Unsigned.size_tclear_session sessClears the memory used to back this session
val clear_utility : Types.Utility.t Ctypes_static.ptr -> Unsigned.size_tclear_utility utilClears the memory used to back this utility
val pickle_account_length : Types.Account.t Ctypes_static.ptr -> Unsigned.size_tpickle_account_length accReturns the number of bytes needed to store an account
val pickle_session_length : Types.Session.t Ctypes_static.ptr -> Unsigned.size_tpickle_session_length sessReturns the number of bytes needed to store a session
val pickle_account : Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpickle_account acc key key_len pickled pickled_lenStores an account as a base64 string. Encrypts the account using the supplied key. Returns the length of the pickled account on success. Returns olm_error() on failure. If the pickle output buffer is smaller than olm_pickle_account_length() then olm_account_last_error() will be "OUTPUT_BUFFER_TOO_SMALL"
val pickle_session : Types.Session.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpickle_session sess key key_len pickled pickled_lenStores a session as a base64 string. Encrypts the session using the supplied key. Returns the length of the pickled session on success. Returns olm_error() on failure. If the pickle output buffer is smaller than olm_pickle_session_length() then olm_session_last_error() will be "OUTPUT_BUFFER_TOO_SMALL"
val unpickle_account : Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tunpickle_account acc key key_len pickled pickled_lenLoads an account from a pickled base64 string. Decrypts the account using the supplied key. Returns olm_error() on failure. If the key doesn't match the one used to encrypt the account then olm_account_last_error() will be "BAD_ACCOUNT_KEY". If the base64 couldn't be decoded then olm_account_last_error() will be "INVALID_BASE64". The input pickled buffer is destroyed
val unpickle_session : Types.Session.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tunpickle_session sess key key_len pickled pickled_lenLoads a session from a pickled base64 string. Decrypts the session using the supplied key. Returns olm_error() on failure. If the key doesn't match the one used to encrypt the account then olm_session_last_error() will be "BAD_ACCOUNT_KEY". If the base64 couldn't be decoded then olm_session_last_error() will be "INVALID_BASE64". The input pickled buffer is destroyed
val create_account_random_length : Types.Account.t Ctypes_static.ptr -> Unsigned.size_tcreate_account_random_length accThe number of random bytes needed to create an account.
val create_account : Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tcreate_account acc random random_lenCreates a new account. Returns olm_error() on failure. If there weren't enough random bytes then olm_account_last_error() will be "NOT_ENOUGH_RANDOM"
val account_identity_keys_length : Types.Account.t Ctypes_static.ptr -> Unsigned.size_taccount_identity_keys_length accThe size of the output buffer needed to hold the identity keys
val account_identity_keys : Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_taccount_identity_keys acc identity_keys identity_keys_lenWrites the public parts of the identity keys for the account into the identity_keys output buffer. Returns olm_error() on failure. If the identity_keys buffer was too small then olm_account_last_error() will be "OUTPUT_BUFFER_TOO_SMALL"
val account_signature_length : Types.Account.t Ctypes_static.ptr -> Unsigned.size_taccount_signature_length accThe length of an ed25519 signature encoded as base64.
val account_sign : Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_taccount_sign acc msg msg_len signature signature_lenSigns a message with the ed25519 key for this account. Returns olm_error() on failure. If the signature buffer was too small then olm_account_last_error() will be "OUTPUT_BUFFER_TOO_SMALL"
val account_one_time_keys_length : Types.Account.t Ctypes_static.ptr -> Unsigned.size_taccount_one_time_keys_length accThe size of the output buffer needed to hold the one time keys
val account_one_time_keys : Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_taccount_one_time_keys acc one_time_keys one_time_keys_lenWrites the public parts of the unpublished one time keys for the account into the one_time_keys output buffer.
The returned data is a JSON-formatted object with the single property curve25519, which is itself an object mapping key id to base64-encoded Curve25519 key. For example:
curve25519: { "AAAAAA": "wo76WcYtb0Vk/pBOdmduiGJ0wIEjW4IBMbbQn7aSnTo"; "AAAAAB": "LRvjo46L1X2vx69sS9QNFD29HWulxrmW11Up5AfAjgU" }Returns olm_error() on failure.
If the one_time_keys buffer was too small then olm_account_last_error() will be "OUTPUT_BUFFER_TOO_SMALL".
val account_mark_keys_as_published : Types.Account.t Ctypes_static.ptr -> Unsigned.size_taccount_mark_keys_as_published accMarks the current set of one time keys as being published.
val account_max_number_of_one_time_keys : Types.Account.t Ctypes_static.ptr -> Unsigned.size_taccount_max_number_of_one_time_keys accThe largest number of one time keys this account can store.
val account_generate_one_time_keys_random_length : Types.Account.t Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_taccount_generate_one_time_keys_random_length acc number_of_keysThe number of random bytes needed to generate a given number of new one time keys.
val account_generate_one_time_keys : Types.Account.t Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_taccount_generate_one_time_keys acc number_of_keys random random_lenGenerates a number of new one time keys. If the total number of keys stored by this account exceeds max_number_of_one_time_keys() then the old keys are discarded. Returns olm_error() on error. If the number of random bytes is too small then olm_account_last_error() will be "NOT_ENOUGH_RANDOM".
val account_generate_fallback_key_random_length : Types.Account.t Ctypes_static.ptr -> Unsigned.size_taccount_generate_fallback_key_random_length accThe number of random bytes needed to generate a fallback key.
val account_generate_fallback_key : Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_taccount_generate_fallback_key acc random random_lenGenerates a new fallback key. Only one previous fallback key is stored. Returns olm_error() on error. If the number of random bytes is too small then olm_account_last_error() will be "NOT_ENOUGH_RANDOM".
val account_fallback_key_length : Types.Account.t Ctypes_static.ptr -> Unsigned.size_taccount_fallback_key_length accThe number of bytes needed to hold the fallback key as returned by olm_account_fallback_key.
val account_fallback_key : Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_taccount_fallback_key acc fallback_key fallback_key_size
val create_outbound_session_random_length : Types.Session.t Ctypes_static.ptr -> Unsigned.size_tcreate_outbound_session_random_length sessThe number of random bytes needed to create an outbound session
val create_outbound_session : Types.Session.t Ctypes_static.ptr -> Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tcreate_outbound_session sess acc their_identity_key their_identity_key_len their_one_time_key their_one_time_key_len random random_lenCreates a new out-bound session for sending messages to a given identity_key and one_time_key. Returns olm_error() on failure. If the keys couldn't be decoded as base64 then olm_session_last_error() will be "INVALID_BASE64" If there weren't enough random bytes then olm_session_last_error() will be "NOT_ENOUGH_RANDOM".
val create_inbound_session : Types.Session.t Ctypes_static.ptr -> Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tcreate_inbound_session sess acc one_time_key_msg one_time_key_msg_lenCreate a new in-bound session for sending/receiving messages from an incoming PRE_KEY message. Returns olm_error() on failure. If the base64 couldn't be decoded then olm_session_last_error will be "INVALID_BASE64". If the message was for an unsupported protocol version then olm_session_last_error() will be "BAD_MESSAGE_VERSION". If the message couldn't be decoded then then olm_session_last_error() will be "BAD_MESSAGE_FORMAT". If the message refers to an unknown one time key then olm_session_last_error() will be "BAD_MESSAGE_KEY_ID".
val create_inbound_session_from : Types.Session.t Ctypes_static.ptr -> Types.Account.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tcreate_inbound_session_from sess acc their_identity_key their_identity_key_len one_time_key_msg one_time_key_msg_lenCreate a new in-bound session for sending/receiving messages from an incoming PRE_KEY message. Returns olm_error() on failure. If the base64 couldn't be decoded then olm_session_last_error will be "INVALID_BASE64". If the message was for an unsupported protocol version then olm_session_last_error() will be "BAD_MESSAGE_VERSION". If the message couldn't be decoded then then olm_session_last_error() will be "BAD_MESSAGE_FORMAT". If the message refers to an unknown one time key then olm_session_last_error() will be "BAD_MESSAGE_KEY_ID".
val session_id_length : Types.Session.t Ctypes_static.ptr -> Unsigned.size_tsession_id_length sessThe length of the buffer needed to return the id for this session.
val session_id : Types.Session.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tsession_id sess id id_lenAn identifier for this session. Will be the same for both ends of the conversation. If the id buffer is too small then olm_session_last_error() will be "OUTPUT_BUFFER_TOO_SMALL".
val session_has_received_message : Types.Session.t Ctypes_static.ptr -> intsession_has_received_message sess
val session_describe : Types.Session.t Ctypes_static.ptr -> char Ctypes_static.ptr -> Unsigned.size_t -> unitsession_describe sess buf buf_lenWrite a null-terminated string describing the internal state of an olm session to the buffer provided for debugging and logging purposes.
val matches_inbound_session : Types.Session.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tmatches_inbound_session sess one_time_key_msg one_time_key_msg_lenChecks if the PRE_KEY message is for this in-bound session. This can happen if multiple messages are sent to this account before this account sends a message in reply. The one_time_key_message buffer is destroyed. Returns 1 if the session matches. Returns 0 if the session does not match. Returns olm_error() on failure. If the base64 couldn't be decoded then olm_session_last_error will be "INVALID_BASE64". If the message was for an unsupported protocol version then olm_session_last_error() will be "BAD_MESSAGE_VERSION". If the message couldn't be decoded then then olm_session_last_error() will be "BAD_MESSAGE_FORMAT".
val matches_inbound_session_from : Types.Session.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tmatches_inbound_session_from sess their_identity_key their_identity_key_len one_time_key_msg one_time_key_msg_lenChecks if the PRE_KEY message is for this in-bound session. This can happen if multiple messages are sent to this account before this account sends a message in reply. The one_time_key_message buffer is destroyed. Returns 1 if the session matches. Returns 0 if the session does not match. Returns olm_error() on failure. If the base64 couldn't be decoded then olm_session_last_error will be "INVALID_BASE64". If the message was for an unsupported protocol version then olm_session_last_error() will be "BAD_MESSAGE_VERSION". If the message couldn't be decoded then then olm_session_last_error() will be "BAD_MESSAGE_FORMAT".
val remove_one_time_keys : Types.Account.t Ctypes_static.ptr -> Types.Session.t Ctypes_static.ptr -> Unsigned.size_tremove_one_time_keys acc sessRemoves the one time keys that the session used from the account. Returns olm_error() on failure. If the account doesn't have any matching one time keys then olm_account_last_error() will be "BAD_MESSAGE_KEY_ID".
val encrypt_message_type : Types.Session.t Ctypes_static.ptr -> Unsigned.size_tencrypt_message_type sessThe type of the next message that olm_encrypt() will return. Returns OLM_MESSAGE_TYPE_PRE_KEY if the message will be a PRE_KEY message. Returns OLM_MESSAGE_TYPE_MESSAGE if the message will be a normal message. Returns olm_error on failure.
val encrypt_random_length : Types.Session.t Ctypes_static.ptr -> Unsigned.size_tencrypt_random_length sessThe number of random bytes needed to encrypt the next message.
val encrypt_message_length : Types.Session.t Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tencrypt_message_length sess plaintext_lenThe size of the next message in bytes for the given number of plain-text bytes
val encrypt : Types.Session.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tencrypt sess plaintext plaintext_len random random_len msg msg_lenEncrypts a message using the session. Returns the length of the message in bytes on success. Writes the message as base64 into the message buffer. Returns olm_error() on failure. If the message buffer is too small then olm_session_last_error() will be "OUTPUT_BUFFER_TOO_SMALL". If there weren't enough random bytes then olm_session_last_error() will be "NOT_ENOUGH_RANDOM".
val decrypt_max_plaintext_length : Types.Session.t Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tdecrypt_max_plaintext_length sess msg_type msg msg_lenThe maximum number of bytes of plain-text a given message could decode to. The actual size could be different due to padding. The input message buffer is destroyed. Returns olm_error() on failure. If the message base64 couldn't be decoded then olm_session_last_error() will be "INVALID_BASE64". If the message is for an unsupported version of the protocol then olm_session_last_error() will be "BAD_MESSAGE_VERSION". If the message couldn't be decoded then olm_session_last_error() will be "BAD_MESSAGE_FORMAT".
val decrypt : Types.Session.t Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tdecrypt sess msg_type msg msg_len plaintext max_plaintext_lenDecrypts a message using the session. The input message buffer is destroyed. Returns the length of the plain-text on success. Returns olm_error() on failure. If the plain-text buffer is smaller than olm_decrypt_max_plaintext_length() then olm_session_last_error() will be "OUTPUT_BUFFER_TOO_SMALL". If the base64 couldn't be decoded then olm_session_last_error() will be "INVALID_BASE64". If the message is for an unsupported version of the protocol then olm_session_last_error() will be "BAD_MESSAGE_VERSION". If the message couldn't be decoded then olm_session_last_error() will be "BAD_MESSAGE_FORMAT". If the MAC on the message was invalid then olm_session_last_error() will be "BAD_MESSAGE_MAC".
val sha256_length : Types.Utility.t Ctypes_static.ptr -> Unsigned.size_tsha256_length utilThe length of the buffer needed to hold the SHA-256 hash.
val sha256 : Types.Utility.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tsha256 util input input_len output output_lenCalculates the SHA-256 hash of the input and encodes it as base64. If the output buffer is smaller than olm_sha256_length() then olm_utility_last_error() will be "OUTPUT_BUFFER_TOO_SMALL".
val ed25519_verify : Types.Utility.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_ted25519_verify util key key_len msg msg_len signature signature_lenVerify an ed25519 signature. If the key was too small then olm_utility_last_error() will be "INVALID_BASE64". If the signature was invalid then olm_utility_last_error() will be "BAD_MESSAGE_MAC".
val pk_encryption_size : unit -> Unsigned.size_tpk_encryption_size ()The size of an encryption object in bytes
val pk_encryption : unit Ctypes_static.ptr -> Types.PkEncryption.t Ctypes_static.ptrpk_encryption memInitialise an encryption object using the supplied memory The supplied memory must be at least olm_pk_encryption_size() bytes
val pk_encryption_last_error : Types.PkEncryption.t Ctypes_static.ptr -> char Ctypes_static.ptrpk_encryption_last_error encryptionA null terminated string describing the most recent error to happen to an encryption object
val clear_pk_encryption : Types.PkEncryption.t Ctypes_static.ptr -> Unsigned.size_tclear_pk_encryption encryptionClears the memory used to back this encryption object
val pk_encryption_set_recipient_key : Types.PkEncryption.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpk_encryption_set_recipient_key encryption public_key public_key_lenSet the recipient's public key for encrypting to
val pk_ciphertext_length : Types.PkEncryption.t Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpk_ciphertext_length encryption plaintext_lenGet the length of the ciphertext that will correspond to a plaintext of the given length.
val pk_mac_length : Types.PkEncryption.t Ctypes_static.ptr -> Unsigned.size_tpk_mac_length encryptionGet the length of the message authentication code.
val pk_key_length : unit -> Unsigned.size_tpk_key_length ()Get the length of a public or ephemeral key
val pk_encrypt_random_length : Types.PkEncryption.t Ctypes_static.ptr -> Unsigned.size_tpk_encrypt_random_length encryptionThe number of random bytes needed to encrypt a message.
val pk_encrypt : Types.PkEncryption.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpk_encrypt encryption plaintext plaintext_len ciphertext ciphertext_len mac mac_len ephermal_key ephemeral_key_size random random_lenEncrypt a plaintext for the recipient set using olm_pk_encryption_set_recipient_key. Writes to the ciphertext, mac, and ephemeral_key buffers, whose values should be sent to the recipient. mac is a Message Authentication Code to ensure that the data is received and decrypted properly. ephemeral_key is the public part of the ephemeral key used (together with the recipient's key) to generate a symmetric encryption key. Returns olm_error() on failure. If the ciphertext, mac, or ephemeral_key buffers were too small then olm_pk_encryption_last_error() will be "OUTPUT_BUFFER_TOO_SMALL". If there weren't enough random bytes then olm_pk_encryption_last_error() will be "OLM_INPUT_BUFFER_TOO_SMALL".
val pk_decryption_size : unit -> Unsigned.size_tpk_decryption_size ()The size of a decryption object in bytes
val pk_decryption : unit Ctypes_static.ptr -> Types.PkDecryption.t Ctypes_static.ptrpk_decryption memInitialise a decryption object using the supplied memory The supplied memory must be at least olm_pk_decryption_size() bytes
val pk_decryption_last_error : Types.PkDecryption.t Ctypes_static.ptr -> char Ctypes_static.ptrpk_decryption_last_error decryptionA null terminated string describing the most recent error to happen to a decription object
val clear_pk_decryption : Types.PkDecryption.t Ctypes_static.ptr -> Unsigned.size_tclear_pk_decryption decryptionClears the memory used to back this decryption object
val pk_private_key_length : unit -> Unsigned.size_tpk_private_key_length ()Get the number of bytes required to store an olm private key
val pk_key_from_private : Types.PkDecryption.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpk_key_from_private decryption pubkey pubkey_len privkey privkey_lenInitialise the key from the private part of a key as returned by olm_pk_get_private_key(). The associated public key will be written to the pubkey buffer. Returns olm_error() on failure. If the pubkey buffer is too small then olm_pk_decryption_last_error() will be "OUTPUT_BUFFER_TOO_SMALL". If the private key was not long enough then olm_pk_decryption_last_error() will be "OLM_INPUT_BUFFER_TOO_SMALL".
Note that the pubkey is a base64 encoded string, but the private key is an unencoded byte array
val pickle_pk_decryption_length : Types.PkDecryption.t Ctypes_static.ptr -> Unsigned.size_tpickle_pk_decryption_length decryptionReturns the number of bytes needed to store a decryption object.
val pickle_pk_decryption : Types.PkDecryption.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpickle_pk_decryption decryption key key_len pickled pickled_lenStores decryption object as a base64 string. Encrypts the object using the supplied key. Returns the length of the pickled object on success. Returns olm_error() on failure. If the pickle output buffer is smaller than olm_pickle_pk_decryption_length() then olm_pk_decryption_last_error() will be "OUTPUT_BUFFER_TOO_SMALL"
val unpickle_pk_decryption : Types.PkDecryption.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tunpickle_pk_decryption decryption key key_len pickled pickled_lenLoads a decryption object from a pickled base64 string. The associated public key will be written to the pubkey buffer. Decrypts the object using the supplied key. Returns olm_error() on failure. If the key doesn't match the one used to encrypt the account then olm_pk_decryption_last_error() will be "BAD_ACCOUNT_KEY". If the base64 couldn't be decoded then olm_pk_decryption_last_error() will be "INVALID_BASE64". The input pickled buffer is destroyed
val pk_max_plaintext_length : Types.PkDecryption.t Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpk_max_plaintext_length decryption ciphertext_lenGet the length of the plaintext that will correspond to a ciphertext of the given length.
val pk_decrypt : Types.PkDecryption.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpk_decrypt decryption ephemeral_key ephemeral_key_len mac mac_len ciphertext ciphertext_len plaintext max_plaintext_lenDecrypt a ciphertext. The input ciphertext buffer is destroyed. See the olm_pk_encrypt function for descriptions of the ephemeral_key and mac arguments. Returns the length of the plaintext on success. Returns olm_error() on failure. If the plaintext buffer is too small then olm_pk_encryption_last_error() will be "OUTPUT_BUFFER_TOO_SMALL".
val pk_get_private_key : Types.PkDecryption.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpk_get_private_key decryption private_key private_key_lenGet the private key for an OlmDecryption object as an unencoded byte array private_key must be a pointer to a buffer of at least olm_pk_private_key_length() bytes and this length must be passed in private_key_length. If the given buffer is too small, returns olm_error() and olm_pk_encryption_last_error() will be "OUTPUT_BUFFER_TOO_SMALL". Returns the number of bytes written.
val pk_signing_size : unit -> Unsigned.size_tpk_signing_size ()The size of a signing object in bytes
val pk_signing : unit Ctypes_static.ptr -> Types.PkSigning.t Ctypes_static.ptrpk_signing memInitialise a signing object using the supplied memory The supplied memory must be at least olm_pk_signing_size() bytes
val pk_signing_last_error : Types.PkSigning.t Ctypes_static.ptr -> char Ctypes_static.ptrpk_signing_last_error signA null terminated string describing the most recent error to happen to a signing object
val clear_pk_signing : Types.PkSigning.t Ctypes_static.ptr -> Unsigned.size_tclear_pk_signing signClears the memory used to back this signing object
val pk_signing_key_from_seed : Types.PkSigning.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpk_signing_key_from_seed sign pubkey pubkey_len seed seed_lenInitialise the signing object with a public/private keypair from a seed. The associated public key will be written to the pubkey buffer. Returns olm_error() on failure. If the public key buffer is too small then olm_pk_signing_last_error() will be "OUTPUT_BUFFER_TOO_SMALL". If the seed buffer is too small then olm_pk_signing_last_error() will be "INPUT_BUFFER_TOO_SMALL".
val pk_signing_seed_length : unit -> Unsigned.size_tpk_signing_seed_length ()The size required for the seed for initialising a signing object.
val pk_signing_public_key_length : unit -> Unsigned.size_tpk_signing_public_key_length ()The size of the public key of a signing object.
val pk_signature_length : unit -> Unsigned.size_tpk_signature_length ()The size of a signature created by a signing object.
val pk_sign : Types.PkSigning.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tpk_sign sign msg msg_len signature signature_lenSign a message. The signature will be written to the signature buffer. Returns olm_error() on failure. If the signature buffer is too small, olm_pk_signing_last_error() will be "OUTPUT_BUFFER_TOO_SMALL".
val sas_last_error : Types.SAS.t Ctypes_static.ptr -> char Ctypes_static.ptrsas_last_error sasA null terminated string describing the most recent error to happen to an SAS object.
val sas : unit Ctypes_static.ptr -> Types.SAS.t Ctypes_static.ptrsas memInitialize an SAS object using the supplied memory. The supplied memory must be at least `olm_sas_size()` bytes.
val clear_sas : Types.SAS.t Ctypes_static.ptr -> Unsigned.size_tclear_sas sasClears the memory used to back an SAS object.
val create_sas_random_length : Types.SAS.t Ctypes_static.ptr -> Unsigned.size_tcreate_sas_random_length sasThe number of random bytes needed to create an SAS object.
val create_sas : Types.SAS.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tcreate_sass sas random random_lenCreates a new SAS object.
Takes the SAS object to create, initialized by `olm_sas()`, and an array of random bytes (and it's length) to use as entropy. The contents of the random buffer may be overwritten.
Returns `olm_error()` on failure. If there weren't enough random bytes then `olm_sas_last_error()` will be `NOT_ENOUGH_RANDOM`.
val sas_pubkey_length : Types.SAS.t Ctypes_static.ptr -> Unsigned.size_tsas_pubkey_length sasThe size of a public key in bytes.
val sas_get_pubkey : Types.SAS.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tsas_get_pubkey sas pubkey pubkey_lenGet the public key for the SAS object. Takes a buffer in which to store the public key, which must be of at least `olm_sas_pubkey_length()`.
Returns `olm_error()` on failure. If the `pubkey` buffer is too small, then `olm_sas_last_error()` will be `OUTPUT_BUFFER_TOO_SMALL`.
val sas_set_their_key : Types.SAS.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tsas_set_their_key sas their_key their_key_lenSets the public key of other user. Takes the SAS object, and the other user's public key (which will be overwritten).
Returns `olm_error()` on failure. If the `their_key` buffer is too small, then `olm_sas_last_error()` will be `INPUT_BUFFER_TOO_SMALL`.
val sas_is_their_key_set : Types.SAS.t Ctypes_static.ptr -> intsas_is_their_key_set sasChecks if their key was set.
val sas_generate_bytes : Types.SAS.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tsas_generate_bytes sas info info_len output output_lenGenerate bytes to use for the short authentication string.
Takes a SAS object, extra information to mix in when generating the bytes, as per the Matrix spec, and a buffer in which to store the output. For hex-based SAS as in the Matrix spec, the length of the output will be 5.
val sas_mac_length : Types.SAS.t Ctypes_static.ptr -> Unsigned.size_tsas_mac_length sasThe size of the message authentication code generated by olm_sas_calculate_mac()`.
val sas_calculate_mac : Types.SAS.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tsas_calculate_mac sas input input_len info info_len mac mac_lenGenerate a message authentication code (MAC) based on the shared secret.
Takes a SAS object, the message to produce the authentication code for, the extra information to mix in when generating the MAC, as per the Matrix spec, and the buffer in which to store the generated MAC.
Returns `olm_error()` on failure. If the `mac` buffer is too small, then `olm_sas_last_error()` will be `OUTPUT_BUFFER_TOO_SMALL`.
val sas_calculate_mac_long_kdf : Types.SAS.t Ctypes_static.ptr -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> unit Ctypes_static.ptr -> Unsigned.size_t -> Unsigned.size_tsas_calculate_mac_long_kdf sas input input_len info info_len mac mac_lenFor compatibility with an old version of Riot.