mbedtls/include/mbedtls
Gilles Peskine baccfef741 mbedtls_ssl_handshake_params: reorder fields to save code size
Reorder fields mbedtls_ssl_handshake_params in order to save code on Arm
Thumb builds. The general idea is to put often-used fields in the direct
access window of 128 elements from the beginning of the structure.

The reordering is a human selection based on a report of field offset and
use counts, and informed by measuring the code size with various
arrangements. Some notes:
* I moved most byte-sized fields at the beginning where they're sure to be
  in the direct access window.
* I moved buffering earlier because it can be around the threshold depending
  on the configuration, and it's accessed in a lot of places.
* I moved several fields, including update_checksum and friends, early so
  that they're guaranteed to be in the early access window.
* I tried moving randbytes or premaster to the early access window, but
  I couldn't find a placement which would save code size, presumably because
  they're bumping too many other fields, and they're mostly accessed through
  memcpy and friends which translates to instructions that don't have an
  offset for free anyway.

Results (arm-none-eabi-gcc 7.3.1, build_arm_none_eabi_gcc_m0plus build):
library/ssl_cli.o: 20200 -> 20104 (diff: 96)
library/ssl_msg.o: 25978 -> 25942 (diff: 36)
library/ssl_srv.o: 22691 -> 22467 (diff: 224)
library/ssl_tls.o: 23570 -> 23390 (diff: 180)

Results (same architecture, config-suite-b.h + MBEDTLS_ECDH_LEGACY_CONTEXT +
MBEDTLS_ECP_RESTARTABLE):
library/ssl_cli.o: 3012 -> 2928 (diff: 84)
library/ssl_msg.o: 2932 -> 2924 (diff: 8)
library/ssl_srv.o: 3288 -> 3232 (diff: 56)
library/ssl_tls.o: 6032 -> 5904 (diff: 128)

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-11-16 17:44:31 +01:00
..
aes.h Change DES and AES functions to MBEDTLS_CHECK_RETURN_TYPICAL 2021-09-29 20:40:45 +02:00
aesni.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
arc4.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
aria.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
asn1.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
asn1write.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
base64.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
bignum.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
blowfish.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
bn_mul.h Fix aarch64 assembly for bignum multiplication 2021-09-24 09:47:01 +01:00
camellia.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
ccm.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
certs.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
chacha20.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
chachapoly.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
check_config.h Remove the duplicate code in mbedtls/include/mbedtls/check_config.h 2021-08-03 09:36:15 +02:00
cipher.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
cipher_internal.h psa: Move from key handle to key identifier 2020-11-10 16:00:41 +01:00
cmac.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
compat-1.3.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
config.h Merge pull request #4845 from mstarzyk-mobica/ecb-alt-ret-2.2x 2021-10-14 12:11:04 +02:00
config_psa.h Merge pull request #5117 from gilles-peskine-arm/psa-rsa-pss_any_salt-2.x 2021-10-29 16:36:46 +02:00
ctr_drbg.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
debug.h use proper formatting macros when using MinGW provided stdio 2021-05-12 08:50:36 -04:00
des.h Change DES and AES functions to MBEDTLS_CHECK_RETURN_TYPICAL 2021-09-29 20:40:45 +02:00
dhm.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
ecdh.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ecdsa.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ecjpake.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ecp.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
ecp_internal.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
entropy.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
entropy_poll.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
error.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
gcm.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
havege.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
hkdf.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
hmac_drbg.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
md.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
md2.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
md4.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
md5.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
md_internal.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
memory_buffer_alloc.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
net.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
net_sockets.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
nist_kw.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
oid.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
padlock.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
pem.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
pk.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
pk_internal.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
pkcs5.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
pkcs11.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
pkcs12.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
platform.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
platform_time.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
platform_util.h Fix typo in comment 2021-09-30 20:34:29 +02:00
poly1305.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
psa_util.h Address review comments 2021-09-30 12:29:27 +02:00
ripemd160.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
rsa.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
rsa_internal.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
sha1.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
sha256.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
sha512.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
ssl.h Document that returning 0 from the recv callback means EOF 2021-08-16 13:00:06 +02:00
ssl_cache.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ssl_ciphersuites.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ssl_cookie.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ssl_internal.h mbedtls_ssl_handshake_params: reorder fields to save code size 2021-11-16 17:44:31 +01:00
ssl_ticket.h Fix typos in C header files 2021-05-12 10:39:58 +02:00
threading.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
timing.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
version.h Bump Library Version Number 2021-07-01 17:52:07 +01:00
x509.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00
x509_crl.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
x509_crt.h Document more precisely what goes into the default profile 2021-06-07 21:24:26 +02:00
x509_csr.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
xtea.h Move MBEDTLS_ERR_xxx Doxygen comments before the definition 2021-08-02 22:57:46 +02:00