Commit graph

9014 commits

Author SHA1 Message Date
Valerio Setti
a7cb845705 pk: add checks for the returned ECC family
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-22 18:39:43 +02:00
Paul Elliott
26070670d6
Merge pull request #7565 from gabor-mezei-arm/7263_split_out_Koblitz_raw_functions
[Bignum] Split out _raw Koblitz reduction functions
2023-05-22 16:03:17 +01:00
Andrzej Kurek
00d55988d9 Fix wrong makefile target
Missing tab and a prerequisite that's not a file
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-22 09:37:55 -04:00
Xiaokang Qian
f33b4a5aed Update comments how to generate the randoms to make it reproducible
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-22 10:55:46 +00:00
Xiaokang Qian
10b6daf755 Fix the comments of sum in ecp function
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-22 02:28:06 +00:00
Xiaokang Qian
be860a14ce Generate test data with special seed 2,3,4
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
bead774daa Fix the limb mismatch issue on 32-bit platform
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
6d02c2fefc Compare the libs of two input value and add comments
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
c304e53209 Remove useless parameters for ecp_mod_add_sub
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
61b0c1c3dd Refine code to align with the styles of ecp_mod_mul_inv
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
4dd1c0a475 Add test data for ecp_add_sub
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
9fe2587ccf Add add_sub test data for named moduli curves
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
5fc7846507 Add add_sub test cases for named moduli curves
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Janos Follath
399fa48e95
Merge pull request #7479 from xkqian/bignumber_test_mul_inv_named_moduli
[Bignum] Bignumber test mul inv named moduli
2023-05-18 11:55:01 +01:00
Paul Elliott
aa266f29e6
Merge pull request #7602 from mprse/AuthorityKeyId_leak_fix
Fix for memory leak while parsing AuthorityKeyId ext
2023-05-18 09:57:56 +01:00
Xiaokang Qian
c8f677d33e Both compare the least significant limb 1 and the left limbs 0
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-18 03:41:31 +00:00
Xiaokang Qian
c1f5e54d2d Remove useless parameter iret for ecp mul_inv cases
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-18 02:02:48 +00:00
Andrzej Kurek
a194904055 Fix subjectAltName test prerequisites
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 15:23:56 -04:00
Andrzej Kurek
5da1d751e9 Add missing memory deallocation
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 15:23:56 -04:00
Andrzej Kurek
13c43f682e Fix a copy-paste typo
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 15:23:56 -04:00
Andrzej Kurek
76c9662e8e Add a test for SubjectAltName writing to a certificate
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 15:23:54 -04:00
Andrzej Kurek
ccdd975286 Add a certificate exercising all supported SAN types
This will be used for comparison in unit tests.
Add a possibility to write certificates with SAN
in cert_write.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 11:45:36 -04:00
Valerio Setti
483738ed67 tests: fixes for using the new public key raw format
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-17 15:38:39 +02:00
Valerio Setti
92c3f36866 test_suite_debug: fix USE_PSA_INIT/DONE guards in a test
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-17 15:38:34 +02:00
Manuel Pégourié-Gonnard
b1c0afe484
Merge pull request #7595 from valeriosetti/deprecate_pk_ec
Set mbedtls_pk_ec() as internal function when ECP_C is not defined
2023-05-17 12:27:03 +02:00
Xiaokang Qian
11dd5c0b36 Compare final result with ASSERT_COMPARE
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
c81272461e Check all of the limbs of result
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
1ae7ca435b Re-order the variable orders and rename them
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
78b93b1902 Refine error check for mbedtls_ecp_modulus_setup
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
afdea64b50 Remove the useless modulus validaty
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
631f63d29d Remove modulus double free
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
d3e86a170a Add back 255 bit test data for SECP224K1 test cases
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
5b6bedfaf3 Add comments to the data file for the cureve secp224k1
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
424da8aa36 Revert to 224bit random data no need leading bit "1"
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
b7f9950234 Increase bit size to 225 for SECP224K1 test cases
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
86cb08ba27 Add comments about how the mod_inv data is generated
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
d244c83dfe Update ecp mul_inv test cases
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
e4dc798b59 Change coding styles of white space
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
8ca64374b1 Tidy up ecp mul_inv_test code
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
3d0c2be8c2 Add ecp test cases for mont mul and inv after named moduli setup
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Xiaokang Qian
5e25f80d8a Add ecp test function for mont mul and inv
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-17 10:02:52 +00:00
Przemek Stekiel
da97ad9f14 Use valid MD5 dependency for test
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-05-17 09:26:42 +02:00
Gilles Peskine
ff7a346201
Merge pull request #7416 from bharsaklemukesh975/update-pkparse-tests-to-use-AES
Updating test-ca.key to use AES instead of DES
2023-05-16 19:15:16 +02:00
Gilles Peskine
63df4ec3ca
Merge pull request #7589 from daverodgman/pr4990
Replace references to Mbed Crypto (rebase)
2023-05-16 19:14:51 +02:00
Paul Elliott
4fa8334bae Convert curve 448 to use ecp core functions
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-05-16 17:51:48 +01:00
Paul Elliott
f0806bee66
Merge pull request #7489 from minosgalanakis/ecp/7246_xtrack_core_shift_l
[Bignum]: Introduce left shift from prototype
2023-05-16 17:13:19 +01:00
Gabor Mezei
03558b847e
Add _raw function to P256K1
Modified the testing to use the generic fast reduction test function.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-05-16 17:30:03 +02:00
Gabor Mezei
e42bb6294e
Add _raw function to P224K1
Modified the testing to use the generic fast reduction test function.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-05-16 17:30:03 +02:00
Gabor Mezei
dacfe56370
Add _raw function to P192K1
Modified the testing to use the generic fast reduction test function.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-05-16 17:29:57 +02:00
Przemek Stekiel
69482f9499 Add test to cover memory leak in authorityCertIssuer case
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-05-16 10:33:02 +02:00
Paul Elliott
926bcb04fe
Merge pull request #7532 from AndrzejKurek/remove-leading-zeroes-ip-parsing
Disallow leading zeroes when parsing IPv4 addresses
2023-05-15 13:59:10 +01:00
Paul Elliott
aba165b58c
Merge pull request #7586 from gilles-peskine-arm/gitignore-objects-at-root
Ignore *.o everywhere
2023-05-15 13:57:24 +01:00
Valerio Setti
77a75685ed pk: align library and tests code to the new internal functions
Note = programs are not aligned to this change because:
- the original mbedtls_pk_ec is not ufficially deprecated
- that function is used in tests when ECP_C is defined, so
  the legacy version of that function is available in that
  case

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-15 11:18:46 +02:00
Fredrik Hesse
cc207bc379 Replace references to Mbed Crypto with Mbed TLS through-out documentation and comments.
Signed-off-by: Fredrik Hesse <fredrik@hesse.se>
2023-05-12 14:59:01 +01:00
Gilles Peskine
8075f76708 Ignore *.o everywhere
We don't commit *.o files anywhere, not even as test data. So ignore them
everywhere.

This resolves *.o files not being ignored under 3rdparty/p256-m.

Also remove a redundant ignore of *.exe in a subdirectory.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-05-12 13:58:05 +02:00
Przemek Stekiel
c4019fa74f Fix peer vs our key missmatch in ffdh key agreement transparent driver
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-05-11 12:06:00 +02:00
Przemek Stekiel
c49163e786 Adapt test driver configuration for FFDH
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-05-11 12:06:00 +02:00
Przemek Stekiel
bfba51d672 Add FFDH support for transparent drivers(generate, export public key)
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-05-11 12:05:53 +02:00
Przemek Stekiel
dccb20204a Add test component for accelerated FFDH
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-05-11 11:31:51 +02:00
Andrzej Kurek
199eab97e7 Add partial support for URI SubjectAltNames
Only exact matching without normalization is supported.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-10 09:57:19 -04:00
Mukesh Bharsakle
4823d5ff0e
Merge branch 'Mbed-TLS:development' into update-pkparse-tests-to-use-AES 2023-05-10 12:35:19 +01:00
Manuel Pégourié-Gonnard
1d046fa0dd
Merge pull request #6010 from mprse/ffdh_import_export
FFDH 1, 2A, 2B: FFDH add support for import/export key, key agreement, key generation + tests
2023-05-10 11:40:54 +02:00
Pengyu Lv
a57f677474 cert_audit: Fix DER files missed from parsing
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-05-10 09:41:33 +08:00
Pengyu Lv
ee870a6e83 cert_audit: Remove merge_auditdata
We maintain a dict with unique AudiData objects
(AuditData with unique underlying X.509 objects).
We don't need merge_auditdata anymore.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-05-10 09:41:33 +08:00
Pengyu Lv
e09d27e723 cert_audit: Use dictionary to store parsed AuditData
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-05-10 09:41:33 +08:00
Pengyu Lv
31e3d12be9 cert_audit: Output format improvement
We should print all the information for each objects
found every line. This makes it easy to analyze the
output.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-05-10 09:41:33 +08:00
Pengyu Lv
13f2ef4949 cert_audit: Calculate identifier for X.509 objects
The identifier is calculated SHA1 hex string from
the DER encoding of each X.509 objects. It's useful
for finding out the identical X.509 objects.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-05-10 09:41:33 +08:00
Pengyu Lv
fd72d9f556 cert_audit: Fix bug in check_cryptography_version
check_cryptography_version didn't provide helpful
message with Python < 3.6, because re.Match object
is not subscriptable.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-05-10 09:41:33 +08:00
Pengyu Lv
0b4832bbf5 cert_audit: Sort the outputs by not_valid_after date
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-05-10 09:41:33 +08:00
Pengyu Lv
fe13bd3d0e cert_audit: Merge audit_data for identical X.509 objects
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-05-10 09:41:33 +08:00
Pengyu Lv
e245c0c734 cert_audit: Support parsing file with multiple PEMs
Previously, if a file had multiple PEM objects, only
the first one would be parsed. This commit add the
support so that we could parse all the PEM objects
in the file.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-05-10 09:41:33 +08:00
Bence Szépkúti
ddfd0a27df
Merge pull request #7399 from lpy4105/issue/7014/certificate-audit-script
cert_audit: Add test certificate date audit script
2023-05-09 13:10:01 +02:00
Gilles Peskine
97edeb4fb8
Merge pull request #6866 from mprse/extract-key-ids
Extracting SubjectKeyId and AuthorityKeyId in case of x509 V3 extensions v.2
2023-05-08 20:38:29 +02:00
Przemek Stekiel
67d3f52617 Use int instead uint in test function arguments
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-05-08 11:15:59 +02:00
Przemek Stekiel
ed9fb78739 Fix parsing of KeyIdentifier (tag length error case) + test
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-05-08 11:15:54 +02:00
Gilles Peskine
fca2d2b78c
Merge pull request #7555 from yuhaoth/pr/remove-delay-milliseconds-test
Remove delay milliseconds test to workaround randome platform-suite fail.
2023-05-07 20:34:44 +02:00
Jerry Yu
8beb25041e fix wrong target detection
For mingw with `-std=c99`, WIN32 is not defined.

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-05-06 13:45:12 +08:00
Tom Cosgrove
ef468ea2ba
Merge pull request #6740 from xkqian/tls13_fix_unkown_pk_type
Remove useless debug log of pk type from test cases
2023-05-05 16:14:59 +01:00
Jerry Yu
484a9e138f Remove delay milliseconds test
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-05-05 17:03:29 +08:00
Valerio Setti
4f387ef277 pk: use better naming for the new key ID field
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-05 10:59:32 +02:00
Valerio Setti
048cd44f77 pk: fix library code for using the new opaque key solution
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-05 10:59:32 +02:00
Jethro Beekman
e3d98fcbf6 Add pkwrite tests for X25519/X448 DER
Signed-off-by: Jethro Beekman <jethro@fortanix.com>
2023-05-04 13:01:47 +02:00
Jethro Beekman
abbba5ed43 Add derive public test for X25519/X448
Signed-off-by: Jethro Beekman <jethro@fortanix.com>
2023-05-04 13:01:47 +02:00
Jethro Beekman
0167244be4 Read and write X25519 and X448 private keys
Signed-off-by: Jethro Beekman <jethro@fortanix.com>
Co-authored-by: Gijs Kwakkel <gijs.kwakkel@fortanix.com>
Signed-off-by: Gijs Kwakkel <gijs.kwakkel@fortanix.com>
2023-05-04 13:01:47 +02:00
Manuel Pégourié-Gonnard
e4072c00c8
Merge pull request #7548 from jethrogb/jb/mbedtls_pem_write_buffer
mbedtls_pem_write_buffer: Correctly report needed buffer size for all possible line lengths and counts
2023-05-04 12:54:56 +02:00
Paul Elliott
b6432832d0
Merge pull request #7490 from paul-elliott-arm/test_ecp_mod_p448
[Bignum] Add unit tests for ecp_mod_p448
2023-05-04 11:39:44 +01:00
Przemek Stekiel
2488afcd71 Add FFDH alg to test driver extensions
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-05-04 10:29:05 +02:00
Gilles Peskine
2eff33cb6f
Merge pull request #6716 from gilles-peskine-arm/test-argument-types-union
Support larger integer test arguments
2023-05-04 10:05:20 +02:00
Jethro Beekman
2593ec4bee Use TEST_EQUAL instead of TEST_ASSERT
Signed-off-by: Jethro Beekman <jethro@fortanix.com>
2023-05-03 17:47:29 +02:00
Jethro Beekman
3477a672b9 Fix cross-platform compilation issue
Signed-off-by: Jethro Beekman <jethro@fortanix.com>
2023-05-03 17:47:27 +02:00
Przemek Stekiel
8194285cf1 Fix parsing of authorityCertSerialNumber (use valid tags)
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-05-03 16:19:16 +02:00
Jethro Beekman
746df88e90 mbedtls_pem_write_buffer: Correctly report needed buffer size for all possible line lengths and counts
Signed-off-by: Jethro Beekman <jethro@fortanix.com>
2023-05-03 15:30:49 +02:00
Kusumit Ghoderao
056f0c5047 Make output_byte return not_supported for pbkdf2
As output functionality is not added yet return PSA_SUCCESS for
now if inputs are passed correctly. If input validation fails
operation is aborted and output_bytes will return PSA_ERROR_BAD_STATE

Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-05-03 17:33:27 +05:30
Manuel Pégourié-Gonnard
f57273c817
Merge pull request #7496 from valeriosetti/issue7480
Fix test gap in PK write: private (opaque) -> public
2023-05-03 12:39:49 +02:00
Kusumit Ghoderao
7c05c00988 Add test cases for pbkdf2 input functions
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-05-03 14:20:37 +05:30
Gilles Peskine
d3ca5e5897
Merge pull request #7328 from mprse/ec-jpake-fix1
Fix the JPAKE driver interface for user+peer
2023-05-02 20:42:25 +02:00
Gilles Peskine
c70d9eab8a
Merge pull request #7412 from silabs-Kusumit/PBKDF2_implementation
PBKDF2: Implement input_integer
2023-05-02 20:41:23 +02:00
Valerio Setti
9a855f21aa test: check for exact length of returned pub key
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 15:45:39 +02:00
Valerio Setti
f5451717af test: optimize code for pk_write_public_from_private()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 15:45:39 +02:00
Valerio Setti
84554e9830 test: use better naming for the newly introduced test function
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 15:45:39 +02:00
Valerio Setti
8820b57b6e test: fix makefile for ec_pub.[der/pem] generation
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 15:45:39 +02:00
Valerio Setti
d860a79029 test: fix wrong private key file
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 15:45:39 +02:00
Valerio Setti
1751341b68 test: add test function for public key derivation starting from private one
Data test cases are also included in the commit.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 15:45:39 +02:00
Valerio Setti
c8b7865612 test: align ec_pub public keyfile with its ec_prv.sec1 counterpart
This change affects:
- both PEM and DER files, since they contain the same public key
  only in different formats
- "ec_pub.comp.pem" since it's the same as "ec_pub.pem" but in
  compressed format

The makefile was also updated accordingly to reflect these
dependencies.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 15:45:39 +02:00
Manuel Pégourié-Gonnard
f317df98ea
Merge pull request #7461 from valeriosetti/issue7460-part1
Fixing USE_PSA_INIT/DONE in SSL/X509/PK test suites
2023-05-02 10:44:13 +02:00
Kusumit Ghoderao
d60dfc0e43 Add test for parse_binary_string
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-05-02 10:47:50 +05:30
Andrzej Kurek
6f400a376e Disallow leading zeroes when parsing IPv4 addresses
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-01 06:23:42 -04:00
Gilles Peskine
14d6b1124b
Merge pull request #7419 from yuhaoth/test/random-time-test-fail
Workaround random `test_suite_platform` fail in time test
2023-04-28 13:17:31 +02:00
Valerio Setti
7c0f91be10 test: use define for initializing ssl_message_queue struct
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-04-28 12:20:34 +02:00
Przemek Stekiel
6d85afa0cc Fix naming: FFDH key -> DH key and fix guard in psa_validate_key_type_and_size_for_key_generation
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-28 11:42:17 +02:00
Valerio Setti
00a256f7b2 test: fix USE_PSA_INIT position in test_suite_ssl
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-04-28 09:37:35 +02:00
Kusumit Ghoderao
0f2f996b92 change binary_string_parser for big-endian input
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-04-28 10:07:10 +05:30
Dave Rodgman
e93c90e881
Merge pull request #7433 from oberon-microsystems/fix-psa-aead-chacha20-test-dependency 2023-04-27 19:13:53 +01:00
Kusumit-Silabs
b6ad6823f0
Update tests/suites/test_suite_psa_crypto.function
Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Kusumit-Silabs <89393006+silabs-Kusumit@users.noreply.github.com>
2023-04-27 22:42:19 +05:30
Kusumit Ghoderao
af0225e4de change binary_string_parser for big-endian input
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-04-27 20:06:58 +05:30
Kusumit Ghoderao
c6fdf1b683 Add tests with INPUT_INTEGER as key_type_arg
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-04-27 17:03:20 +05:30
Kusumit Ghoderao
12e0b4b452 Use key_type_arg for determining input method
Remove input_types_arg variable in test function
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-04-27 16:58:23 +05:30
Przemek Stekiel
4c0da51ee7 mbedtls_test_psa_exported_key_sanity_check: check for length equality for DH keys
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-27 13:04:20 +02:00
Przemek Stekiel
2c9fc07cc4 Fix FFDH tests dependencies
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-27 12:41:32 +02:00
Przemek Stekiel
2e7c33d530 Use import_with_data for testing FFDH invalid key length
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-27 12:31:42 +02:00
Paul Elliott
16648be171 Add Curve 448 tests
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-04-26 22:23:27 +01:00
Gilles Peskine
b70c4e07d0 Adjust code style for pointer types and casts
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:59:28 +02:00
Gilles Peskine
2986accd20 typo
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:57:50 +02:00
Gilles Peskine
578613322a Add test cases with a question mark
The test framework used to treat them specially (but no longer does). Add
these test cases as non-regression for how the test framework allows "?"
and especially "??" (which I think in the very distant path needed special
handling because the test data was embedded in a .c file, and thus ?? could
be interpreted as the prefix of a trigraph).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:50:57 +02:00
Gilles Peskine
9a75131da1 Fix wrong comment
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
5472242b67 Explain the format argument expected by the test functions
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
fa83a7ec1e Fix typos in test descriptions
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
8b32d20c50 Test the line number returned by parse_test_data
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
7768a8e0a6 Remove string hack for mbedtls_mpi_mod_int testing
Now that the test framework can pass arbitrary values of type
mbedtls_mpi_sint, just do that.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
6f5082bf4d Allow more signed integer types in test function arguments
Now that the C code supports the full range of intmax_t, allow any size of
signed integer type in the .data file parser.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
872948cc72 Support larger integer test arguments: C part
Change the type of signed integer arguments from int32_t to intmax_t.
This allows the C code to work with test function arguments with a range
larger than int32_t. A subsequent commit will change the .datax generator
to support larger types.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
4ea4ad082b parse_function_arguments: stricter type parsing
Use normalization the equality comparisons instead of loose regular
expressions to determine the type of an argument of a test function.

Now declarations are parsed in a stricter way: there can't be ignored junk
at the beginning or at the end. For example, `long long unsigned int x`
was accepted as a test function argument (but not `long long unsigned x`),
although this was misleading since the value was truncated to the range of
int. Now only recognized types are accepted.

The new code is slightly looser in that it accepts `char const*` as well as
`const char*`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
47e2e8817d Support (void) as an argument list of a test function
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
096f0ca7e5 parse_function_arguments: extract per-argument function
Internal refactoring only, no behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
400cde607b parse_function_arguments: make local_vars a list
Internal refactoring only, no behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
b3c2eaf00f Support different types in the parameter store
The test framework stores size_t and int32_t values in the parameter store
by converting them all to int. This is ok in practice, since we assume int
covers int32_t and we don't have test data larger than 2GB. But it's
confusing and error-prone. So make the parameter store a union, which allows
size_t values not to be potentially truncated and makes the code a little
clearer.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
5226eb5cd3 Simplify parsing of integers in .datax files
In the .datax parser, since we're calling strtol() anyway, rely on it for
verification. This makes the .datax parser very slightly more
liberal (leading spaces and '+' are now accepted), and changes the
interpretation of numbers with leading zeros to octal.

Before, an argument like :0123: was parsed as decimal, but an argument like
:0123+1: was parsed as a C expression and hence the leading zero marked an
octal representation. Now, a leading zero is always interpreted according to
C syntax, namely indicating octal. There are no nonzero integer constants
with a leading zero in a .data file, so this does not affect existing test
cases.

In the .datax generator, allow negative arguments to be 'int' (before, they
were systematically treated as 'exp' even though they didn't need to be).

In the .datax parser, validate the range of integer constants. They have to
fit in int32_t. In the .datax generator, use 'exp' instead of 'int' for
integer constants that are out of range.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
a9946952b4 Exercise string parsing in the test framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:40:02 +02:00
Gilles Peskine
1a24895bfd Simplify string escapes
Treat backslash as a universal escape character: "\n" is a newline,
backslash escapes any non-alphanumeric character.

This affects some test cases that had "\," standing for backslash-comma.
With the new uniform treatment of backslashes, this needs to be "\\,".

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:39:54 +02:00
Gilles Peskine
ca25deee12 Factor get_function_info out of gen_from_test_data
No intended behavior change. This commit is mainly to satisfy pylint, which
complains that gen_from_test_data now has too many variables. But it's a
good thing anyway to make the function a little more readable.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:38:41 +02:00
Gilles Peskine
8542f5c81f Add line number to a few error messages
This is just a quick improvement, not meant to tackle the problem as a
whole.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:38:40 +02:00
Gilles Peskine
bc3db2e30a printf testing: exercise integer parsing in the test framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:38:40 +02:00
Gilles Peskine
187932639b Remove stdint.h substitute for older MSVC
We now require at least Visual Studio 2013, which has stdint.h per
 https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/y4hta57s(v=vs.120)
so the workaround to define C99 types on pre-C99 MSVC is no longer needed.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:38:40 +02:00
Gilles Peskine
6c607e5a55 Remove declarations of the nonstandard function strcasecmp
It is no longer used.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:38:40 +02:00
Gilles Peskine
017f0b7369 Stop supporting non-canonical case in mpi_write_string test data
We're using the non-standard function strcasecmp() just so that the case
of digits beyond 9 can be different in the library and in the test data.
Use matching case in the test data, and use a standard function for the
comparison.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 19:38:40 +02:00
David Horstmann
9643575d92 Limit OIDs to 128 components
The longest OID known by oid-info.com is 34 components[1], so 128
should be plenty and will limit the potential for attacks.

[1] http://oid-info.com/get/1.3.6.1.4.1.1248.1.1.2.1.3.21.69.112.115.111.110.32.83.116.121.108.117.115.32.80.114.111.32.52.57.48.48

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-04-26 11:50:14 +01:00
Janos Follath
91a618375a
Merge pull request #7427 from minosgalanakis/ecp/7258_ecp_mod_p256K1_add_test_cases
ECP: Add Unit Tests for secp256k1
2023-04-26 08:52:24 +01:00
Przemek Stekiel
654bef0be0 Fix typos, comments, style, optimize macros
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-26 09:07:20 +02:00
Przemek Stekiel
1702d5a1f4 test driver: add support for FFDH key agreement
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-26 09:07:20 +02:00
Przemek Stekiel
7cf26dfca3 Add sanity check for FFDH key excercise
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-26 09:07:20 +02:00