16720 Commits

Author SHA1 Message Date
Werner Lewis
02c9d3b9c2 Fix parsing of special chars in X509 DN values
Use escape mechanism defined in RFC 1779 when parsing commas and other
special characters in X509 DN values. Resolves failures when generating
a certificate with a CSR containing a comma in subject value.
Fixes #769.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-06-08 14:38:38 +01:00
Dave Rodgman
bdd6905a5c
Merge pull request #5850 from bootstrap-prime/mbedtls-2.28
Fix typos in documentation and constants with typo finding tool
2022-05-19 16:53:37 +01:00
Paul Elliott
d03d6d4ca0
Merge pull request #5849 from gilles-peskine-arm/psa-raw_key_agreement-buffer_too_small-2.28
Backport 2.28: Make psa_raw_key_agreement return BUFFER_TOO_SMALL
2022-05-19 16:05:27 +01:00
bootstrap-prime
7ef96ea856
Fix typos in documentation and constants with typo finding tool
Signed-off-by: bootstrap-prime <bootstrap.prime@gmail.com>
2022-05-18 14:08:33 -04:00
Gilles Peskine
3afb7c33d5 Update PSA compliance test branch
Update to a branch with a fix for the test case
"expected error for psa_raw_key_agreement - Small buffer size"
since we just fixed the corresponding bug.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-05-18 16:25:39 +02:00
Gilles Peskine
42313fbfcc psa_raw_key_agreement: return BUFFER_TOO_SMALL when warranted
psa_raw_key_agreement() returned PSA_ERROR_INVALID_ARGUMENT instead of
PSA_ERROR_BUFFER_TOO_SMALL when the output buffer was too small for ECDH,
the only algorithm that is currently implemented. Make it return the correct
error code.

The reason for the wrong error code is that ecdh.c returns
MBEDTLS_ERR_ECP_BAD_INPUT_DATA, presumably for similarith with dhm.c. It
might make sense to change ecdh.c to use MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL,
but dhm.c doesn't have an existing BUFFER_TOO_SMALL error. To minimize the
impact of the fix, handle this in the PSA layer.

Fixes #5735.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-05-17 16:29:55 +02:00
Gilles Peskine
47cfdfd452 Use TEST_LE_U in some places where it applies
Systematically replace "TEST_ASSERT( $x <= $y )" by "TEST_LE_U( $x, $y )" in
test_suite_psa_crypto. In this file, all occurrences of this pattern are
size_t so unsigned.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-05-17 16:29:50 +02:00
Gilles Peskine
063700d612 New test helper macros TEST_LE_U, TEST_LE_S
Test assertions for integer comparisons that display the compared values on
failure. Similar to TEST_EQUAL.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-05-17 16:26:29 +02:00
Gilles Peskine
d0d777e6bc Separate the validation of the size macros and of the function
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-05-17 16:26:29 +02:00
Gilles Peskine
d48874f657 Improve PSA_RAW_KEY_AGREEMENT_OUTPUT_SIZE validation
We want to check:
1. actual output <= PSA_RAW_KEY_AGREEMENT_OUTPUT_SIZE (the output fits
   if the caller uses the key-specific buffer size macro)
2. actual output <= PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE (the output fits
   if the caller uses the generic buffer size macro)
3. PSA_RAW_KEY_AGREEMENT_OUTPUT_SIZE <= PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE
   (consistency in the calculation)

We were only testing (1) and (2). Test (3) as well. (1) and (3) together
imply (2) so there's no need to test (2).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-05-17 16:26:29 +02:00
Gilles Peskine
7d1502939a Test psa_raw_key_agreement with a larger/smaller buffer
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-05-17 16:26:29 +02:00
Manuel Pégourié-Gonnard
529bf9d95d
Merge pull request #5619 from mprse/backport_sig_ver_tests
Backport RSA signature/verification tests
2022-05-12 12:13:02 +02:00
Dave Rodgman
a0026604a2
Merge pull request #5733 from daverodgman/warmsocks_spellingfixes_2.28
Backport 2.28: Fixed spelling and typographical errors found by CodeSpell
2022-05-12 09:26:43 +01:00
Paul Elliott
bd7e048844
Merge pull request #5816 from paul-elliott-arm/travis_project_2.28
Backport 2.28: Revert Coverity project name change in Travis
2022-05-06 19:11:01 +01:00
Paul Elliott
211c69dab8 Revert Coverity project name change
Although Coverity have now changed their URL to point at the new
project, they did not change the project name, it would seem.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2022-05-06 14:10:42 +01:00
Paul Elliott
9c4f159f75
Merge pull request #5805 from paul-elliott-arm/travis_coverity_fix_2.28
Backport 2.28: Rotate coverity secret token in travis
2022-05-05 18:10:52 +01:00
Paul Elliott
9a0c8ed030
Merge pull request #5802 from wernerlewis/asn1_memcpy_null_2.28
[Backport 2.28] Fix memcpy() UB in mbedtls_asn1_named_data()
2022-05-04 23:20:34 +01:00
Werner Lewis
6342debc72 Add ChangeLog entry
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-05-04 16:27:54 +01:00
Paul Elliott
08f803f9e9 Change coverity secret token in travis
Travis stopped being able to push builds to coverity due to the token
apparently being no longer valid. Rotating the token to see if that
fixes things.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2022-05-04 14:19:44 +01:00
Werner Lewis
12ddae870c Fix memcpy() UB in mbedtls_asn1_named_data()
Removes a case in mbedtls_asn1_named_data() where memcpy() could be
called with a null pointer and zero length. A test case is added for
this code path, to catch the undefined behavior when running tests with
UBSan.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-05-04 12:23:26 +01:00
Dave Rodgman
beb5ad7751 Minor spelling / grammar improvements
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-04-28 18:23:12 +01:00
Andrzej Kurek
293e452e83 Fix additional misspellings found by codespell
Remaining hits seem to be hex data, certificates,
and other miscellaneous exceptions.
List generated by running codespell -w -L
keypair,Keypair,KeyPair,keyPair,ciph,nd

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-28 18:22:24 +01:00
Dave Rodgman
6caaa1c927 Revert spelling fixes to ChangeLog
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-04-28 18:22:23 +01:00
Shaun Case
0e7791ff07 Redo of PR#5345. Fixed spelling and typographical errors found by CodeSpell.
Signed-off-by: Shaun Case <warmsocks@gmail.com>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-04-28 18:22:20 +01:00
Gilles Peskine
585a412129
Merge pull request #5760 from tom-daubney-arm/2-28_correct_x509_flag_parse_tests
[Backport 2.28] Set flag to proper value in x509 parse tests
2022-04-28 18:27:41 +02:00
Gilles Peskine
9aa892b833
Merge pull request #5754 from gilles-peskine-arm/psa-storage-format-test-exercise-2.28
Backport 2.28: PSA storage format: exercise key
2022-04-28 18:20:09 +02:00
Gilles Peskine
f87d84361c
Merge pull request #5740 from gilles-peskine-arm/psa-crypto-config-file-2.28
Backport 2.28: Support alternative MBEDTLS_PSA_CRYPTO_CONFIG_FILE
2022-04-28 18:17:45 +02:00
Gilles Peskine
4d6070ca6d
Merge pull request #5778 from mpg/doc-allowed-pks-2.28
[Backport 2.28] Fix documentation of allowed_pks field in mbedtls_x509_crt_profile
2022-04-28 18:13:52 +02:00
Gilles Peskine
238f976ad1 Note that MBEDTLS_CONFIG_FILE can't be defined inside the config file
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-26 18:13:01 +02:00
Gilles Peskine
8290976801 Fix references to mbedtls_config.h
These were a mistake when backporting the change from the development
branch, where mbedtls/config.h has been renamed to mbedtls/mbedtls_config.h.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-26 18:10:11 +02:00
Manuel Pégourié-Gonnard
2b28e4ecee Clarify wording of documentation
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-25 11:57:09 +02:00
Hanno Becker
c61543dc71 Adapt ChangeLog
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-25 11:57:09 +02:00
Hanno Becker
f501cb57a5 Clarify documentation of mbedtls_x509_crt_profile
This commit fixes #1992: The documentation of mbedtls_x509_crt_profile
previously stated that the bitfield `allowed_pks` defined which signature
algorithms shall be allowed in CRT chains. In actual fact, however,
the field also applies to guard the public key of the end entity
certificate.

This commit changes the documentation to state that `allowed_pks`
applies to the public keys of all CRTs in the provided chain.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-25 11:57:09 +02:00
Gilles Peskine
500e48f095 Consistently use "ARC4" in PSA docs and comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-25 09:49:39 +02:00
Gilles Peskine
988391d1cb
Merge pull request #5769 from mpg/ecdsa-range-test-2.28
[Backport 2.28]  Expand negative coverage of ECDSA verification
2022-04-22 16:43:41 +02:00
Gilles Peskine
8e9e1f6819
Merge pull request #5744 from mpg/benchmark-ecc-heap-2.28
[backport 2.28]  Improve benchmarking of ECC heap usage
2022-04-22 16:43:04 +02:00
Manuel Pégourié-Gonnard
5aeb61ccb4 Improve readability and relevance of values
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-22 10:38:38 +02:00
Manuel Pégourié-Gonnard
bcaba030ec Expand negative coverage of ECDSA verification
Motivated by CVE-2022-21449, to which we're not vulnerable, but we
didn't have a test for it. Now we do.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-22 10:38:38 +02:00
Gilles Peskine
35de7b013a
Merge pull request #5741 from gilles-peskine-arm/depends-curves-positive-only-2.28
Backport 2.28: Don't test with all-but-one elliptic curves
2022-04-21 12:34:47 +02:00
Gilles Peskine
f7a101af3c
Merge pull request #5730 from gilles-peskine-arm/ssl-opt-auto-psk-2.28
Backport 2.28: Run ssl-opt.sh in more reduced configurations
2022-04-21 12:03:43 +02:00
Gilles Peskine
b973ae43db Use MAX_SIZE macros instead of hard-coding IV/nonce max size
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-21 11:14:52 +02:00
Gilles Peskine
b534759e19 Remove redundant initialization of iv_length
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-21 11:14:30 +02:00
Gilles Peskine
62de767b27 test_psa_crypto_config_accel_ecdsa: disable obsolete hashes
MD2 and MD4 were declared as enabled (PSA_WANT_ALG_MD{2,4} defined) but not
actually implemented in the test driver (MBEDTLS_MD{2,4}_C) not defined. Fix
this inconsistency caued deterministic ECDSA tests using those hashes to
fail. Now MD2 and MD4 are consistently off and the offending test cases
don't run.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-21 11:05:16 +02:00
Thomas Daubney
b84f8d4e88 Corrects flag set in tests
Corrects flag value from 0xFFFFFFF to 0xFFFFFFFF in
x509 parse tests.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2022-04-21 08:35:29 +01:00
Gilles Peskine
784e65b7e2 Add RC4 positive test
Only 128-bit keys are supported.

Test data from RFC 6229.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-20 20:58:04 +02:00
Gilles Peskine
4da5a85f80 cipher_alg_without_iv: also test multipart operations
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-20 20:58:04 +02:00
Gilles Peskine
69d9817a66 cipher_alg_without_iv: generalized to also do decryption
Test set_iv/generate_iv after decrypt_setup. Test successful decryption.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-20 20:58:04 +02:00
Gilles Peskine
5f50420dc8 cipher_encrypt_alg_without_iv: validate size macros independently
Validate the size macros directly from the output length in the test data,
rather than using the value returned by the library. This is equivalent
since the value returned by the library is checked to be identical.

Enforce that SIZE() <= MAX_SIZE(), in addition to length <= SIZE(). This is
stronger than the previous code which merely enforced length <= SIZE() and
length <= MAX_SIZE().

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-20 20:58:04 +02:00
Gilles Peskine
4a83c1047f Fix RC4 multipart PSA
RC4 doesn't take an IV.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-20 20:58:04 +02:00
Gilles Peskine
c768600de7 Mbed TLS supports RC4 only with 128-bit keys
In PSA tests, don't try to exercise RC4 keys with other sizes. Do test that
attempts to use RC4 keys of other sizes fail with NOT_SUPPORTED (import does
work, which is not really useful, but removing import support would
technically break backward compatibility).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-20 20:58:04 +02:00