1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00
samba-mirror/lib/crypto
Michael Tokarev 712117155e replace direct calls to memset_s() with commonly used macros
samba provides macros for zeroing various structures in memory,
and all code uses them instead of relying on memset_s().
However, a few places use memset_s() directly.  Replace these
usages with macros for consistency and to be able to replace
memset_s() easier.

A few notes.

Commit 03a50d8f7d "lib:util: Check memset_s() error
code in talloc_keep_secret_destructor()" (Aug-2022) added a check
for error return from memset_s().  This is the only place in whole
codebase which bothers about doing this.  But I've difficult time
figuring out the intention.  Was there a real case when this code
path is actually executed?

Commit 7658c9bf0a "lib:crypto: Remove redundant array
zeroing" (Nov-2023) removed the OTHER line from the two lines used
to zero memory in here.  Initially the code used both memset_s()
*and* ZERO_ARRAY_LEN(), the former has been removed.  This change
removes the other - memset_s(), reintroducing ZERO_ARRAY_LEN().
Here however, it's probably better to use BURN_PTR instead of
ZERO_ARRAY - in this place and a few lines above.

Commit 8dddea2ced "lib:talloc: Use memset_s() to avoid
the call gets optimized out" (Feb-2024) is a recent commit which
introduces memset_s().  However, it does not seem like it makes
any difference whatsoever for a testsuite, or that it actually
needs to clean up the memory to begin with.

We've quite an assortment of all this memory zeroing stuff.  Also
it is repeated in replace.h and memory.h (two sets in these files
are different but has big intersection).  I'd say, to fix this mess,
things from replace.h should be removed in favour of memory.h, and
necessary includes added, but this is for the next time.  We also
have lots of direct usages of memset_s() in heimdal code.

Cc: Joseph Sutton <josephsutton@catalyst.net.nz>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2025-01-02 17:01:30 +00:00
..
tests lib:crypto: Add test for samba_gnutls_sp800_108_derive_key() using NIST test vectors 2023-11-30 01:03:28 +00:00
aes.h Remove redundant check and fallback for AES CMAC 128 as we now require GnuTLS 3.6.13 2023-06-30 14:00:38 +00:00
crypto.h Remove redundant check and fallback for AES CMAC 128 as we now require GnuTLS 3.6.13 2023-06-30 14:00:38 +00:00
gkdi.c lib:crypto: Fix Coverity build 2024-04-24 05:16:29 +00:00
gkdi.h lib:crypto: Add constant denoting maximum GKDI clock skew in minutes 2024-05-16 02:11:36 +00:00
gmsa.c lib:crypto: Reformat source code 2024-04-16 03:58:31 +00:00
gmsa.h lib:crypto: Add functions for deriving gMSA passwords 2024-02-16 02:41:36 +00:00
gnutls_aead_aes_256_cbc_hmac_sha512.c lib:crypto: Change error return to SMB_ASSERT() 2022-10-05 04:23:32 +00:00
gnutls_arcfour_confounded_md5.c lib:crypto: Fix code spelling 2023-09-11 02:42:41 +00:00
gnutls_error.c libcli:util: Add gnutls_error_to_werror() 2019-06-27 12:54:22 +00:00
gnutls_helpers.h lib:crypto: Remove unused macro definitions 2024-07-02 03:39:35 +00:00
gnutls_server_end_point_cb.c lib/crypto: add legacy_gnutls_server_end_point_cb() if needed 2024-04-23 23:50:33 +00:00
gnutls_sp800_108.c replace direct calls to memset_s() with commonly used macros 2025-01-02 17:01:30 +00:00
gnutls_weak_crypto.c lib:crypto: Improve comment about weak crypto 2023-04-03 03:56:35 +00:00
md4.c lib:crypto: Fix undefined behavior in md4 2018-11-22 22:13:27 +01:00
md4.h
md4test.c lib:crypto: Include only the required header files 2019-02-27 07:59:26 +00:00
py_crypto.c Use python.h from libreplace 2023-11-20 15:37:33 +00:00
REQUIREMENTS crypto: Update REQUIREMENTS file with new minimum version 2019-08-21 09:57:30 +00:00
test_gkdi_key_derivation.c lib:crypto: Fix code formatting 2024-02-16 02:41:36 +00:00
test_gkdi.c lib:crypto: Add more unit tests for GKDI functions 2024-04-21 22:10:36 +00:00
wscript lib/crypto: add legacy_gnutls_server_end_point_cb() if needed 2024-04-23 23:50:33 +00:00