Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve crypto docs around "AAD" #7876

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve crypto docs around "AAD"
  • Loading branch information
whatyouhide committed Nov 16, 2023
commit bc16d8a973c11c0b6473ff634e1e2af8916660df
2 changes: 2 additions & 0 deletions lib/crypto/doc/src/crypto.xml
Original file line number Diff line number Diff line change
@@ -835,6 +835,8 @@ end
<p>For decryption, set the <c>EncryptFlag</c> to <c>false</c> and put the tag to be checked
in the argument <c>TagOrTagLength</c>.
</p>
<p>The <c>AAD</c> argument represents the Additional Authentication Data. It's optional. If it's
Copy link
Contributor

@IngelaAndin IngelaAndin Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that we should clarify this a little further. I suggest:

"AAD (Additional Authenticated data) is plaintext that will not be encrypted, but will be covered by authenticity protection. It should be provided by the AAD argument, but can be the empty binary and in that case a plain AE (Authenticated Encryption) is performed instead of the AEAD (Authenticated Encryption with Associated Data). This function only supports ciphers
that can be used both with and without AAD. "

What do you think? See also https://en.wikipedia.org/wiki/Authenticated_encryption

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IngelaAndin I like that, thanks for expanding on the doc! I updated the PR with your suggestion 🙃

not needed, it can be set to an empty binary (<c>&lt;&lt;&gt;&gt;</c>).
<p>See <seeguide marker="crypto:new_api#example-of-crypto_one_time_aead-6">examples in the User's Guide.</seeguide>
</p>
</desc>
4 changes: 2 additions & 2 deletions lib/crypto/doc/src/new_api.xml
Original file line number Diff line number Diff line change
@@ -257,8 +257,8 @@
&lt;&lt;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>
3> Txt = [&lt;&lt;"First bytes">>,&lt;&lt;"Second bytes">>].
[&lt;&lt;"First bytes">>,&lt;&lt;"Second bytes">>]
4> AAD = &lt;&lt;"Some bytes">>.
&lt;&lt;"Some bytes">>
4> AAD = &lt;&lt;"Some additional auth data">>.
&lt;&lt;"Some additional auth data">>
5> crypto:crypto_one_time_aead(aes_128_gcm, Key, IV, Txt, AAD, true).
{&lt;&lt;240,130,38,96,130,241,189,52,3,190,179,213,132,1,72,
192,103,176,90,104,15,71,158>>,