Commit a86f589a9f

Luiz Berti <luizberti@users.noreply.github.com>
2023-07-17 23:16:41
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
1 parent bf827d0
Changed files (2)
doc
lib
std
doc/langref.html.in
@@ -8772,6 +8772,8 @@ test "integer cast panic" {
       <p>{#syntax#}dest{#endsyntax#} must be a mutable slice or a mutable pointer to an array.
       It may have any alignment, and it may have any element type.</p>
       <p>{#syntax#}elem{#endsyntax#} is coerced to the element type of {#syntax#}dest{#endsyntax#}.</p>
+      <p>For securely zeroing out sensitive contents from memory, you should use
+      {#syntax#}std.crypto.utils.secureZero{#endsyntax#}</p>
       {#header_close#}
 
       {#header_open|@min#}
lib/std/crypto/chacha20.zig
@@ -15,12 +15,12 @@ pub const ChaCha20IETF = ChaChaIETF(20);
 
 /// IETF-variant of the ChaCha20 stream cipher, reduced to 12 rounds.
 /// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
-/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.
+/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
 pub const ChaCha12IETF = ChaChaIETF(12);
 
 /// IETF-variant of the ChaCha20 stream cipher, reduced to 8 rounds.
 /// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
-/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.
+/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
 pub const ChaCha8IETF = ChaChaIETF(8);
 
 /// Original ChaCha20 stream cipher.
@@ -28,12 +28,12 @@ pub const ChaCha20With64BitNonce = ChaChaWith64BitNonce(20);
 
 /// Original ChaCha20 stream cipher, reduced to 12 rounds.
 /// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
-/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.
+/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
 pub const ChaCha12With64BitNonce = ChaChaWith64BitNonce(12);
 
 /// Original ChaCha20 stream cipher, reduced to 8 rounds.
 /// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
-/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.
+/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
 pub const ChaCha8With64BitNonce = ChaChaWith64BitNonce(8);
 
 /// XChaCha20 (nonce-extended version of the IETF ChaCha20 variant) stream cipher
@@ -41,12 +41,12 @@ pub const XChaCha20IETF = XChaChaIETF(20);
 
 /// XChaCha20 (nonce-extended version of the IETF ChaCha20 variant) stream cipher, reduced to 12 rounds
 /// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
-/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.
+/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
 pub const XChaCha12IETF = XChaChaIETF(12);
 
 /// XChaCha20 (nonce-extended version of the IETF ChaCha20 variant) stream cipher, reduced to 8 rounds
 /// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
-/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.
+/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
 pub const XChaCha8IETF = XChaChaIETF(8);
 
 /// ChaCha20-Poly1305 authenticated cipher, as designed for TLS
@@ -54,12 +54,12 @@ pub const ChaCha20Poly1305 = ChaChaPoly1305(20);
 
 /// ChaCha20-Poly1305 authenticated cipher, reduced to 12 rounds
 /// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
-/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.
+/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
 pub const ChaCha12Poly1305 = ChaChaPoly1305(12);
 
 /// ChaCha20-Poly1305 authenticated cipher, reduced to 8 rounds
 /// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
-/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.
+/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
 pub const ChaCha8Poly1305 = ChaChaPoly1305(8);
 
 /// XChaCha20-Poly1305 authenticated cipher
@@ -67,12 +67,12 @@ pub const XChaCha20Poly1305 = XChaChaPoly1305(20);
 
 /// XChaCha20-Poly1305 authenticated cipher
 /// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
-/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.
+/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
 pub const XChaCha12Poly1305 = XChaChaPoly1305(12);
 
 /// XChaCha20-Poly1305 authenticated cipher
 /// Reduced-rounds versions are faster than the full-round version, but have a lower security margin.
-/// However, ChaCha is still believed to have a comfortable security even with only with 8 rounds.
+/// However, ChaCha is still believed to have a comfortable security even with only 8 rounds.
 pub const XChaCha8Poly1305 = XChaChaPoly1305(8);
 
 // Vectorized implementation of the core function