@@ -158,6 +158,9 @@ pub trait Aead: AeadCore {
158158 /// AES-GCM-SIV, ChaCha20Poly1305). [`Aead`] implementations which do not
159159 /// use a postfix tag will need to override this to correctly assemble the
160160 /// ciphertext message.
161+ ///
162+ /// # Errors
163+ /// AEAD algorithm implementations may return an error if the plaintext or AAD are too long.
161164 fn encrypt < ' msg , ' aad > (
162165 & self ,
163166 nonce : & Nonce < Self > ,
@@ -181,6 +184,11 @@ pub trait Aead: AeadCore {
181184 /// AES-GCM-SIV, ChaCha20Poly1305). [`Aead`] implementations which do not
182185 /// use a postfix tag will need to override this to correctly parse the
183186 /// ciphertext message.
187+ ///
188+ /// # Errors
189+ /// - if the `ciphertext` is inauthentic (i.e. tag verification failure)
190+ /// - if the `ciphertext` is too long
191+ /// - if the `aad` is too long
184192 fn decrypt < ' msg , ' aad > (
185193 & self ,
186194 nonce : & Nonce < Self > ,
@@ -217,6 +225,9 @@ impl<T: AeadInOut> Aead for T {
217225/// In-place and inout AEAD trait which handles the authentication tag as a return value/separate parameter.
218226pub trait AeadInOut : AeadCore {
219227 /// Encrypt the data in the provided [`InOutBuf`], returning the authentication tag.
228+ ///
229+ /// # Errors
230+ /// AEAD algorithm implementations may return an error if the plaintext or AAD are too long.
220231 fn encrypt_inout_detached (
221232 & self ,
222233 nonce : & Nonce < Self > ,
@@ -226,7 +237,12 @@ pub trait AeadInOut: AeadCore {
226237
227238 /// Decrypt the data in the provided [`InOutBuf`], returning an error in the event the
228239 /// provided authentication tag is invalid for the given ciphertext (i.e. ciphertext
229- /// is modified/unauthentic)
240+ /// is modified/unauthentic).
241+ ///
242+ /// # Errors
243+ /// - if the `ciphertext` is inauthentic (i.e. tag verification failure)
244+ /// - if the `ciphertext` is too long
245+ /// - if the `aad` is too long
230246 fn decrypt_inout_detached (
231247 & self ,
232248 nonce : & Nonce < Self > ,
@@ -242,6 +258,7 @@ pub trait AeadInOut: AeadCore {
242258 /// The exact size needed is cipher-dependent, but generally includes
243259 /// the size of an authentication tag.
244260 ///
261+ /// # Errors
245262 /// Returns an error if the buffer has insufficient capacity to store the
246263 /// resulting ciphertext message.
247264 fn encrypt_in_place (
@@ -275,6 +292,9 @@ pub trait AeadInOut: AeadCore {
275292 ///
276293 /// The buffer will be truncated to the length of the original plaintext
277294 /// message upon success.
295+ ///
296+ /// # Errors
297+ /// - if the `ciphertext` is inauthentic (i.e. tag verification failure)
278298 fn decrypt_in_place (
279299 & self ,
280300 nonce : & Nonce < Self > ,
@@ -306,6 +326,7 @@ pub trait AeadInOut: AeadCore {
306326///
307327/// NOTE: deprecated! Please migrate to [`AeadInOut`].
308328#[ deprecated( since = "0.6.0" , note = "use `AeadInOut` instead" ) ]
329+ #[ allow( clippy:: missing_errors_doc) ]
309330pub trait AeadInPlace : AeadCore {
310331 /// Encrypt the given buffer containing a plaintext message in-place.
311332 #[ deprecated( since = "0.6.0" , note = "use `AeadInOut::encrypt_in_place` instead" ) ]
@@ -435,10 +456,13 @@ pub trait Buffer: AsRef<[u8]> + AsMut<[u8]> {
435456 self . as_ref ( ) . is_empty ( )
436457 }
437458
438- /// Extend this buffer from the given slice
459+ /// Extend this buffer from the given slice.
460+ ///
461+ /// # Errors
462+ /// If the buffer has insufficient capacity.
439463 fn extend_from_slice ( & mut self , other : & [ u8 ] ) -> Result < ( ) > ;
440464
441- /// Truncate this buffer to the given size
465+ /// Truncate this buffer to the given size.
442466 fn truncate ( & mut self , len : usize ) ;
443467}
444468
0 commit comments