OlmPkDecryption

Struct OlmPkDecryption 

Source
pub struct OlmPkDecryption { /* private fields */ }
Expand description

The decryption part of a PK encrypted channel.

Implementations§

Source§

impl OlmPkDecryption

Source

pub fn new() -> Self

Create a new PK decryption object initializing the private key to a random value.

§Panics
  • NOT_ENOUGH_RANDOM if there’s not enough random data provided when creating the OlmPkDecryption object.
  • on malformed UTF-8 coding of the public key that is generated by libolm.
Source

pub fn private_key_length() -> usize

Get the number of bytes a private key needs to have.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, OlmPkDecryptionError>

Create a new PK decryption object from the given private key.

§Arguments

Warning: The caller needs to ensure that the passed in bytes are cryptographically sound.

§Panics
  • on malformed UTF-8 coding of the public key that is generated by libolm.
Source

pub fn pickle(&self, mode: PicklingMode) -> String

Store a PkDecryption object.

Stores a OlmPkDecryption object as a base64 string. Encrypts the object using the supplied passphrase. Returns a byte object containing the base64 encoded string of the pickled session.

§Arguments
  • mode - The pickle mode that should be used to store the decryption object.
§Panics
  • OUTPUT_BUFFER_TOO_SMALL for OlmSession’s pickled buffer
  • on malformed UTF-8 coding of the pickling provided by libolm
Source

pub fn unpickle( pickle: String, mode: PicklingMode, ) -> Result<Self, OlmPkDecryptionError>

Restore a previously stored OlmPkDecryption object.

Creates a OlmPkDecryption object from a pickled base64 string. Decrypts the pickled object using the supplied passphrase.

§Arguments
  • mode - The pickle mode that should be used to store the decryption object.
§C-API equivalent

olm_unpickle_pk_decryption

§Errors
  • BadAccountKey if the key doesn’t match the one the account was encrypted with
  • InvalidBase64 if decoding the supplied pickled string slice fails
§Panics
  • on malformed UTF-8 coding of the public key that is generated by libolm.
Source

pub fn decrypt( &self, message: PkMessage, ) -> Result<String, OlmPkDecryptionError>

Decrypts a PK message using this decryption object.

Decoding is lossy, meaing if the decrypted plaintext contains invalid UTF-8 symbols, they will be returned as U+FFFD (�).

§Arguments
  • message - The encrypted PkMessage that should be decrypted.
§C-API equivalent

olm_pk_decrypt

§Errors
  • InvalidBase64 on invalid base64 coding for supplied arguments
  • BadMessageVersion on unsupported protocol version
  • BadMessageFormat on failing to decode the message
  • BadMessageMac on invalid message MAC
§Panics
  • OutputBufferTooSmall on plaintext output buffer
Source

pub fn public_key(&self) -> &str

Get the public key of the decryption object.

This can be used to initialize a encryption object to encrypt messages for this decryption object.

Trait Implementations§

Source§

impl Default for OlmPkDecryption

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for OlmPkDecryption

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for OlmPkDecryption

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.