Commit graph

17917 commits

Author SHA1 Message Date
Joe Subbiani
a032963d65 Modify comment descriptions of add_xxx_ciphersuites()
Modify the comments to include the use of the translate function
and retire the explanation of maintaining 2 seperate lists

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:52 +01:00
Joe Subbiani
6452f1ee35 Modify file name comments to match the file rename
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:52 +01:00
Joe Subbiani
0fadf8ef7d Improve coding style and consistancy
- Replace uses of mbed and gnu with mbedtls and gnutls respectivley.
 - Uses sys.exit() rather than exit()
 - Rename format() as it is an inbuilt python function
 - Add error information if incorrect arguments are passsed to
   translate_ciphers.py

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:52 +01:00
Joe Subbiani
34d62620fb Reduce calls to translate_ciphers.py in compat.sh
After every edge case to append which ciphers were being used
a call to translate_ciphers.py was being made.

Now a call to translate_ciphers are made at the end of every
function where ciphersuite names are being added. This occurs
3 times. 1 for MBedTLS, GNUTLS and OpenSSL. 1 for MBedTLS and
OpenSSL and another 1 for MBedTLS and GNUTLS.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:52 +01:00
Joe Subbiani
d16d273a40 Compact 2 format functions to 1
In translate_ciphers.py there were 2 format functions that were
virtually identical and a check was made beforehand to decide
which one to call. Now the check is made inside a single function
to reduce duplicate code

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:52 +01:00
Joe Subbiani
15d7124661 Replace lists with calls to translate_ciphersuite.py
Replace the OpenSSL $O_CIPHERS and GNU $G_CIPHERS declarations
with calls to translate_ciphersuite.py

Declared a new variable for each sublist $CIPHERS which is appended
to MBedTLS $M_CIPHERS and translated+appended to the OpenSSL and GNU
lists.

Fixes #4674

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:52 +01:00
Joe Subbiani
a16ccac1d9 Format files and add license comment
Changes to pass tests/scripts/check_files.py
-Add missing new line at end of each file
-Remove any trailing whitespaces
-Added file shebang comments

Added license info and purpose of file descriptions. The 2 test_translate...
files may not be stay later down the line, but incase they do become
permanent, it is good to add the appropriate comments now.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:51 +01:00
Joe Subbiani
29239b00a6 Move translate scripts to test directory
To be used by compat.sh, the files were moved to the same directory.
The files were also renamed to be distinguishable aside from their
file extensions

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:51 +01:00
Joe Subbiani
97cd599545 Implement bash script for testing
Added formatting functions to translate_ciphersuite.py to take a string
of multiple ciphersuite names, in the current compat.sh and output the
translated ciphersuite names in the same format

Created test_translate.sh which uses samples from compat.sh to compare
against the translated versions to ensure the translations are produced
in the correct format

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:51 +01:00
Joe Subbiani
3ad58329da Reformat translation functions and test in seperate file
Moved the test over to a seperate file, where I can start experimenting with
how the script will be called.
Commented and improved the translation functions. They should be more readable,
however I added comments anyway to quickly identify every step involved with
te translation from MBedTLS to GNU or OpenSSL

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:51 +01:00
Joe Subbiani
8394484f0a Add draft python tool to translate MBed ciphersuites
Created 2 functions
 - translate_gnu()
 - translate_ossl()

Each function takes a parameter `m_cipher` (expected in the MBedTLS naming
standard), and through a series of edge cases/replaces, modifies the
ciphersuite name to match the GNU and OpenSSL naming conventions respectively.

This will serve as to maintain a single list that can be translated, rather
than maintaining 3 lists for OpenSSL and GNU also.

This commit serves as a checkpoint, and the program will be cleaned up in the
future.

The program currently runs a series of tests to check every given ciphersuite name
combination in compat.sh to ensure they are translated correctly.

Some OpenSSL names appear to have typos and as such have been corrected in
this program until I have recieved more information. The errors were commented
out to keep note of.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-09-02 18:53:51 +01:00
Ronald Cron
13592ca654
Merge pull request #4879 from yuhaoth/pr/upgrade-gnutls-next
Upgrade gnutls next
2021-09-02 16:38:19 +02:00
Mateusz Starzyk
df2507301b Use AES-128 for multipart CCM corner cases tests
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-09-02 12:36:02 +02:00
Jerry Yu
75261df2e3 fix comment issues
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2021-09-02 17:56:20 +08:00
Mateusz Starzyk
64f0b5f454 Return BAD_INPUT error for CCM context's erroneous state
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-09-02 11:50:54 +02:00
Jerry Yu
b12d81d1a3 Add feature tests for gnutls-next
Test NO_TICKETS and DISABLE_TLS13_COMPAT_MODE

Change-Id: Idf21b36bd64c7eefe4e0e6fb875b2e06ebb0aa07
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2021-09-02 17:31:10 +08:00
Jerry Yu
ab46aa0436 Upgrade gnutls-next to 3.7.2
v3.7.2 introduces DISABLE_TLS13_COMPAT_MODE. That can be
used to verify if TLS13 COMPATIBLE is not available.

Change-Id: Id68748e92504835b5a63b2565a618f728e7222f6
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2021-09-02 17:31:10 +08:00
Gilles Peskine
0bf740ee4f
Merge pull request #4765 from gilles-peskine-arm/all.sh-subshells-3.0
Run all.sh components in a subshell
2021-09-02 10:26:58 +02:00
Gilles Peskine
88d681ca35 Make size_t -> int downcasts explicit
mbedtls_cipher_setkey takes an int argument. Cast explicitly, otherwise MSVC
complains.

Where possible, just stick to size_t.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-09-01 16:57:23 +02:00
Gilles Peskine
6f015a8798
Merge pull request #2327 from kennethsoerensen/pkparse-warning
Remove compiler warning if only MBEDTLS_PK_PARSE_C is defined
2021-09-01 16:53:45 +02:00
Paul Elliott
b0450febe6 Tests for sending too much data after set lengths
We previously had tests for not sending enough (additional) data, but
were missing tests for sending too much. I have added these to the state
tests, as I don't think this is complex enough to deserve a standalone
test.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-09-01 15:09:15 +01:00
Paul Elliott
7f62842247 Add test for calling update when nonce not set
Previously only testing calling update_ad in this state.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-09-01 15:09:15 +01:00
Paul Elliott
c6d11d02f5 Aligh update buffer test variables with psa naming
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-09-01 15:09:15 +01:00
Paul Elliott
3d7d52c2ed Formatting fixes
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-09-01 15:09:15 +01:00
Mateusz Starzyk
7251eda6ff Replace BAD_SEQUENCE error with BAD_INPUT
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-09-01 13:26:44 +02:00
Mateusz Starzyk
e40ae6bbed Fix typo
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-09-01 12:47:49 +02:00
Manuel Pégourié-Gonnard
5a8abb144c
Merge pull request #4883 from mstarzyk-mobica/fix_psa_sign_msg
PSA MAC computation with _HASH flag implies _MESSAGE.
2021-09-01 12:23:20 +02:00
Gilles Peskine
6ac8f94a72 Fix cipher info key length sanity checks
Most supported ciphers have a 128-bit, 192-bit or 256-bit keys. List the
exceptions explicitly.

This commit fixes a test failure with the null cipher and an incorrect
comment that omitted several key lengths.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-09-01 08:31:49 +02:00
Gilles Peskine
ca939959e4 Allow read-only access to lists of certificates, CRL, CRL entries
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 23:18:07 +02:00
Gilles Peskine
2e9d65f928 Note that custom info structures are not supported
This was already documented for mbedtls_md_info_t. Also document it for
mbedtls_pk_info_t (where it's fairly obvious since the structure is not
defined in a public header) and for mbedtls_cipher_info_t (where it's not
obvious since the structure is defined in a public header).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 23:08:55 +02:00
Gilles Peskine
44ffc79d29 Copyediting in comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 23:08:55 +02:00
Gilles Peskine
842edf474c Make many fields of X.509 structures public
The structures mbedtls_x509_time, mbedtls_x509_crl_entry, mbedtls_x509_crl,
mbedtls_x509_crt, mbedtls_x509_san_other_name,
mbedtls_x509_subject_alternative_name, mbedtls_x509_csr are designed to
expose the result of parsing X.509 data. Document many of their fields as
being publicly readable.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 22:54:27 +02:00
Gilles Peskine
b89d9c0599 Make fields of ASN.1 data structures public
The structures mbedtls_asn1_buf, mbedtls_asn1_bitstring,
mbedtls_asn1_sequence and mbedtls_asn1_named_data are designed to allow
access to data after parsing. Make their fields public.

Document that chaining fields are essentially read-only.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 22:54:27 +02:00
Gilles Peskine
b11d61e095 mbedtls_net_context: make fd public on Unix/POSIX platforms
On platforms with BSD-like sockets, it is useful for applications to have
access to the underlying file descriptor so that they can use functions like
select() and poll().

Do not promise that the field will exist on other platforms such as
Windows (where the type and name of the field are technically wrong because
Windows socket handles are actually not file descriptors).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 22:54:27 +02:00
Gilles Peskine
ce9e3a92fe Remove redundant null check
mbedtls_cipher_info_get_xxx has well-defined behavior on NULL, so no need to
check first.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 22:54:27 +02:00
Gilles Peskine
e720dbe177 Use cipher_info accessor functions in TLS code
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 22:54:27 +02:00
Gilles Peskine
80932fa944 Don't access cipher_info private fields in sample programs
Use the new accessor functions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 22:52:41 +02:00
Gilles Peskine
0be02bd823 Add accessor functions for cipher_info fields
Add functions to read the type, mode, name and key_bitlen fields from
mbedtls_cipher_info_t. These are the fields that applications are most
likely to care about.

TLS code also uses iv_size and block_size, which it might make sense to
expose, but most applications shouldn't need those, so I'm not exposing them
for now.

Call the new functions in unit tests, so they're at least smoke-tested.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 22:52:41 +02:00
Gilles Peskine
a73b577744 Make the fields of mbedtls_ecp_curve_info public
The whole point of this structure is to provide information, both for the
library's own sake and to applications.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31 22:52:41 +02:00
Kenneth Soerensen
e28d49b3b6 Remove compiler warning if only MBEDTLS_PK_PARSE_C is defined
Warning reported with IAR compiler:
"mbedtls\library\pkparse.c",1167  Warning[Pe550]: variable "ret" was set but never used

Signed-off-by: Kenneth Soerensen <knnthsrnsn@gmail.com>
2021-08-31 13:05:12 +02:00
Mateusz Starzyk
1ebcd55afa Extend mac_key_policy test.
Add checks for psa_mac_compute and psa_mac_verify.

Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-08-30 17:11:01 +02:00
Manuel Pégourié-Gonnard
e45ee40f7e
Merge pull request #4811 from hanno-arm/tls13_ciphersuite_api
Add TLS 1.3 ciphersuite and key exchange identifiers and API
2021-08-30 09:47:46 +02:00
Paul Elliott
5e69aa5709 Remove NULL check for set nonce
Also remove tests which would pass NULL to this function.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
2e450093e1 Remove variables declared as unused
They are now always being used.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
efda3408ce Fix formatting issues
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
3242f6c8ef Fix formatting issue
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
b8db2c5726 Remove extra blank lines
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
daf5c8954c Remove extraneous state checks
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
6f0e72038d Align set nonce variables with psa convention
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00
Paul Elliott
f127763ec9 Align generate nonce variables with psa convention
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-08-25 17:40:40 +01:00