libmbedtls: mbedtls_mpi_exp_mod(): optimize mempool usage

With W allocated in the mempool instead of the stack it is more important
to utilize the mempool in a stack like way.

With this patch allocation and initialization of W is moved to a point
where all following mempool allocations are free before the function

This reduces maximum memory consumption of mempool in regression case
8101 for an AArch64 TA in from 17280 to 7640 bytes. Figures for an
AArch32 TA are 12040 to 5288 bytes.

Reviewed-by: Joakim Bech <>
Signed-off-by: Jens Wiklander <>
1 file changed
tree: 73c81dbd65cebf949a5be00bc14d406489e93fe1
  1. .github/
  2. core/
  3. keys/
  4. lib/
  5. mk/
  6. scripts/
  7. ta/
  8. .gitignore
  9. .shippable.yml
  10. .travis.yml
  14. Makefile
  16. typedefs.checkpatch

OP-TEE Trusted OS

This git contains source code for the secure side implementation of OP-TEE project.

All official OP-TEE documentation has moved to

// OP-TEE core maintainers