ta_playready.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef __TRUSTZONE_TA_PLAYREADY__
  2. #define __TRUSTZONE_TA_PLAYREADY__
  3. #define TZ_TA_PLAYREADY_UUID "b25bf100-d276-11e2-8b8b-0800200c9a66"
  4. #define PLAYREADY_PROVISIONED_CERT 1
  5. #define PLAYREADY_PROVISIONED_KEY 2
  6. #define PLAYREADY_PROVISIONED_CLEAR_KEY 3 /* for debug */
  7. #define TZ_DRM_UI64EQL 1
  8. #define TZ_DRM_UI64LES 2
  9. #define TZ_TOKEN_TOKEN 1
  10. #define TZ_TOKEN_VALUE 2
  11. #define TZ_VALUE_TOKEN 3
  12. #define SUPPORT_MULTIPLE_INSTANCE 1
  13. #define C_SECONDS_IN_ROLLBACK_GRACE_PERIOD 30
  14. /* Data Structure for Playready TA */
  15. /* You should define data structure used both in REE/TEE here
  16. N/A for Playready TA */
  17. /* Command for Playready TA */
  18. #define TZCMD_PLAYREADY_BASE 0x00000000
  19. #define TZCMD_PLAYREADY_PROVISIONED_DATA_GET 0x00000001
  20. #define TZCMD_PLAYREADY_ECCP256_KEYPAIR_GEN 0x00000002
  21. #define TZCMD_PLAYREADY_ECCP256_KEY_SET 0x00000003
  22. #define TZCMD_PLAYREADY_ECDSAP256_SIGN 0x00000004
  23. #define TZCMD_PLAYREADY_ECCP256_DECRYPT 0x00000005
  24. #define TZCMD_PLAYREADY_OMAC1_KEY_SET 0x00000006
  25. #define TZCMD_PLAYREADY_OMAC1_VERIFY 0x00000007
  26. #define TZCMD_PLAYREADY_OMAC1_SIGN 0x00000008
  27. #define TZCMD_PLAYREADY_COPYBYTE 0x00000009
  28. #define TZCMD_PLAYREADY_CONTENTKEY_AESCTR_SET 0x0000000a
  29. #define TZCMD_PLAYREADY_CONTENT_AESCTR_DECRYPT 0x0000000b
  30. #define TZCMD_PLAYREADY_AESECB_KEY_SET 0x0000000c
  31. #define TZCMD_PLAYREADY_AESECB_ENCRYPT 0x0000000d
  32. #define TZCMD_PLAYREADY_AESECB_DECRYPT 0x0000000e
  33. #define TZCMD_PLAYREADY_GET_KFKEY 0x0000000f
  34. #define TZCMD_PLAYREADY_AESCBC_KEY_SET 0x00000010
  35. #define TZCMD_PLAYREADY_AESCBC_ENCRYPT 0x00000011
  36. #define TZCMD_PLAYREADY_AESCBC_DECRYPT 0x00000012
  37. #define TZCMD_PLAYREADY_HANDLE_CONTENT_AESCTR_DECRYPT 0x00000013
  38. #define TZCMD_PLAYREADY_KEYFILE_DECRYPT 0x00000014
  39. #define TZCMD_PLAYREADY_KEYFILE_ENCRYPT 0x00000015
  40. #define TZCMD_PLAYREADY_TOKENTIME_COMPARE 0x00000016
  41. #define TZCMD_PLAYREADY_TOKENTIME_UPDATE 0x00000017
  42. #define TZCMD_PLAYREADY_MACHINEDATETIME_CHECK 0x00000019
  43. #define TZCMD_PLAYREADY_GET_HWID 0x00000020
  44. /* SUPPORT_PLAYREADY_SECURE_CLOCK*/
  45. #define TZ_SECURETIME_BIRTHDATE 1392967151
  46. /* used for getting encrypted prtime struct to save file when shutdown and
  47. suspend or after THREAD_SAVEFILE_VALUE second*/
  48. #define TZCMD_PLAYREADY_GET_CURRENT_COUNTER 0x00000030
  49. /* used for set new playready time using the current rtc counter and
  50. encrypted saved prtime struct when resume and bootup*/
  51. #define TZCMD_PLAYREADY_SET_CURRENT_COUNTER 0x00000031
  52. /* used for increase current counter at least PR_TIME_INC_COUNTER secs
  53. and no more than PR_TIME_MAX_COUNTER_OFFSET secs*/
  54. #define TZCMD_PLAYREADY_INC_CURRENT_COUNTER 0x00000032
  55. /* used for network time-sync module to sync pr_time*/
  56. #define TZCMD_PLAYREADY_SET_CURRENT_PRTIME 0x00000033
  57. #define PR_TIME_INC_COUNTER 10
  58. #define PR_TIME_MAX_COUNTER_OFFSET 15
  59. #define PR_TIME_FILE_BASE 50000
  60. #define PR_TIME_FILE_ERROR_SIGN (PR_TIME_FILE_BASE + 1)
  61. #define PR_TIME_FILE_OK_SIGN (PR_TIME_FILE_BASE + 2)
  62. #define NO_SECURETD_FILE (PR_TIME_FILE_BASE + 3)
  63. #define PR_TIME_ERROR_SETPRTIME (PR_TIME_FILE_BASE + 4)
  64. struct TZ_JG_SECURECLOCK_INFO {
  65. unsigned long long hwcounter;
  66. unsigned long long pr_time;
  67. char signature[8];
  68. };
  69. struct TM_PR {
  70. int tm_sec; /* seconds */
  71. int tm_min; /* minutes */
  72. int tm_hour; /* hours */
  73. int tm_mday; /* day of the month */
  74. int tm_mon; /* month */
  75. int tm_year; /* year */
  76. int tm_wday; /* day of the week */
  77. int tm_yday; /* day in the year */
  78. int tm_isdst; /* daylight saving time */
  79. long int tm_gmtoff; /* Seconds east of UTC. */
  80. const char *tm_zone; /* Timezone abbreviation. */
  81. };
  82. /*end of SUPPORT_PLAYREADY_SECURE_CLOCK*/
  83. struct PLAYREADY_IVDATA {
  84. unsigned long long qwInitializationVector;
  85. unsigned long long qwBlockOffset;
  86. unsigned long bByteOffset;
  87. };
  88. struct TZ_PLAYREADY_ENCINFO {
  89. char role[100];
  90. /*total enc buffer size */
  91. unsigned int dataSize;
  92. /* trunk number */
  93. unsigned int segNum;
  94. /* IV data for each trunk */
  95. struct PLAYREADY_IVDATA iv[10];
  96. /* pointer to an integer array, each element describe clear data size*/
  97. unsigned int offset[10];
  98. /* pointer to an integer array, each element describe enc data size */
  99. unsigned int length[10];
  100. /* true : dstData is a handle; false : dstData is a buffer; */
  101. unsigned int dstHandle;
  102. };
  103. #ifdef SUPPORT_MULTIPLE_INSTANCE
  104. #define DRM_AES_KEYSIZE_128 (16) /* Size ( in bytes ) of a 128 bit key */
  105. /* Now at least two or more process will use ta_playready.c at same time,
  106. drm server and media server */
  107. #define MAX_AESECB_KEYS_INSTANCE 4
  108. #define MAX_OMAC1_KEYS_INSTANCE 4
  109. struct TZ_PLAYREADY_AESECB_KEYS {
  110. uint32_t handle; /* tee session handle */
  111. char aesecbKey[DRM_AES_KEYSIZE_128];
  112. uint32_t bProtect;
  113. uint32_t bInUse;
  114. };
  115. struct TZ_PLAYREADY_OMAC1_KEYS {
  116. uint32_t handle; /* tee session handle */
  117. char omac1Key[DRM_AES_KEYSIZE_128];
  118. uint32_t bProtect;
  119. uint32_t bInUse;
  120. };
  121. #endif
  122. #endif /* __TRUSTZONE_TA_PLAYREADY__ */