aboutsummaryrefslogtreecommitdiff
path: root/tests/src
AgeCommit message (Collapse)AuthorFilesLines
2023-01-11Switch to the new code styleGilles Peskine18-3031/+2903
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16Fix leak of modulus structures in testsGilles Peskine1-0/+6
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16New helper function to allocate and read a modulusGilles Peskine1-0/+17
When including <test/bignum_helpers.h>, the library/ directory now needs to be on the include path. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16Move bignum helpers to their own moduleGilles Peskine2-84/+122
Move bignum-related helper functions to their own files under tests/include and tests/src. The primary motivation is that a subsequent commit will make bignum_helpers.h include library/bignum*.h, but we want to be able to include <test/helpers.h> without having the library directory on the include path (we do this in some programs under programs/ intended for testing). Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-29Minor formatting fixes to address code review commentsAditya Deshpande1-2/+1
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-11-28Add test function for opaque driver (simply returns ↵Aditya Deshpande1-2/+25
PSA_ERROR_NOT_SUPPORTED), and address other review comments. Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-11-22Merge branch 'development' into driver-wrapper-key-agreementAditya Deshpande1-2/+26
2022-11-22Merge branch 'development' into driver-wrapper-key-agreementAditya Deshpande1-1/+5
2022-11-21Add tests for the key agreement driver wrapper to ↵Aditya Deshpande1-0/+2
test_suite_psa_crypto_driver_wrappers Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-11-15Support negative zero as MPI test inputGilles Peskine1-2/+26
The bignum module does not officially support "negative zero" (an mbedtls_mpi object with s=-1 and all limbs zero). However, we have a history of bugs where a function that should produce an official zero (with s=1), produces a negative zero in some circumstances. So it's good to check that the bignum functions are robust when passed a negative zero as input. And for that, we need a way to construct a negative zero from test case arguments. There are checks that functions don't produce negative zeros as output in the test suite. Skip those checks if there's a negative zero input: we don't want functions to _create_ negative zeros, but we don't mind if they _propagate_ negative zeros. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-09Forbid empty mpi_core in test dataGilles Peskine1-1/+5
This way static analyzers have a chance of knowing we don't expect the bignum functions to support empty inputs. As things are, Coverity keeps complaining about it. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-08Add default return case to mbedtls_test_transparent_key_agreement()Aditya Deshpande1-0/+10
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-11-07Merge branch 'development' into driver-wrapper-key-agreementAditya Deshpande1-2/+2
2022-11-07Fix formatting and code commentsAditya Deshpande1-1/+1
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-11-07Refactor call hierarchy for ECDH so that it goes through the driver wrapper ↵Aditya Deshpande1-9/+30
in a similar fashion to ECDSA. Add component_test_psa_config_accel_ecdh to all.sh to test key agreement driver wrapper with libtestdriver1. Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-10-19test_suite_psa_crypto: adapt dependenies and guards so the test can run in ↵Przemek Stekiel1-2/+2
the driver-only build Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-14Newlines at end of file + trim trailing whitespaceAditya Deshpande1-2/+2
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-10-14Add driver wrapper function for raw key agreement, along with test call for ↵Aditya Deshpande1-0/+73
transparent drivers. Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-10-14Merge pull request #6383 from mprse/aead_driver_testManuel Pégourié-Gonnard1-12/+90
Enable testing of AEAD drivers with libtestdriver1
2022-10-10mbedtls_test_read_mpi_core: allow odd number of hex digitsGilles Peskine1-3/+30
Test functions must now take a char* argument rather than data_t*. This does not affect existing test data. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-05Readability improvementGilles Peskine1-1/+1
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-02test_driver_aead.c: add support for LIBTESTDRIVER1 testsPrzemek Stekiel1-12/+90
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-09-30New function mbedtls_test_read_mpi_coreGilles Peskine1-0/+18
Allocate and read an MPI from a binary test argument. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-30Allow test assertions on constant-flow scalar dataGilles Peskine1-0/+13
When testing a function that is supposed to be constant-flow, we declare the inputs as constant-flow secrets with TEST_CF_SECRET. The result of such a function is itself a constant-flow secret, so it can't be tested with comparison operators. In TEST_EQUAL, TEST_LE_U and TEST_LE_S, declare the values to be compared as public. This way, test code doesn't need to explicitly declare results as public if they're only used by one of these macros. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-16Make legacy_or_psa.h public.Manuel Pégourié-Gonnard1-1/+1
As a public header, it should no longer include common.h, just use build_info.h which is what we actually need anyway. Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-08-23Remove unnecessary `psa/crypto.h` includeAndrzej Kurek1-4/+0
This is now included in `legacy_or_psa.h`. Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-08-22Update SHA and MD5 dependencies in the SSL moduleAndrzej Kurek1-18/+26
The same elements are now also used when MBEDTLS_USE_PSA_CRYPTO is defined and respective SHA / MD5 defines are missing. A new set of macros added in #6065 is used to reflect these dependencies. Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-08-01Remove radix arg from mbedtls_test_read_mpiWerner Lewis1-2/+2
All uses have radix argument removed, using script. Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-07-01Initilize variableGabor Mezei1-1/+1
Coverity scan detected a problem of an uinitilized variable. Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-06-20Merge pull request #5834 from mprse/HKDF_1Gilles Peskine1-2/+28
HKDF 1: PSA: implement HKDF_Expand and HKDF_Extract algorithms
2022-06-14exercise_key_agreement_key: add special handling for HKDF_EXPANDPrzemek Stekiel1-2/+21
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-06-14exercise_key_agreement_key: provide SALT for HKDF_EXTRACTPrzemek Stekiel1-0/+7
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-05-16New test helper macros TEST_LE_U, TEST_LE_SGilles Peskine1-0/+46
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-11Redo of PR#5345. Fixed spelling and typographical errors found by CodeSpell.Shaun Case1-2/+2
Signed-off-by: Shaun Case <warmsocks@gmail.com> Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-04-21Use MAX_SIZE macros instead of hard-coding IV/nonce max sizeGilles Peskine1-2/+2
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-21Remove redundant initialization of iv_lengthGilles Peskine1-1/+1
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-15No need to recalculate iv_lengthGilles Peskine1-1/+1
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-15exercise_key: support combined key agreement+derivation algorithmsGilles Peskine1-0/+24
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-15exercise_key: signature: detect function/algorithm incompatibilityGilles Peskine1-1/+12
Don't try to use {sign,verify}_message on algorithms that only support {sign_verify}_hash. Normally exercise_key() tries all usage that is supported by policy, however PSA_KEY_USAGE_{SIGN,VERIFY}_MESSAGE is implied by PSA_KEY_USAGE_{SIGN,VERIFY}_HASH so it's impossible for the test data to omit the _MESSAGE policies with hash-only algorithms. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-15Use PSA_AEAD_NONCE_LENGTH when exercising AEAD keysGilles Peskine1-14/+7
Don't re-code the logic to determine a valid nonce length. This fixes exercise_key() for PSA_ALG_CHACHA20_POLY1305, which was trying to use a 16-byte nonce. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-15exercise_key: support modes where IV length is not 16Gilles Peskine1-12/+18
Support ECB, which has no IV. The code also now supports arbitrary IV lengths based on the algorithm and key type. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-10Merge pull request #5292 from mprse/asym_encryptGilles Peskine1-0/+161
Driver dispatch for PSA asymmetric encryption + RSA tests
2022-03-07Change names rsa->asymmetric_encryptionPrzemek Stekiel1-22/+22
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-02-07Merge pull request #5282 from AndrzejKurek/import-opaque-driver-wrappersRonald Cron1-2/+11
Add tests for an opaque import in the driver wrappers
2022-02-03Test driver: keep variable declarations firstAndrzej Kurek1-8/+8
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-02-03Test drivers: rename import call source to driver locationAndrzej Kurek1-2/+2
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-02-02test_driver_rsa.c: Fix commentPrzemyslaw Stekiel1-1/+1
Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>
2022-02-02Compact the argument listsPrzemyslaw Stekiel1-44/+16
Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>
2022-01-19Mark unused variable in tests for cases with reduced configsAndrzej Kurek1-0/+1
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-01-10test_driver_rsa.c: fix include file namePrzemyslaw Stekiel1-1/+1
Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>