api.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. /*############################################################################
  2. # Copyright 2016-2017 Intel Corporation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################*/
  16. #ifndef EPID_VERIFIER_1_1_API_H_
  17. #define EPID_VERIFIER_1_1_API_H_
  18. #include <stddef.h>
  19. #include "epid/common/1.1/types.h"
  20. #include "epid/common/errors.h"
  21. #include "epid/common/stdtypes.h"
  22. #include "epid/verifier/api.h"
  23. /*!
  24. * \file
  25. * \brief Intel(R) EPID SDK verifier Intel(R) EPID 1.1 API.
  26. */
  27. /// Intel(R) EPID 1.1 Verifier functionality
  28. /*!
  29. \defgroup Epid11VerifierModule Intel(R) EPID 1.1 support
  30. To verify signatures coming from member devices that belong to an
  31. Intel&reg; EPID 1.1 group, you need to use Intel&reg; EPID 1.1
  32. verifier APIs.
  33. If you are acting as a verifier for both Intel&reg; EPID 1.1 and 2.0
  34. members, you can determine if you need version 1.1 or 2.0
  35. verification by checking the Intel&reg; EPID version field in the
  36. group public key file (see ::EpidParseFileHeader). You can also
  37. check the version in other binary issuer material, such as the
  38. GroupRL and SigRL.
  39. The 1.1 verifier APIs take a verifier context as input. Each
  40. verifier context (::Epid11VerifierCtx) represents a verifier for a
  41. single group.
  42. The Intel&reg; EPID 1.1 specification does not provide hash algorithm
  43. selection and verifier blacklist revocation. Therefore, APIs such as
  44. ::EpidVerifierSetHashAlg and ::EpidVerifierSetVerifierRl are not
  45. available.
  46. You can find the Intel&reg; EPID 1.1 API headers in the 1.1
  47. directories, for example, `epid/verifier/1.1/api.h`.
  48. Intel&reg; EPID 1.1 APIs and data structures are indicated with the
  49. "Epid11" prefix. For example, the Intel&reg; EPID 1.1 version of
  50. ::EpidParseGroupPubKeyFile is called ::Epid11ParseGroupPubKeyFile,
  51. and the Intel&reg; EPID 1.1 version of `GroupRl` is `Epid11GroupRl`.
  52. \ingroup EpidVerifierModule
  53. @{
  54. */
  55. /// Internal context of Intel(R) EPID 1.1 verifier.
  56. typedef struct Epid11VerifierCtx Epid11VerifierCtx;
  57. /// Intel(R) EPID 1.1 Pre-computed verifier settings.
  58. /*!
  59. Serialized form of the information about a verifier that remains stable for
  60. a given set of keys.
  61. This API supports Intel(R) EPID 1.1 verification.
  62. \note e12 = 0 implies that this data is not valid
  63. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  64. support</b></a>
  65. */
  66. #pragma pack(1)
  67. typedef struct Epid11VerifierPrecomp {
  68. Epid11GroupId gid; ///< group ID
  69. Epid11GtElemStr e12; ///< an element in GT
  70. Epid11GtElemStr e22; ///< an element in GT
  71. Epid11GtElemStr e2w; ///< an element in GT
  72. } Epid11VerifierPrecomp;
  73. #pragma pack()
  74. /// Creates a new Intel(R) EPID 1.1 verifier context.
  75. /*!
  76. Must be called to create the verifier context that is used by
  77. other "Verifier" APIs.
  78. Allocates memory for the context, then initialize it.
  79. Epid11VerifierDelete() must be called to safely release the member context.
  80. \param[in] pub_key
  81. The group certificate.
  82. \param[in] precomp
  83. Optional pre-computed data. If NULL the value is computed internally and is
  84. readable using Epid11VerifierWritePrecomp().
  85. \param[out] ctx
  86. Newly constructed verifier context.
  87. \returns ::EpidStatus
  88. \note
  89. If the result is not ::kEpidNoErr the content of ctx is undefined.
  90. \see Epid11VerifierDelete
  91. \see Epid11VerifierWritePrecomp
  92. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  93. support</b></a>
  94. */
  95. EpidStatus Epid11VerifierCreate(Epid11GroupPubKey const* pub_key,
  96. Epid11VerifierPrecomp const* precomp,
  97. Epid11VerifierCtx** ctx);
  98. /// Deletes an existing Intel(R) EPID 1.1 verifier context.
  99. /*!
  100. Must be called to safely release a verifier context created using
  101. Epid11VerifierCreate().
  102. De-initializes the context, frees memory used by the context, and sets the
  103. context pointer to NULL.
  104. \param[in,out] ctx
  105. The verifier context. Can be NULL.
  106. \see Epid11VerifierCreate
  107. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  108. support</b></a>
  109. */
  110. void Epid11VerifierDelete(Epid11VerifierCtx** ctx);
  111. /// Serializes the pre-computed Intel(R) EPID 1.1 verifier settings.
  112. /*!
  113. \param[in] ctx
  114. The verifier context.
  115. \param[out] precomp
  116. The Serialized pre-computed verifier settings.
  117. \returns ::EpidStatus
  118. \note
  119. If the result is not ::kEpidNoErr the content of precomp is undefined.
  120. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  121. support</b></a>
  122. */
  123. EpidStatus Epid11VerifierWritePrecomp(Epid11VerifierCtx const* ctx,
  124. Epid11VerifierPrecomp* precomp);
  125. /// Sets the Intel(R) EPID 1.1 private key based revocation list.
  126. /*!
  127. The caller is responsible to for ensuring the revocation list is authorized,
  128. e.g signed by the issuer. The caller is also responsible checking the version
  129. of the revocation list. The call will fail if trying to set an older version
  130. of the revocation list than was last set.
  131. This API supports Intel(R) EPID 1.1 verification.
  132. \attention
  133. The memory pointed to by priv_rl will be accessed directly by the verifier
  134. until a new list is set or the verifier is destroyed. Do not modify the
  135. contents of this memory. The behavior of subsequent operations that rely on
  136. the revocation list will be undefined if the memory is modified.
  137. \attention
  138. It is the responsibility of the caller to free the memory pointed to by priv_rl
  139. after the verifier is no longer using it.
  140. \param[in,out] ctx
  141. The verifier context.
  142. \param[in] priv_rl
  143. The private key based revocation list.
  144. \param[in] priv_rl_size
  145. The size of the private key based revocation list in bytes.
  146. \returns ::EpidStatus
  147. \note
  148. If the result is not ::kEpidNoErr the private key based revocation list
  149. pointed to by the verifier is undefined.
  150. \see Epid11VerifierCreate
  151. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  152. support</b></a>
  153. */
  154. EpidStatus Epid11VerifierSetPrivRl(Epid11VerifierCtx* ctx,
  155. Epid11PrivRl const* priv_rl,
  156. size_t priv_rl_size);
  157. /// Sets the Intel(R) EPID 1.1 signature based revocation list.
  158. /*!
  159. The caller is responsible to for ensuring the revocation list is authorized,
  160. e.g signed by the issuer. The caller is also responsible checking the version
  161. of the revocation list. The call will fail if trying to set an older version
  162. of the revocation list than was last set.
  163. This API supports Intel(R) EPID 1.1 verification.
  164. \attention
  165. The memory pointed to by sig_rl will be accessed directly by the verifier
  166. until a new list is set or the verifier is destroyed. Do not modify the
  167. contents of this memory. The behavior of subsequent operations that rely on
  168. the revocation list will be undefined if the memory is modified.
  169. \attention
  170. It is the responsibility of the caller to free the memory pointed to by sig_rl
  171. after the verifier is no longer using it.
  172. \param[in,out] ctx
  173. The verifier context.
  174. \param[in] sig_rl
  175. The signature based revocation list.
  176. \param[in] sig_rl_size
  177. The size of the signature based revocation list in bytes.
  178. \returns ::EpidStatus
  179. \note
  180. If the result is not ::kEpidNoErr the signature based revocation list pointed
  181. to by the verifier is undefined.
  182. \see Epid11VerifierCreate
  183. \see SdkOverview_11Verifier \see <a
  184. href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  185. support</b></a>
  186. */
  187. EpidStatus Epid11VerifierSetSigRl(Epid11VerifierCtx* ctx,
  188. Epid11SigRl const* sig_rl,
  189. size_t sig_rl_size);
  190. /// Sets the Intel(R) EPID 1.1 group based revocation list.
  191. /*!
  192. The caller is responsible to for ensuring the revocation list is authorized,
  193. e.g signed by the issuer. The caller is also responsible checking the version
  194. of the revocation list. The call will fail if trying to set an older version
  195. of the revocation list than was last set.
  196. This API supports Intel(R) EPID 1.1 verification.
  197. \attention
  198. The memory pointed to by grp_rl will be accessed directly by the verifier
  199. until a new list is set or the verifier is destroyed. Do not modify the
  200. contents of this memory. The behavior of subsequent operations that rely on
  201. the revocation list will be undefined if the memory is modified.
  202. \attention
  203. It is the responsibility of the caller to free the memory pointed to by grp_rl
  204. after the verifier is no longer using it.
  205. \param[in,out] ctx
  206. The verifier context.
  207. \param[in] grp_rl
  208. The group based revocation list.
  209. \param[in] grp_rl_size
  210. The size of the group based revocation list in bytes.
  211. \returns ::EpidStatus
  212. \note
  213. If the result is not ::kEpidNoErr the group based revocation list pointed
  214. to by the verifier is undefined.
  215. \see Epid11VerifierCreate
  216. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  217. support</b></a>
  218. */
  219. EpidStatus Epid11VerifierSetGroupRl(Epid11VerifierCtx* ctx,
  220. Epid11GroupRl const* grp_rl,
  221. size_t grp_rl_size);
  222. /// Sets the basename to be used by a verifier.
  223. /*!
  224. This API allows setting a zero length base name.
  225. \warning
  226. Not all members in the Intel(R) EPID 1.1 ecosystem may support zero length
  227. basenames. They may interpret a zero length basename as random base.
  228. \param[in, out] ctx
  229. The verifier context.
  230. \param[in] basename
  231. The basename. Pass NULL for random base.
  232. \param[in] basename_len
  233. Number of bytes in basename buffer. Must be 0 if basename is NULL.
  234. \returns ::EpidStatus
  235. \see Epid11VerifierCreate
  236. */
  237. EpidStatus Epid11VerifierSetBasename(Epid11VerifierCtx* ctx,
  238. void const* basename, size_t basename_len);
  239. /// Verifies an Intel(R) EPID 1.1 signature and checks revocation status.
  240. /*!
  241. \param[in] ctx
  242. The verifier context.
  243. \param[in] sig
  244. The signature.
  245. \param[in] sig_len
  246. The size of sig in bytes.
  247. \param[in] msg
  248. The message that was signed.
  249. \param[in] msg_len
  250. The size of msg in bytes.
  251. \returns ::EpidStatus
  252. \retval ::kEpidSigValid
  253. Signature validated successfully
  254. \retval ::kEpidSigInvalid
  255. Signature is invalid
  256. \retval ::kEpidSigRevokedInGroupRl
  257. Signature revoked in GroupRl
  258. \retval ::kEpidSigRevokedInPrivRl
  259. Signature revoked in PrivRl
  260. \retval ::kEpidSigRevokedInSigRl
  261. Signature revoked in SigRl
  262. \note
  263. If the result is not ::kEpidNoErr or one of the values listed above the
  264. verify should de considered to have failed.
  265. \see Epid11VerifierCreate
  266. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  267. support</b></a>
  268. */
  269. EpidStatus Epid11Verify(Epid11VerifierCtx const* ctx,
  270. Epid11Signature const* sig, size_t sig_len,
  271. void const* msg, size_t msg_len);
  272. /// Determines if two Intel(R) EPID 1.1 signatures are linked.
  273. /*!
  274. The Intel(R) EPID scheme allows signatures to be linked. If basename
  275. option is specified when signing signatures with the same basename will be
  276. linkable. This linking capability allows the verifier, or anyone, to know
  277. whether two Intel(R) EPID signatures are generated by the same member.
  278. This API supports Intel(R) EPID 1.1 verification.
  279. \param[in] sig1
  280. A basic signature.
  281. \param[in] sig2
  282. A basic signature.
  283. \result bool
  284. \retval true
  285. if the signatures were generated by the same member
  286. \retval false
  287. if it couldn't be determined if the signatures were generated by
  288. the same member
  289. \note
  290. The input signatures should be verified using Epid11VerifyBasicSig() before
  291. invocation. Behavior is undefined if either of the signatures cannot be
  292. verified.
  293. \see Epid11VerifyBasicSig
  294. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  295. support</b></a>
  296. */
  297. bool Epid11AreSigsLinked(Epid11BasicSignature const* sig1,
  298. Epid11BasicSignature const* sig2);
  299. /// Verifies an Intel(R) EPID 1.1 member signature without revocation checks.
  300. /*!
  301. Used in constrained environments where, due to limited memory, it may not
  302. be possible to process through a large and potentially unbounded revocation
  303. list.
  304. \param[in] ctx
  305. The verifier context.
  306. \param[in] sig
  307. The basic signature.
  308. \param[in] msg
  309. The message that was signed.
  310. \param[in] msg_len
  311. The size of msg in bytes.
  312. \returns ::EpidStatus
  313. \note
  314. This function should be used in conjunction with Epid11NrVerify() and
  315. Epid11CheckPrivRlEntry().
  316. \note
  317. If the result is not ::kEpidNoErr the verify should be considered to have
  318. failed.
  319. \see Epid11VerifierCreate
  320. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  321. support</b></a>
  322. */
  323. EpidStatus Epid11VerifyBasicSig(Epid11VerifierCtx const* ctx,
  324. Epid11BasicSignature const* sig,
  325. void const* msg, size_t msg_len);
  326. /// Verifies the non-revoked proof for a single Intel(R) EPID 1.1 signature
  327. /// based revocation list entry.
  328. /*!
  329. Used in constrained environments where, due to limited memory, it may not
  330. be possible to process through a large and potentially unbounded revocation
  331. list.
  332. This API supports Intel(R) EPID 1.1 verification.
  333. \param[in] ctx
  334. The verifier context.
  335. \param[in] sig
  336. The basic signature.
  337. \param[in] msg
  338. The message that was signed.
  339. \param[in] msg_len
  340. The size of msg in bytes.
  341. \param[in] sigrl_entry
  342. The signature based revocation list entry.
  343. \param[in] proof
  344. The non-revoked proof.
  345. \returns ::EpidStatus
  346. \note
  347. Sig should be verified using Epid11VerifyBasicSig() before invocation. Behavior
  348. is undefined if sig cannot be verified.
  349. \note
  350. This function should be used in conjunction with Epid11VerifyBasicSig() and
  351. Epid11CheckPrivRlEntry().
  352. \note
  353. If the result is not ::kEpidNoErr the verify should de considered to have
  354. failed.
  355. \see Epid11VerifierCreate
  356. \see Epid11VerifyBasicSig
  357. \see Epid11CheckPrivRlEntry
  358. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  359. support</b></a>
  360. */
  361. EpidStatus Epid11NrVerify(Epid11VerifierCtx const* ctx,
  362. Epid11BasicSignature const* sig, void const* msg,
  363. size_t msg_len, Epid11SigRlEntry const* sigrl_entry,
  364. Epid11NrProof const* proof);
  365. /// Verifies an Intel(R) EPID 1.1 signature has not been revoked in the
  366. /// private key based revocation list.
  367. /*!
  368. Used in constrained environments where, due to limited memory, it may not
  369. be possible to process through a large and potentially unbounded revocation
  370. list.
  371. This API supports Intel(R) EPID 1.1 verification.
  372. \param[in] ctx
  373. The verifier context.
  374. \param[in] sig
  375. The basic signature.
  376. \param[in] f
  377. The private key based revocation list entry.
  378. \note
  379. Sig should be verified using Epid11VerifyBasicSig() before invocation. Behavior
  380. is undefined if sig cannot be verified.
  381. \note
  382. This function should be used in conjunction with Epid11NrVerify() and
  383. Epid11VerifyBasicSig().
  384. \note
  385. If the result is not ::kEpidNoErr the verify should de considered to have
  386. failed.
  387. \returns ::EpidStatus
  388. \see Epid11VerifierCreate
  389. \see Epid11NrVerify
  390. \see Epid11VerifyBasicSig
  391. \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
  392. support</b></a>
  393. */
  394. EpidStatus Epid11CheckPrivRlEntry(Epid11VerifierCtx const* ctx,
  395. Epid11BasicSignature const* sig,
  396. FpElemStr const* f);
  397. /*! @} */
  398. #endif // EPID_VERIFIER_1_1_API_H_