Commit Graph

16339 Commits

Author SHA1 Message Date
Janos Follath
2079aa7838
Merge pull request #4939 from gilles-peskine-arm/psa_cipher_update_ecp-unused_parameter-2.x
Backport 2.x: Fix parameter set but unused on psa_cipher_update_ecb
2021-09-13 13:55:16 +01:00
Gilles Peskine
0390016096 Fix the size in bytes
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-09-13 12:54:46 +02:00
Gilles Peskine
a63ba6cd93 psa_cipher_update_ecb: remove parameter output_size
This parameter was set but not used, which was pointless. Clang 14 detects
this and legitimately complains.

Remove the parameter. This is an internal function, only called once. The
caller already has a sufficient check on the output buffer size which
applies in more cases, so there is no real gain in robustness in adding the
same check inside the internal function.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-09-13 12:54:46 +02:00
Gilles Peskine
7b1c916fe8 Document the internal function psa_cipher_update_ecb
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-09-13 12:54:45 +02:00
Archana
6d342f3e1d
Remove dependency of builtin keys on storage
The psa_open_key API depends on MBEDTLS_PSA_CRYPTO_STORAGE_C.
This is unnecessary for builtin keys and so is fixed.
Updated an open_fail test vector keeping with the same.

Signed-off-by: Archana <archana.madhavan@silabs.com>
2021-09-11 22:31:06 +05:30
Mateusz Starzyk
7d13539d1b Disable MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE in default config.
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-09-06 12:19:25 +02:00
Mateusz Starzyk
b3d344c225 Remove MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES option.
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-09-06 12:18:53 +02:00
Gilles Peskine
9be53ffd10
Merge pull request #4903 from kennethsoerensen/pkparse-warning_2.x
Backport 2.x: Remove compiler warning if only MBEDTLS_PK_PARSE_C is d…
2021-09-01 16:53:50 +02:00
Kenneth Soerensen
c4e950ea53 Backport 2.x: 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-09-01 11:18:30 +02:00
Ronald Cron
b4c0668fa5
Merge pull request #4841 from JoeSubbiani/ByteReadingMacros2_2.x
Backport 2.x: Byte reading macros
2021-08-24 09:02:01 +02:00
Joe Subbiani
11b7131c2e Fix macro use in ssl_msg.c
After implementing MBEDTLS_PUT_UINT16_BE, I did not remove the
assignment to a variable

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-23 12:49:14 +01:00
Joe Subbiani
b1f6eef88b Remove commented out code
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-23 11:45:36 +01:00
Joe Subbiani
a651e6f762 Tidy up grouped MBEDTLS_BYTE_x macros
exchange groups of the byte reading macros with MBEDTLS_PUT_UINTxyz
and then shift the pointer afterwards. Easier to read as you can
see how big the data is that you are putting in, and in the case of
UINT32 AND UINT64 it saves some vertical space.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-23 11:35:25 +01:00
Joe Subbiani
24647c5cd2 Minor coding style improvement
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-20 15:56:22 +01:00
Joe Subbiani
efb8fae492 Compress byte reading macros in if statements
exchange MBEDTLS_BYTE_x in if statements with MBEDTLS_GET_UINT16_BE

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-20 12:57:09 +01:00
Joe Subbiani
2f98d791c3 Tidy up ssl_*.c grouped MBEDTLS_BYTE_x macros
exchange groups of the byte reading macros with MBEDTLS_PUT_UINTxyz
and then shift the pointer afterwards. Easier to read as you can
see how big the data is that you are putting in, and in the case of
UINT32 AND UINT64 it saves some vertical space.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-20 11:44:44 +01:00
Joe Subbiani
23fec2538e Replace remaining byte shift with macro
Replace another instance of >> 8 with MBEDTLS_BYTE_1

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-18 16:23:47 +01:00
Joe Subbiani
d6ea063371 Move #include "common.h" where config.h used to be
After removing config.h, the inclusion of it in common.h would be too late
in the code. Therefore common.h has been moved to where config.h used to
be included.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-18 12:57:54 +01:00
Joe Subbiani
4446e82146 Remove redundant config.h includes definitions
common.h already includes config.h, so a a file uses common.h
it no longer requires the definition/inclusion of config.h

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-18 12:50:12 +01:00
Joe Subbiani
a724ef9d11 Add more instances of Byte Reading Macros
added more uses of byte reading macros where appropriate.
changed the positioning of some brackets for consitancy in
coding style

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-18 12:06:57 +01:00
Joe Subbiani
b763ba4198 Remove macro that does not belong in 2.x
MBEDTLS_ALLOW_PRIVATE_ACCESS existed in development and was copied
over whilst cherry-picking commits.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-18 11:59:16 +01:00
Manuel Pégourié-Gonnard
5c385aca19
Merge pull request #4873 from mpg/bio_recv_ret_0_eof-2.x
Backport 2.x: Document that returning 0 from the recv callback means EOF
2021-08-17 10:30:59 +02:00
Hanno Becker
c8ac785fc3 Document that returning 0 from the recv callback means EOF
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-08-16 13:00:06 +02:00
Manuel Pégourié-Gonnard
f87422f019
Merge pull request #4427 from gilles-peskine-arm/tls_ext_cid-config-2.x
Backport 2.x: Allow configuring MBEDTLS_TLS_EXT_CID at compile time
2021-08-13 10:50:02 +02:00
Manuel Pégourié-Gonnard
9c6cc6945e
Merge pull request #4855 from mpg/add-arm-linux-build-2.x
Backport 2.x: Add arm-linux-gnueabi-gcc build
2021-08-12 13:16:07 +02:00
Manuel Pégourié-Gonnard
9a260a628a Fix missing dependency on Travis
Was getting errors like:

In file included from /usr/include/limits.h:25:0,
                 from /usr/lib/gcc-cross/arm-linux-gnueabi/5/include-fixed/limits.h:168,
                 from /usr/lib/gcc-cross/arm-linux-gnueabi/5/include-fixed/syslimits.h:7,
                 from /usr/lib/gcc-cross/arm-linux-gnueabi/5/include-fixed/limits.h:34,
                 from ../include/mbedtls/check_config.h:30,
                 from ../include/mbedtls/build_info.h:81,
                 from common.h:26,
                 from asn1write.c:20:
/usr/include/features.h:367:25: fatal error: sys/cdefs.h: No such file or directory

There are two packages to choose from: armhf or armel. Since the comment
in all.sh says we're trying to be close to Debian's "armel"
architecture, choose that, and fix a comment that was mentioning
gnueabihf for no apparent reason.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-08-09 12:09:41 +02:00
Manuel Pégourié-Gonnard
cbb365ce3b Enable arm-linux-gnueabi-gcc build on Travis
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-08-09 12:09:38 +02:00
Manuel Pégourié-Gonnard
719301693d Add arm-linux-gnueabi-gcc build to all.sh
Currently it can't be mandatory, since we can't install the required toolchain
on Jenkins right away.

Also, while at it, remove `SHELL='sh -x'` from the other arm5vte component; it
was a leftover from debugging.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-08-09 12:08:39 +02:00
Gilles Peskine
7b8571fcb5 New macro MBEDTLS_CHECK_RETURN
Put this macro before a function declaration to indicate that its result
must be checked. This commit supports GCC-like compilers and MSVC >=2012.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-05 13:49:44 +02:00
Gilles Peskine
1b95b34c4b
Merge pull request #4696 from yutotakano/fix-ssl-opt.sh-hard-abort-2.x
Backport 2.x: ssl-opt.sh: Skip tests instead of conditional hard abort
2021-08-04 10:16:42 +02:00
Joe Subbiani
ca8a7cf82d Implement byte reading macros to remaining files
The previous commits cherry picked from the changes made with relation
to the development branch. This commit makes the appropriate chnages to
the files not present in the development branch.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 16:42:42 +01:00
Joe Subbiani
f15da890fb Replace remaining MBEDTLS_CHAR with MBEDTLS_BYTE
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 16:10:38 +01:00
Joe Subbiani
8799e54a21 Remove trailing whitespace
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:09:27 +01:00
Joe Subbiani
d3a3f21ad5 Improve documentation and add more uses of MBEDTLS_PUT
minor changes, such as improving the documentation for the byte reading
macros, and using MBEDTLS_PUT_UINT16_xy in place of byte reading
macro combinations

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:09:21 +01:00
Joe Subbiani
896f4eeaf7 Improve consitency throughout library/common.h
Replace the contents of MBEDTLS_PUT_UINTx_yz contained inconsitent
but similar/duplicate code to the MBEDTLS_BYTE_x macros. Therefore
the contents of the macros now utilise the byte reading macros.

MBEDTLS_PUT_UINT64_LE's written order was also not consitent with
the other PUT macros, so that was modified.

Documentation comment said LSB instead of MSB and that has also been
resolved.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:09:12 +01:00
Joe Subbiani
c54e908656 Replace instances of byte reading macros with PUT
Instances of a group of byte reading macros which are equivilant to
MBEDTLS_PUT_UINTx_yz

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:09:05 +01:00
Joe Subbiani
197e9edae5 Remove trailing white space
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:08:58 +01:00
Joe Subbiani
281956d5c3 Remove use of byte reading macro for uint16
Accidently used MBEDTLS_BYTE_16 for a uint16 variable

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:08:50 +01:00
Joe Subbiani
6627fb284a Replace instances of byte reading macros with PUT
Instances of a group of byte reading macros which are equivilant to
MBEDTLS_PUT_UINTx_yz

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:08:41 +01:00
Joe Subbiani
ad1115a3fd Use byte reading macros in places not using a byte mask
byte shifting opertations throughout library/ were only replaced with
the byte reading macros when an 0xff mask was being used.
The byte reading macros are now more widley used, however they have not
been used in all cases of a byte shift operation, as it detracted from
the immediate readability or otherwise did not seem appropriate.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:08:33 +01:00
Joe Subbiani
1bd5d7da82 Add UINT64 GET and PUT macros
Copy over the GET/PUT_UINT64_LE/BE macros from aes.c and sha512.c
Add the MBEDTLS_ prefix to all 4 macros.
Modify the GET_UINT64 macros to no longer take a target variable
as a parameter, so when the macro function is called it must be
assigned to a variable in the same statement.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:08:26 +01:00
Joe Subbiani
c045dc14b0 Replace MBEDTLS_CHAR_x with MBEDTLS_BYTE_x
The CHAR macros casted to an unsigned char which in this project
is garunteed to be 8 bits - the same as uint8_t (which BYTE casts
to) therefore, instances of CHAR have been swapped with BYTE and
the number of macros have been cut down

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:08:06 +01:00
Joe Subbiani
5b96e67ea1 Replace "four bytes" with "two bytes" in macro documentation
When writing the documentation 4 bytes was written instead of 2 for
MBEDTLS_UINT16_LE

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:02:54 +01:00
Joe Subbiani
6350d3a0dd Remove trailing whitespaces
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:02:47 +01:00
Joe Subbiani
1000037831 Replace 3 byte shift with appropriate macro
aria.c has a shift by 3 bytes, but does not use the 0xff masking.
aparently this is not a problem and it is tidier to use the maco.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:02:41 +01:00
Joe Subbiani
0a65d531c5 Improve common.h macro documentation
Imrpoved the descriptions of the macros and parameters and
changing the name of the MBEDTLS_PUT_UINT... macro parameters
to be more descriptive

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:02:31 +01:00
Joe Subbiani
6b897c930c Add Character byte reading macros
These cast to an unsigned char rather than a uint8_t
like with MBEDTLS_BYTE_x
These save alot of space and will improve maintence by
replacing the appropriate code with MBEDTLS_CHAR_x

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 14:01:51 +01:00
Joe Subbiani
9231d5f919 GET macros use a target variable
The GET macros used to write to a macro parameter, but now
they can be used to assign a value to the desired variable
rather than pass it in as an argument and have it modified
in the macro function.

Due to this MBEDTLS_BYTES_TO_U32_LE is the same as
MBEDTLS_GET_UINT32_LE and was there for replaced in the
appropriate files and removed from common.h

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 13:39:57 +01:00
Joe Subbiani
266476da00 Document common.h and remove changelog
Added documenttion comments to common.h and removed the changelog
as it is not really necessary for refactoring.

Also modified a comment in aria.c to be clearer

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 13:39:43 +01:00
Joe Subbiani
4530b27021 Move GET/PUT_UINT16_LE macros to common.h
Although these only appear in one file: psa_crypto_storage.c
it is tidy to give it the same prefix as the UINT32 macros
and to store them in the fame file

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-03 13:39:29 +01:00