Skip to content

Commit d77ef65

Browse files
authored
Merge pull request #7876 from whatyouhide/improve-crypto-docs-on-aad
Improve crypto docs around "AAD"
2 parents 87aabb2 + 83a2c4b commit d77ef65

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

lib/crypto/doc/src/crypto.xml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<item>
4343
<url href="https://www.nist.gov/publications/sha-3-standard-permutation-based-hash-and-extendable-output-functions?pub_id=919061">
4444
SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions [FIPS PUB 202]
45-
</url>
45+
</url>
4646
</item>
4747
<tag>BLAKE2</tag>
4848
<item>
@@ -404,7 +404,7 @@
404404
<desc>
405405
<code>srp_public() = key_integer() </code>
406406
<p>Where is <c>A</c> or <c>B</c> from <url href="http://srp.stanford.edu/design.html">SRP design</url></p>
407-
407+
408408
<code>srp_private() = key_integer() </code>
409409
<p>Where is <c>a</c> or <c>b</c> from <url href="http://srp.stanford.edu/design.html">SRP design</url></p>
410410
</desc>
@@ -630,7 +630,7 @@ end
630630
</section>
631631

632632
<!--================ FUNCTIONS ================-->
633-
633+
634634

635635
<funcs>
636636
<func>
@@ -709,7 +709,7 @@ end
709709
<p>Uses the <seeerl marker="#error_3tup">3-tuple style</seeerl> for error handling.</p>
710710
<p>
711711
It does an actual crypto operation on a part of the full text. If the part is less
712-
than a number of full blocks, only the full blocks (possibly none) are encrypted
712+
than a number of full blocks, only the full blocks (possibly none) are encrypted
713713
or decrypted and the remaining bytes are saved to the next <c>crypto_update</c> operation.
714714
The <c>State</c> should be created with
715715
<seemfa marker="crypto#crypto_init/3">crypto_init/3</seemfa>
@@ -835,6 +835,12 @@ end
835835
<p>For decryption, set the <c>EncryptFlag</c> to <c>false</c> and put the tag to be checked
836836
in the argument <c>TagOrTagLength</c>.
837837
</p>
838+
<p>Additional Authentication Data (AAD) is plaintext data that will not be encrypted,
839+
but will be covered by authenticity protection. It should be provided through the <c>AAD</c>
840+
argument, but can be an empty binary as well (<c>&lt;&lt;&gt;&gt;</c>) if not needed. In that
841+
case, a plain AE (Authenticated Encryption) is performed instead of AEAD (Authenticated
842+
Encryption with Associated Data). This function only supports ciphers that can be used both with
843+
and without AAD.</p>
838844
<p>See <seeguide marker="crypto:new_api#example-of-crypto_one_time_aead-6">examples in the User's Guide.</seeguide>
839845
</p>
840846
</desc>
@@ -1715,7 +1721,7 @@ FloatValue = rand:uniform(). % again
17151721
</func>
17161722

17171723
</funcs>
1718-
1724+
17191725

17201726
<funcs>
17211727
<fsdescription>
@@ -1728,7 +1734,7 @@ FloatValue = rand:uniform(). % again
17281734
<desc>
17291735
<p>Fetches the corresponding public key from a private key stored in an Engine.
17301736
The key must be of the type indicated by the Type parameter.
1731-
</p>
1737+
</p>
17321738
</desc>
17331739
</func>
17341740

@@ -1952,20 +1958,20 @@ FloatValue = rand:uniform(). % again
19521958
<desc>
19531959
<p>
19541960
Loads an engine given by <c>EngineId</c> and the path to the dynamic library
1955-
implementing the engine. An error tuple is returned if the engine can't be loaded.
1961+
implementing the engine. An error tuple is returned if the engine can't be loaded.
19561962

19571963
</p>
19581964
<p>
19591965
This function differs from the normal engine_load in the sense that it
19601966
also add the engine id to OpenSSL's internal engine list. The difference between
1961-
the first call and the following is that the first loads the engine with the dynamical
1967+
the first call and the following is that the first loads the engine with the dynamical
19621968
engine and the following calls fetch it from the OpenSSL's engine list.
19631969
All references that is returned are equal.
19641970
</p>
19651971
<p>
19661972
Use <c>engine_unload/1</c> function to remove the references. But remember that
19671973
<c>engine_unload/1</c> just removes the references to the engine and not the
1968-
tag in OpenSSL's engine list. That has to be done with the <c>engine_remove/1</c>
1974+
tag in OpenSSL's engine list. That has to be done with the <c>engine_remove/1</c>
19691975
function when needed (just called once, from any of the references you got).
19701976
</p>
19711977
<p>

lib/crypto/doc/src/new_api.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@
257257
&lt;&lt;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>
258258
3> Txt = [&lt;&lt;"First bytes">>,&lt;&lt;"Second bytes">>].
259259
[&lt;&lt;"First bytes">>,&lt;&lt;"Second bytes">>]
260-
4> AAD = &lt;&lt;"Some bytes">>.
261-
&lt;&lt;"Some bytes">>
260+
4> AAD = &lt;&lt;"Some additional auth data">>.
261+
&lt;&lt;"Some additional auth data">>
262262
5> crypto:crypto_one_time_aead(aes_128_gcm, Key, IV, Txt, AAD, true).
263263
{&lt;&lt;240,130,38,96,130,241,189,52,3,190,179,213,132,1,72,
264264
192,103,176,90,104,15,71,158>>,

0 commit comments

Comments
 (0)