
The current rsa_verify() requires five parameters for a RSA public key for efficiency while RSA, in theory, requires only two. In addition, those parameters are expected to come from FIT image.
So this function won't fit very well when we want to use it for the purpose of implementing UEFI secure boot, in particular, image authentication as well as variable authentication, where the essential two parameters are set to be retrieved from one of X509 certificates in signature database.
So, in this patch, additional three parameters will be calculated on the fly when rsa_verify() is called without fdt which should contain parameters above.
This calculation heavily relies on "big-number (or multi-precision) library." Therefore some routines from BearSSL[1] under MIT license are imported in this implementation. See Patch#2. # Please let me know if this is not appropriate.
# Checkpatch will complain with lots of warnings/errors, but # I intentionally don't fix them for maximum maintainability.
AKASHI Takahiro (3): lib: rsa: decouple rsa from FIT image verification lib: rsa: generate additional parameters for public key lib: rsa: add rsa_verify_with_pkey()
include/u-boot/rsa-mod-exp.h | 3 + lib/rsa/Kconfig | 14 + lib/rsa/Makefile | 3 +- lib/rsa/rsa-keyprop.c | 631 +++++++++++++++++++++++++++++++++++ lib/rsa/rsa-verify.c | 63 +++- 5 files changed, 705 insertions(+), 9 deletions(-) create mode 100644 lib/rsa/rsa-keyprop.c