sec_hrid.c 728 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "typedefs.h"
  2. #include "sec_hrid.h"
  3. #include "sec_devinfo.h"
  4. u32 get_hrid_size(void)
  5. {
  6. return HRID_SIZE;
  7. }
  8. u32 get_hrid(unsigned char *rid, unsigned char *rid_sz)
  9. {
  10. u32 ret = E_SUCCESS;
  11. u32 i, j;
  12. if (rid_sz == NULL) {
  13. return E_BUF_SIZE_ZERO_OR_NULL;
  14. }
  15. if (rid == NULL) {
  16. return E_BUF_ZERO_OR_NULL;
  17. }
  18. if (*rid_sz < (HRID_SIZE * 4)) {
  19. return E_BUF_NOT_ENOUGH;
  20. }
  21. for (i = 0; i < HRID_SIZE; i++) {
  22. u32 reg_val = 0;
  23. reg_val = seclib_get_devinfo_with_index(12 + i);
  24. for (j = 0; j < 4; j++) {
  25. *(rid + i * 4 + j) = (reg_val & (0xff << (8 * j))) >> (8 * j);
  26. }
  27. }
  28. *rid_sz = HRID_SIZE * 4;
  29. return ret;
  30. }