aboutsummaryrefslogtreecommitdiff
path: root/doc/html/VerifysigWalkthru.html
blob: c66ada5df30d927ade08bcd0bbaa7949a4913716 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!-- HTML header for doxygen 1.8.10-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Intel&reg; Enhanced Privacy ID SDK: Verifying an Intel&reg; EPID Signature</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="epidstyle.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a 
                            onclick="storeLink('index.html')"
                            id="projectlink" 
                            class="index.html" 
                            href="index.html">Intel&reg; Enhanced Privacy ID SDK</a>
&#160;<span id="projectnumber">3.0.0</span>
</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('VerifysigWalkthru.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Verifying an Intel&reg; EPID Signature </div>  </div>
</div><!--header-->
<div class="contents">
<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. Verifysig is built during the <a class="el" href="BuildingSdk.html">SDK build</a>.</p>
<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 speciifc APIs see <a href="group___epid11_verifier_module.html"><b>EPID 1.1 support</b></a>.</p>
<p><br />
</p>
<p>First, we include headers so we have access to needed declarations.</p>
<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;util/buffutil.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;util/envutil.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="verifier_2api_8h.html">epid/verifier/api.h</a>&quot;</span></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>
<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="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>
<p><br />
</p>
<p>We define a stub function responsible for checking that the CA certificate is authorized by the root CA.</p>
<p><div class="fragment"><div class="line"><span class="keywordtype">bool</span> IsCaCertAuthorizedByRootCa(<span class="keywordtype">void</span> <span class="keyword">const</span>* data, <span class="keywordtype">size_t</span> size) {</div><div class="line">  (void)data;</div><div class="line">  (void)size;</div><div class="line">  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line">}</div></div><!-- fragment --></p>
<p>IsCaCertAuthorizedByRootCa is called from <code>main.c</code> to validate the CA certificate before calling <code>Verify</code>. 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>
<p><br />
</p>
<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>
<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">                  <a class="code" href="struct_verifier_precomp.html">VerifierPrecomp</a>* verifier_precomp,</div><div class="line">                  <span class="keywordtype">bool</span> verifier_precomp_is_input) {</div></div><!-- fragment --></p>
<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>
<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>
<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>
<p>The member and the verifier agree on the message, basename, hash algorithm, and SigRL that the verifier uses for verification.</p>
<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>
<p><br />
</p>
<p>Next we do basic variable setup.</p>
<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>
<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>
<p><br />
</p>
<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>
<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>
<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>
<p><br />
</p>
<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>
<p><div class="fragment"><div class="line">    result = <a class="code" href="group___epid_verifier_module.html#ga1d116daaee5466a1485d26ebc4e3ab70">EpidVerifierCreate</a>(</div><div class="line">        &amp;pub_key, verifier_precomp_is_input ? verifier_precomp : NULL, &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>
<p>If a pre-computation blob is provided to the top level application, we use it. Otherwise, we pass in <code>NULL</code>.</p>
<p><br />
</p>
<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>
<p><div class="fragment"><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>
<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>
<p><br />
</p>
<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>
<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>
<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>
<p><br />
</p>
<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>
<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>
<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>
<p><br />
</p>
<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>
<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>
<p><br />
</p>
<p>We set the private key based revocation list using <a class="el" href="group___epid_verifier_module.html#gafab08180a43b58ce2e1d56c4b070bb0e" title="Sets the private key based revocation list. ">EpidVerifierSetPrivRl</a>.</p>
<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#ggafdb27c77c2c4b32c807e326a8a0da360aeedd19b8a1cbdecf963f90b4860e02b8">kEpidSigInvalid</a> == result) {</div><div class="line">        <span class="comment">// authentication failure</span></div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</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 = AllocBuffer(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>
<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>
<ul>
<li>extract the private key based revocation list</li>
<li>validate that the revocation list was signed by the private key corresponding to the provided CA certificate</li>
<li>validate that the size of the input buffer is correct</li>
<li>determine the required size of the revocation list output buffer</li>
</ul>
<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>
<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>
<p><br />
</p>
<p>Next, we set the signature based revocation list using <a class="el" href="group___epid_verifier_module.html#ga4c7c9820409ee06f30bb8dc75fdd5dcf" title="Sets the signature based revocation list. ">EpidVerifierSetSigRl</a>.</p>
<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#ggafdb27c77c2c4b32c807e326a8a0da360aeedd19b8a1cbdecf963f90b4860e02b8">kEpidSigInvalid</a> == result) {</div><div class="line">        <span class="comment">// authentication failure</span></div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</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 = AllocBuffer(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>
<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>
<ul>
<li>extract the signature based revocation list</li>
<li>validate that the revocation list was signed by the private key corresponding to the provided CA certificate</li>
<li>validate that the size of the input buffer is correct</li>
<li>determine the required size of the revocation list output buffer</li>
</ul>
<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>
<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>
<p><br />
</p>
<p>Next, we set the group based revocation list using <a class="el" href="group___epid_verifier_module.html#ga1d41d6ef4dabbc30ec28452edd6baffb" title="Sets the group based revocation list. ">EpidVerifierSetGroupRl</a>.</p>
<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#ggafdb27c77c2c4b32c807e326a8a0da360aeedd19b8a1cbdecf963f90b4860e02b8">kEpidSigInvalid</a> == result) {</div><div class="line">        <span class="comment">// authentication failure</span></div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</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 = AllocBuffer(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>
<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>
<ul>
<li>extract the group based revocation list</li>
<li>validate that the revocation list was signed by the private key corresponding to the provided CA certificate</li>
<li>validate that the size of the input buffer is correct</li>
<li>determine the required size of the revocation list output buffer</li>
</ul>
<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>
<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>
<p><br />
</p>
<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>
<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>
<p>The verifier is responsible for ensuring that the verifier revocation list is authorized. Validating it is outside the scope of this example.</p>
<p><br />
</p>
<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>
<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 />
</p>
<p>Finally, we clean up and exit.</p>
<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>
<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>
<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>
<p>After deleting the verifier context, we can also delete the revocation lists.</p>
<p>We return from <code>Verify</code> with the success or error status.</p>
<p><br />
</p>
<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>
<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="EpidOverview.html">Introduction to the Intel&reg; EPID Scheme</a> in the documentation. </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.10-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">
      &copy; 2016 Intel Corporation
    </li>
  </ul>
</div>
</body>
</html>