mod_exp_uclass.c 935 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #include <common.h>
  7. #include <dm.h>
  8. #include <u-boot/rsa-mod-exp.h>
  9. #include <errno.h>
  10. #include <fdtdec.h>
  11. #include <malloc.h>
  12. #include <asm/io.h>
  13. #include <linux/list.h>
  14. #if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
  15. DECLARE_GLOBAL_DATA_PTR;
  16. #endif
  17. int rsa_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
  18. struct key_prop *node, uint8_t *out)
  19. {
  20. struct mod_exp_ops *ops = (struct mod_exp_ops *)device_get_ops(dev);
  21. #if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
  22. static bool done;
  23. if (!done) {
  24. done = true;
  25. ops->mod_exp += gd->reloc_off;
  26. }
  27. #endif
  28. if (!ops->mod_exp)
  29. return -ENOSYS;
  30. return ops->mod_exp(dev, sig, sig_len, node, out);
  31. }
  32. UCLASS_DRIVER(mod_exp) = {
  33. .id = UCLASS_MOD_EXP,
  34. .name = "rsa_mod_exp",
  35. };