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