Struct wow_srp::wrath_header::ServerCrypto
source · pub struct ServerCrypto { /* private fields */ }
wrath-header
only.Expand description
Main struct for encryption or decryption.
Created from ProofSeed::into_server_header_crypto
.
Handles both encryption and decryption of headers through the
ServerEncrypterHalf
and ServerDecrypterHalf
structs.
Can be split into a ServerEncrypterHalf
and ServerDecrypterHalf
through
the ServerCrypto::split
method. This is useful if you have this struct behind a
mutex and don’t want to lock both reading and writing at the same time.
Implementations§
source§impl ServerCrypto
impl ServerCrypto
sourcepub fn decrypter(&mut self) -> &mut ServerDecrypterHalf
pub fn decrypter(&mut self) -> &mut ServerDecrypterHalf
Direct access to the internal ServerDecrypterHalf
.
sourcepub fn encrypter(&mut self) -> &mut ServerEncrypterHalf
pub fn encrypter(&mut self) -> &mut ServerEncrypterHalf
Direct access to the internal ServerEncrypterHalf
.
sourcepub fn encrypt(&mut self, data: &mut [u8])
pub fn encrypt(&mut self, data: &mut [u8])
Raw access to the encryption.
Use either the server
Write
function, or
the server array function.
sourcepub fn write_encrypted_server_header<W: Write>(
&mut self,
write: W,
size: u32,
opcode: u16
) -> Result<()>
pub fn write_encrypted_server_header<W: Write>( &mut self, write: W, size: u32, opcode: u16 ) -> Result<()>
Convenience wrapper for ServerEncrypterHalf::write_encrypted_server_header
.
§Errors
Has the same errors as ServerEncrypterHalf::write_encrypted_server_header
.
sourcepub fn encrypt_server_header(&mut self, size: u32, opcode: u16) -> &[u8] ⓘ
pub fn encrypt_server_header(&mut self, size: u32, opcode: u16) -> &[u8] ⓘ
Convenience wrapper for ServerEncrypterHalf::encrypt_server_header
.
sourcepub fn decrypt(&mut self, data: &mut [u8])
pub fn decrypt(&mut self, data: &mut [u8])
Raw access to decryption.
Use either the server
Read
function, or
the server array functions.
sourcepub fn read_and_decrypt_client_header<R: Read>(
&mut self,
reader: R
) -> Result<ClientHeader>
pub fn read_and_decrypt_client_header<R: Read>( &mut self, reader: R ) -> Result<ClientHeader>
Convenience wrapper for ServerDecrypterHalf::read_and_decrypt_client_header
.
§Errors
Has the same errors as ServerDecrypterHalf::read_and_decrypt_client_header
.
sourcepub fn decrypt_client_header(&mut self, data: [u8; 6]) -> ClientHeader
pub fn decrypt_client_header(&mut self, data: [u8; 6]) -> ClientHeader
Convenience wrapper for ServerDecrypterHalf::decrypt_client_header
.
Prefer this over directly using Self::decrypt
.
sourcepub fn split(self) -> (ServerEncrypterHalf, ServerDecrypterHalf)
pub fn split(self) -> (ServerEncrypterHalf, ServerDecrypterHalf)
Split the ServerCrypto
into two parts for use with split connections.
It is intended for the ServerEncrypterHalf
to be stored with the write half of
the connection and for the ServerDecrypterHalf
to be stored with the read half
of the connection.
This is not necessary to do unless you actually can split your connections into read and write halves, and you have some reason for not just keeping the crypto together like if you don’t want locking encryption to also lock decryption in a mutex.
Trait Implementations§
source§impl Clone for ServerCrypto
impl Clone for ServerCrypto
source§fn clone(&self) -> ServerCrypto
fn clone(&self) -> ServerCrypto
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ServerCrypto
impl Debug for ServerCrypto
source§impl Hash for ServerCrypto
impl Hash for ServerCrypto
source§impl Ord for ServerCrypto
impl Ord for ServerCrypto
source§fn cmp(&self, other: &ServerCrypto) -> Ordering
fn cmp(&self, other: &ServerCrypto) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for ServerCrypto
impl PartialEq for ServerCrypto
source§fn eq(&self, other: &ServerCrypto) -> bool
fn eq(&self, other: &ServerCrypto) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for ServerCrypto
impl PartialOrd for ServerCrypto
source§fn partial_cmp(&self, other: &ServerCrypto) -> Option<Ordering>
fn partial_cmp(&self, other: &ServerCrypto) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more