Skip to content

Commit

Permalink
doc: add comments for functions
Browse files Browse the repository at this point in the history
Add comments for functions:
- encrypt_auth_inplace
- decrypt_auth_inplace
  • Loading branch information
Taowyoo committed May 2, 2023
1 parent 64207ad commit 4b8c50a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions mbedtls/src/cipher/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,25 @@ impl Cipher {
Ok(plain_len)
}

/// The authenticated encryption (AEAD/NIST_KW) function.
///
/// For AEAD modes, the tag will be appended to the ciphertext, as recommended by RFC 5116.
/// (NIST_KW doesn't have a separate tag.)
///
/// # Arguments
///
/// * `ad` - The additional data to authenticate
/// * `data_with_tag` - The data to be encrypted and authenticated, along with space for the tag
/// * `tag_len` - The length of the tag to be generated
///
/// # Returns
///
/// * `Result<usize>` - The length of the encrypted data on success
///
/// # Errors
///
/// * `Error::CipherBadInputData` - If the size of `data_with_tag` minus `tag_len` is less than
/// or equal to zero
pub fn encrypt_auth_inplace(
&mut self,
ad: &[u8],
Expand Down Expand Up @@ -455,6 +474,29 @@ impl Cipher {
Ok(olen)
}


/// The authenticated encryption (AEAD/NIST_KW) function.
///
/// If the data is not authentic, then the output buffer is zeroed out to
/// prevent the unauthentic plaintext being used, making this interface safer.
///
/// For AEAD modes, the tag must be appended to the ciphertext, as recommended by RFC 5116.
/// (NIST_KW doesn't have a separate tag.)
///
/// # Arguments
///
/// * `ad` - The additional data to authenticate
/// * `data_with_tag` - The data to be encrypted and authenticated, along with space for the tag
/// * `tag_len` - The length of the tag to be generated
///
/// # Returns
///
/// * `Result<usize>` - The length of the decrypted data on success
///
/// # Errors
///
/// * `Error::CipherBadInputData` - If the size of `data_with_tag` minus `tag_len` is less than
/// or equal to zero
pub fn decrypt_auth_inplace(
&mut self,
ad: &[u8],
Expand Down

0 comments on commit 4b8c50a

Please sign in to comment.