Struct matrix_sdk_crypto::olm::SessionKey
pub struct SessionKey { /* private fields */ }
Expand description
The session key, can be used to create a InboundGroupSession
.
Uses the session-sharing format described in the Olm spec.
+—+––+––––+––––+––––+––––+——+———–+ | V | i | R(i,0) | R(i,1) | R(i,2) | R(i,3) | Kpub | Signature | +—+––+––––+––––+––––+––––+——+———–+ 0 1 5 37 69 101 133 165 229 bytes
The version byte, V, is “\x02”. This is followed by the ratchet index, iii, which is encoded as a big-endian 32-bit integer; the 128 bytes of the ratchet; and the public part of the Ed25519 keypair.
The data is then signed using the Ed25519 key, and the 64-byte signature is appended.
Implementations§
§impl SessionKey
impl SessionKey
pub fn from_bytes(bytes: &[u8]) -> Result<SessionKey, SessionKeyDecodeError>
pub fn from_bytes(bytes: &[u8]) -> Result<SessionKey, SessionKeyDecodeError>
Deserialize the SessionKey
from a byte slice.
pub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Serialize the SessionKey
to a base64 encoded string.
This method will first use the SessionKey::to_bytes()
to
convert the session key to a byte vector and then encode the byte vector
to a string using unpadded base64 as the encoding.
pub fn from_base64(key: &str) -> Result<SessionKey, SessionKeyDecodeError>
pub fn from_base64(key: &str) -> Result<SessionKey, SessionKeyDecodeError>
Deserialize the SessionKey
from base64 encoded string.
Trait Implementations§
§impl<'de> Deserialize<'de> for SessionKey
impl<'de> Deserialize<'de> for SessionKey
§fn deserialize<D>(
deserializer: D
) -> Result<SessionKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<SessionKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl Serialize for SessionKey
impl Serialize for SessionKey
§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
§impl TryFrom<&[u8]> for SessionKey
impl TryFrom<&[u8]> for SessionKey
§impl TryFrom<&str> for SessionKey
impl TryFrom<&str> for SessionKey
§impl Zeroize for SessionKey
impl Zeroize for SessionKey
Auto Trait Implementations§
impl Freeze for SessionKey
impl RefUnwindSafe for SessionKey
impl Send for SessionKey
impl Sync for SessionKey
impl Unpin for SessionKey
impl UnwindSafe for SessionKey
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CompatExt for T
impl<T> CompatExt for T
source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more