Module Olm.Sas
type t
=
{
buf : char Ctypes.ptr;
sas : C.Types.SAS.t Ctypes_static.ptr;
}
val clear : C.Types.SAS.t Ctypes_static.ptr -> (int, [> `OlmError ]) Core.result
clear sas
Clear memory backing the given
sas
pointer.
val check_error : t -> Unsigned.size_t -> (int, [> OlmError.t ]) Core.result
check_error t ret
Check whether return code
ret
is equal to `olm_error()` ( -1 ), returning the return value as an int if not, and the `last_error` from the sast
if so.
val set_their_pubkey : t -> string -> (int, [> OlmError.t ]) Core.result
set_their_pubkey t key
Set the public
key
of the other user in the SAS objectt
. It needs to be set before bytes can be generated for the authentication string and a MAC can be calculated.
val alloc : unit -> t
alloc ()
Allocate an
C.Types.SAS.t
and return the pointers in at
.
val create : ?other_users_pubkey:string -> unit -> (t, [> OlmError.t ]) Core.result
create ?other_users_pubkey ()
Create a new SAS object with
alloc ()
, additionally setting the other users public key if provided.
val pubkey : t -> (string, [> OlmError.t ]) Core.result
pubkey t
Get the public key of the SAS object
t
that can then be shared with another user to perform the authentication process.
val other_key_set : t -> bool
other_key_set t
Check if the other user's pubkey has been set.
val generate_bytes : t -> string -> int -> (string, [> OlmError.t | `ValueError of string ]) Core.result
generate_bytes t extra_info length
Generate bytes to use for the short authentication string with SAS object
t
. Suppliedextra_info
is mixed in when generating the number of bytes indicated bylength
.
val calculate_mac : t -> string -> string -> (string, [> OlmError.t ]) Core.result
calculate_mac t msg extra_info
Generate a message authentication code (MAC) based on the shared secret held in the SAS object
t
, formsg
.extra_info
is mixed in with when generating the MAC.
val calculate_mac_long_kdf : t -> string -> string -> (string, [> OlmError.t ]) Core.result
calculate_mac_long_kdf t msg extra_info
For compatibility with an old version of Riot. Should not be used unless compatibility with an older non-tagged Olm version is required.