use crate::{zest_block::ZestBlock, zest_hash::zest4096};
pub fn zest_enc(
padded_text: Vec<ZestBlock>,
key: ZestBlock,
init_ctr_enc: Option<ZestBlock>,
init_result_dgst: Option<ZestBlock>,
init_ctr_dgst: Option<ZestBlock>,
) -> Vec<ZestBlock> {
let mut cipher_text = vec![];
let mut counter = init_ctr_enc.unwrap_or_else(ZestBlock::new);
let mut result_dgst = init_result_dgst.unwrap_or_else(ZestBlock::new);
let mut ctr_dgst = init_ctr_dgst.unwrap_or_else(ZestBlock::new);
for text_block in padded_text {
let mut cipher_block = zest4096(key ^ counter);
cipher_block ^= text_block;
counter.increment_block();
cipher_text.push(cipher_block);
result_dgst ^= zest4096(text_block + ctr_dgst);
ctr_dgst.increment_block();
}
cipher_text.push(result_dgst);
cipher_text
}