pub struct Message {
pub source_public_key: Vec<u8>,
pub destination_public_key: Vec<u8>,
pub received_time: i64,
pub payload_digest: Vec<u8>,
pub stamp: Option<Stamp>,
pub scheme: i32,
pub salt: Vec<u8>,
pub payload_hmac: Vec<u8>,
pub payload_size: u64,
pub payload: Vec<u8>,
}
Expand description
The primary message used in communication over the relay protocol.
Fields§
§source_public_key: Vec<u8>
The source public key.
destination_public_key: Vec<u8>
The destinations public key.
received_time: i64
Maleable server time.
payload_digest: Vec<u8>
The SHA-256 digest of the payload.
stamp: Option<Stamp>
The stamp attached to the message.
scheme: i32
The encryption scheme used on the serialized Payload
to produce the
payload
field.
salt: Vec<u8>
The salt
is used to salt both the payload_hmac
and the encryption key.
payload_hmac: Vec<u8>
The HMAC of the payload
, specifically HMAC(HMAC(sdG, salt), payload_digest)
.
payload_size: u64
The size, in bytes, of the payload
.
payload: Vec<u8>
The encrypted payload
.
Implementations§
Source§impl Message
impl Message
Sourcepub fn scheme(&self) -> EncryptionScheme
pub fn scheme(&self) -> EncryptionScheme
Returns the enum value of scheme
, or the default if the field is set to an invalid enum value.
Sourcepub fn set_scheme(&mut self, value: EncryptionScheme)
pub fn set_scheme(&mut self, value: EncryptionScheme)
Sets scheme
to the provided enum value.
Source§impl Message
impl Message
Sourcepub fn digest(&self) -> Result<[u8; 32], DigestError>
pub fn digest(&self) -> Result<[u8; 32], DigestError>
Get the SHA-256 digest of the payload
, if payload_digest
is missing then calculate it.
Sourcepub fn parse(self) -> Result<ParsedMessage, ParseError>
pub fn parse(self) -> Result<ParsedMessage, ParseError>
Parse the Message to construct a ParsedMessage.
The involves deserialization of both public keys, calculation of the payload digest, and coercion of byte fields into arrays.
Trait Implementations§
Source§impl Message for Message
impl Message for Message
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Source§fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Source§fn decode<B>(buf: B) -> Result<Self, DecodeError>
fn decode<B>(buf: B) -> Result<Self, DecodeError>
Source§fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
Source§fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
self
. Read moreSource§fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
self
.