1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * (C) Copyright 2014 Freescale Semiconductor, Inc
4 * Author: Ruchika Gupta <ruchika.gupta@freescale.com>
5 */
6
7 #include <common.h>
8 #include <dm.h>
9 #include <asm/global_data.h>
10 #include <u-boot/rsa-mod-exp.h>
11 #include <errno.h>
12 #include <fdtdec.h>
13 #include <malloc.h>
14 #include <asm/io.h>
15 #include <linux/list.h>
16
17 #if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
18 DECLARE_GLOBAL_DATA_PTR;
19 #endif
20
rsa_mod_exp(struct udevice * dev,const uint8_t * sig,uint32_t sig_len,struct key_prop * node,uint8_t * out)21 int rsa_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
22 struct key_prop *node, uint8_t *out)
23 {
24 struct mod_exp_ops *ops = (struct mod_exp_ops *)device_get_ops(dev);
25
26 #if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
27 static bool done;
28
29 if (!done) {
30 done = true;
31 ops->mod_exp += gd->reloc_off;
32 }
33 #endif
34
35 if (!ops->mod_exp)
36 return -ENOSYS;
37
38 return ops->mod_exp(dev, sig, sig_len, node, out);
39 }
40
41 UCLASS_DRIVER(mod_exp) = {
42 .id = UCLASS_MOD_EXP,
43 .name = "rsa_mod_exp",
44 };
45