Gilles Peskine
2a296729d0
Merge pull request #8084 from AgathiyanB/remove-type-qualifier-in-assignment-casts
...
Remove type qualifier in assignment casts
2023-08-24 18:02:11 +00:00
Agathiyan Bragadeesh
457ac84f01
Refactor previous fix
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-23 11:35:26 +01:00
Agathiyan Bragadeesh
4c7d7bf583
Add guard for empty AttributeValue
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-23 11:28:30 +01:00
Jerry Yu
782b966666
replace target arch macros in padlock
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-23 17:15:35 +08:00
Jerry Yu
d6e312dde4
replace aesni target detection macros
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-23 17:15:34 +08:00
Jerry Yu
72fd0bdc71
replace arm64 macro and aesce enable flag
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-23 17:15:34 +08:00
Agathiyan Bragadeesh
15df01240d
Fix code style
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 17:50:00 +01:00
Agathiyan Bragadeesh
4606bf3f38
Refactor reading AttributeValue in dn gets
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 17:29:18 +01:00
Agathiyan Bragadeesh
022f86f108
Prevent output of escaped null characters dn gets
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 16:56:04 +01:00
Agathiyan Bragadeesh
d9d79bb74b
Rename parse_attribute_value_ber_encoded
...
Now renamed to parse_attribute_value_der_encoded to be consistent with
names elsewhere
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 16:43:58 +01:00
Agathiyan Bragadeesh
8aa74ab6a9
Add return for buffer too small when reading OIDs
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 16:42:27 +01:00
Agathiyan Bragadeesh
f3b9724dcd
Remove questionable use of macro.
...
MBEDTLS_X509_SAFE_SNPRINTF was used after mbedtls_oid_get_numeric_string
so instead we have expanded the macro and kept the relevant code.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 16:37:11 +01:00
Agathiyan Bragadeesh
07f472a88b
Add corruption detected return when writing asn1
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 16:29:39 +01:00
Tom Cosgrove
3d2d599d3e
Merge pull request #7996 from gilles-peskine-arm/small_primes-gaps
...
Reduce the size of the small primes table used by primality testing
2023-08-22 12:48:56 +00:00
Agathiyan Bragadeesh
ba386ec23e
Remove magic number for null tag
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
12b9d7040e
Remove x509_oid_from_numericoid
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
fb94702762
Add catch for alloc error x509_oid_from_numericoid
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
4294ccc608
Use mbedtls_calloc instead of calloc
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
55d93192b1
Fix oid memory leak
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
f826d1113e
Reject null bytes in DER encoded values in DNs
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
eb55867520
Fix code style
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
9caaa6d967
Reject escaped null hexpairs in DNs
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
957ca0595d
Accept short name/ber encoded data in DNs
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
17984874af
Change error from unknown oid to invalid name
...
Since the implementation no longer needs to know the oid, it makes more
sense for the error message to be an invalid name.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
f88bd5ac86
Accept any valid oid in string_to_names
...
Instead of using x509_attrs, use generic oid conversion.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
af70c7dce7
Write numeric oid directly to buffer
...
mbedtls_oid_get_numeric_string now points to output buffer in dn_gets
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
a7f9630925
Remove duplicate '+' in comparison string
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
5adffb2488
Refactor dn_gets use library function to write tag
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
2bf09a61a3
Fix style on left shift operations
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
e18a1789fd
Use MBEDTLS_X509_MAX_DN_NAME_SIZE for buffer size
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
ee642d93a8
Format preprocessor conditionals
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
ed88eefe8e
Rename in_tag to in_attr_type
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
97178f231f
Fix code style in mbedtls_x509_string_to_names
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
7f639fc7ab
Fix Windows x64 build errors with type conversions
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
39ba121d3a
Fix memory leak in alternative code route
...
If no oid is found, and x509_attr_descr_from_numericoid returns NULL,
previously the memory allocated for the oid wasn't freed.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
f818e01edb
FIx memory leak in x509_attr_descr_from_numericoid;
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
a1f5c2d06f
Move declaration of variables in dn_gets to top
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
0a4b6d88d0
Alter conditions on hexstring output dn_gets
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
4987c8fcb0
Fix code style on x509.c and x509_create.c
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
c9d74f3109
Refactor AttributeType in mbedtls_x509_dn_gets
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
0eb6673a80
Add preprocessor config guards
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
6cbfae591a
Parse DER tag mbedtls_x509_string_to_names
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
ddc720d209
Add mbedtls_x509_dn_gets hexstring output
...
If the data is a bitstring or an octet string, instead use the hexstring
of the BER encoding (RFC 4514 Section 2.4)
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
b73778d8f9
Implement parse_attribute_value_ber_encoded
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
e119f3c0ea
Refactor mbedtls_x509_string_to_names
...
This refactor is to accomodate future support of numericoid/hexstring
attributetype value pairs.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
f0e1ac59d8
Rewrite nibble_to_hex_digit for readability
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
9d2507c81d
Rename x509_int_to_hexdigit to nibble_to_hex_digit
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
ef2decbe4a
Escape hexpairs characters RFC 4514
...
Converts none ascii to escaped hexpairs in mbedtls_x509_dn_gets and
interprets hexpairs in mbedtls_x509_string_to_names.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:38:16 +01:00
Agathiyan Bragadeesh
48513b8639
Escape special characters RFC 4514
...
This escapes special characters according to RFC 4514 in
mbedtls_x509_dn_gets and de-escapes in mbedtls_x509_string_to_names.
This commit does not handle hexpairs.
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:38:16 +01:00
Gilles Peskine
30b0378008
Fix off-by-one error
...
The value of p after adding the last entry in the gap table is not used.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 11:06:47 +02:00
Dave Rodgman
e20d688463
Fix missing operand modifier
...
Co-authored-by: Yanray Wang <yanray.wang@arm.com>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-22 08:46:18 +01:00
Dave Rodgman
0c99a9083e
Avoid signed right shift UB
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-21 17:06:24 +01:00
Tom Cosgrove
31b2d7414d
Merge pull request #8053 from gilles-peskine-arm/mpi_exp_mod-remove_initial_copy
...
mbedtls_mpi_exp_mod: remove spurious copy of the output variable
2023-08-21 15:50:28 +00:00
Gilles Peskine
0addbe6dc7
Merge pull request #8069 from paul-elliott-arm/fix_ecjpake_deadcode
...
Fix logical dead code found by Coverity
2023-08-21 14:44:36 +00:00
Dave Rodgman
65204f8fc8
Merge pull request #8035 from daverodgman/aesce-support-perf
...
Make mbedtls_aesce_has_support more efficient
2023-08-21 14:39:08 +00:00
Tom Cosgrove
d29648026b
Merge pull request #8017 from ivq/unchecked_return
...
Fix a few unchecked return values
2023-08-21 13:02:53 +00:00
Janos Follath
e220d258fd
Merge pull request #8086 from yanesca/remove-new-bignum
...
Remove new bignum when not needed
2023-08-21 10:59:41 +00:00
Dave Rodgman
0ce0fbc32a
Simplify aarch64 asm for mbedtls_ct_uint_lt
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-21 07:58:50 +01:00
Dave Rodgman
3ab114e3da
Move non-function-specific macro outside of function definition
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-21 07:54:11 +01:00
Gilles Peskine
ead1766b5f
Fix PBKDF2 with empty salt segment on platforms where malloc(0)=NULL
...
"Fix PBKDF2 with empty salt on platforms where malloc(0)=NULL" took care of
making an empty salt work. But it didn't fix the case of an empty salt
segment followed by a non-empty salt segment, which still invoked memcpy
with a potentially null pointer as the source. This commit fixes that case,
and also simplifies the logic in the function a little.
Test data obtained with:
```
pip3 install cryptodome
python3 -c 'import sys; from Crypto.Hash import SHA256; from Crypto.Protocol.KDF import PBKDF2; cost = int(sys.argv[1], 0); salt = bytes.fromhex(sys.argv[2]); password = bytes.fromhex(sys.argv[3]); n = int(sys.argv[4], 0); print(PBKDF2(password=password, salt=salt, dkLen=n, count=cost, hmac_hash_module=SHA256).hex())' 1 "" "706173737764" 64
```
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-20 22:05:16 +02:00
Dave Rodgman
f2249ec905
Rename mbedtls_aesce_has_support macro to satisfy case rules
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-20 20:20:12 +01:00
Dave Rodgman
b30adce7fd
Use -1 as uninitialised marker
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-20 20:20:12 +01:00
Dave Rodgman
4566132163
Make mbedtls_aesce_has_support more efficient
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-20 20:20:12 +01:00
Dave Rodgman
1fdc884ed8
Merge pull request #7384 from yuhaoth/pr/add-aes-accelerator-only-mode
...
AES: Add accelerator only mode
2023-08-18 20:55:44 +00:00
David Horstmann
cfae6a1ae9
Fix incorrect detection of HardwareModuleName
...
The hardware module name otherName SAN contains 2 OIDs:
OtherName ::= SEQUENCE {
type-id OBJECT IDENTIFIER,
value [0] EXPLICIT ANY DEFINED BY type-id }
HardwareModuleName ::= SEQUENCE {
hwType OBJECT IDENTIFIER,
hwSerialNum OCTET STRING }
The first, type-id, is the one that identifies the otherName as a
HardwareModuleName. The second, hwType, identifies the type of hardware.
This change fixes 2 issues:
1. We were erroneously trying to identify HardwareModuleNames by looking
at hwType, not type-id.
2. We accidentally inverted the check so that we were checking that
hwType did NOT match HardwareModuleName.
This fix ensures that type-id is correctly checked to make sure that it
matches the OID for HardwareModuleName.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-18 19:31:39 +01:00
David Horstmann
2ea44d28de
Fix: Set type_id in x509_get_other_name()
...
When parsing a subject alternative name of type otherName, retain the
type-id field of the otherName. Previously this was not copied to the
mbedtls_x509_san_other_name struct when it should have been.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-18 18:36:02 +01:00
Jerry Yu
0a6272d6c9
revert padlock from aesni module
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-18 17:35:59 +08:00
Jerry Yu
61fc5ed5f3
improve readability of error message
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-18 17:28:48 +08:00
Jerry Yu
372f7a04d0
Add missing check
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-18 17:26:25 +08:00
Gilles Peskine
eeaad50cd6
Merge pull request #8079 from adeaarm/port_IAR_build_fix
...
Small fixes for IAR support
2023-08-17 19:10:51 +00:00
Gilles Peskine
73936868b8
Merge remote-tracking branch 'development' into psa_crypto_config-in-full
...
Conflicts:
* tests/scripts/all.sh: component_test_crypto_full_no_cipher was removed
in the development branch.
2023-08-17 19:46:34 +02:00
Antonio de Angelis
8e9d6b927e
Remove the workaround for psa_key_agreement_internal
...
Remove the workaround for psa_key_agreement_internal to
have a shared_secret array always non-zero. The spec is
recently updated so that PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE
is always non-zero
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-17 15:27:56 +01:00
Janos Follath
f2334b7b39
Remove new bignum when not needed
...
New bignum modules are only needed when the new ecp_curves module is
present. Remove them when they are not needed to save code size.
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-08-17 14:36:59 +01:00
Gilles Peskine
294be94922
Merge pull request #7818 from silabs-Kusumit/PBKDF2_cmac_implementation
...
PBKDF2 CMAC implementation
2023-08-17 11:15:16 +00:00
Jerry Yu
9608447545
replace padlock_c with padlock_have_code
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 18:10:45 +08:00
Jerry Yu
3a0f044bde
improve readability
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 17:06:21 +08:00
Agathiyan Bragadeesh
9ebfa7f64c
Fix style
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-17 10:00:45 +01:00
Jerry Yu
e9c6b53e74
remove return-type when runtime detection enabled without plain c
...
This case does not exist
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 13:53:38 +08:00
Jerry Yu
1b4c7eda80
add hardware only check for padlock
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 11:25:17 +08:00
Jerry Yu
9e628621b4
Add via padlock detection macro
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 11:20:09 +08:00
Jerry Yu
2319af0d64
Change the order of runtime detection
...
If aesni is available, we will use it.
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 10:38:57 +08:00
Jerry Yu
35b59d7805
exclude arm64ec mode for aesni
...
AESNI does not work correctly for msvc arm64ec
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 10:34:15 +08:00
Dave Rodgman
f4efd19dd0
Reduce code size in ccm
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-16 22:37:32 +01:00
Dave Rodgman
509b567911
add ifdefs to reduce size of mbedtls_to_psa_error
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-16 22:37:29 +01:00
Dave Rodgman
6f6820345a
add #ifdefs to reduce switch size
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-16 18:44:32 +01:00
Dave Rodgman
864f594acc
Adjust layout of some stucts
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-16 18:04:44 +01:00
Dave Rodgman
164614af3d
Reduce code-size to access key slots init flag
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-16 17:56:28 +01:00
Dave Rodgman
58c8b942d2
Eliminate redundant version of mbedtls_ct_memcmp
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-16 17:51:04 +01:00
Dave Rodgman
6a9fb932fb
Use MBEDTLS_GET_UINT16_BE in mbedtls_ecp_tls_read_group_id
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-16 17:50:36 +01:00
Agathiyan Bragadeesh
285f85f962
Remove unnecessary const type qualifiers in casts
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-16 17:15:48 +01:00
Antonio de Angelis
f1adc2a7a1
Use asm instead of __asm in constant_time.c
...
The original IAR fix submitted to TF-M directly changed asm to __asm.
But mbed TLS now has a workaround for such cases hence just remove the
original change modification.
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-16 12:48:48 +01:00
Antonio de Angelis
1ee4d1228c
Fix error strings without quotes
...
Some of the error strings that should be printed with the
error preprocessor directive are missing quotes
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-16 12:48:33 +01:00
TTornblom
e4f6d79bbe
BUILD: Update For IAR support
...
Applied the same change as in mbed-crypto for using this as a sub
project with the IAR toolchain. Use __asm generic ,and avoid empty
enum. Avoid declaration of array with null size. This is a porting
of the original patch contributed to trusted-firmware-m.
Signed-off-by: TTornblom <thomas.tornblom@iar.com>
Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-16 12:36:21 +01:00
Jerry Yu
516cf27d45
fix msvc build fail on i386 target
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-16 17:33:32 +08:00
Gilles Peskine
a4c01dd6e9
Merge pull request #7991 from sarveshb14/fix/psa_rsa_signature_using_large_stack
...
rsa_signature: Use heap memory to allocate DER encoded RSA private key
2023-08-16 09:23:29 +00:00
Jerry Yu
3ce0398d1d
Add compiler cflags error message
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-16 17:22:18 +08:00
Gilles Peskine
d370f93898
Merge pull request #7898 from AndrzejKurek/csr-rfc822-dn
...
OPC UA - add support for RFC822 and DirectoryName SubjectAltNames when generating CSR's
2023-08-16 09:19:46 +00:00
Jerry Yu
c628486cd9
enable runtime detection when padlock enabled and plain c disabled
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-16 16:14:02 +08:00
Jerry Yu
cc068ae631
fix -Werror=return-type
when runtime detection enabled and plain c disabled
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-16 16:14:01 +08:00
Jerry Yu
e62ff09569
Restore aesni for i386
...
intrinsic code can be work on i386 also
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-16 14:33:16 +08:00
David Horstmann
ba44e918b8
Remove unnecessary include from constant_time.c
...
This was added in order to use TEST_CF_XYZ macros which have since been
removed.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-15 15:17:22 +01:00
Dave Rodgman
e3330f86d2
Make naming more consistent
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-14 15:26:28 +01:00
Dave Rodgman
0b7bf876e4
Fix compile fail for empty enum in cipher_wrap
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-14 14:25:29 +01:00
Dave Rodgman
2f4e6e748c
Merge pull request #8066 from paul-elliott-arm/aes_memcpy_iv_fix
...
Fix potential corruption of IV for AES CBC with zero length
2023-08-14 09:32:45 +01:00
Paul Elliott
2a12fc20f2
Fix logical dead code found by Coverity
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-08-11 17:45:20 +01:00
Paul Elliott
2ad93674dc
Fix potential corruption of IV for AES CBC
...
If passed a zero length, AES CBC could potentially corrupt the passed
in IV by memcpying it over itself. Although this might be ok with
more recent compilers, its not for every compiler we support. Found
by coverity.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-08-11 17:04:06 +01:00
Paul Elliott
ecb95bea1d
Fix incorrect size used for zeroization of buffer
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-08-11 16:41:04 +01:00
Chien Wong
2e3858f5eb
Undo a change
...
Signed-off-by: Chien Wong <m@xv97.com>
2023-08-11 18:16:06 +08:00
Dave Rodgman
42391b4378
Perf improvement in memcpy_if
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-11 08:47:38 +01:00
Dave Rodgman
246210e3c4
Test CT asm under valgrind
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-11 08:47:38 +01:00
Dave Rodgman
822c9c7d4e
Fix unified asm syntax issue
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-11 08:47:38 +01:00
Dave Rodgman
ef2527901e
Add aarch32 const-time asm
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-11 08:47:38 +01:00
Dave Rodgman
c9ed5dee69
Add aarch64 const-time asm
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-11 08:47:38 +01:00
Valerio Setti
711f853b48
ssl_tls13: fix guard for FFDH function
...
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-08-11 06:33:52 +02:00
Jerry Yu
240bb11171
Add gnu check for aseni assembly code
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-11 10:45:35 +08:00
Manuel Pégourié-Gonnard
54da1a69a2
Merge pull request #7578 from daverodgman/safer-ct5
...
Improve constant-time interface
2023-08-10 16:57:39 +00:00
Gilles Peskine
e6cb45e68e
mbedtls_mpi_exp_mod: remove spurious copy of the output variable
...
Clear some confusion between `X` as the output variable and "X" as a name
given to the accumulator. Previous iterations of the code used the variable
`X` as the accumulator, but now that the accumulator is `W[x_index]`, some
of the comments didn't make sense.
Remove the copy of the initial value of `X` into `W[x_index]`, which was
meaningless: the initial value of an output variable should not, and did
not, matter. `W[x_index]` is later overridden unconditionally to take the
value `RR`.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-10 15:59:28 +02:00
Dave Rodgman
48fb8a3448
Fix some renames that were missed
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-10 14:01:51 +01:00
Dave Rodgman
b364a22adf
Fix mbedtls_ct_size_if_else_0 docs
...
Co-authored-by: Tom Cosgrove <tom.cosgrove@arm.com>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-10 12:25:25 +01:00
Dave Rodgman
38b227c16b
Improve docs
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-10 12:18:27 +01:00
Dave Rodgman
ac69b45486
Document and test mbedtls_ct_size_if_else_0
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-10 12:18:13 +01:00
Dave Rodgman
065f912465
Fix comment typo
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-10 12:11:58 +01:00
Dave Rodgman
98ddc01a7c
Rename ...if0 to ...else_0
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-10 12:11:31 +01:00
Dave Rodgman
b7825ceb3e
Rename uint->bool operators to reflect input types
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-10 11:58:18 +01:00
Gilles Peskine
b2bc1712a5
Reduce the size of the small primes table used by primality testing
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-10 12:16:02 +02:00
Manuel Pégourié-Gonnard
6beec7ca5e
Merge pull request #7989 from valeriosetti/issue7754
...
driver-only ECC: BN.PK testing
2023-08-10 09:43:56 +00:00
Manuel Pégourié-Gonnard
d170419eab
Merge pull request #7999 from valeriosetti/issue7759
...
Driver-only ECC: TLS: rm uses of mbedtls_debug_print_mpi
2023-08-10 08:34:57 +00:00
Manuel Pégourié-Gonnard
91c8372c01
Merge pull request #6999 from ivq/ecp_doc
...
Doc: Add note on special use of A in ecp group structure
2023-08-10 08:24:05 +00:00
Dave Rodgman
e5fbd93eaf
Merge pull request #8049 from daverodgman/bignum_codesize_misc
...
Bignum codesize misc
2023-08-10 10:58:13 +01:00
Jerry Yu
8189f32945
improve aesni check for x86_64
...
`MBEDTLS_AESNI_C` does not depends on `MBEDTLS_HAVE_ASM`
when intrinsic is available.
And compiler relative checks only work on x86_64, it should
be only checked on x86_64.
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-10 15:17:45 +08:00
Valerio Setti
e1d7c9dabd
pkwrite: fix internal buffer size in pk_write_ec_pubkey()
...
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-08-10 07:40:18 +02:00
Jerry Yu
13696bb07b
improve check config option for i386
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-10 13:36:32 +08:00
Jerry Yu
ba42b076f9
Remove asm check for aarch64 aesce
...
we implement it with aesce intrinsic. No asm needed.
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-10 12:53:26 +08:00
Valerio Setti
a7c9e09dd0
pkwrite: add new internal symbol to properly size DER buffer
...
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-08-10 06:43:23 +02:00
Valerio Setti
97b28f81d8
pkparse: remove unnecessary header
...
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-08-10 06:43:23 +02:00
Manuel Pégourié-Gonnard
7dccb66d49
test: disable RSA support on the test ecc_no_bignum component
...
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-08-10 06:43:23 +02:00
Valerio Setti
ca4c15dd25
debug: remove redundant variable assignments
...
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-08-10 06:41:31 +02:00
Dave Rodgman
960eca997d
code style
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-09 20:43:18 +01:00
Dave Rodgman
4883f109a0
Reduce code size for exp_mod_get_window_size
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-09 20:42:54 +01:00
Dave Rodgman
ebcd78561c
Remove redundant code in mbedtls_mpi_cmp_abs
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-09 18:57:22 +01:00
Dave Rodgman
fa703e38a2
Use __builtin_ctz to count trailing zeros
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-09 18:56:07 +01:00
Dave Rodgman
f3df105b37
Generate smaller code for picking a sign value
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-09 18:55:41 +01:00
Paul Elliott
2f12a29cdd
Merge pull request #7896 from AgathiyanB/gitignore-generated-files-toggle
...
Add script to toggle ignoring generated files
2023-08-09 14:54:32 +00:00
Jerry Yu
c4508c07f6
improve error message and config check for padlock
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-08 12:57:06 +08:00
Gilles Peskine
444d1e7608
Merge pull request #8036 from tom-cosgrove-arm/fix-rijndael-and-drbg-pdf-links
...
Update links to Rijndael paper and NIST SP 800-90 DRBGs
2023-08-07 19:15:58 +00:00
Gilles Peskine
a79256472c
Merge pull request #7788 from marekjansta/fix-x509-ec-algorithm-identifier
...
Fixed x509 certificate generation to conform to RFCs when using ECC key
2023-08-07 19:14:54 +00:00
Chien Wong
153ae464db
Improve doc on special use of A in ecp group structure
...
Signed-off-by: Chien Wong <m@xv97.com>
2023-08-07 23:02:31 +08:00
Dave Rodgman
c98f8d996a
Merge branch 'development' into safer-ct5
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-07 11:47:35 +01:00
Jerry Yu
5fcdd6a28a
remove unnecessary definition
...
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-07 15:32:58 +08:00
Tom Cosgrove
ce37c5e1ce
Update links to Rijndael paper and NIST SP 800-90 DRBGs
...
The link to the DRBG paper points to the March 2007 version, the same as the
original link (rather than the latest version).
The amended Rijndael paper has a two-page "Note on naming" prefix.
Fixes #7193
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-08-04 13:55:03 +01:00