api.h 16 KB

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