Module Olm.Session
module Message : sig ... endtype t={buf : char Ctypes.ptr;ses : C.Types.Session.t Ctypes_static.ptr;}
val clear : C.Types.Session.t Ctypes_static.ptr -> (int, [> `OlmError ]) Core.resultclear sesClear memory backing the given
sespointer.
val check_error : t -> Unsigned.size_t -> (int, [> OlmError.t ]) Core.resultcheck_error t retCheck whether return code
retis equal to `olm_error()` ( -1 ), returning the return value as an int if not, and the `last_error` from the sessiontif so.
val alloc : unit -> talloc ()Allocate an
C.Types.Session.tand return the pointers in at.
val create_inbound : ?identity_key:string -> Account.t -> Message.t -> (t, [> OlmError.t | `ValueError of string ]) Core.resultcreate_inbound ?identity_key acc msgCreate a new in-bound session with the account
accfor sending/receiving messages from an incoming prekeymsg. If an?identity_keyis supplied, it will be used to check whether themsgwas actually sent using it. If the base64 key cannot be decoded, the error will will be`InvalidBase64.`BadMessageVersionresults if themsgwas for an unsupported protocol. If themsgcould not be decoded,`BadMessageFormatwill result. If the message refers to an unknown one-time key, then the error will be`BadMessageKeyId.
val create_outbound : Account.t -> string -> string -> (t, [> OlmError.t | `ValueError of string ]) Core.resultcreate_outbound acc identity_key one_time_keyCreates a new outbound session with the account
accfor sending messages to a givenidentity_keyandone_time_key. If the keys couldn't be decoded as base64 then the error message will be "INVALID_BASE64".
val pickle : ?pass:string -> t -> (string, [> OlmError.t ]) Core.resultpickle ?pass tStores an session object
tas a base64 string. Encrypting it using the optionally supplied passphrase?pass. Returns a base64 encoded string of the pickled session on success.
val from_pickle : ?pass:string -> string -> (t, [> OlmError.t | `ValueError of string ]) Core.resultfrom_pickle ?pass pickleLoads an session from a pickled base64-encoded string
pickleand returns at, decrypted with the optionally supplied passphrase?pass. If the passphrase doesn't match the one used to encrypt the session then the error will be`BadAccountKey. If the base64 couldn't be decoded then the error will be`InvalidBase64.
val encrypt : t -> string -> (Message.t, [> OlmError.t | `ValueError of string ]) Core.resultencrypt t plaintextEncrypts a
plaintextmessage using the sessiont. Returns the ciphertext as a base64 encoded string on success.
val decrypt : ?ignore_unicode_errors:bool -> t -> Message.t -> (string, [> OlmError.t | `ValueError of string | `UnicodeError ]) Core.resultdecrypt t msgDecrypts a
msgusing the sessiont. Invalid unicode characters are replaced withUutf.u_repunlessignore_unicode_errorsis set to true. If the base64 cannot be decoded, the error will be`InvalidBase64.`BadMessageVersionresults if the message was for an unsupported protocol. If themsgcould not be decoded,`BadMessageFormatwill result. If the MAC on the message was invalid then the error message will be "BAD_MESSAGE_MAC".
val id : t -> (string, [> OlmError.t ]) Core.resultid tGet the identifier for the session
t. It will be the same for both ends of the conversation.
val matches : ?identity_key:string -> t -> Message.t -> (bool, [> OlmError.t | `ValueError of string ]) Core.resultmatches ?identity_key t msgChecks if the PreKey
msg(`ValueError if not PreKey) is for the in-bound sessiont. This can happen if multiple messages are sent totbefore it sends a message in reply. Returns true if the session matches, false if not. Ifidentity_keyis provided, themsgwill be checked against it to ensure it came from the expected sender.
val remove_one_time_keys : t -> Account.t -> (int, [> OlmError.t ]) Core.resultremove_one_time_keys t accRemoves the one-time keys that the session
tused from the accountacc. If the account doesn't have any matching one-time keys then the error will be`BadMessageKeyId.