Skip to content

Commit

Permalink
Make it clear that encryption is with AEAD (google#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddrysdale authored Jan 21, 2023
1 parent 4423922 commit 8aa7edf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 0.3.4 - TBD

- Add non-default `std` feature that turns on `impl Error for CoseError`.
- Add `cwt::ClaimsSetBuilder::private_claim` method.
- Update documentation for existing encryption methods to make it clear that they only support AEAD encryption.

## 0.3.3 - 2022-09-30

- Add `CoseKeyBuilder` methods `kty`, `key_type` and `new_okp_key`.
Expand Down
48 changes: 24 additions & 24 deletions src/encrypt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ impl AsCborValue for CoseRecipient {
}

impl CoseRecipient {
/// Decrypt the `ciphertext` value, using `cipher` to decrypt the cipher text and
/// combined AAD.
/// Decrypt the `ciphertext` value with an AEAD, using `cipher` to decrypt the cipher text and
/// combined AAD as per RFC 8152 section 5.3.
///
/// # Panics
///
Expand Down Expand Up @@ -140,9 +140,9 @@ impl CoseRecipientBuilder {
self
}

/// Calculate the ciphertext value, using `cipher` to generate the encrypted bytes from the
/// plaintext and combined AAD (in that order). Any protected header values should be set
/// before using this method.
/// Calculate the ciphertext value with an AEAD, using `cipher` to generate the encrypted bytes
/// from the plaintext and combined AAD (in that order) as per RFC 8152 section 5.3. Any
/// protected header values should be set before using this method.
///
/// # Panics
///
Expand All @@ -162,9 +162,9 @@ impl CoseRecipientBuilder {
self.ciphertext(cipher(plaintext, &aad))
}

/// Calculate the ciphertext value, using `cipher` to generate the encrypted bytes from the
/// plaintext and combined AAD (in that order). Any protected header values should be set
/// before using this method.
/// Calculate the ciphertext value with an AEAD, using `cipher` to generate the encrypted bytes
/// from the plaintext and combined AAD (in that order) as per RFC 8152 section 5.3. Any
/// protected header values should be set before using this method.
///
/// # Panics
///
Expand All @@ -183,8 +183,8 @@ impl CoseRecipientBuilder {
Ok(self.ciphertext(cipher(plaintext, &aad)?))
}

/// Construct the combined AAD data needed for encryption. Any protected header values should be
/// set before using this method.
/// Construct the combined AAD data needed for encryption with an AEAD. Any protected header
/// values should be set before using this method.
///
/// # Panics
///
Expand Down Expand Up @@ -261,7 +261,7 @@ impl AsCborValue for CoseEncrypt {
}

impl CoseEncrypt {
/// Decrypt the `ciphertext` value, using `cipher` to decrypt the cipher text and
/// Decrypt the `ciphertext` value with an AEAD, using `cipher` to decrypt the cipher text and
/// combined AAD.
///
/// # Panics
Expand Down Expand Up @@ -291,9 +291,9 @@ impl CoseEncryptBuilder {
builder_set! {unprotected: Header}
builder_set_optional! {ciphertext: Vec<u8>}

/// Calculate the ciphertext value, using `cipher` to generate the encrypted bytes from the
/// plaintext and combined AAD (in that order). Any protected header values should be set
/// before using this method.
/// Calculate the ciphertext value with an AEAD, using `cipher` to generate the encrypted bytes
/// from the plaintext and combined AAD (in that order) as per RFC 8152 section 5.3. Any
/// protected header values should be set before using this method.
#[must_use]
pub fn create_ciphertext<F>(self, plaintext: &[u8], external_aad: &[u8], cipher: F) -> Self
where
Expand All @@ -307,9 +307,9 @@ impl CoseEncryptBuilder {
self.ciphertext(cipher(plaintext, &aad))
}

/// Calculate the ciphertext value, using `cipher` to generate the encrypted bytes from the
/// plaintext and combined AAD (in that order). Any protected header values should be set
/// before using this method.
/// Calculate the ciphertext value with an AEAD, using `cipher` to generate the encrypted bytes
/// from the plaintext and combined AAD (in that order) as per RFC 8152 section 5.3. Any
/// protected header values should be set before using this method.
pub fn try_create_ciphertext<F, E>(
self,
plaintext: &[u8],
Expand Down Expand Up @@ -389,7 +389,7 @@ impl AsCborValue for CoseEncrypt0 {
}

impl CoseEncrypt0 {
/// Decrypt the `ciphertext` value, using `cipher` to decrypt the cipher text and
/// Decrypt the `ciphertext` value with an AEAD, using `cipher` to decrypt the cipher text and
/// combined AAD.
///
/// # Panics
Expand Down Expand Up @@ -419,9 +419,9 @@ impl CoseEncrypt0Builder {
builder_set! {unprotected: Header}
builder_set_optional! {ciphertext: Vec<u8>}

/// Calculate the ciphertext value, using `cipher` to generate the encrypted bytes from the
/// plaintext and combined AAD (in that order). Any protected header values should be set
/// before using this method.
/// Calculate the ciphertext value with an AEAD, using `cipher` to generate the encrypted bytes
/// from the plaintext and combined AAD (in that order) as per RFC 8152 section 5.3. Any
/// protected header values should be set before using this method.
#[must_use]
pub fn create_ciphertext<F>(self, plaintext: &[u8], external_aad: &[u8], cipher: F) -> Self
where
Expand All @@ -435,9 +435,9 @@ impl CoseEncrypt0Builder {
self.ciphertext(cipher(plaintext, &aad))
}

/// Calculate the ciphertext value, using `cipher` to generate the encrypted bytes from the
/// plaintext and combined AAD (in that order). Any protected header values should be set
/// before using this method.
/// Calculate the ciphertext value with an AEAD, using `cipher` to generate the encrypted bytes
/// from the plaintext and combined AAD (in that order) as per RFC 8152 section 5.3. Any
/// protected header values should be set before using this method.
pub fn try_create_ciphertext<F, E>(
self,
plaintext: &[u8],
Expand Down

0 comments on commit 8aa7edf

Please sign in to comment.