Gilles Peskine | 89f0a53 | 2019-01-31 11:47:57 +0100 | [diff] [blame^] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 5 | <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| 6 | <meta name="generator" content="Doxygen 1.8.11"/> |
| 7 | <title>Platform Security Architecture — cryptography and keystore interface: Random generation</title> |
| 8 | <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 9 | <script type="text/javascript" src="jquery.js"></script> |
| 10 | <script type="text/javascript" src="dynsections.js"></script> |
| 11 | <link href="search/search.css" rel="stylesheet" type="text/css"/> |
| 12 | <script type="text/javascript" src="search/searchdata.js"></script> |
| 13 | <script type="text/javascript" src="search/search.js"></script> |
| 14 | <script type="text/javascript"> |
| 15 | $(document).ready(function() { init_search(); }); |
| 16 | </script> |
| 17 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 18 | </head> |
| 19 | <body> |
| 20 | <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 21 | <div id="titlearea"> |
| 22 | <table cellspacing="0" cellpadding="0"> |
| 23 | <tbody> |
| 24 | <tr style="height: 56px;"> |
| 25 | <td id="projectalign" style="padding-left: 0.5em;"> |
| 26 | <div id="projectname">Platform Security Architecture — cryptography and keystore interface |
| 27 |  <span id="projectnumber">beta 1 — 2019-01-21</span> |
| 28 | </div> |
| 29 | </td> |
| 30 | </tr> |
| 31 | </tbody> |
| 32 | </table> |
| 33 | </div> |
| 34 | <!-- end header part --> |
| 35 | <!-- Generated by Doxygen 1.8.11 --> |
| 36 | <script type="text/javascript"> |
| 37 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| 38 | </script> |
| 39 | <div id="navrow1" class="tabs"> |
| 40 | <ul class="tablist"> |
| 41 | <li><a href="index.html"><span>Main Page</span></a></li> |
| 42 | <li class="current"><a href="modules.html"><span>Modules</span></a></li> |
| 43 | <li><a href="annotated.html"><span>Classes</span></a></li> |
| 44 | <li><a href="files.html"><span>Files</span></a></li> |
| 45 | <li> |
| 46 | <div id="MSearchBox" class="MSearchBoxInactive"> |
| 47 | <span class="left"> |
| 48 | <img id="MSearchSelect" src="search/mag_sel.png" |
| 49 | onmouseover="return searchBox.OnSearchSelectShow()" |
| 50 | onmouseout="return searchBox.OnSearchSelectHide()" |
| 51 | alt=""/> |
| 52 | <input type="text" id="MSearchField" value="Search" accesskey="S" |
| 53 | onfocus="searchBox.OnSearchFieldFocus(true)" |
| 54 | onblur="searchBox.OnSearchFieldFocus(false)" |
| 55 | onkeyup="searchBox.OnSearchFieldChange(event)"/> |
| 56 | </span><span class="right"> |
| 57 | <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> |
| 58 | </span> |
| 59 | </div> |
| 60 | </li> |
| 61 | </ul> |
| 62 | </div> |
| 63 | </div><!-- top --> |
| 64 | <!-- window showing the filter options --> |
| 65 | <div id="MSearchSelectWindow" |
| 66 | onmouseover="return searchBox.OnSearchSelectShow()" |
| 67 | onmouseout="return searchBox.OnSearchSelectHide()" |
| 68 | onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| 69 | </div> |
| 70 | |
| 71 | <!-- iframe showing the search results (closed by default) --> |
| 72 | <div id="MSearchResultsWindow"> |
| 73 | <iframe src="javascript:void(0)" frameborder="0" |
| 74 | name="MSearchResults" id="MSearchResults"> |
| 75 | </iframe> |
| 76 | </div> |
| 77 | |
| 78 | <div class="header"> |
| 79 | <div class="summary"> |
| 80 | <a href="#nested-classes">Classes</a> | |
| 81 | <a href="#func-members">Functions</a> </div> |
| 82 | <div class="headertitle"> |
| 83 | <div class="title">Random generation</div> </div> |
| 84 | </div><!--header--> |
| 85 | <div class="contents"> |
| 86 | <table class="memberdecls"> |
| 87 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a> |
| 88 | Classes</h2></td></tr> |
| 89 | <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structpsa__generate__key__extra__rsa.html">psa_generate_key_extra_rsa</a></td></tr> |
| 90 | <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> |
| 91 | </table><table class="memberdecls"> |
| 92 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> |
| 93 | Functions</h2></td></tr> |
| 94 | <tr class="memitem:ga1985eae417dfbccedf50d5fff54ea8c5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__random.html#ga1985eae417dfbccedf50d5fff54ea8c5">psa_generate_random</a> (uint8_t *output, size_t output_size)</td></tr> |
| 95 | <tr class="memdesc:ga1985eae417dfbccedf50d5fff54ea8c5"><td class="mdescLeft"> </td><td class="mdescRight">Generate random bytes. <a href="#ga1985eae417dfbccedf50d5fff54ea8c5">More...</a><br /></td></tr> |
| 96 | <tr class="separator:ga1985eae417dfbccedf50d5fff54ea8c5"><td class="memSeparator" colspan="2"> </td></tr> |
| 97 | <tr class="memitem:ga72921520494b4f007a3afb904cd9ecdd"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__random.html#ga72921520494b4f007a3afb904cd9ecdd">psa_generate_key</a> (<a class="el" href="group__platform.html#gabf6d5fd4e2ea89ecd425c88f057e7f75">psa_key_handle_t</a> handle, <a class="el" href="group__crypto__types.html#ga578159487dfc7096cb191b0d2befe628">psa_key_type_t</a> type, size_t bits, const void *extra, size_t extra_size)</td></tr> |
| 98 | <tr class="memdesc:ga72921520494b4f007a3afb904cd9ecdd"><td class="mdescLeft"> </td><td class="mdescRight">Generate a key or key pair. <a href="#ga72921520494b4f007a3afb904cd9ecdd">More...</a><br /></td></tr> |
| 99 | <tr class="separator:ga72921520494b4f007a3afb904cd9ecdd"><td class="memSeparator" colspan="2"> </td></tr> |
| 100 | </table> |
| 101 | <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> |
| 102 | <h2 class="groupheader">Function Documentation</h2> |
| 103 | <a class="anchor" id="ga72921520494b4f007a3afb904cd9ecdd"></a> |
| 104 | <div class="memitem"> |
| 105 | <div class="memproto"> |
| 106 | <table class="memname"> |
| 107 | <tr> |
| 108 | <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_generate_key </td> |
| 109 | <td>(</td> |
| 110 | <td class="paramtype"><a class="el" href="group__platform.html#gabf6d5fd4e2ea89ecd425c88f057e7f75">psa_key_handle_t</a> </td> |
| 111 | <td class="paramname"><em>handle</em>, </td> |
| 112 | </tr> |
| 113 | <tr> |
| 114 | <td class="paramkey"></td> |
| 115 | <td></td> |
| 116 | <td class="paramtype"><a class="el" href="group__crypto__types.html#ga578159487dfc7096cb191b0d2befe628">psa_key_type_t</a> </td> |
| 117 | <td class="paramname"><em>type</em>, </td> |
| 118 | </tr> |
| 119 | <tr> |
| 120 | <td class="paramkey"></td> |
| 121 | <td></td> |
| 122 | <td class="paramtype">size_t </td> |
| 123 | <td class="paramname"><em>bits</em>, </td> |
| 124 | </tr> |
| 125 | <tr> |
| 126 | <td class="paramkey"></td> |
| 127 | <td></td> |
| 128 | <td class="paramtype">const void * </td> |
| 129 | <td class="paramname"><em>extra</em>, </td> |
| 130 | </tr> |
| 131 | <tr> |
| 132 | <td class="paramkey"></td> |
| 133 | <td></td> |
| 134 | <td class="paramtype">size_t </td> |
| 135 | <td class="paramname"><em>extra_size</em> </td> |
| 136 | </tr> |
| 137 | <tr> |
| 138 | <td></td> |
| 139 | <td>)</td> |
| 140 | <td></td><td></td> |
| 141 | </tr> |
| 142 | </table> |
| 143 | </div><div class="memdoc"> |
| 144 | |
| 145 | <p>Generate a key or key pair. </p> |
| 146 | <dl class="params"><dt>Parameters</dt><dd> |
| 147 | <table class="params"> |
| 148 | <tr><td class="paramdir"></td><td class="paramname">handle</td><td>Handle to the slot where the key will be stored. It must have been obtained by calling <a class="el" href="group__key__management.html#ga40094b77b7a42b9c8e158395113f1a35">psa_allocate_key()</a> or <a class="el" href="group__key__management.html#ga4108f255d3eaa6d23a7a14b684af8d7c">psa_create_key()</a> and must not contain key material yet. </td></tr> |
| 149 | <tr><td class="paramdir"></td><td class="paramname">type</td><td>Key type (a <code>PSA_KEY_TYPE_XXX</code> value). </td></tr> |
| 150 | <tr><td class="paramdir"></td><td class="paramname">bits</td><td>Key size in bits. </td></tr> |
| 151 | <tr><td class="paramdir">[in]</td><td class="paramname">extra</td><td>Extra parameters for key generation. The interpretation of this parameter depends on <code>type</code>. All types support <code>NULL</code> to use default parameters. Implementation that support the generation of vendor-specific key types that allow extra parameters shall document the format of these extra parameters and the default values. For standard parameters, the meaning of <code>extra</code> is as follows:<ul> |
| 152 | <li>For a symmetric key type (a type such that <a class="el" href="group__crypto__types.html#gab138ae2ebf2905dfbaf4154db2620939">PSA_KEY_TYPE_IS_ASYMMETRIC</a>(<code>type</code>) is false), <code>extra</code> must be <code>NULL</code>.</li> |
| 153 | <li>For an elliptic curve key type (a type such that <a class="el" href="group__crypto__types.html#ga88e01fa06b585654689a99bcc06bbe66">PSA_KEY_TYPE_IS_ECC</a>(<code>type</code>) is false), <code>extra</code> must be <code>NULL</code>.</li> |
| 154 | <li>For an RSA key (<code>type</code> is <a class="el" href="group__crypto__types.html#ga581f50687f5d650456925278948f2799">PSA_KEY_TYPE_RSA_KEYPAIR</a>), <code>extra</code> is an optional <a class="el" href="structpsa__generate__key__extra__rsa.html">psa_generate_key_extra_rsa</a> structure specifying the public exponent. The default public exponent used when <code>extra</code> is <code>NULL</code> is 65537.</li> |
| 155 | <li>For an DSA key (<code>type</code> is <a class="el" href="group__crypto__types.html#ga011010ee28c20388f3d89fb27088ed62">PSA_KEY_TYPE_DSA_KEYPAIR</a>), <code>extra</code> is an optional structure specifying the key domain parameters. The key domain parameters can also be provided by <a class="el" href="group__import__export.html#ga091da8d3d39137fd6ad59f2b10234300" title="Set domain parameters for a key. ">psa_set_key_domain_parameters()</a>, which documents the format of the structure.</li> |
| 156 | <li>For a DH key (<code>type</code> is <a class="el" href="group__crypto__types.html#ga39b63c6b97a62a316c0660bf72b2fdd5">PSA_KEY_TYPE_DH_KEYPAIR</a>), the <code>extra</code> is an optional structure specifying the key domain parameters. The key domain parameters can also be provided by <a class="el" href="group__import__export.html#ga091da8d3d39137fd6ad59f2b10234300" title="Set domain parameters for a key. ">psa_set_key_domain_parameters()</a>, which documents the format of the structure. </li> |
| 157 | </ul> |
| 158 | </td></tr> |
| 159 | <tr><td class="paramdir"></td><td class="paramname">extra_size</td><td>Size of the buffer that <code>extra</code> points to, in bytes. Note that if <code>extra</code> is <code>NULL</code> then <code>extra_size</code> must be zero.</td></tr> |
| 160 | </table> |
| 161 | </dd> |
| 162 | </dl> |
| 163 | <dl class="retval"><dt>Return values</dt><dd> |
| 164 | <table class="retval"> |
| 165 | <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. If the key is persistent, the key material and the key's metadata have been saved to persistent storage. </td></tr> |
| 166 | <tr><td class="paramname"><a class="el" href="group__error.html#gadf22718935657c2c3168c228204085f9">PSA_ERROR_INVALID_HANDLE</a></td><td></td></tr> |
| 167 | <tr><td class="paramname"><a class="el" href="group__error.html#gac2fee3a51249fbea45360aaa911f3e58">PSA_ERROR_OCCUPIED_SLOT</a></td><td>There is already a key in the specified slot. </td></tr> |
| 168 | <tr><td class="paramname"><a class="el" href="group__error.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td></td></tr> |
| 169 | <tr><td class="paramname"><a class="el" href="group__error.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td></td></tr> |
| 170 | <tr><td class="paramname"><a class="el" href="group__error.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| 171 | <tr><td class="paramname"><a class="el" href="group__error.html#ga4deb59fec02297ec5d8b42178323f675">PSA_ERROR_INSUFFICIENT_ENTROPY</a></td><td></td></tr> |
| 172 | <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 173 | <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 174 | <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 175 | <tr><td class="paramname"><a class="el" href="group__error.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The library has not been previously initialized by <a class="el" href="group__initialization.html#ga2de150803fc2f7dc6101d5af7e921dd9" title="Library initialization. ">psa_crypto_init()</a>. It is implementation-dependent whether a failure to initialize results in this error code. </td></tr> |
| 176 | </table> |
| 177 | </dd> |
| 178 | </dl> |
| 179 | |
| 180 | </div> |
| 181 | </div> |
| 182 | <a class="anchor" id="ga1985eae417dfbccedf50d5fff54ea8c5"></a> |
| 183 | <div class="memitem"> |
| 184 | <div class="memproto"> |
| 185 | <table class="memname"> |
| 186 | <tr> |
| 187 | <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_generate_random </td> |
| 188 | <td>(</td> |
| 189 | <td class="paramtype">uint8_t * </td> |
| 190 | <td class="paramname"><em>output</em>, </td> |
| 191 | </tr> |
| 192 | <tr> |
| 193 | <td class="paramkey"></td> |
| 194 | <td></td> |
| 195 | <td class="paramtype">size_t </td> |
| 196 | <td class="paramname"><em>output_size</em> </td> |
| 197 | </tr> |
| 198 | <tr> |
| 199 | <td></td> |
| 200 | <td>)</td> |
| 201 | <td></td><td></td> |
| 202 | </tr> |
| 203 | </table> |
| 204 | </div><div class="memdoc"> |
| 205 | |
| 206 | <p>Generate random bytes. </p> |
| 207 | <dl class="section warning"><dt>Warning</dt><dd>This function <b>can</b> fail! Callers MUST check the return status and MUST NOT use the content of the output buffer if the return status is not <a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a>.</dd></dl> |
| 208 | <dl class="section note"><dt>Note</dt><dd>To generate a key, use <a class="el" href="group__random.html#ga72921520494b4f007a3afb904cd9ecdd" title="Generate a key or key pair. ">psa_generate_key()</a> instead.</dd></dl> |
| 209 | <dl class="params"><dt>Parameters</dt><dd> |
| 210 | <table class="params"> |
| 211 | <tr><td class="paramdir">[out]</td><td class="paramname">output</td><td>Output buffer for the generated data. </td></tr> |
| 212 | <tr><td class="paramdir"></td><td class="paramname">output_size</td><td>Number of bytes to generate and output.</td></tr> |
| 213 | </table> |
| 214 | </dd> |
| 215 | </dl> |
| 216 | <dl class="retval"><dt>Return values</dt><dd> |
| 217 | <table class="retval"> |
| 218 | <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td></td></tr> |
| 219 | <tr><td class="paramname"><a class="el" href="group__error.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td></td></tr> |
| 220 | <tr><td class="paramname"><a class="el" href="group__error.html#ga4deb59fec02297ec5d8b42178323f675">PSA_ERROR_INSUFFICIENT_ENTROPY</a></td><td></td></tr> |
| 221 | <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 222 | <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 223 | <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 224 | <tr><td class="paramname"><a class="el" href="group__error.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The library has not been previously initialized by <a class="el" href="group__initialization.html#ga2de150803fc2f7dc6101d5af7e921dd9" title="Library initialization. ">psa_crypto_init()</a>. It is implementation-dependent whether a failure to initialize results in this error code. </td></tr> |
| 225 | </table> |
| 226 | </dd> |
| 227 | </dl> |
| 228 | |
| 229 | </div> |
| 230 | </div> |
| 231 | </div><!-- contents --> |
| 232 | <!-- start footer part --> |
| 233 | <hr class="footer"/><address class="footer"><small> |
| 234 | Generated by  <a href="http://www.doxygen.org/index.html"> |
| 235 | <img class="footer" src="doxygen.png" alt="doxygen"/> |
| 236 | </a> 1.8.11 |
| 237 | </small></address> |
| 238 | </body> |
| 239 | </html> |