123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <!-- 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® Enhanced Privacy ID SDK: Implementation Notes</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® Enhanced Privacy ID SDK</a>
-  <span id="projectnumber">2.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('ImplementationNotes.html','');});
- </script>
- <div id="doc-content">
- <div class="header">
- <div class="headertitle">
- <div class="title">Implementation Notes </div> </div>
- </div><!--header-->
- <div class="contents">
- <div class="toc"><h3>Table of Contents</h3>
- <ul><li class="level1"><a href="#ImplementationNotes_Prng">Random Number Generation</a></li>
- <li class="level1"><a href="#ImplementationNotes_ProtectingSecrets">Protecting Secrets</a></li>
- <li class="level1"><a href="#ImplementationNotes_MathPrimitives">Replacing Math Primitives</a></li>
- <li class="level1"><a href="#ImplementationNotes_SerializedTypes">Octstring/Buffer Types</a></li>
- <li class="level1"><a href="#ImplementationNotes_FlexibleArrays">Flexible Arrays</a></li>
- </ul>
- </div>
- <div class="textblock"><h1><a class="anchor" id="ImplementationNotes_Prng"></a>
- Random Number Generation</h1>
- <p>Some SDK APIs require a random number data source. A <a class="el" href="group___epid_common.html#ga6119a2c0323a3fca9e502b24bc378c2c" title="Generates random data. ">BitSupplier</a> provides a source of random data. This function should be a cryptographically secure random number generator.</p>
- <dl class="section warning"><dt>Warning</dt><dd>The pseudo-random number generator provided with the examples is for sample use only and is not suitable for cryptographically secure applications.</dd></dl>
- <h1><a class="anchor" id="ImplementationNotes_ProtectingSecrets"></a>
- Protecting Secrets</h1>
- <p>Member code works with private keys, so member code must be run in a trusted environment.</p>
- <dl class="section warning"><dt>Warning</dt><dd>If member memory is available to an untrusted source, the member private key could be exposed.</dd></dl>
- <p>The <a class="el" href="group___epid_common.html#gad471f600f6032f432b99432fda97a070" title="Clear information stored in block of memory pointer to by ptr. ">EpidZeroMemory</a> function is used by the memory allocation routines <a class="el" href="group___epid_common.html#gada170fd890504b013139f4a33033ae4b" title="Allocates memory of size bytes. ">EpidAlloc</a>, <a class="el" href="group___epid_common.html#ga6911838728d546e4a51d7bcb8404525c" title="Reallocates memory allocated by EpidAlloc. ">EpidRealloc</a> and <a class="el" href="group___epid_common.html#gaeae76709e6bfc80c9d79ec4943ccc1ac" title="Frees memory allocated by EpidAlloc. ">EpidFree</a> to wipe the memory as memory is freed.</p>
- <dl class="section warning"><dt>Warning</dt><dd>The <a class="el" href="group___epid_common.html#gad471f600f6032f432b99432fda97a070" title="Clear information stored in block of memory pointer to by ptr. ">EpidZeroMemory</a> function may be optimized away by some compilers. If it is, you should consider using a compiler or operating system specific memory sanitization function (e.g. memcpy_s or SecureZeroMemory).</dd></dl>
- <h1><a class="anchor" id="ImplementationNotes_MathPrimitives"></a>
- Replacing Math Primitives</h1>
- <p>SDK math primitives are designed to be replaced with your own implementation if you need to rely on custom hardware for performance. The SDK is designed to simplify this process by isolating implementation details behind a clearly defined interface, defined by the non-internal headers the <code>epid/common/math</code> directory. Math functionality has detailed tests to ease validation.</p>
- <h1><a class="anchor" id="ImplementationNotes_SerializedTypes"></a>
- Octstring/Buffer Types</h1>
- <p>Serialized information in the SDK is passed in fixed size buffer types whenever possible. Collectively these fixed size buffer types are called Octstrings.</p>
- <p>In <a class="el" href="types_8h.html" title="SDK data types. ">epid/common/types.h</a>, there are a large number of packed structs that contain other packed structs, which eventually contain OctStr* types. Normally these are named *Str and are refered to as Str types.</p>
- <p>OctStr* types are buffers that hold N bits, where N is the number at the end of the type name. These types usually represent numbers in a Big Endian format (buffer[0] is the most significant value).</p>
- <p>Str types generally represent fixed size groups of numbers such as a point or vector.</p>
- <p>OctStr* and Str types are usually populated by reading a buffer from a file or other storage, or by calling a serialize function. OctStr* and Str types must be packed so that the compiler does not insert padding. In the current code, this is done using pragmas.</p>
- <div class="fragment"><div class="line"><span class="preprocessor">#pragma pack(1)</span></div><div class="line"></div><div class="line"><span class="comment">// OctStr* type holding 256 bits</span></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct_oct_str256.html">OctStr256</a> {</div><div class="line"> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="struct_oct_str256.html#a359781bb84f5717a16094583a00ef14e">data</a>[256 / CHAR_BIT]; </div><div class="line">} <a class="code" href="struct_oct_str256.html">OctStr256</a>;</div><div class="line"></div><div class="line"><span class="comment">// Str type consisting of a single 256 bit number</span></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct_fq_elem_str.html">FqElemStr</a> {</div><div class="line"> <a class="code" href="struct_oct_str256.html">OctStr256</a> <a class="code" href="struct_oct_str256.html#a359781bb84f5717a16094583a00ef14e">data</a>; </div><div class="line">} <a class="code" href="struct_fq_elem_str.html">FqElemStr</a>;</div><div class="line"></div><div class="line"><span class="comment">// Str type consisting of a two other Str types</span></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct_g1_elem_str.html">G1ElemStr</a> {</div><div class="line"> <a class="code" href="struct_fq_elem_str.html">FqElemStr</a> x; </div><div class="line"> <a class="code" href="struct_fq_elem_str.html">FqElemStr</a> y; </div><div class="line">} <a class="code" href="struct_g1_elem_str.html">G1ElemStr</a>;</div></div><!-- fragment --><p>Many APIs use void* parameters where OctStr* types are expected. If more than one size is allowed, a size parameter is usually also required.</p>
- <h1><a class="anchor" id="ImplementationNotes_FlexibleArrays"></a>
- Flexible Arrays</h1>
- <p>A common idiom in the SDK is the use of flexible array types. These types are structs with the last element being an array of size 1 of some type. Flexible array types always have a size value embedded in the struct. The name of the count and array fields differs between flexible array types.</p>
- <div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>Sample {</div><div class="line"> <a class="code" href="struct_oct_str32.html">OctStr32</a> data; </div><div class="line"> <a class="code" href="struct_oct_str32.html">OctStr32</a> count; </div><div class="line"> <a class="code" href="struct_g1_elem_str.html">G1ElemStr</a> array[1]; </div><div class="line">} Sample;</div></div><!-- fragment --><p>Flexible array types are expected to be in a buffer of size <code>sizeof(FA) + ((N-1) * sizeof(E))</code> where FA is the flexible array type, N is the number of elements in the array and E is the type of each element. Note that this may be smaller than <code>sizeof(FA)</code> if N is 0, in which case referencing any element is an error.</p>
- <div class="fragment"><div class="line">Sample* AllocSample(<span class="keywordtype">size_t</span> count) {</div><div class="line"> <span class="keywordflow">return</span> (Sample*)malloc(<span class="keyword">sizeof</span>(Sample)</div><div class="line"> + (count * <span class="keyword">sizeof</span>(<a class="code" href="struct_g1_elem_str.html">G1ElemStr</a>))</div><div class="line"> - <span class="keyword">sizeof</span>(<a class="code" href="struct_g1_elem_str.html">G1ElemStr</a>));</div><div class="line">}</div></div><!-- fragment --><p>In many cases, functions that accept flexible array types will also expect a buffer size that is compared against the computed size of the array as a sanity check. </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">
- © 2016 Intel Corporation
- </li>
- </ul>
- </div>
- </body>
- </html>
|