Struct matrix_sdk_crypto::olm::SessionKey
source · [−]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
sourceimpl SessionKey
impl SessionKey
sourcepub fn to_bytes(&self) -> Vec<u8, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_bytes(&self) -> Vec<u8, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Serialize the SessionKey
to a byte vector.
sourcepub fn from_bytes(bytes: &[u8]) -> Result<SessionKey, SessionKeyDecodeError>
pub fn from_bytes(bytes: &[u8]) -> Result<SessionKey, SessionKeyDecodeError>
Deserialize the SessionKey
from a byte slice.
sourcepub 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.
sourcepub 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
sourceimpl<'de> Deserialize<'de> for SessionKey
impl<'de> Deserialize<'de> for SessionKey
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Serialize for SessionKey
impl Serialize for SessionKey
sourcefn 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,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for SessionKey
impl Send for SessionKey
impl Sync for SessionKey
impl Unpin for SessionKey
impl UnwindSafe for SessionKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more