Jaeden Amero | e54e693 | 2018-08-06 16:19:58 +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.13"/> |
| 7 | <meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 8 | <title>Platform Security Architecture — cryptography and keystore interface: Message digests</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="search/search.css" rel="stylesheet" type="text/css"/> |
| 13 | <script type="text/javascript" src="search/searchdata.js"></script> |
| 14 | <script type="text/javascript" src="search/search.js"></script> |
| 15 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 16 | </head> |
| 17 | <body> |
| 18 | <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 19 | <div id="titlearea"> |
| 20 | <table cellspacing="0" cellpadding="0"> |
| 21 | <tbody> |
| 22 | <tr style="height: 56px;"> |
| 23 | <td id="projectalign" style="padding-left: 0.5em;"> |
| 24 | <div id="projectname">Platform Security Architecture — cryptography and keystore interface |
| 25 |  <span id="projectnumber">Working draft</span> |
| 26 | </div> |
| 27 | </td> |
| 28 | </tr> |
| 29 | </tbody> |
| 30 | </table> |
| 31 | </div> |
| 32 | <!-- end header part --> |
| 33 | <!-- Generated by Doxygen 1.8.13 --> |
| 34 | <script type="text/javascript"> |
| 35 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| 36 | </script> |
| 37 | <script type="text/javascript" src="menudata.js"></script> |
| 38 | <script type="text/javascript" src="menu.js"></script> |
| 39 | <script type="text/javascript"> |
| 40 | $(function() { |
| 41 | initMenu('',true,false,'search.php','Search'); |
| 42 | $(document).ready(function() { init_search(); }); |
| 43 | }); |
| 44 | </script> |
| 45 | <div id="main-nav"></div> |
| 46 | </div><!-- top --> |
| 47 | <!-- window showing the filter options --> |
| 48 | <div id="MSearchSelectWindow" |
| 49 | onmouseover="return searchBox.OnSearchSelectShow()" |
| 50 | onmouseout="return searchBox.OnSearchSelectHide()" |
| 51 | onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| 52 | </div> |
| 53 | |
| 54 | <!-- iframe showing the search results (closed by default) --> |
| 55 | <div id="MSearchResultsWindow"> |
| 56 | <iframe src="javascript:void(0)" frameborder="0" |
| 57 | name="MSearchResults" id="MSearchResults"> |
| 58 | </iframe> |
| 59 | </div> |
| 60 | |
| 61 | <div class="header"> |
| 62 | <div class="summary"> |
| 63 | <a href="#define-members">Macros</a> | |
| 64 | <a href="#typedef-members">Typedefs</a> | |
| 65 | <a href="#func-members">Functions</a> </div> |
| 66 | <div class="headertitle"> |
| 67 | <div class="title">Message digests</div> </div> |
| 68 | </div><!--header--> |
| 69 | <div class="contents"> |
| 70 | <table class="memberdecls"> |
| 71 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a> |
| 72 | Macros</h2></td></tr> |
| 73 | <tr class="memitem:gaef340331ce3cba2b57e1fc5624bf1f99"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__hash.html#gaef340331ce3cba2b57e1fc5624bf1f99">PSA_HASH_SIZE</a>(alg)</td></tr> |
| 74 | <tr class="separator:gaef340331ce3cba2b57e1fc5624bf1f99"><td class="memSeparator" colspan="2"> </td></tr> |
| 75 | </table><table class="memberdecls"> |
| 76 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a> |
| 77 | Typedefs</h2></td></tr> |
| 78 | <tr class="memitem:ga3c4205d2ce66c4095fc5c78c25273fab"><td class="memItemLeft" align="right" valign="top">typedef struct psa_hash_operation_s </td><td class="memItemRight" valign="bottom"><a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a></td></tr> |
| 79 | <tr class="separator:ga3c4205d2ce66c4095fc5c78c25273fab"><td class="memSeparator" colspan="2"> </td></tr> |
| 80 | </table><table class="memberdecls"> |
| 81 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> |
| 82 | Functions</h2></td></tr> |
| 83 | <tr class="memitem:ga8d72896cf70fc4d514c5c6b978912515"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup</a> (<a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a> *operation, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg)</td></tr> |
| 84 | <tr class="separator:ga8d72896cf70fc4d514c5c6b978912515"><td class="memSeparator" colspan="2"> </td></tr> |
| 85 | <tr class="memitem:ga65b16ef97d7f650899b7db4b7d1112ff"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__hash.html#ga65b16ef97d7f650899b7db4b7d1112ff">psa_hash_update</a> (<a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a> *operation, const uint8_t *input, size_t input_length)</td></tr> |
| 86 | <tr class="separator:ga65b16ef97d7f650899b7db4b7d1112ff"><td class="memSeparator" colspan="2"> </td></tr> |
| 87 | <tr class="memitem:ga4795fd06a0067b0adcd92e9627b8c97e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__hash.html#ga4795fd06a0067b0adcd92e9627b8c97e">psa_hash_finish</a> (<a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a> *operation, uint8_t *hash, size_t hash_size, size_t *hash_length)</td></tr> |
| 88 | <tr class="separator:ga4795fd06a0067b0adcd92e9627b8c97e"><td class="memSeparator" colspan="2"> </td></tr> |
| 89 | <tr class="memitem:ga7be923c5700c9c70ef77ee9b76d1a5c0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__hash.html#ga7be923c5700c9c70ef77ee9b76d1a5c0">psa_hash_verify</a> (<a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a> *operation, const uint8_t *hash, size_t hash_length)</td></tr> |
| 90 | <tr class="separator:ga7be923c5700c9c70ef77ee9b76d1a5c0"><td class="memSeparator" colspan="2"> </td></tr> |
| 91 | <tr class="memitem:gab0b4d5f9912a615559497a467b532928"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__hash.html#gab0b4d5f9912a615559497a467b532928">psa_hash_abort</a> (<a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a> *operation)</td></tr> |
| 92 | <tr class="separator:gab0b4d5f9912a615559497a467b532928"><td class="memSeparator" colspan="2"> </td></tr> |
| 93 | </table> |
| 94 | <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> |
| 95 | <h2 class="groupheader">Macro Definition Documentation</h2> |
| 96 | <a id="gaef340331ce3cba2b57e1fc5624bf1f99"></a> |
| 97 | <h2 class="memtitle"><span class="permalink"><a href="#gaef340331ce3cba2b57e1fc5624bf1f99">◆ </a></span>PSA_HASH_SIZE</h2> |
| 98 | |
| 99 | <div class="memitem"> |
| 100 | <div class="memproto"> |
| 101 | <table class="memname"> |
| 102 | <tr> |
| 103 | <td class="memname">#define PSA_HASH_SIZE</td> |
| 104 | <td>(</td> |
| 105 | <td class="paramtype"> </td> |
| 106 | <td class="paramname">alg</td><td>)</td> |
| 107 | <td></td> |
| 108 | </tr> |
| 109 | </table> |
| 110 | </div><div class="memdoc"> |
| 111 | <b>Value:</b><div class="fragment"><div class="line">( \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == PSA_ALG_MD2 ? 16 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == PSA_ALG_MD4 ? 16 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == PSA_ALG_MD5 ? 16 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == PSA_ALG_RIPEMD160 ? 20 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == PSA_ALG_SHA_1 ? 20 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == <a class="code" href="group__crypto__types.html#ga25d6a3244d10a7148fe6b026d1979f7b">PSA_ALG_SHA_224</a> ? 28 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == <a class="code" href="group__crypto__types.html#ga619471f978e13cdd0a1e37145e4bf341">PSA_ALG_SHA_256</a> ? 32 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == <a class="code" href="group__crypto__types.html#ga58af64dd9a86a287e8da9ed7739eead4">PSA_ALG_SHA_384</a> ? 48 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == <a class="code" href="group__crypto__types.html#gafba3ae409f46d3dd7f37a0910660c3e9">PSA_ALG_SHA_512</a> ? 64 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == <a class="code" href="group__crypto__types.html#ga3fe2d7c3c80e3186ca78d16a35d5d931">PSA_ALG_SHA_512_224</a> ? 28 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == <a class="code" href="group__crypto__types.html#ga5910b3964c14e9613e8643a45b09c2d4">PSA_ALG_SHA_512_256</a> ? 32 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == <a class="code" href="group__crypto__types.html#ga16f5fe34ccce68c2fada1224c054a999">PSA_ALG_SHA3_224</a> ? 28 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == <a class="code" href="group__crypto__types.html#gaace70d9515489bbe3c5e7ac1b7d9155b">PSA_ALG_SHA3_256</a> ? 32 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == <a class="code" href="group__crypto__types.html#gab0f079257ea75e2acfe2fc3b38c78cd8">PSA_ALG_SHA3_384</a> ? 48 : \</div><div class="line"> PSA_ALG_HMAC_HASH(alg) == <a class="code" href="group__crypto__types.html#ga37e5dbe936dddb155e76f2997de27188">PSA_ALG_SHA3_512</a> ? 64 : \</div><div class="line"> 0)</div><div class="ttc" id="group__crypto__types_html_gaace70d9515489bbe3c5e7ac1b7d9155b"><div class="ttname"><a href="group__crypto__types.html#gaace70d9515489bbe3c5e7ac1b7d9155b">PSA_ALG_SHA3_256</a></div><div class="ttdeci">#define PSA_ALG_SHA3_256</div><div class="ttdef"><b>Definition:</b> crypto.h:686</div></div> |
| 112 | <div class="ttc" id="group__crypto__types_html_ga16f5fe34ccce68c2fada1224c054a999"><div class="ttname"><a href="group__crypto__types.html#ga16f5fe34ccce68c2fada1224c054a999">PSA_ALG_SHA3_224</a></div><div class="ttdeci">#define PSA_ALG_SHA3_224</div><div class="ttdef"><b>Definition:</b> crypto.h:684</div></div> |
| 113 | <div class="ttc" id="group__crypto__types_html_ga37e5dbe936dddb155e76f2997de27188"><div class="ttname"><a href="group__crypto__types.html#ga37e5dbe936dddb155e76f2997de27188">PSA_ALG_SHA3_512</a></div><div class="ttdeci">#define PSA_ALG_SHA3_512</div><div class="ttdef"><b>Definition:</b> crypto.h:690</div></div> |
| 114 | <div class="ttc" id="group__crypto__types_html_ga619471f978e13cdd0a1e37145e4bf341"><div class="ttname"><a href="group__crypto__types.html#ga619471f978e13cdd0a1e37145e4bf341">PSA_ALG_SHA_256</a></div><div class="ttdeci">#define PSA_ALG_SHA_256</div><div class="ttdef"><b>Definition:</b> crypto.h:674</div></div> |
| 115 | <div class="ttc" id="group__crypto__types_html_gafba3ae409f46d3dd7f37a0910660c3e9"><div class="ttname"><a href="group__crypto__types.html#gafba3ae409f46d3dd7f37a0910660c3e9">PSA_ALG_SHA_512</a></div><div class="ttdeci">#define PSA_ALG_SHA_512</div><div class="ttdef"><b>Definition:</b> crypto.h:678</div></div> |
| 116 | <div class="ttc" id="group__crypto__types_html_ga25d6a3244d10a7148fe6b026d1979f7b"><div class="ttname"><a href="group__crypto__types.html#ga25d6a3244d10a7148fe6b026d1979f7b">PSA_ALG_SHA_224</a></div><div class="ttdeci">#define PSA_ALG_SHA_224</div><div class="ttdef"><b>Definition:</b> crypto.h:672</div></div> |
| 117 | <div class="ttc" id="group__crypto__types_html_ga58af64dd9a86a287e8da9ed7739eead4"><div class="ttname"><a href="group__crypto__types.html#ga58af64dd9a86a287e8da9ed7739eead4">PSA_ALG_SHA_384</a></div><div class="ttdeci">#define PSA_ALG_SHA_384</div><div class="ttdef"><b>Definition:</b> crypto.h:676</div></div> |
| 118 | <div class="ttc" id="group__crypto__types_html_ga3fe2d7c3c80e3186ca78d16a35d5d931"><div class="ttname"><a href="group__crypto__types.html#ga3fe2d7c3c80e3186ca78d16a35d5d931">PSA_ALG_SHA_512_224</a></div><div class="ttdeci">#define PSA_ALG_SHA_512_224</div><div class="ttdef"><b>Definition:</b> crypto.h:680</div></div> |
| 119 | <div class="ttc" id="group__crypto__types_html_ga5910b3964c14e9613e8643a45b09c2d4"><div class="ttname"><a href="group__crypto__types.html#ga5910b3964c14e9613e8643a45b09c2d4">PSA_ALG_SHA_512_256</a></div><div class="ttdeci">#define PSA_ALG_SHA_512_256</div><div class="ttdef"><b>Definition:</b> crypto.h:682</div></div> |
| 120 | <div class="ttc" id="group__crypto__types_html_gab0f079257ea75e2acfe2fc3b38c78cd8"><div class="ttname"><a href="group__crypto__types.html#gab0f079257ea75e2acfe2fc3b38c78cd8">PSA_ALG_SHA3_384</a></div><div class="ttdeci">#define PSA_ALG_SHA3_384</div><div class="ttdef"><b>Definition:</b> crypto.h:688</div></div> |
| 121 | </div><!-- fragment --><p>The size of the output of <a class="el" href="group__hash.html#ga4795fd06a0067b0adcd92e9627b8c97e">psa_hash_finish()</a>, in bytes.</p> |
| 122 | <p>This is also the hash size that <a class="el" href="group__hash.html#ga7be923c5700c9c70ef77ee9b76d1a5c0">psa_hash_verify()</a> expects.</p> |
| 123 | <dl class="params"><dt>Parameters</dt><dd> |
| 124 | <table class="params"> |
| 125 | <tr><td class="paramname">alg</td><td>A hash algorithm (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#gac9280662bb482590b4b33d1dcd32930f">PSA_ALG_IS_HASH</a>(<code>alg</code>) is true), or an HMAC algorithm (<a class="el" href="group__crypto__types.html#ga70f397425684b3efcde1e0e34c28261f">PSA_ALG_HMAC</a>(<code>hash_alg</code>) where <code>hash_alg</code> is a hash algorithm).</td></tr> |
| 126 | </table> |
| 127 | </dd> |
| 128 | </dl> |
| 129 | <dl class="section return"><dt>Returns</dt><dd>The hash size for the specified hash algorithm. If the hash algorithm is not recognized, return 0. An implementation may return either 0 or the correct size for a hash algorithm that it recognizes, but does not support. </dd></dl> |
| 130 | |
| 131 | </div> |
| 132 | </div> |
| 133 | <h2 class="groupheader">Typedef Documentation</h2> |
| 134 | <a id="ga3c4205d2ce66c4095fc5c78c25273fab"></a> |
| 135 | <h2 class="memtitle"><span class="permalink"><a href="#ga3c4205d2ce66c4095fc5c78c25273fab">◆ </a></span>psa_hash_operation_t</h2> |
| 136 | |
| 137 | <div class="memitem"> |
| 138 | <div class="memproto"> |
| 139 | <table class="memname"> |
| 140 | <tr> |
| 141 | <td class="memname">typedef struct psa_hash_operation_s <a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a></td> |
| 142 | </tr> |
| 143 | </table> |
| 144 | </div><div class="memdoc"> |
| 145 | <p>The type of the state data structure for multipart hash operations.</p> |
| 146 | <p>This is an implementation-defined <code>struct</code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation. </p> |
| 147 | |
| 148 | </div> |
| 149 | </div> |
| 150 | <h2 class="groupheader">Function Documentation</h2> |
| 151 | <a id="gab0b4d5f9912a615559497a467b532928"></a> |
| 152 | <h2 class="memtitle"><span class="permalink"><a href="#gab0b4d5f9912a615559497a467b532928">◆ </a></span>psa_hash_abort()</h2> |
| 153 | |
| 154 | <div class="memitem"> |
| 155 | <div class="memproto"> |
| 156 | <table class="memname"> |
| 157 | <tr> |
| 158 | <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_hash_abort </td> |
| 159 | <td>(</td> |
| 160 | <td class="paramtype"><a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a> * </td> |
| 161 | <td class="paramname"><em>operation</em></td><td>)</td> |
| 162 | <td></td> |
| 163 | </tr> |
| 164 | </table> |
| 165 | </div><div class="memdoc"> |
| 166 | <p>Abort a hash operation.</p> |
| 167 | <p>Aborting an operation frees all associated resources except for the <code>operation</code> structure itself. Once aborted, the operation object can be reused for another operation by calling <a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup()</a> again.</p> |
| 168 | <p>You may call this function any time after the operation object has been initialized by any of the following methods:</p><ul> |
| 169 | <li>A call to <a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup()</a>, whether it succeeds or not.</li> |
| 170 | <li>Initializing the <code>struct</code> to all-bits-zero.</li> |
| 171 | <li>Initializing the <code>struct</code> to logical zeros, e.g. <code>psa_hash_operation_t operation = {0}</code>.</li> |
| 172 | </ul> |
| 173 | <p>In particular, calling <a class="el" href="group__hash.html#gab0b4d5f9912a615559497a467b532928">psa_hash_abort()</a> after the operation has been terminated by a call to <a class="el" href="group__hash.html#gab0b4d5f9912a615559497a467b532928">psa_hash_abort()</a>, <a class="el" href="group__hash.html#ga4795fd06a0067b0adcd92e9627b8c97e">psa_hash_finish()</a> or <a class="el" href="group__hash.html#ga7be923c5700c9c70ef77ee9b76d1a5c0">psa_hash_verify()</a> is safe and has no effect.</p> |
| 174 | <dl class="params"><dt>Parameters</dt><dd> |
| 175 | <table class="params"> |
| 176 | <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Initialized hash operation.</td></tr> |
| 177 | </table> |
| 178 | </dd> |
| 179 | </dl> |
| 180 | <dl class="retval"><dt>Return values</dt><dd> |
| 181 | <table class="retval"> |
| 182 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td></td></tr> |
| 183 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td><code>operation</code> is not an active hash operation. </td></tr> |
| 184 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 185 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 186 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 187 | </table> |
| 188 | </dd> |
| 189 | </dl> |
| 190 | |
| 191 | </div> |
| 192 | </div> |
| 193 | <a id="ga4795fd06a0067b0adcd92e9627b8c97e"></a> |
| 194 | <h2 class="memtitle"><span class="permalink"><a href="#ga4795fd06a0067b0adcd92e9627b8c97e">◆ </a></span>psa_hash_finish()</h2> |
| 195 | |
| 196 | <div class="memitem"> |
| 197 | <div class="memproto"> |
| 198 | <table class="memname"> |
| 199 | <tr> |
| 200 | <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_hash_finish </td> |
| 201 | <td>(</td> |
| 202 | <td class="paramtype"><a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a> * </td> |
| 203 | <td class="paramname"><em>operation</em>, </td> |
| 204 | </tr> |
| 205 | <tr> |
| 206 | <td class="paramkey"></td> |
| 207 | <td></td> |
| 208 | <td class="paramtype">uint8_t * </td> |
| 209 | <td class="paramname"><em>hash</em>, </td> |
| 210 | </tr> |
| 211 | <tr> |
| 212 | <td class="paramkey"></td> |
| 213 | <td></td> |
| 214 | <td class="paramtype">size_t </td> |
| 215 | <td class="paramname"><em>hash_size</em>, </td> |
| 216 | </tr> |
| 217 | <tr> |
| 218 | <td class="paramkey"></td> |
| 219 | <td></td> |
| 220 | <td class="paramtype">size_t * </td> |
| 221 | <td class="paramname"><em>hash_length</em> </td> |
| 222 | </tr> |
| 223 | <tr> |
| 224 | <td></td> |
| 225 | <td>)</td> |
| 226 | <td></td><td></td> |
| 227 | </tr> |
| 228 | </table> |
| 229 | </div><div class="memdoc"> |
| 230 | <p>Finish the calculation of the hash of a message.</p> |
| 231 | <p>The application must call <a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup()</a> before calling this function. This function calculates the hash of the message formed by concatenating the inputs passed to preceding calls to <a class="el" href="group__hash.html#ga65b16ef97d7f650899b7db4b7d1112ff">psa_hash_update()</a>.</p> |
| 232 | <p>When this function returns, the operation becomes inactive.</p> |
| 233 | <dl class="section warning"><dt>Warning</dt><dd>Applications should not call this function if they expect a specific value for the hash. Call <a class="el" href="group__hash.html#ga7be923c5700c9c70ef77ee9b76d1a5c0">psa_hash_verify()</a> instead. Beware that comparing integrity or authenticity data such as hash values with a function such as <code>memcmp</code> is risky because the time taken by the comparison may leak information about the hashed data which could allow an attacker to guess a valid hash and thereby bypass security controls.</dd></dl> |
| 234 | <dl class="params"><dt>Parameters</dt><dd> |
| 235 | <table class="params"> |
| 236 | <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Active hash operation. </td></tr> |
| 237 | <tr><td class="paramdir">[out]</td><td class="paramname">hash</td><td>Buffer where the hash is to be written. </td></tr> |
| 238 | <tr><td class="paramdir"></td><td class="paramname">hash_size</td><td>Size of the <code>hash</code> buffer in bytes. </td></tr> |
| 239 | <tr><td class="paramdir">[out]</td><td class="paramname">hash_length</td><td>On success, the number of bytes that make up the hash value. This is always <a class="el" href="group__hash.html#gaef340331ce3cba2b57e1fc5624bf1f99">PSA_HASH_SIZE</a>(<code>alg</code>) where <code>alg</code> is the hash algorithm that is calculated.</td></tr> |
| 240 | </table> |
| 241 | </dd> |
| 242 | </dl> |
| 243 | <dl class="retval"><dt>Return values</dt><dd> |
| 244 | <table class="retval"> |
| 245 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| 246 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The operation state is not valid (not started, or already completed). </td></tr> |
| 247 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga695025f4ec11249aee7ea3d0f65e01c8">PSA_ERROR_BUFFER_TOO_SMALL</a></td><td>The size of the <code>hash</code> buffer is too small. You can determine a sufficient buffer size by calling <a class="el" href="group__hash.html#gaef340331ce3cba2b57e1fc5624bf1f99">PSA_HASH_SIZE</a>(<code>alg</code>) where <code>alg</code> is the hash algorithm that is calculated. </td></tr> |
| 248 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| 249 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 250 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 251 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 252 | </table> |
| 253 | </dd> |
| 254 | </dl> |
| 255 | |
| 256 | </div> |
| 257 | </div> |
| 258 | <a id="ga8d72896cf70fc4d514c5c6b978912515"></a> |
| 259 | <h2 class="memtitle"><span class="permalink"><a href="#ga8d72896cf70fc4d514c5c6b978912515">◆ </a></span>psa_hash_setup()</h2> |
| 260 | |
| 261 | <div class="memitem"> |
| 262 | <div class="memproto"> |
| 263 | <table class="memname"> |
| 264 | <tr> |
| 265 | <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_hash_setup </td> |
| 266 | <td>(</td> |
| 267 | <td class="paramtype"><a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a> * </td> |
| 268 | <td class="paramname"><em>operation</em>, </td> |
| 269 | </tr> |
| 270 | <tr> |
| 271 | <td class="paramkey"></td> |
| 272 | <td></td> |
| 273 | <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> </td> |
| 274 | <td class="paramname"><em>alg</em> </td> |
| 275 | </tr> |
| 276 | <tr> |
| 277 | <td></td> |
| 278 | <td>)</td> |
| 279 | <td></td><td></td> |
| 280 | </tr> |
| 281 | </table> |
| 282 | </div><div class="memdoc"> |
| 283 | <p>Start a multipart hash operation.</p> |
| 284 | <p>The sequence of operations to calculate a hash (message digest) is as follows:</p><ol type="1"> |
| 285 | <li>Allocate an operation object which will be passed to all the functions listed here.</li> |
| 286 | <li>Call <a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup()</a> to specify the algorithm.</li> |
| 287 | <li>Call <a class="el" href="group__hash.html#ga65b16ef97d7f650899b7db4b7d1112ff">psa_hash_update()</a> zero, one or more times, passing a fragment of the message each time. The hash that is calculated is the hash of the concatenation of these messages in order.</li> |
| 288 | <li>To calculate the hash, call <a class="el" href="group__hash.html#ga4795fd06a0067b0adcd92e9627b8c97e">psa_hash_finish()</a>. To compare the hash with an expected value, call <a class="el" href="group__hash.html#ga7be923c5700c9c70ef77ee9b76d1a5c0">psa_hash_verify()</a>.</li> |
| 289 | </ol> |
| 290 | <p>The application may call <a class="el" href="group__hash.html#gab0b4d5f9912a615559497a467b532928">psa_hash_abort()</a> at any time after the operation has been initialized with <a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup()</a>.</p> |
| 291 | <p>After a successful call to <a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup()</a>, the application must eventually terminate the operation. The following events terminate an operation:</p><ul> |
| 292 | <li>A failed call to <a class="el" href="group__hash.html#ga65b16ef97d7f650899b7db4b7d1112ff">psa_hash_update()</a>.</li> |
| 293 | <li>A call to <a class="el" href="group__hash.html#ga4795fd06a0067b0adcd92e9627b8c97e">psa_hash_finish()</a>, <a class="el" href="group__hash.html#ga7be923c5700c9c70ef77ee9b76d1a5c0">psa_hash_verify()</a> or <a class="el" href="group__hash.html#gab0b4d5f9912a615559497a467b532928">psa_hash_abort()</a>.</li> |
| 294 | </ul> |
| 295 | <dl class="params"><dt>Parameters</dt><dd> |
| 296 | <table class="params"> |
| 297 | <tr><td class="paramdir">[out]</td><td class="paramname">operation</td><td>The operation object to use. </td></tr> |
| 298 | <tr><td class="paramdir"></td><td class="paramname">alg</td><td>The hash algorithm to compute (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#gac9280662bb482590b4b33d1dcd32930f">PSA_ALG_IS_HASH</a>(<code>alg</code>) is true).</td></tr> |
| 299 | </table> |
| 300 | </dd> |
| 301 | </dl> |
| 302 | <dl class="retval"><dt>Return values</dt><dd> |
| 303 | <table class="retval"> |
| 304 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| 305 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td><code>alg</code> is not supported or is not a hash algorithm. </td></tr> |
| 306 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| 307 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 308 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 309 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 310 | </table> |
| 311 | </dd> |
| 312 | </dl> |
| 313 | |
| 314 | </div> |
| 315 | </div> |
| 316 | <a id="ga65b16ef97d7f650899b7db4b7d1112ff"></a> |
| 317 | <h2 class="memtitle"><span class="permalink"><a href="#ga65b16ef97d7f650899b7db4b7d1112ff">◆ </a></span>psa_hash_update()</h2> |
| 318 | |
| 319 | <div class="memitem"> |
| 320 | <div class="memproto"> |
| 321 | <table class="memname"> |
| 322 | <tr> |
| 323 | <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_hash_update </td> |
| 324 | <td>(</td> |
| 325 | <td class="paramtype"><a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a> * </td> |
| 326 | <td class="paramname"><em>operation</em>, </td> |
| 327 | </tr> |
| 328 | <tr> |
| 329 | <td class="paramkey"></td> |
| 330 | <td></td> |
| 331 | <td class="paramtype">const uint8_t * </td> |
| 332 | <td class="paramname"><em>input</em>, </td> |
| 333 | </tr> |
| 334 | <tr> |
| 335 | <td class="paramkey"></td> |
| 336 | <td></td> |
| 337 | <td class="paramtype">size_t </td> |
| 338 | <td class="paramname"><em>input_length</em> </td> |
| 339 | </tr> |
| 340 | <tr> |
| 341 | <td></td> |
| 342 | <td>)</td> |
| 343 | <td></td><td></td> |
| 344 | </tr> |
| 345 | </table> |
| 346 | </div><div class="memdoc"> |
| 347 | <p>Add a message fragment to a multipart hash operation.</p> |
| 348 | <p>The application must call <a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup()</a> before calling this function.</p> |
| 349 | <p>If this function returns an error status, the operation becomes inactive.</p> |
| 350 | <dl class="params"><dt>Parameters</dt><dd> |
| 351 | <table class="params"> |
| 352 | <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Active hash operation. </td></tr> |
| 353 | <tr><td class="paramdir">[in]</td><td class="paramname">input</td><td>Buffer containing the message fragment to hash. </td></tr> |
| 354 | <tr><td class="paramdir"></td><td class="paramname">input_length</td><td>Size of the <code>input</code> buffer in bytes.</td></tr> |
| 355 | </table> |
| 356 | </dd> |
| 357 | </dl> |
| 358 | <dl class="retval"><dt>Return values</dt><dd> |
| 359 | <table class="retval"> |
| 360 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| 361 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The operation state is not valid (not started, or already completed). </td></tr> |
| 362 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| 363 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 364 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 365 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 366 | </table> |
| 367 | </dd> |
| 368 | </dl> |
| 369 | |
| 370 | </div> |
| 371 | </div> |
| 372 | <a id="ga7be923c5700c9c70ef77ee9b76d1a5c0"></a> |
| 373 | <h2 class="memtitle"><span class="permalink"><a href="#ga7be923c5700c9c70ef77ee9b76d1a5c0">◆ </a></span>psa_hash_verify()</h2> |
| 374 | |
| 375 | <div class="memitem"> |
| 376 | <div class="memproto"> |
| 377 | <table class="memname"> |
| 378 | <tr> |
| 379 | <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_hash_verify </td> |
| 380 | <td>(</td> |
| 381 | <td class="paramtype"><a class="el" href="group__hash.html#ga3c4205d2ce66c4095fc5c78c25273fab">psa_hash_operation_t</a> * </td> |
| 382 | <td class="paramname"><em>operation</em>, </td> |
| 383 | </tr> |
| 384 | <tr> |
| 385 | <td class="paramkey"></td> |
| 386 | <td></td> |
| 387 | <td class="paramtype">const uint8_t * </td> |
| 388 | <td class="paramname"><em>hash</em>, </td> |
| 389 | </tr> |
| 390 | <tr> |
| 391 | <td class="paramkey"></td> |
| 392 | <td></td> |
| 393 | <td class="paramtype">size_t </td> |
| 394 | <td class="paramname"><em>hash_length</em> </td> |
| 395 | </tr> |
| 396 | <tr> |
| 397 | <td></td> |
| 398 | <td>)</td> |
| 399 | <td></td><td></td> |
| 400 | </tr> |
| 401 | </table> |
| 402 | </div><div class="memdoc"> |
| 403 | <p>Finish the calculation of the hash of a message and compare it with an expected value.</p> |
| 404 | <p>The application must call <a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup()</a> before calling this function. This function calculates the hash of the message formed by concatenating the inputs passed to preceding calls to <a class="el" href="group__hash.html#ga65b16ef97d7f650899b7db4b7d1112ff">psa_hash_update()</a>. It then compares the calculated hash with the expected hash passed as a parameter to this function.</p> |
| 405 | <p>When this function returns, the operation becomes inactive.</p> |
| 406 | <dl class="section note"><dt>Note</dt><dd>Implementations shall make the best effort to ensure that the comparison between the actual hash and the expected hash is performed in constant time.</dd></dl> |
| 407 | <dl class="params"><dt>Parameters</dt><dd> |
| 408 | <table class="params"> |
| 409 | <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Active hash operation. </td></tr> |
| 410 | <tr><td class="paramdir">[in]</td><td class="paramname">hash</td><td>Buffer containing the expected hash value. </td></tr> |
| 411 | <tr><td class="paramdir"></td><td class="paramname">hash_length</td><td>Size of the <code>hash</code> buffer in bytes.</td></tr> |
| 412 | </table> |
| 413 | </dd> |
| 414 | </dl> |
| 415 | <dl class="retval"><dt>Return values</dt><dd> |
| 416 | <table class="retval"> |
| 417 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>The expected hash is identical to the actual hash of the message. </td></tr> |
| 418 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga35927f755d232c4766de600f2c49e9f2">PSA_ERROR_INVALID_SIGNATURE</a></td><td>The hash of the message was calculated successfully, but it differs from the expected hash. </td></tr> |
| 419 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The operation state is not valid (not started, or already completed). </td></tr> |
| 420 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| 421 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 422 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 423 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 424 | </table> |
| 425 | </dd> |
| 426 | </dl> |
| 427 | |
| 428 | </div> |
| 429 | </div> |
| 430 | </div><!-- contents --> |
| 431 | <!-- start footer part --> |
| 432 | <hr class="footer"/><address class="footer"><small> |
| 433 | Generated by  <a href="http://www.doxygen.org/index.html"> |
| 434 | <img class="footer" src="doxygen.png" alt="doxygen"/> |
| 435 | </a> 1.8.13 |
| 436 | </small></address> |
| 437 | </body> |
| 438 | </html> |