[−][src]Trait pwbox::Cipher
Authenticated symmetric cipher.
Associated Constants
const KEY_LEN: usize
Byte size of a key.
const NONCE_LEN: usize
Byte size of a nonce (aka initialization vector, or IV).
const MAC_LEN: usize
Byte size of a message authentication code (MAC).
Required methods
fn seal(message: &[u8], nonce: &[u8], key: &[u8]) -> CipherOutput
Encrypts message
with the provided key
and nonce
.
Safety
When used within PwBox
, key
and nonce
are guaranteed
to have correct sizes.
fn open(
output: &mut [u8],
encrypted: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
output: &mut [u8],
encrypted: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
Implementations on Foreign Types
impl Cipher for ChaCha20Poly1305
[src]
const KEY_LEN: usize
[src]
const NONCE_LEN: usize
[src]
const MAC_LEN: usize
[src]
fn seal(message: &[u8], nonce: &[u8], key: &[u8]) -> CipherOutput
[src]
fn open(
output: &mut [u8],
encrypted: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
[src]
output: &mut [u8],
encrypted: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
Implementors
impl Cipher for Aes128Gcm
[src]
const KEY_LEN: usize
[src]
const NONCE_LEN: usize
[src]
const MAC_LEN: usize
[src]
fn seal(message: &[u8], nonce: &[u8], key: &[u8]) -> CipherOutput
[src]
fn open(
output: &mut [u8],
enc: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
[src]
output: &mut [u8],
enc: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
impl Cipher for pwbox::sodium::ChaCha20Poly1305
[src]
const KEY_LEN: usize
[src]
const NONCE_LEN: usize
[src]
const MAC_LEN: usize
[src]
fn seal(message: &[u8], nonce: &[u8], key: &[u8]) -> CipherOutput
[src]
fn open(
output: &mut [u8],
enc: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
[src]
output: &mut [u8],
enc: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
impl Cipher for XSalsa20Poly1305
[src]
const KEY_LEN: usize
[src]
const NONCE_LEN: usize
[src]
const MAC_LEN: usize
[src]
fn seal(message: &[u8], nonce: &[u8], key: &[u8]) -> CipherOutput
[src]
fn open(
output: &mut [u8],
enc: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
[src]
output: &mut [u8],
enc: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
impl<C, M> Cipher for CipherWithMac<C, M> where
C: UnauthenticatedCipher,
M: Mac,
[src]
C: UnauthenticatedCipher,
M: Mac,
const KEY_LEN: usize
[src]
Equals to the sum of key sizes for the cipher and MAC.
const NONCE_LEN: usize
[src]
const MAC_LEN: usize
[src]
fn seal(message: &[u8], nonce: &[u8], key: &[u8]) -> CipherOutput
[src]
Works as follows:
- Split the key into
cipher_key
(first bytes of the key) andmac_key
(remaining bytes). - Encrypt the
message
using the cipher undercipher_key
andnonce
. - Compute MAC over the ciphertext with
mac_key
.
fn open(
output: &mut [u8],
enc: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
[src]
output: &mut [u8],
enc: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
Works as follows:
- Split the key into
cipher_key
(first bytes of the key) andmac_key
(remaining bytes). - Compute MAC over the ciphertext with
mac_key
. If MAC is not equal to the supplied one, returnNone
. - Decrypt the ciphertext under the
cipher_key
andnonce
.