diff options
author | Gilles Peskine <Gilles.Peskine@arm.com> | 2020-08-26 10:24:26 +0200 |
---|---|---|
committer | Gilles Peskine <Gilles.Peskine@arm.com> | 2020-08-26 10:24:26 +0200 |
commit | 6c75152b9f1a5dac1d92b793cb0c1d93b161c690 (patch) | |
tree | ed6cea6fc141d41065e787eadb38f80d33590566 | |
parent | 34f063ca4761fb95e6060eeda26544f9f8c2c65d (diff) | |
download | mbed-tls-6c75152b9f1a5dac1d92b793cb0c1d93b161c690.tar.gz |
Explain the purpose of check_parity
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
-rw-r--r-- | tests/suites/test_suite_psa_crypto_metadata.function | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/suites/test_suite_psa_crypto_metadata.function b/tests/suites/test_suite_psa_crypto_metadata.function index 96d3afb3d..abee922e7 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.function +++ b/tests/suites/test_suite_psa_crypto_metadata.function @@ -57,6 +57,16 @@ TEST_ASSERT( PSA_##flag( alg ) == !! ( ( flags ) & flag ) ) /* Check the parity of value. + * + * There are several numerical encodings for which the PSA Cryptography API + * specification deliberately defines encodings that all have the same + * parity. This way, a data glitch that flips one bit in the data cannot + * possibly turn a valid encoding into another valid encoding. Here in + * the tests, we check that the values (including Mbed TLS vendor-specific + * values) have the expected parity. + * + * The expected parity is even so that 0 is considered a valid encoding. + * * Return 0 if value has even parity and a nonzero value otherwise. */ int check_parity( uint32_t value ) { |