protected_output_certificates.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * Copyright (C) 2011-2017 Intel Corporation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in
  12. * the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Intel Corporation nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. */
  31. #ifndef _PROTECTED_OUTPUT_CERTIFICATES_H
  32. #define _PROTECTED_OUTPUT_CERTIFICATES_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #pragma pack(push)
  37. #pragma pack(1)
  38. /*
  39. * EC-DSA keys and signatures lengths
  40. */
  41. #define ECDSA_PRIVKEY_LEN 32
  42. #define ECDSA_PUBKEY_LEN 64
  43. #define ECDSA_SECKEY_LEN 32
  44. #define ECDSA_SIGNATURE_LEN 64
  45. /* Data structures */
  46. // EC-DSA Private Key
  47. typedef unsigned char EcDsaPrivKey[ECDSA_PRIVKEY_LEN];
  48. // EC-DSA Public Key
  49. typedef unsigned char EcDsaPubKey[ECDSA_PUBKEY_LEN];
  50. // EC-DSA Session Key
  51. typedef unsigned char EcDsaSecKey[ECDSA_SECKEY_LEN];
  52. // EC-DSA Signature
  53. typedef unsigned char EcDsaSig[ECDSA_SIGNATURE_LEN];
  54. /*
  55. * 3rd Party Certificate
  56. */
  57. // Type of the certificate: PROTECTED_OUTPUT
  58. #define PUBCERT3P_TYPE_PROTECTED_OUTPUT 0x00000000
  59. #define PUBCERT3P_TYPE_MV_SRV 0x00000001
  60. #define PUBCERT3P_TYPE_RESERVED 0x00000000
  61. #define PUBCERT3P_TYPE_AACS_PLAYBACK 0x00000001
  62. #define PUBCERT3P_TYPE_AACS_ADVANCED_USAGE 0x00000002
  63. #define PUBCERT3P_TYPE_AACS_ISV_KEY_PROVISIONING 0x00000003
  64. // Issuer id: Intel
  65. #define PUBCERT3P_ISSUER_ID 0x00000000
  66. // PROTECTED_OUTPUT 1.5 3rd Party Certificate
  67. typedef struct _Cert3p {
  68. // 3rd Party signed part
  69. struct _SignBy3p {
  70. unsigned int CertificateType;
  71. unsigned char TimeValidStart[8];
  72. unsigned char TimeValidEnd[8];
  73. unsigned int Id3p;
  74. unsigned int IssuerId;
  75. EcDsaPubKey PubKey3p;
  76. } SignBy3p;
  77. EcDsaSig Sign3p;
  78. // Intel signed part,
  79. struct _SignedByIntel
  80. {
  81. unsigned char TimeValidStart[8];
  82. unsigned char TimeValidEnd[8];
  83. EcDsaPubKey PubKeyVerify3p;
  84. } SignByIntel;
  85. EcDsaSig SignIntel;
  86. } Cert3p;
  87. // 3rd Party Certificate Signed By Intel structs, added after RCRs / MV1.0 in 2010
  88. typedef struct _Cert3pIntelSigned {
  89. unsigned char TimeValidStart[8];
  90. unsigned char TimeValidEnd[8];
  91. EcDsaPubKey PubKeyVerify3p;
  92. EcDsaSig SignIntel;
  93. } Cert3pIntelSigned;
  94. typedef struct _Cert3pIntelSigned1 {
  95. unsigned short IntelSignedVersion;
  96. unsigned char TimeValidStart[8];
  97. unsigned char TimeValidEnd[8];
  98. unsigned short IntelSignedCertificateType;
  99. EcDsaPubKey PubKeyVerify3p;
  100. EcDsaSig SignIntel;
  101. } Cert3pIntelSigned1;
  102. // PROTECTED_OUTPUT2.0/MV 1.0 3rd Party Certificate
  103. typedef struct _Cert3pMV {
  104. // 3rd Party signed part
  105. struct _SignBy3p {
  106. unsigned int CertificateType;
  107. unsigned char TimeValidStart[8];
  108. unsigned char TimeValidEnd[8];
  109. unsigned int Id3p;
  110. unsigned int IssuerId;
  111. EcDsaPubKey PubKey3p;
  112. } SignBy3p;
  113. EcDsaSig Sign3p;
  114. // Intel signed part, modified after RCRs
  115. union
  116. {
  117. Cert3pIntelSigned IntelSigned;
  118. Cert3pIntelSigned1 IntelSigned1;
  119. } SignByIntel;
  120. } Cert3pMV;
  121. /*
  122. * Cert3pType, enumerates type of new Cert3p type, added in RCR, define if MV command are allowed
  123. */
  124. typedef enum _Cert3pType
  125. {
  126. PROTECTED_OUTPUT_EPID_PUBCERT3P_TYPE_PROTECTED_OUTPUT15, //IntelSignedVersion = 0, IntelSignedCertificateType = 0;
  127. PROTECTED_OUTPUT_EPID_PUBCERT3P_TYPE_PROTECTED_OUTPUT20, //IntelSignedVersion = 1, IntelSignedCertificateType = 0;
  128. PROTECTED_OUTPUT_EPID_PUBCERT3P_TYPE_MV_APP, //IntelSignedVersion = 1, IntelSignedCertificateType = 1;
  129. PROTECTED_OUTPUT_EPID_PUBCERT3P_TYPE_MV_SRV //IntelSignedVersion = 1, IntelSignedCertificateType = 1, CertificateType = 0x00000001 (Server) for Trusted Time
  130. } Cert3pType;
  131. /*
  132. * SafeID Certificate
  133. */
  134. // PCH SafeID Public Certificate
  135. typedef struct _SafeIdCert {
  136. unsigned char sver[2];
  137. unsigned char blobid[2];
  138. unsigned int Gid;
  139. unsigned char h1[64];
  140. unsigned char h2[64];
  141. unsigned char w[192];
  142. EcDsaSig SignIntel;
  143. } SafeIdCert;
  144. /*
  145. * SafeID Standard Parameters (crtyptosystem context)
  146. */
  147. typedef struct _SafeIdParams {
  148. unsigned char sver[2];
  149. unsigned char blobid[2];
  150. unsigned char p[32];
  151. unsigned char q[32];
  152. unsigned char h[4];
  153. unsigned char a[32];
  154. unsigned char b[32];
  155. unsigned char coeff0[32];
  156. unsigned char coeff1[32];
  157. unsigned char coeff2[32];
  158. unsigned char qnr[32];
  159. unsigned char orderG2[96];
  160. unsigned char p_prim[32];
  161. unsigned char q_prim[32];
  162. unsigned char h_prim[4];
  163. unsigned char a_prim[32];
  164. unsigned char b_prim[32];
  165. unsigned char g1[64];
  166. unsigned char g2[192];
  167. unsigned char g3[64];
  168. EcDsaSig SignIntel;
  169. } SafeIdParams;
  170. /**
  171. * SafeID Private Key Based Revocation List
  172. */
  173. typedef struct _SafeIdPrivKeyRlHdr {
  174. unsigned char sver[2];
  175. unsigned char blobid[2];
  176. unsigned int Gid;
  177. unsigned int RlVer;
  178. unsigned int n;
  179. } SafeIdPrivKeyRlHdr;
  180. #define SAFEID_F_KEY_SIZE 32
  181. #define SAFEID_B_K_SIZE 128
  182. #define SAFEID_SVER 0x0100
  183. #define SAFEID_KEY_REV_LIST_BLOBID 0x0d00
  184. #define SAFEID_SIG_REV_LIST_BLOBID 0x0e00
  185. /*
  186. * SafeId certificates, parameters and signatures lengths; application certificates length
  187. */
  188. #define CERTIFICATE_3P_LEN sizeof(Cert3p)
  189. #define SAFEID_PARAM_LEN sizeof(SafeIdParams) // SafeID cryptosystem context length
  190. #define SAFEID_CERT_LEN sizeof(SafeIdCert) // SafeID certificate length
  191. #define SAFEID_SIG_LEN 569 // SafeID signature length
  192. // SafeID Signature
  193. typedef unsigned char SafeIdSig[SAFEID_SIG_LEN];
  194. #pragma pack(pop)
  195. #ifdef __cplusplus
  196. }
  197. #endif
  198. #endif//_PROTECTED_OUTPUT_CERTIFICATES_H