• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!-- HTML header for doxygen 1.8.10-->
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4<head>
5<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
6<meta http-equiv="X-UA-Compatible" content="IE=9"/>
7<meta name="generator" content="Doxygen 1.8.14"/>
8<title>Intel&reg; Enhanced Privacy ID SDK: Verifying an Intel&reg; EPID Signature</title>
9<link href="tabs.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="dynsections.js"></script>
12<link href="navtree.css" rel="stylesheet" type="text/css"/>
13<script type="text/javascript" src="resize.js"></script>
14<script type="text/javascript" src="navtreedata.js"></script>
15<script type="text/javascript" src="navtree.js"></script>
16<script type="text/javascript">
17/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
18  $(document).ready(initResizable);
19/* @license-end */</script>
20<link href="doxygen.css" rel="stylesheet" type="text/css" />
21<link href="epidstyle.css" rel="stylesheet" type="text/css"/>
22</head>
23<body>
24<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
25<div id="titlearea">
26<table cellspacing="0" cellpadding="0">
27 <tbody>
28 <tr style="height: 56px;">
29  <td id="projectalign" style="padding-left: 0.5em;">
30   <div id="projectname"><a
31                            onclick="storeLink('index.html')"
32                            id="projectlink"
33                            class="index.html"
34                            href="index.html">Intel&reg; Enhanced Privacy ID SDK</a>
35&#160;<span id="projectnumber">6.0.1</span>
36</div>
37  </td>
38 </tr>
39 </tbody>
40</table>
41</div>
42<!-- end header part -->
43<!-- Generated by Doxygen 1.8.14 -->
44</div><!-- top -->
45<div id="side-nav" class="ui-resizable side-nav-resizable">
46  <div id="nav-tree">
47    <div id="nav-tree-contents">
48      <div id="nav-sync" class="sync"></div>
49    </div>
50  </div>
51  <div id="splitbar" style="-moz-user-select:none;"
52       class="ui-resizable-handle">
53  </div>
54</div>
55<script type="text/javascript">
56/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
57$(document).ready(function(){initNavTree('_user_manual__verifying_an_intel_epid_signature.html','');});
58/* @license-end */
59</script>
60<div id="doc-content">
61<div class="header">
62  <div class="headertitle">
63<div class="title">Verifying an Intel&reg; EPID Signature </div>  </div>
64</div><!--header-->
65<div class="contents">
66<div class="textblock"><p>This walkthrough of the <code>verifysig</code> example shows you how to use SDK APIs to verify an Intel&reg; EPID 2.0 signature. <code>verifysig</code> is built during the <a class="el" href="_building_sdk.html">SDK build</a>.</p>
67<p>To verify an Intel&reg; EPID 1.1 signature see the example code in <code>verifysig11.c</code>. For information on Intel&reg; EPID 1.1 specific APIs see <a href="group___epid11_verifier_module.html"><b>Intel&reg; EPID 1.1 support</b></a>.</p>
68<p><br />
69</p>
70<h1><a class="anchor" id="verifysigWalktrhu_overview"></a>
71Summary</h1>
72<p>In the code example below, we take this approach:</p>
73<ul>
74<li>Extract and authenticate issuer provided material</li>
75<li>Create the verifier context to allow us to call other verifier APIs</li>
76<li>Verify signature</li>
77<li>Clean up</li>
78</ul>
79<p><br />
80</p>
81<h1><a class="anchor" id="verifysigWalkthrough_main"></a>
82Verifysig Walkthrough</h1>
83<p>First, we include headers so we have access to needed declarations.</p>
84<p><div class="fragment"><div class="line"><span class="preprocessor">#include &quot;src/verifysig.h&quot;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;stdlib.h&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="file__parser_8h.html">epid/common/file_parser.h</a>&quot;</span></div></div><!-- fragment --></p>
85<p>The utility headers are used by <code>verifysig</code> for logging and buffer management. The <code><a class="el" href="verifier_2api_8h.html" title="Intel(R) EPID SDK verifier API. ">epid/verifier/api.h</a></code> header provides access to the core verifier APIs, and the <code><a class="el" href="file__parser_8h.html" title="Intel(R) EPID issuer material parsing utilities. ">epid/common/file_parser.h</a></code> header provides an API for parsing buffers formatted according to the various IoT Intel&reg; EPID binary file formats.</p>
86<p><br />
87</p>
88<p>In <code>main.c</code>, we define a stub function, IsCaCertAuthorizedByRootCa, which is responsible for checking that the CA certificate is authorized by the root CA. Before calling <code>verify</code>, we call this function, IsCaCertAuthorizedByRootCa. In an actual implementation, you need to provide an implementation to validate the issuing CA certificate with the CA root certificate before using it in parse functions.</p>
89<p><br />
90</p>
91<p>We use <code>Verify</code> to verify an Intel&reg; EPID signature. <code>Verify</code> is a wrapper function that isolates SDK API functionality for the purpose of this walkthrough.</p>
92<p><div class="fragment"><div class="line"><a class="code" href="group___error_codes.html#gafdb27c77c2c4b32c807e326a8a0da360">EpidStatus</a> Verify(<a class="code" href="struct_epid_signature.html">EpidSignature</a> <span class="keyword">const</span>* sig, <span class="keywordtype">size_t</span> sig_len, <span class="keywordtype">void</span> <span class="keyword">const</span>* msg,</div><div class="line">                  <span class="keywordtype">size_t</span> msg_len, <span class="keywordtype">void</span> <span class="keyword">const</span>* basename, <span class="keywordtype">size_t</span> basename_len,</div><div class="line">                  <span class="keywordtype">void</span> <span class="keyword">const</span>* signed_priv_rl, <span class="keywordtype">size_t</span> signed_priv_rl_size,</div><div class="line">                  <span class="keywordtype">void</span> <span class="keyword">const</span>* signed_sig_rl, <span class="keywordtype">size_t</span> signed_sig_rl_size,</div><div class="line">                  <span class="keywordtype">void</span> <span class="keyword">const</span>* signed_grp_rl, <span class="keywordtype">size_t</span> signed_grp_rl_size,</div><div class="line">                  <a class="code" href="struct_verifier_rl.html">VerifierRl</a> <span class="keyword">const</span>* ver_rl, <span class="keywordtype">size_t</span> ver_rl_size,</div><div class="line">                  <span class="keywordtype">void</span> <span class="keyword">const</span>* signed_pub_key, <span class="keywordtype">size_t</span> signed_pub_key_size,</div><div class="line">                  <a class="code" href="struct_epid_ca_certificate.html">EpidCaCertificate</a> <span class="keyword">const</span>* cacert, <a class="code" href="group___epid_types.html#ga5e450438f6f9a5eacd0cf5ce354ec890">HashAlg</a> hash_alg,</div><div class="line">                  <span class="keywordtype">void</span>** verifier_precomp, <span class="keywordtype">size_t</span>* verifier_precomp_size) {</div></div><!-- fragment --></p>
93<p>The <code>Verify</code> parameters were either sent by the verifier to the member, or they were part of the member's configuration. The exceptions are the <code>sig</code> and <code>sig_len</code> parameters, which we use to input the signature to be verified.</p>
94<p>The verifier might send the message to the member or there may be another mechanism to choose the message, but the way the message is communicated is outside the scope of the Intel&reg; EPID scheme.</p>
95<p>We use the parameters <code>verifier_precomp</code> and <code>verifier_precomp_is_input</code> to pass in a pre-computation blob if provided. We can use the pre-computation blob to increase performance when verifying signatures repeatedly with the same group public key.</p>
96<p>The member and the verifier agree on the message, basename, hash algorithm, and SigRL that the verifier uses for verification.</p>
97<dl class="section warning"><dt>Warning</dt><dd>The use of a name-based signature creates a platform unique pseudonymous identifier. Because it reduces the member's privacy, the user should be notified when it is used and should have control over its use.</dd></dl>
98<p><br />
99</p>
100<p>Next we do basic variable setup.</p>
101<p><div class="fragment"><div class="line">  <a class="code" href="group___error_codes.html#gafdb27c77c2c4b32c807e326a8a0da360">EpidStatus</a> result = <a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360aa08f0d2e394b37694117a6a32bc71e6e">kEpidErr</a>;</div><div class="line">  <a class="code" href="group___epid_verifier_module.html#gaf172a5f8f7f069d38c5838b723a1a85c">VerifierCtx</a>* ctx = NULL;</div><div class="line">  <a class="code" href="struct_priv_rl.html">PrivRl</a>* priv_rl = NULL;</div><div class="line">  <a class="code" href="struct_sig_rl.html">SigRl</a>* sig_rl = NULL;</div><div class="line">  <a class="code" href="struct_group_rl.html">GroupRl</a>* grp_rl = NULL;</div><div class="line"></div><div class="line">  <span class="keywordflow">do</span> {</div><div class="line">    <a class="code" href="struct_group_pub_key.html">GroupPubKey</a> pub_key = {0};</div></div><!-- fragment --></p>
102<p>We create pointers to resources to be allocated and we use the <code>do {} while(0)</code> idiom so that we can reliably free resources on return from <code>Verify</code>. We also allocate the group public key on the stack.</p>
103<p><br />
104</p>
105<p>Next, we authenticate and extract the group public key using <a class="el" href="group___file_parser.html#ga43fdbc1bf2edd3695d21cb457365afbb" title="Extracts group public key from buffer in issuer binary format. ">EpidParseGroupPubKeyFile</a>.</p>
106<p><div class="fragment"><div class="line">    result = <a class="code" href="group___file_parser.html#ga43fdbc1bf2edd3695d21cb457365afbb">EpidParseGroupPubKeyFile</a>(signed_pub_key, signed_pub_key_size,</div><div class="line">                                      cacert, &amp;pub_key);</div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line">    }</div></div><!-- fragment --></p>
107<p><a class="el" href="group___file_parser.html#ga43fdbc1bf2edd3695d21cb457365afbb" title="Extracts group public key from buffer in issuer binary format. ">EpidParseGroupPubKeyFile</a> takes a buffer containing a group public key in issuer binary format and validates that the public key is signed by the private key that corresponds to the provided CA certificate, reading the key into <code>pub_key</code> in the process.</p>
108<p>Next, if a pre-computation blob is being used, we make sure that it is not in a legacy format.</p>
109<p><div class="fragment"><div class="line">    <span class="keywordflow">if</span> (*verifier_precomp &amp;&amp;</div><div class="line">        *verifier_precomp_size != <span class="keyword">sizeof</span>(<a class="code" href="struct_verifier_precomp.html">VerifierPrecomp</a>)) {</div><div class="line">      result = <a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360ad134d6cc95a9dcb1b1a9f9c358047cbf">kEpidBadArgErr</a>;</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line">    }</div><div class="line">    *verifier_precomp_size = <span class="keyword">sizeof</span>(<a class="code" href="struct_verifier_precomp.html">VerifierPrecomp</a>);</div></div><!-- fragment --></p>
110<p><br />
111</p>
112<p>Next, we create a verifier context using <a class="el" href="group___epid_verifier_module.html#ga1d116daaee5466a1485d26ebc4e3ab70" title="Creates a new verifier context. ">EpidVerifierCreate</a>.</p>
113<p><div class="fragment"><div class="line">    result = <a class="code" href="group___epid_verifier_module.html#ga1d116daaee5466a1485d26ebc4e3ab70">EpidVerifierCreate</a>(&amp;pub_key, *verifier_precomp, &amp;ctx);</div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line">    }</div></div><!-- fragment --></p>
114<p>If a pre-computation blob is provided to the top level application, we use it. Otherwise, we pass in <code>NULL</code>.</p>
115<p><br />
116</p>
117<p>Then we serialize pre-computed verifier data using <a class="el" href="group___epid_verifier_module.html#ga92df4d00ea4ee59d7bfd35b23da03392" title="Serializes the pre-computed verifier settings. ">EpidVerifierWritePrecomp</a>.</p>
118<p><div class="fragment"><div class="line">    <span class="keywordflow">if</span> (!*verifier_precomp) {</div><div class="line">      *verifier_precomp = calloc(1, *verifier_precomp_size);</div><div class="line">    }</div><div class="line">    result = <a class="code" href="group___epid_verifier_module.html#ga92df4d00ea4ee59d7bfd35b23da03392">EpidVerifierWritePrecomp</a>(ctx, *verifier_precomp);</div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line">    }</div></div><!-- fragment --></p>
119<p>The serialized verifier pre-computation blob can be used to greatly increase performance of <a class="el" href="group___epid_verifier_module.html#ga1d116daaee5466a1485d26ebc4e3ab70" title="Creates a new verifier context. ">EpidVerifierCreate</a> in future sessions if the same group public key is used.</p>
120<p><br />
121</p>
122<p>We use <a class="el" href="group___epid_verifier_module.html#ga97b58b2382f24756b66a357f1e825c92" title="Sets the hash algorithm to be used by a verifier. ">EpidVerifierSetHashAlg</a> to indicate the hash algorithm used for verification, which should be the same algorithm that the member used when signing.</p>
123<p><div class="fragment"><div class="line">    result = <a class="code" href="group___epid_verifier_module.html#ga97b58b2382f24756b66a357f1e825c92">EpidVerifierSetHashAlg</a>(ctx, hash_alg);</div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line">    }</div></div><!-- fragment --></p>
124<p>After the hash algorithm is set, future calls to <a class="el" href="group___epid_verifier_module.html#gae3f9c37628e18b880d8bbee3e7f55064" title="Verifies a signature and checks revocation status. ">EpidVerify</a> will use the same algorithm.</p>
125<p><br />
126</p>
127<p>We use <a class="el" href="group___epid_verifier_module.html#ga1c3810ef361da678a1f77823bd9c37a6" title="Sets the basename to be used by a verifier. ">EpidVerifierSetBasename</a> to indicate the basename used for verification, which should be the same one that the member used when signing.</p>
128<p><div class="fragment"><div class="line">    result = <a class="code" href="group___epid_verifier_module.html#ga1c3810ef361da678a1f77823bd9c37a6">EpidVerifierSetBasename</a>(ctx, basename, basename_len);</div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line">    }</div></div><!-- fragment --></p>
129<p>After the basename is set, future calls to <a class="el" href="group___epid_verifier_module.html#gae3f9c37628e18b880d8bbee3e7f55064" title="Verifies a signature and checks revocation status. ">EpidVerify</a> will use the same basename.</p>
130<p><br />
131</p>
132<p>Before we verify a signature, we have to configure revocation lists so that we can check to see if a signer's group membership has been revoked.</p>
133<dl class="section note"><dt>Note</dt><dd>Configured revocation lists are referenced directly by the verifier until a new revocation list is set or the verifier is destroyed. Until the verifier is destroyed, we do not modify the revocation lists.</dd></dl>
134<p><br />
135</p>
136<p>We set the private key revocation list using <a class="el" href="group___epid_verifier_module.html#gafab08180a43b58ce2e1d56c4b070bb0e" title="Sets the private key based revocation list. ">EpidVerifierSetPrivRl</a>.</p>
137<p><div class="fragment"><div class="line">    <span class="keywordflow">if</span> (signed_priv_rl) {</div><div class="line">      <span class="comment">// authenticate and determine space needed for RL</span></div><div class="line">      <span class="keywordtype">size_t</span> priv_rl_size = 0;</div><div class="line">      result = <a class="code" href="group___file_parser.html#gadc033fb23e3cbda56aa7e3d412060b7e">EpidParsePrivRlFile</a>(signed_priv_rl, signed_priv_rl_size, cacert,</div><div class="line">                                   NULL, &amp;priv_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      priv_rl = calloc(1, priv_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (!priv_rl) {</div><div class="line">        result = <a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a11a4d2f1c37064eb663de08dc57bcda8">kEpidMemAllocErr</a>;</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      <span class="comment">// fill the rl</span></div><div class="line">      result = <a class="code" href="group___file_parser.html#gadc033fb23e3cbda56aa7e3d412060b7e">EpidParsePrivRlFile</a>(signed_priv_rl, signed_priv_rl_size, cacert,</div><div class="line">                                   priv_rl, &amp;priv_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      <span class="comment">// set private key based revocation list</span></div><div class="line">      result = <a class="code" href="group___epid_verifier_module.html#gafab08180a43b58ce2e1d56c4b070bb0e">EpidVerifierSetPrivRl</a>(ctx, priv_rl, priv_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line">    }  <span class="comment">// if (signed_priv_rl)</span></div></div><!-- fragment --></p>
138<p>We use <a class="el" href="group___file_parser.html#gadc033fb23e3cbda56aa7e3d412060b7e" title="Extracts private key revocation list from buffer in issuer binary format. ">EpidParsePrivRlFile</a> to:</p>
139<ul>
140<li>extract the private key revocation list</li>
141<li>validate that the revocation list was signed by the private key corresponding to the provided CA certificate</li>
142<li>validate that the size of the input buffer is correct</li>
143<li>determine the required size of the revocation list output buffer</li>
144</ul>
145<p>To determine the required <code>priv_rl</code> buffer size, we provide a null pointer for the output buffer when calling <a class="el" href="group___file_parser.html#gadc033fb23e3cbda56aa7e3d412060b7e" title="Extracts private key revocation list from buffer in issuer binary format. ">EpidParsePrivRlFile</a>.</p>
146<p>After we find out the required size of the <code>priv_rl</code> buffer, we allocate memory for it. Then we fill the buffer using <a class="el" href="group___file_parser.html#gadc033fb23e3cbda56aa7e3d412060b7e" title="Extracts private key revocation list from buffer in issuer binary format. ">EpidParsePrivRlFile</a>.</p>
147<p><br />
148</p>
149<p>Next, we set the signature revocation list using <a class="el" href="group___epid_verifier_module.html#ga4c7c9820409ee06f30bb8dc75fdd5dcf" title="Sets the signature based revocation list. ">EpidVerifierSetSigRl</a>.</p>
150<p><div class="fragment"><div class="line">    <span class="keywordflow">if</span> (signed_sig_rl) {</div><div class="line">      <span class="comment">// authenticate and determine space needed for RL</span></div><div class="line">      <span class="keywordtype">size_t</span> sig_rl_size = 0;</div><div class="line">      result = <a class="code" href="group___file_parser.html#ga237ef5a43076aa6fc6eb18829a93da3f">EpidParseSigRlFile</a>(signed_sig_rl, signed_sig_rl_size, cacert,</div><div class="line">                                  NULL, &amp;sig_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      sig_rl = calloc(1, sig_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (!sig_rl) {</div><div class="line">        result = <a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a11a4d2f1c37064eb663de08dc57bcda8">kEpidMemAllocErr</a>;</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      <span class="comment">// fill the rl</span></div><div class="line">      result = <a class="code" href="group___file_parser.html#ga237ef5a43076aa6fc6eb18829a93da3f">EpidParseSigRlFile</a>(signed_sig_rl, signed_sig_rl_size, cacert,</div><div class="line">                                  sig_rl, &amp;sig_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      <span class="comment">// set signature based revocation list</span></div><div class="line">      result = <a class="code" href="group___epid_verifier_module.html#ga4c7c9820409ee06f30bb8dc75fdd5dcf">EpidVerifierSetSigRl</a>(ctx, sig_rl, sig_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line">    }  <span class="comment">// if (signed_sig_rl)</span></div></div><!-- fragment --></p>
151<p>We use <a class="el" href="group___file_parser.html#ga237ef5a43076aa6fc6eb18829a93da3f" title="Extracts signature revocation list from buffer in issuer binary format. ">EpidParseSigRlFile</a> to:</p>
152<ul>
153<li>extract the signature revocation list</li>
154<li>validate that the revocation list was signed by the private key corresponding to the provided CA certificate</li>
155<li>validate that the size of the input buffer is correct</li>
156<li>determine the required size of the revocation list output buffer</li>
157</ul>
158<p>To determine the required <code>sig_rl</code> buffer size, we provide a null pointer for the output buffer when calling <a class="el" href="group___file_parser.html#ga237ef5a43076aa6fc6eb18829a93da3f" title="Extracts signature revocation list from buffer in issuer binary format. ">EpidParseSigRlFile</a>.</p>
159<p>After we find out the required size of the <code>sig_rl</code> buffer, we allocate memory for it. Then we fill the buffer using <a class="el" href="group___file_parser.html#ga237ef5a43076aa6fc6eb18829a93da3f" title="Extracts signature revocation list from buffer in issuer binary format. ">EpidParseSigRlFile</a>.</p>
160<p><br />
161</p>
162<p>Next, we set the group revocation list using <a class="el" href="group___epid_verifier_module.html#ga1d41d6ef4dabbc30ec28452edd6baffb" title="Sets the group based revocation list. ">EpidVerifierSetGroupRl</a>.</p>
163<p><div class="fragment"><div class="line">    <span class="keywordflow">if</span> (signed_grp_rl) {</div><div class="line">      <span class="comment">// authenticate and determine space needed for RL</span></div><div class="line">      <span class="keywordtype">size_t</span> grp_rl_size = 0;</div><div class="line">      result = <a class="code" href="group___file_parser.html#gad767f72dc55307b872a8b5600da3fd6f">EpidParseGroupRlFile</a>(signed_grp_rl, signed_grp_rl_size, cacert,</div><div class="line">                                    NULL, &amp;grp_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      grp_rl = calloc(1, grp_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (!grp_rl) {</div><div class="line">        result = <a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a11a4d2f1c37064eb663de08dc57bcda8">kEpidMemAllocErr</a>;</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      <span class="comment">// fill the rl</span></div><div class="line">      result = <a class="code" href="group___file_parser.html#gad767f72dc55307b872a8b5600da3fd6f">EpidParseGroupRlFile</a>(signed_grp_rl, signed_grp_rl_size, cacert,</div><div class="line">                                    grp_rl, &amp;grp_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line">      <span class="comment">// set group revocation list</span></div><div class="line">      result = <a class="code" href="group___epid_verifier_module.html#ga1d41d6ef4dabbc30ec28452edd6baffb">EpidVerifierSetGroupRl</a>(ctx, grp_rl, grp_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line">    }  <span class="comment">// if (signed_grp_rl)</span></div></div><!-- fragment --></p>
164<p>We use <a class="el" href="group___file_parser.html#gad767f72dc55307b872a8b5600da3fd6f" title="Extracts group revocation list from buffer in issuer binary format. ">EpidParseGroupRlFile</a> to:</p>
165<ul>
166<li>extract the group revocation list</li>
167<li>validate that the revocation list was signed by the private key corresponding to the provided CA certificate</li>
168<li>validate that the size of the input buffer is correct</li>
169<li>determine the required size of the revocation list output buffer</li>
170</ul>
171<p>To determine the required <code>grp_rl</code> buffer size, we provide a null pointer for the output buffer when calling <a class="el" href="group___file_parser.html#gad767f72dc55307b872a8b5600da3fd6f" title="Extracts group revocation list from buffer in issuer binary format. ">EpidParseGroupRlFile</a>.</p>
172<p>After we find out the required size of the <code>grp_rl</code> buffer, we allocate memory for it. Then we fill the buffer using <a class="el" href="group___file_parser.html#gad767f72dc55307b872a8b5600da3fd6f" title="Extracts group revocation list from buffer in issuer binary format. ">EpidParseGroupRlFile</a>.</p>
173<p><br />
174</p>
175<p>Next, we set the verifier blacklist using <a class="el" href="group___epid_verifier_module.html#ga0909703a0a4dfe080374d0d99077465a" title="Sets the verifier revocation list. ">EpidVerifierSetVerifierRl</a>.</p>
176<p><div class="fragment"><div class="line">    <span class="keywordflow">if</span> (ver_rl) {</div><div class="line">      <span class="comment">// set verifier based revocation list</span></div><div class="line">      result = <a class="code" href="group___epid_verifier_module.html#ga0909703a0a4dfe080374d0d99077465a">EpidVerifierSetVerifierRl</a>(ctx, ver_rl, ver_rl_size);</div><div class="line">      <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line">    }</div></div><!-- fragment --></p>
177<p>The verifier is responsible for ensuring that the verifier revocation list is authorized. Validating it is outside the scope of this example.</p>
178<p><br />
179</p>
180<p>Next, we use <a class="el" href="group___epid_verifier_module.html#gae3f9c37628e18b880d8bbee3e7f55064" title="Verifies a signature and checks revocation status. ">EpidVerify</a> to verify that the Intel&reg; EPID signature was created by a valid member of a group in good standing.</p>
181<p><div class="fragment"><div class="line">    result = <a class="code" href="group___epid_verifier_module.html#gae3f9c37628e18b880d8bbee3e7f55064">EpidVerify</a>(ctx, sig, sig_len, msg, msg_len);</div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group___error_codes.html#ggafdb27c77c2c4b32c807e326a8a0da360a8a6861e14322ca9193498ffc955537f9">kEpidNoErr</a> != result) {</div><div class="line">      <span class="keywordflow">break</span>;</div><div class="line">    }</div></div><!-- fragment --> <br />
182</p>
183<p>Finally, we clean up and exit.</p>
184<p><div class="fragment"><div class="line">  } <span class="keywordflow">while</span> (0);</div><div class="line"></div><div class="line">  <span class="comment">// delete verifier</span></div><div class="line">  <a class="code" href="group___epid_verifier_module.html#ga6707e691f4b3916f9c684d5bbd463d12">EpidVerifierDelete</a>(&amp;ctx);</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (priv_rl) free(priv_rl);</div><div class="line">  <span class="keywordflow">if</span> (sig_rl) free(sig_rl);</div><div class="line">  <span class="keywordflow">if</span> (grp_rl) free(grp_rl);</div><div class="line"></div><div class="line">  <span class="keywordflow">return</span> result;</div><div class="line">}</div></div><!-- fragment --></p>
185<p>If we made it past verification without an error, we set the return code appropriately and fall out of the <code>do-while</code> loop. If there was an error earlier, all breaks in the <code>do-while</code> loop bring us to this point with an error status.</p>
186<p>Then we free the allocated resources. <a class="el" href="group___epid_verifier_module.html#ga6707e691f4b3916f9c684d5bbd463d12" title="Deletes an existing verifier context. ">EpidVerifierDelete</a> deletes the verifier context.</p>
187<p>After deleting the verifier context, we can also delete the revocation lists.</p>
188<p>We return from <code>Verify</code> with the success or error status.</p>
189<p><br />
190</p>
191<p>This concludes the <code>verifysig</code> walkthrough. Now you should be able to verify an Intel&reg; EPID signature using the SDK APIs.</p>
192<p>To learn more about the SDK APIs see the <a href="modules.html"><b>API Reference</b></a>. To learn more about the Intel&reg; EPID Scheme see <a class="el" href="_epid_overview.html">Introduction to the Intel&reg; EPID Scheme</a> in the documentation. </p>
193</div></div><!-- contents -->
194</div><!-- doc-content -->
195<!-- HTML footer for doxygen 1.8.10-->
196<!-- start footer part -->
197<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
198  <ul>
199    <li class="footer">
200      &copy; 2016-2017 Intel Corporation
201    </li>
202  </ul>
203</div>
204</body>
205</html>
206