Skip to content

Commit

Permalink
more review
Browse files Browse the repository at this point in the history
  • Loading branch information
keks committed Dec 19, 2024
1 parent 1d5588c commit 15b5b01
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 255 deletions.
2 changes: 2 additions & 0 deletions chacha20poly1305/src/hacl/aead_chacha20poly1305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ Note: Encryption and decryption can be executed in-place, i.e., `input` and `out
@param key Pointer to 32 bytes of memory where the AEAD key is read from.
@param nonce Pointer to 12 bytes of memory where the AEAD nonce is read from.
*/
#[allow(clippy::too_many_arguments)]
pub fn encrypt(
output: &mut [u8],
tag: &mut [u8],
Expand Down Expand Up @@ -572,6 +573,7 @@ If decryption fails, the array `output` remains unchanged and the function retur
@returns 0 on succeess; 1 on failure.
*/
#[allow(clippy::too_many_arguments)]
pub fn decrypt(
output: &mut [u8],
input: &[u8],
Expand Down
1 change: 1 addition & 0 deletions chacha20poly1305/src/hacl/chacha20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ pub fn chacha20_encrypt(len: u32, out: &mut [u8], text: &[u8], key: &[u8], n: &[
crate::hacl::chacha20::chacha20_update(&ctx, len, out, text)
}

#[allow(dead_code)]
pub fn chacha20_decrypt(len: u32, out: &mut [u8], cipher: &[u8], key: &[u8], n: &[u8], ctr: u32) {
let mut ctx: [u32; 16] = [0u32; 16usize];
crate::hacl::chacha20::chacha20_init(&mut ctx, key, n, ctr);
Expand Down
252 changes: 0 additions & 252 deletions chacha20poly1305/src/hacl/chacha20_vec32.rs

This file was deleted.

4 changes: 2 additions & 2 deletions chacha20poly1305/src/impl_hacl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub fn encrypt<'a>(

let aad_len: u32 = aad.len().try_into().map_err(|_| AeadError::AadTooLarge)?;

// we already knwo that ptxt.len() < u32::MAX, so we can safely add here.
if ctxt.len() < ptxt.len() + TAG_LEN {
// we already knwo that ptxt.len() < u32::MAX, so we can safely add if we use u64.
if (ctxt.len() as u64) < (ptxt.len() as u64) + (TAG_LEN as u64) {
return Err(AeadError::CiphertextTooShort);
}

Expand Down
1 change: 0 additions & 1 deletion chacha20poly1305/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ mod hacl {

pub(crate) mod aead_chacha20poly1305;
pub(crate) mod chacha20;
pub(crate) mod chacha20_vec32;
}

mod impl_hacl;
Expand Down
5 changes: 5 additions & 0 deletions rsa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ pub mod hacl {
/// The hash algorithm used for signing or verifying.
#[derive(Clone, Copy, Debug)]
pub enum DigestAlgorithm {
/// The SHA256 hash algorithm
Sha2_256,

/// The SHA384 hash algorithm
Sha2_384,

/// The SHA512 hash algorithm
Sha2_512,
}

Expand Down

0 comments on commit 15b5b01

Please sign in to comment.