pub struct Message { /* private fields */ }
Expand description
An encrypted Olm message.
Contains metadata that is required to find the correct ratchet state of a
Session
necessary to decrypt the message.
Implementations§
Source§impl Message
impl Message
Sourcepub const fn ratchet_key(&self) -> Curve25519PublicKey
pub const fn ratchet_key(&self) -> Curve25519PublicKey
The public part of the ratchet key, that was used when the message was encrypted.
Sourcepub const fn chain_index(&self) -> u64
pub const fn chain_index(&self) -> u64
The index of the chain that was used when the message was encrypted.
Sourcepub fn ciphertext(&self) -> &[u8] ⓘ
pub fn ciphertext(&self) -> &[u8] ⓘ
The actual ciphertext of the message.
Sourcepub const fn mac_truncated(&self) -> bool
pub const fn mac_truncated(&self) -> bool
Has the MAC been truncated in this Olm message.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, DecodeError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, DecodeError>
Try to decode the given byte slice as a Olm Message
.
The expected format of the byte array is described in the
Message::to_bytes()
method.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Encode the Message
as an array of bytes.
Olm Message
s consist of a one-byte version, followed by a variable
length payload and a fixed length message authentication code.
+--------------+------------------------------------+-----------+
| Version Byte | Payload Bytes | MAC Bytes |
+--------------+------------------------------------+-----------+
The payload uses a format based on the Protocol Buffers encoding. It consists of the following key-value pairs:
Name | Tag | Type | Meaning |
---|---|---|---|
Ratchet-Key | 0x0A | String | The public part of the ratchet key |
Chain-Index | 0x10 | Integer | The chain index, of the message |
Cipher-Text | 0x22 | String | The cipher-text of the message |
Sourcepub fn from_base64(message: &str) -> Result<Self, DecodeError>
pub fn from_base64(message: &str) -> Result<Self, DecodeError>
Try to decode the given string as a Olm Message
.
The string needs to be a base64 encoded byte array that follows the
format described in the Message::to_bytes()
method.
Sourcepub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Encode the Message
as a string.
This method first calls Message::to_bytes()
and then encodes the
resulting byte array as a string using base64 encoding.