Module Pk.Decryption
type t
=
{
buf : char Ctypes.ptr;
pk_dec : C.Types.PkDecryption.t Ctypes_static.ptr;
pubkey : string;
}
val clear : C.Types.PkDecryption.t Ctypes_static.ptr -> (int, [> `OlmError ]) Core.result
clear pk_dec
Clear memory backing the given
pk_dec
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 pk decryption objectt
if so.
val alloc : unit -> t
alloc ()
Allocate an
C.Types.Pk.Decryption.t
and return the pointers in at
.
val create : unit -> (t, [> OlmError.t ]) Core.result
create ()
Create a new PK decryption object, returning its pointers and public key in a
t
val pickle : ?pass:string -> t -> (string, [> OlmError.t ]) Core.result
pickle ?pass t
Stores a PK decryption object
t
as a base64 string, encrypting it using the optionally supplied passphrasepass
. Returns a base64 encoded string of the pickled pk decryption on success.
val from_pickle : ?pass:string -> string -> (t, [> OlmError.t | `ValueError of string ]) Core.result
from_pickle ?pass pickle
Loads PK decryption object from a pickled base64-encoded string
pickle
and returns at
, decrypted with the optionally supplied passphrasepass
. If the passphrase doesn't match the one used to encrypt the account then the error will be`BadAccountKey
. If the base64 couldn't be decoded then the error will be`InvalidBase64
.
val decrypt : ?ignore_unicode_errors:bool -> t -> Message.t -> (string, [> OlmError.t | `UnicodeError ]) Core.result
decrypt t msg
Decrypts a previously encrypted pk
msg
into plaintext witht
. Invalid unicode characters are replaced withUutf.u_rep
unlessignore_unicode_errors
is set to true.
val private_key : t -> (string, [> OlmError.t ]) Core.result
private_key t
Get the private key from
t
.