File 0412-crypto-Add-doc-warning-about-AEAD-decryption-tag-len.patch of Package erlang
From 2b53202bd8dfcda87c72d9d614e21b729cb7805d Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Thu, 4 Sep 2025 15:58:07 +0200
Subject: [PATCH 1/2] crypto: Add doc warning about AEAD decryption tag length
---
lib/crypto/src/crypto.erl | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index 27dc2e51dd..b5259cb2c9 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -1772,6 +1772,13 @@ length is wanted, the `crypto_one_time_aead/6` form may be used.
For decryption, set the `EncryptFlag` to `false` and put the tag to be checked
in the argument `TagOrTagLength`.
+> #### Warning {: .warning }
+>
+> The length of the tag at decryption is not checked by the function. It is the
+> caller's responsibility to ensure that the length of the tag matches the
+> length of the tag used when the data was encrypted. Otherwise the decryption
+> may succeed if the given tag only matches the start of the proper tag.
+
Additional Authentication Data (AAD) is plaintext data that will not be
encrypted, but will be covered by authenticity protection. It should be provided
through the `AAD` argument, but can be an empty binary as well (`<<>>`) if not
--
2.51.0