authorgravatar for luizberti@users.noreply.github.comLuiz Berti <luizberti@users.noreply.github.com> 2023-07-17 18:16:41-03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-07-17 21:16:41+00:00
loga86f589a9f03622aa13eab4895c505c7f131c075
tree5f441bcea8ae255ad35b1ec9aa49d26f76f1b4bc
parentbf827d0b555df47ad2a2ea2062e2c855255c74d1
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Small documentation fixes on `std.crypto` (#16427)

* Small documentation fix of ChaCha variants Previous documentation was seemingly copy-pasted and left behind some errors where the number of rounds was not properly updated. * Suggest `std.crypto.utils.secureZero` on `@memset` docs * Revert previous change

2 files changed, 12 insertions(+), 10 deletions(-)

doc/langref.html.in+2
...@@ -8772,6 +8772,8 @@ test "integer cast panic" {...@@ -8772,6 +8772,8 @@ test "integer cast panic" {
8772 <p>{#syntax#}dest{#endsyntax#} must be a mutable slice or a mutable pointer to an array.8772 <p>{#syntax#}dest{#endsyntax#} must be a mutable slice or a mutable pointer to an array.
8773 It may have any alignment, and it may have any element type.</p>8773 It may have any alignment, and it may have any element type.</p>
8774 <p>{#syntax#}elem{#endsyntax#} is coerced to the element type of {#syntax#}dest{#endsyntax#}.</p>8774 <p>{#syntax#}elem{#endsyntax#} is coerced to the element type of {#syntax#}dest{#endsyntax#}.</p>
8775 <p>For securely zeroing out sensitive contents from memory, you should use
8776 {#syntax#}std.crypto.utils.secureZero{#endsyntax#}</p>
8775 {#header_close#}8777 {#header_close#}
87768778
8777 {#header_open|@min#}8779 {#header_open|@min#}
lib/std/crypto/chacha20.zig+10-10
...@@ -15,12 +15,12 @@ pub const ChaCha20IETF = ChaChaIETF(20);...@@ -15,12 +15,12 @@ pub const ChaCha20IETF = ChaChaIETF(20);
1515
16/// IETF-variant of the ChaCha20 stream cipher, reduced to 12 rounds.16/// IETF-variant of the ChaCha20 stream cipher, reduced to 12 rounds.
17/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.17/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
18/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.18/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
19pub const ChaCha12IETF = ChaChaIETF(12);19pub const ChaCha12IETF = ChaChaIETF(12);
2020
21/// IETF-variant of the ChaCha20 stream cipher, reduced to 8 rounds.21/// IETF-variant of the ChaCha20 stream cipher, reduced to 8 rounds.
22/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.22/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
23/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.23/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
24pub const ChaCha8IETF = ChaChaIETF(8);24pub const ChaCha8IETF = ChaChaIETF(8);
2525
26/// Original ChaCha20 stream cipher.26/// Original ChaCha20 stream cipher.
...@@ -28,12 +28,12 @@ pub const ChaCha20With64BitNonce = ChaChaWith64BitNonce(20);...@@ -28,12 +28,12 @@ pub const ChaCha20With64BitNonce = ChaChaWith64BitNonce(20);
2828
29/// Original ChaCha20 stream cipher, reduced to 12 rounds.29/// Original ChaCha20 stream cipher, reduced to 12 rounds.
30/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.30/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
31/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.31/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
32pub const ChaCha12With64BitNonce = ChaChaWith64BitNonce(12);32pub const ChaCha12With64BitNonce = ChaChaWith64BitNonce(12);
3333
34/// Original ChaCha20 stream cipher, reduced to 8 rounds.34/// Original ChaCha20 stream cipher, reduced to 8 rounds.
35/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.35/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
36/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.36/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
37pub const ChaCha8With64BitNonce = ChaChaWith64BitNonce(8);37pub const ChaCha8With64BitNonce = ChaChaWith64BitNonce(8);
3838
39/// XChaCha20 (nonce-extended version of the IETF ChaCha20 variant) stream cipher39/// XChaCha20 (nonce-extended version of the IETF ChaCha20 variant) stream cipher
...@@ -41,12 +41,12 @@ pub const XChaCha20IETF = XChaChaIETF(20);...@@ -41,12 +41,12 @@ pub const XChaCha20IETF = XChaChaIETF(20);
4141
42/// XChaCha20 (nonce-extended version of the IETF ChaCha20 variant) stream cipher, reduced to 12 rounds42/// XChaCha20 (nonce-extended version of the IETF ChaCha20 variant) stream cipher, reduced to 12 rounds
43/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.43/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
44/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.44/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
45pub const XChaCha12IETF = XChaChaIETF(12);45pub const XChaCha12IETF = XChaChaIETF(12);
4646
47/// XChaCha20 (nonce-extended version of the IETF ChaCha20 variant) stream cipher, reduced to 8 rounds47/// XChaCha20 (nonce-extended version of the IETF ChaCha20 variant) stream cipher, reduced to 8 rounds
48/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.48/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
49/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.49/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
50pub const XChaCha8IETF = XChaChaIETF(8);50pub const XChaCha8IETF = XChaChaIETF(8);
5151
52/// ChaCha20-Poly1305 authenticated cipher, as designed for TLS52/// ChaCha20-Poly1305 authenticated cipher, as designed for TLS
...@@ -54,12 +54,12 @@ pub const ChaCha20Poly1305 = ChaChaPoly1305(20);...@@ -54,12 +54,12 @@ pub const ChaCha20Poly1305 = ChaChaPoly1305(20);
5454
55/// ChaCha20-Poly1305 authenticated cipher, reduced to 12 rounds55/// ChaCha20-Poly1305 authenticated cipher, reduced to 12 rounds
56/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.56/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
57/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.57/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
58pub const ChaCha12Poly1305 = ChaChaPoly1305(12);58pub const ChaCha12Poly1305 = ChaChaPoly1305(12);
5959
60/// ChaCha20-Poly1305 authenticated cipher, reduced to 8 rounds60/// ChaCha20-Poly1305 authenticated cipher, reduced to 8 rounds
61/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.61/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
62/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.62/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
63pub const ChaCha8Poly1305 = ChaChaPoly1305(8);63pub const ChaCha8Poly1305 = ChaChaPoly1305(8);
6464
65/// XChaCha20-Poly1305 authenticated cipher65/// XChaCha20-Poly1305 authenticated cipher
...@@ -67,12 +67,12 @@ pub const XChaCha20Poly1305 = XChaChaPoly1305(20);...@@ -67,12 +67,12 @@ pub const XChaCha20Poly1305 = XChaChaPoly1305(20);
6767
68/// XChaCha20-Poly1305 authenticated cipher68/// XChaCha20-Poly1305 authenticated cipher
69/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.69/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
70/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.70/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
71pub const XChaCha12Poly1305 = XChaChaPoly1305(12);71pub const XChaCha12Poly1305 = XChaChaPoly1305(12);
7272
73/// XChaCha20-Poly1305 authenticated cipher73/// XChaCha20-Poly1305 authenticated cipher
74/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.74/// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
75/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.75/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
76pub const XChaCha8Poly1305 = XChaChaPoly1305(8);76pub const XChaCha8Poly1305 = XChaChaPoly1305(8);
7777
78// Vectorized implementation of the core function78// Vectorized implementation of the core function