path: root/lib/rsa
diff options
authorRuchika Gupta <>2015-01-23 16:01:54 +0530
committerSimon Glass <>2015-01-29 17:09:58 -0700
commitc937ff6dc2ee3fcd8f97087427fe8ba5086852c4 (patch)
tree89b3ea84175cb9b3ed225aed222cd3ac3a15217f /lib/rsa
parent11a9662ba9ed40829fd10acb3a0c75d148159921 (diff)
lib/rsa: Modify rsa to use DM driver
Modify rsa_verify to use the rsa driver of DM library .The tools will continue to use the same RSA sw library. CONFIG_RSA is now dependent on CONFIG_DM. All configurations which enable FIT based signatures have been modified to enable CONFIG_DM by default. Signed-off-by: Ruchika Gupta <> CC: Simon Glass <> Acked-by: Simon Glass <>
Diffstat (limited to 'lib/rsa')
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index f8bc086fd7..da45daffd3 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -12,6 +12,7 @@
#include <asm/errno.h>
#include <asm/types.h>
#include <asm/unaligned.h>
+#include <dm.h>
#include "fdt_host.h"
#include "mkimage.h"
@@ -43,6 +44,9 @@ static int rsa_verify_key(struct key_prop *prop, const uint8_t *sig,
const uint8_t *padding;
int pad_len;
int ret;
+#if !defined(USE_HOSTCC)
+ struct udevice *mod_exp_dev;
if (!prop || !sig || !hash || !algo)
return -EIO;
@@ -63,7 +67,17 @@ static int rsa_verify_key(struct key_prop *prop, const uint8_t *sig,
uint8_t buf[sig_len];
+#if !defined(USE_HOSTCC)
+ ret = uclass_get_device(UCLASS_MOD_EXP, 0, &mod_exp_dev);
+ if (ret) {
+ printf("RSA: Can't find Modular Exp implementation\n");
+ return -EINVAL;
+ }
+ ret = rsa_mod_exp(mod_exp_dev, sig, sig_len, prop, buf);
ret = rsa_mod_exp_sw(sig, sig_len, prop, buf);
if (ret) {
debug("Error in Modular exponentation\n");
return ret;
OpenPOWER on IntegriCloud