csf_tbbr.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright 2018-2021 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. *
  7. */
  8. #include <errno.h>
  9. #include <common/debug.h>
  10. #include <csf_hdr.h>
  11. #include <dcfg.h>
  12. #include <drivers/auth/crypto_mod.h>
  13. #include <snvs.h>
  14. #include <plat/common/platform.h>
  15. #include "plat_common.h"
  16. extern bool rotpk_not_dpld;
  17. extern uint8_t rotpk_hash_table[MAX_KEY_ENTRIES][SHA256_BYTES];
  18. extern uint32_t num_rotpk_hash_entries;
  19. /*
  20. * In case of secure boot, return ptr of rotpk_hash table in key_ptr and
  21. * number of hashes in key_len
  22. */
  23. int plat_get_rotpk_info(void *cookie, void **key_ptr, unsigned int *key_len,
  24. unsigned int *flags)
  25. {
  26. uint32_t mode = 0U;
  27. *flags = ROTPK_NOT_DEPLOYED;
  28. /* ROTPK hash table must be available for secure boot */
  29. if (rotpk_not_dpld == true) {
  30. if (check_boot_mode_secure(&mode) == true) {
  31. /* Production mode, don;t continue further */
  32. if (mode == 1U) {
  33. return -EAUTH;
  34. }
  35. /* For development mode, rotpk flag false
  36. * indicates that SRK hash comparison might
  37. * have failed. This is not fatal error.
  38. * Continue in this case but transition SNVS
  39. * to non-secure state
  40. */
  41. transition_snvs_non_secure();
  42. return 0;
  43. } else {
  44. return 0;
  45. }
  46. }
  47. /*
  48. * We return the complete hash table and number of entries in
  49. * table for NXP platform specific implementation.
  50. * Here hash is always assume as SHA-256
  51. */
  52. *key_ptr = rotpk_hash_table;
  53. *key_len = num_rotpk_hash_entries;
  54. *flags = ROTPK_IS_HASH;
  55. return 0;
  56. }
  57. int plat_get_nv_ctr(void *cookie, unsigned int *nv_ctr)
  58. {
  59. /*
  60. * No support for non-volatile counter. Update the ROT key to protect
  61. * the system against rollback.
  62. */
  63. *nv_ctr = 0U;
  64. return 0;
  65. }
  66. int plat_set_nv_ctr(void *cookie, unsigned int nv_ctr)
  67. {
  68. return 0;
  69. }