summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRuchika Gupta <ruchika.gupta@freescale.com>2015-01-23 16:01:54 +0530
committerSimon Glass <sjg@chromium.org>2015-01-29 17:09:58 -0700
commitc937ff6dc2ee3fcd8f97087427fe8ba5086852c4 (patch)
tree89b3ea84175cb9b3ed225aed222cd3ac3a15217f /lib
parent11a9662ba9ed40829fd10acb3a0c75d148159921 (diff)
downloadu-boot-imx-c937ff6dc2ee3fcd8f97087427fe8ba5086852c4.zip
u-boot-imx-c937ff6dc2ee3fcd8f97087427fe8ba5086852c4.tar.gz
u-boot-imx-c937ff6dc2ee3fcd8f97087427fe8ba5086852c4.tar.bz2
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 <ruchika.gupta@freescale.com> CC: Simon Glass <sjg@chromium.org> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/rsa/rsa-verify.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index f8bc086..da45daf 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>
#else
#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;
+#endif
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);
+#else
ret = rsa_mod_exp_sw(sig, sig_len, prop, buf);
+#endif
if (ret) {
debug("Error in Modular exponentation\n");
return ret;