mbedtls/tests
Gilles Peskine ead1766b5f Fix PBKDF2 with empty salt segment on platforms where malloc(0)=NULL
"Fix PBKDF2 with empty salt on platforms where malloc(0)=NULL" took care of
making an empty salt work. But it didn't fix the case of an empty salt
segment followed by a non-empty salt segment, which still invoked memcpy
with a potentially null pointer as the source. This commit fixes that case,
and also simplifies the logic in the function a little.

Test data obtained with:
```
pip3 install cryptodome
python3 -c 'import sys; from Crypto.Hash import SHA256; from Crypto.Protocol.KDF import PBKDF2; cost = int(sys.argv[1], 0); salt = bytes.fromhex(sys.argv[2]); password = bytes.fromhex(sys.argv[3]); n = int(sys.argv[4], 0); print(PBKDF2(password=password, salt=salt, dkLen=n, count=cost, hmac_hash_module=SHA256).hex())' 1 "" "706173737764" 64
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-20 22:05:16 +02:00
..
.jenkins
configs PSA_CRYPTO_DRIVER_TEST_ALL is incompatible with MBEDTLS_PSA_CRYPTO_CONFIG 2023-07-26 22:34:13 +02:00
data_files Merge pull request #7898 from AndrzejKurek/csr-rfc822-dn 2023-08-16 09:19:46 +00:00
docker/bionic Point to docker images used in the CI 2022-12-15 10:08:26 +01:00
git-scripts Fix typographical errors in .md files found by cspell 2022-07-29 13:44:01 +01:00
include Merge pull request #7936 from AgathiyanB/assert-false-macro 2023-08-10 15:01:34 +00:00
opt-testcases Adapt names (curves -> groups) 2023-07-05 09:26:26 +02:00
scripts Merge remote-tracking branch 'development' into psa_crypto_config-in-full 2023-08-17 19:46:34 +02:00
src Merge pull request #7936 from AgathiyanB/assert-false-macro 2023-08-10 15:01:34 +00:00
suites Fix PBKDF2 with empty salt segment on platforms where malloc(0)=NULL 2023-08-20 22:05:16 +02:00
.gitignore Add gitignore anchors to denote generated files 2023-07-06 17:58:18 +01:00
CMakeLists.txt Fix build errors in CMake 2023-03-13 19:20:42 +08:00
compat-in-docker.sh Use OPENSSL everywhere, not OPENSSL_CMD 2022-12-19 11:42:12 +01:00
compat.sh Merge pull request #7136 from yanrayw/5692-record-compatsh-test-cases 2023-07-10 12:08:32 +01:00
context-info.sh
Descriptions.txt
make-in-docker.sh Point to docker images used in the CI 2022-12-15 10:08:26 +01:00
Makefile Fix build errors in CMake 2023-03-13 19:20:42 +08:00
ssl-opt-in-docker.sh Use OPENSSL everywhere, not OPENSSL_CMD 2022-12-19 11:42:12 +01:00
ssl-opt.sh ssl-opt: remove redundant requirement for RSA_C 2023-08-11 09:37:14 +02:00