Simon Butcher
6944e05956
Merge remote-tracking branch 'public/pr/2232' into development
2019-01-08 15:33:28 +00:00
Simon Butcher
012a06cbf6
Merge remote-tracking branch 'public/pr/2228' into development
2019-01-08 15:26:58 +00:00
Andrzej Kurek
2349c4db88
Adapt to the new key allocation mechanism
2019-01-08 09:36:01 -05:00
Jaeden Amero
d94d671f14
psa: Test that generator initializers work
2019-01-08 14:28:04 +00:00
Jaeden Amero
5bae227da0
psa: Add initializers for cipher operation objects
...
Add new initializers for cipher operation objects and use them in our
tests and library code. Prefer using the macro initializers due to their
straightforwardness.
2019-01-08 14:28:04 +00:00
Jaeden Amero
769ce27f12
psa: Add initializers for MAC operation objects
...
Add new initializers for MAC operation objects and use them in our tests
and library code. Prefer using the macro initializers due to their
straightforwardness.
2019-01-08 14:28:04 +00:00
Jaeden Amero
6a25b41ac3
psa: Add initializers for hash operation objects
...
Add new initializers for hash operation objects and use them in our
tests and library code. Prefer using the macro initializers due to their
straightforwardness.
2019-01-08 14:28:04 +00:00
Jaeden Amero
70261c513a
psa: Add initializers for key policies
...
Add new initializers for key policies and use them in our docs, example
programs, tests, and library code. Prefer using the macro initializers
due to their straightforwardness.
2019-01-08 14:28:04 +00:00
Jaeden Amero
8c7e95d9e0
tests: Remove unused key policy objects
...
persistent_key_import() and persistent_key_destroy() don't need to and
don't use key policy objects. Remove unused key policy objects.
2019-01-04 15:38:07 +00:00
Simon Butcher
6c164e754b
Update the version of the library to 2.16.0
2018-12-21 10:51:51 +00:00
Gilles Peskine
c08fc1d7e9
Move MIN and MAX macros from PSA tests to helpers.function
2018-12-20 18:47:53 +01:00
Gilles Peskine
d76f181617
Prefer ASSERT_ALLOC to calloc+TEST_ASSERT in PSA tests
...
To allocate memory dynamically in a test, call ASSERT_ALLOC which
takes care of calling calloc and of checking for NULL.
2018-12-20 18:47:53 +01:00
Gilles Peskine
1f2aa0e3b0
Remove useless null checks of data_t* parameters
...
The test framework never passes NULL for a data_t* parameter, so
testing them against NULL is clutter.
2018-12-20 18:47:53 +01:00
Gilles Peskine
40ab95bdbc
Remove checks of test parameters against SIZE_MAX
...
Our code base doesn't even support 16-bit platforms, so those checks
are always trivially true.
2018-12-20 18:47:53 +01:00
Gilles Peskine
0dfba2ddf0
Use ASSERT_COMPARE in preference to memcmp in PSA tests
2018-12-20 18:47:52 +01:00
Gilles Peskine
f812dcf4ae
Rewrap some lines after the macro changes
...
Change the way some lines are wrapped to cut at a more logical place.
This commit mainly rewrites multi-line calls to TEST_EQUAL, and also a
few calls to PSA_ASSERT.
2018-12-20 18:47:52 +01:00
Gilles Peskine
fe11b72b93
Use TEST_EQUAL(a,b) in preference to TEST_ASSERT(a==b)
...
This commit is the result of the following command, followed by
reindenting (but not wrapping lines):
perl -00 -i -pe 's/^( *)TEST_ASSERT\(([^;=]*)(?: |\n *)==([^;=]*)\);$/${1}TEST_EQUAL($2,$3);/gm' tests/suites/test_suite_psa_*.function
2018-12-20 18:47:52 +01:00
Gilles Peskine
8817f61007
Use PSA_ASSERT(a) in preference to TEST_ASSERT(a==PSA_SUCCESS)
...
This commit is the result of the following command, followed by
reindenting (but not wrapping lines):
perl -00 -i -pe 's/^( *)TEST_ASSERT\(([^;=]*)(?: |\n *)==\s*PSA_SUCCESS\s*\);$/${1}PSA_ASSERT($2 );/gm' tests/suites/test_suite_psa_*.function
2018-12-20 18:47:52 +01:00
Gilles Peskine
0f915f1d2a
Indent PSA tests according to K&R rules with Mbed TLS tweaks
...
Only whitespace changes in this commit.
2018-12-20 18:47:52 +01:00
Gilles Peskine
9d8eea7e19
Wrap some multiline expressions in parentheses
...
This guarantees that they'll be indented as desired under most
indentation rules.
2018-12-20 18:47:52 +01:00
Gilles Peskine
5f7aeeea06
New test macro TEST_EQUAL
...
TEST_EQUAL(expr1, expr2) is just TEST_ASSERT((expr1) == (expr2)) for
now, but in the future I hope that it will print out the differing
values.
2018-12-20 18:47:52 +01:00
Gilles Peskine
0174be2c17
Move the PSA_ASSERT macro to the common helpers file
...
It's potentially useful in all PSA test suites, of which there are now
several.
2018-12-20 18:47:52 +01:00
Gilles Peskine
f055ad7512
Add a safety check to ARRAY_LENGTH
...
Cause a compilation error on ARRAY_LENGTH(p) where p is a pointer as
opposed to an array. This only works under GCC and compatible
compilers such as Clang. On other compilers, ARRAY_LENGTH works but
doesn't check the type of its argument.
2018-12-20 18:47:52 +01:00
Simon Butcher
ad7c2105a2
Merge remote-tracking branch 'public/pr/2274' into development
2018-12-20 12:16:57 +00:00
Simon Butcher
12b4240300
Merge remote-tracking branch 'public/pr/2288' into development
2018-12-20 12:16:46 +00:00
Simon Butcher
c831193c85
Merge remote-tracking branch 'public/pr/2302' into development
2018-12-20 12:16:39 +00:00
Simon Butcher
1efda39f8a
Merge remote-tracking branch 'public/pr/2297' into development
2018-12-20 12:16:29 +00:00
Simon Butcher
5aa7809ac8
Merge remote-tracking branch 'public/pr/2275' into development
2018-12-20 12:15:19 +00:00
Simon Butcher
780cf189b0
Merge remote-tracking branch 'public/pr/2271' into development
2018-12-20 12:15:08 +00:00
Simon Butcher
032c037052
Merge remote-tracking branch 'public/pr/2270' into development
2018-12-20 12:04:13 +00:00
Simon Butcher
a033633bb0
Merge remote-tracking branch 'public/pr/2269' into development
2018-12-20 12:02:56 +00:00
Simon Butcher
70935a4001
Merge remote-tracking branch 'public/pr/2299' into development
2018-12-20 12:02:23 +00:00
Simon Butcher
003c0e032f
Merge remote-tracking branch 'public/pr/2292' into development
2018-12-20 12:02:17 +00:00
Simon Butcher
decf2f5c2c
Merge remote-tracking branch 'public/pr/2291' into development
2018-12-20 12:02:11 +00:00
Simon Butcher
65ce5dc981
Merge remote-tracking branch 'public/pr/2290' into development
2018-12-20 12:02:05 +00:00
Simon Butcher
ad2e0dae32
Merge remote-tracking branch 'public/pr/2283' into development
2018-12-20 12:01:58 +00:00
Simon Butcher
0bbf7f450d
Merge remote-tracking branch 'public/pr/2279' into development
2018-12-20 12:01:49 +00:00
Simon Butcher
962b7b17d5
Merge remote-tracking branch 'public/pr/2273' into development
2018-12-20 12:01:17 +00:00
Simon Butcher
6be67a6518
Merge remote-tracking branch 'public/pr/2281' into development
2018-12-20 12:01:09 +00:00
Simon Butcher
dac513e246
Merge remote-tracking branch 'public/pr/2282' into development
2018-12-20 12:01:04 +00:00
Simon Butcher
ccafd14fee
Merge remote-tracking branch 'public/pr/2276' into development
2018-12-20 12:00:57 +00:00
Simon Butcher
2a8d32c6c1
Merge remote-tracking branch 'public/pr/2287' into development
2018-12-20 12:00:50 +00:00
Gilles Peskine
743e3988dc
Avoid unused-variable warnings for str as well
...
The exact guard is FS_IO && PK_PARSE_C. Just keep it simple.
2018-12-20 12:29:48 +01:00
Gilles Peskine
88ca3a244e
Avoid unused-variable warnings in some configurations
2018-12-20 12:26:16 +01:00
Gilles Peskine
d6027119be
Fix dependencies on MBEDTLS_FS_IO
2018-12-20 12:15:41 +01:00
Hanno Becker
73b79841b2
Remove parameter validation for deprecated function in ECDSA module
2018-12-20 09:53:24 +00:00
k-stachowiak
dd63359dae
Add tests for valid NULL in ccm_free()
2018-12-19 19:02:39 +01:00
k-stachowiak
508bcd96db
Remove unneeded test for the CCM free function
2018-12-19 19:02:39 +01:00
k-stachowiak
26d365eb54
Add parameter validation for CCM
2018-12-19 19:02:39 +01:00
k-stachowiak
fb54360f8c
Prevent unused variable in some configurations
2018-12-19 18:34:21 +01:00
Gilles Peskine
6af45ec53e
PK: document context validity requirements
...
Document when a context must be initialized or not, when it must be
set up or not, and whether it needs a private key or a public key will
do.
The implementation is sometimes more liberal than the documentation,
accepting a non-set-up context as a context that can't perform the
requested information. This preserves backward compatibility.
2018-12-19 18:10:03 +01:00
k-stachowiak
a85edd9415
Split the unconditional and conditional parameter validation tests
2018-12-19 18:06:35 +01:00
Hanno Becker
f25ee7f79d
Fix parameter validation for mbedtls_mpi_lsb()
...
The MPI_VALIDATE_RET() macro cannot be used for parameter
validation of mbedtls_mpi_lsb() because this function returns
a size_t.
Use the underlying MBEDTLS_INTERNAL_VALIDATE_RET() insteaed,
returning 0 on failure.
Also, add a test for this behaviour.
2018-12-19 16:51:50 +00:00
Gilles Peskine
d54b97503b
pk parse: the password is optional
...
For mbedtls_pk_parse_key and mbedtls_pk_parse_keyfile, the password is
optional. Clarify what this means: NULL is ok and means no password.
Validate parameters and test accordingly.
2018-12-19 17:36:14 +01:00
k-stachowiak
516897a44a
Remove unnecessary parameter validation from the Cipher module
2018-12-19 17:34:58 +01:00
k-stachowiak
95070a8286
Make some cipher parameter validation unconditional
2018-12-19 17:34:58 +01:00
k-stachowiak
5b01f8b3ae
Add a new line at the end of the test data file
2018-12-19 17:34:13 +01:00
k-stachowiak
90b8d4a11e
Include static cipher functions in the parameter validation scheme
2018-12-19 17:34:13 +01:00
k-stachowiak
a539070f82
Make all parameter validation tests optional
2018-12-19 17:34:13 +01:00
Krzysztof Stachowiak
e0215d7869
Add Cipher module parameter validation
2018-12-19 17:34:13 +01:00
k-stachowiak
5fccb3edf3
Add tests for valid NULL in gcm_free()
2018-12-19 17:30:38 +01:00
k-stachowiak
8ffc92a1e8
Add parameter validation for the GCM module
2018-12-19 17:30:38 +01:00
Gilles Peskine
ee3cfec3cc
PK sign/verify: hash=NULL is ok if md_alg=0 and hash_len=0
2018-12-19 17:11:44 +01:00
Gilles Peskine
998fbfbe68
Properly test pk_write with an empty output buffer
...
This needs a real key to test properly.
2018-12-19 17:08:51 +01:00
Gilles Peskine
cc274c2ebf
Do run the valid parameters test function
2018-12-19 17:08:01 +01:00
Gilles Peskine
1f19fa6f62
PK: Fix free(NULL) in library and tests
...
free() functions are documented as no-ops on NULL. Implement and test
this correctly.
2018-12-19 14:18:39 +01:00
Hanno Becker
f947c0a2dd
Move testing of mbedtls_blowfish_free() to separate test case
...
It should be tested regardless of the setting of MBEDTLS_CHECK_PARAMS.
2018-12-19 12:52:59 +00:00
Hanno Becker
49acc64c69
Minor improvements to Blowfish documentation and tests
2018-12-19 12:52:59 +00:00
Hanno Becker
e38b4cd661
Test parameter validation for Blowfish module
2018-12-19 12:52:59 +00:00
Hanno Becker
0294072c09
Avoid unused variable warning in ARIA param validation test
2018-12-19 12:51:00 +00:00
Hanno Becker
14b91e8e22
Move testing of mbedtls_aria_free() to separate test
...
The test that mbedtls_aria_free() accepts NULL parameters
can be performed even if MBEDTLS_CHECK_PARAMS is unset, but
was previously included in the test case aria_invalid_params()
which is only executed if MBEDTLS_CHECK_PARAMS is set.
2018-12-19 12:51:00 +00:00
Hanno Becker
fac1d44d62
Fix style in ARIA parameter validation tests
2018-12-19 12:51:00 +00:00
Hanno Becker
b0de9f5b03
Test that mbedtls_aria_free() accepts NULL parameter
2018-12-19 12:51:00 +00:00
Hanno Becker
9e45c1607e
Test parameter validation for ARIA module
2018-12-19 12:51:00 +00:00
Hanno Becker
f1931760d8
Move test of mbedtls_camellia_free() to separate test
...
The acceptance of NULL should be tested regardless of the
setting of MBEDTLS_CHECK_PARAMS.
2018-12-19 12:47:55 +00:00
Hanno Becker
ff62f44ad7
Remove duplicated parameter check in CAMELLIA module
2018-12-19 12:47:55 +00:00
Hanno Becker
e939de7247
Minor fixes to Camellia parameter validation
2018-12-19 12:47:55 +00:00
Hanno Becker
75788371df
Test parameter validation for CAMELLIA module
2018-12-19 12:47:55 +00:00
Gilles Peskine
e146e7dbae
Don't use TEST_VALID_PARAM with a value
...
TEST_VALID_PARAM is only for functions that return void. This commit
fixes the build with clang -Wunused-comparison.
2018-12-19 13:21:22 +01:00
Hanno Becker
1959535038
Add parameter validation test for mbedtls_ecp_check_pub_priv()
2018-12-19 08:52:08 +00:00
Hanno Becker
549e455a42
Add parameter validation test for mbedtls_ecp_gen_privkey()
2018-12-19 08:52:02 +00:00
Hanno Becker
0a4fa9b1fb
Add parameter validation test for mbedtls_ecp_check_budget()
2018-12-19 08:51:58 +00:00
Hanno Becker
807c107c3c
Fix typos in ECP test suite
2018-12-19 08:51:55 +00:00
Simon Butcher
54b789aa74
Merge remote-tracking branch 'public/pr/2298' into development
2018-12-19 08:08:14 +00:00
Gilles Peskine
78438e4109
Test parameter validation for pk, pkparse and pkwrite
2018-12-19 00:55:47 +01:00
Hanno Becker
59274d43cb
Remove unnecessary call to mbedtls_mpi_free() in MPI tests
2018-12-18 23:27:03 +00:00
Hanno Becker
b48e1aa846
Add separate test for mbedtls_mpi_free() accepting NULL
2018-12-18 23:25:01 +00:00
Hanno Becker
e118504a5f
Numerous minor improvements to bignum documentation
2018-12-18 18:12:13 +00:00
Hanno Becker
56b661cbf8
Add test that mbedtls_mpi_free() accepts NULL parameter
2018-12-18 18:12:13 +00:00
Hanno Becker
afb607b9db
Add tests for parameter validation in MPI module
2018-12-18 18:12:13 +00:00
Hanno Becker
d22df58a56
Add missing guards around SHA-1 tests
2018-12-18 17:02:03 +00:00
Hanno Becker
adc9b178ca
Minor improvements to DHM module
2018-12-18 16:59:09 +00:00
Hanno Becker
8c8a93c574
Test parameter validation for DHM module
2018-12-18 16:59:09 +00:00
Hanno Becker
4fbd4bf442
Fix guard in SHA-512 tests
2018-12-18 16:37:43 +00:00
Hanno Becker
36beb04fd5
Add tests or SHA-256 parameter validation
2018-12-18 16:31:06 +00:00
Hanno Becker
686c9a0e8d
Test SHA-512 parameter validation
2018-12-18 15:33:14 +00:00
Hanno Becker
a994b2379f
Test that xxx_free() functions accept NULL parameter
2018-12-18 15:30:30 +00:00
Hanno Becker
ae2ff02ff1
Add tests for ChaChaPoly parameter validation
...
Parameter validation was previously performed and tested unconditionally
for the ChaCha/Poly modules. This commit therefore only needs go guard the
existing tests accordingly and use the appropriate test macros for parameter
validation.
2018-12-18 15:30:30 +00:00
Hanno Becker
af05a90349
Test parameter validation in ECDSA module
2018-12-18 14:31:50 +00:00
Hanno Becker
491db772c3
Test parameter validation for ECJPAKE module
2018-12-18 14:31:18 +00:00