pem_to_pub_c.py: Add sanity check for public exponent of TA signing key

This change fixes a potential security vulnerability.

The public exponent of the TA signing key is stored by OP-TEE OS as an
unsigned 32-bit integer. While rarely seen in the wild, public exponents
that overflow this storage field exist. Although the C compiler usually
generates an overflow warning when such an exponent would be set, this
happens only once after the key was changed and is easily overlooked.
With this change the script throws an exception, notifying the user of the
unsuitable key.

Without the sanity check, such an unsuitable key would simply lead to
TA signature verification failures. However, if the public exponent e
is close to a multiple of 2^32, a small exponent attack to forge a
signature might be feasible.

Signed-off-by: Markus S. Wamser <markus.wamser@mixed-mode.de>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
[jf: add file name to commit subject]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
1 file changed
tree: af94a1cb5333978dcf57185574fbb6c5d829568c
  1. .github/
  2. core/
  3. keys/
  4. lib/
  5. mk/
  6. scripts/
  7. ta/
  8. .gitignore
  9. .shippable.yml
  10. .travis.yml
  11. CHANGELOG.md
  12. LICENSE
  13. MAINTAINERS
  14. Makefile
  15. README.md
  16. typedefs.checkpatch
README.md

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 http://optee.readthedocs.io.

// OP-TEE core maintainers