pub trait SimplexSecretBox {
// Required methods
fn init(key: &XSalsa20Key, nonce: &XSalsa20Nonce) -> Self;
fn encrypt_chunk(&mut self, chunk: impl AsRef<[u8]>, buf: impl AsMut<[u8]>);
fn decrypt_chunk(&mut self, chunk: impl AsRef<[u8]>, buf: impl AsMut<[u8]>);
fn auth_tag(&mut self) -> Poly1305Tag;
fn verify_tag(&mut self, tag_to_verify: &Poly1305Tag) -> bool;
}Available on crate feature
crypto only.Required Methods§
Sourcefn init(key: &XSalsa20Key, nonce: &XSalsa20Nonce) -> Self
fn init(key: &XSalsa20Key, nonce: &XSalsa20Nonce) -> Self
Return a properly initialized SimpleX secretbox.
Beware that SimpleX uses a non-standard initialization like this:
intermediate = hsalsa20(xsalsa20_key, [0u8; 16]); xsalsa20 = xsalsa20_init(intermediate, xsalsa20_nonce); poly1305_key = (first 32 bytes of xsalsa20 cipherstream);
Sourcefn encrypt_chunk(&mut self, chunk: impl AsRef<[u8]>, buf: impl AsMut<[u8]>)
fn encrypt_chunk(&mut self, chunk: impl AsRef<[u8]>, buf: impl AsMut<[u8]>)
Write a ciphertext into a buf. Update poly1305 but do not authenticate the chunk, the
auth tag must be put only at the end of the whole message.
Sourcefn decrypt_chunk(&mut self, chunk: impl AsRef<[u8]>, buf: impl AsMut<[u8]>)
fn decrypt_chunk(&mut self, chunk: impl AsRef<[u8]>, buf: impl AsMut<[u8]>)
Write a plaintext into a buf. chunk is always pure ciphertext, simploxide utilities
guarantee that auth_tag won’t appear in the input chunk.
fn auth_tag(&mut self) -> Poly1305Tag
fn verify_tag(&mut self, tag_to_verify: &Poly1305Tag) -> bool
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl SimplexSecretBox for SecretBox
Available on crate feature
native_crypto only.