Skip to content

Commit

Permalink
eax: add API for online encryption/decryption (#214)
Browse files Browse the repository at this point in the history
This can be useful for two reasons, in addition to having the existing one-shot-like API:

1. The associated data can be processed separately
2. The protected data can be processed in a streaming fashion, rather than requiring it to be entirely allocated and 
    contiguous.
  • Loading branch information
Xanewok authored Sep 30, 2020
1 parent f961d58 commit 0a4b0a9
Show file tree
Hide file tree
Showing 2 changed files with 453 additions and 3 deletions.
8 changes: 5 additions & 3 deletions eax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#![deny(unsafe_code)]
#![warn(missing_docs, rust_2018_idioms)]

pub use aead::{self, AeadInPlace, Error, NewAead};
pub use aead::{self, AeadInPlace, Error, NewAead, Nonce};

use block_cipher::{
consts::{U0, U16},
Expand All @@ -103,6 +103,8 @@ pub const C_MAX: u64 = (1 << 36) + 16;
/// EAX tags
pub type Tag = GenericArray<u8, U16>;

pub mod online;

/// EAX: generic over an underlying block cipher implementation.
///
/// This type is generic to support substituting alternative cipher
Expand Down Expand Up @@ -142,7 +144,7 @@ where

fn encrypt_in_place_detached(
&self,
nonce: &GenericArray<u8, Self::NonceSize>,
nonce: &Nonce<Self::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
) -> Result<Tag, Error> {
Expand Down Expand Up @@ -175,7 +177,7 @@ where

fn decrypt_in_place_detached(
&self,
nonce: &GenericArray<u8, Self::NonceSize>,
nonce: &Nonce<Self::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
tag: &Tag,
Expand Down
Loading

0 comments on commit 0a4b0a9

Please sign in to comment.