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: Asymmetric cryptography</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="#func-members">Functions</a> </div> |
| 65 | <div class="headertitle"> |
| 66 | <div class="title">Asymmetric cryptography</div> </div> |
| 67 | </div><!--header--> |
| 68 | <div class="contents"> |
| 69 | <table class="memberdecls"> |
| 70 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a> |
| 71 | Macros</h2></td></tr> |
| 72 | <tr class="memitem:ga10c472a35f04051add6b20cc228ffc11"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__asymmetric.html#ga10c472a35f04051add6b20cc228ffc11">PSA_ECDSA_SIGNATURE_SIZE</a>(curve_bits)   (PSA_BITS_TO_BYTES(curve_bits) * 2)</td></tr> |
| 73 | <tr class="memdesc:ga10c472a35f04051add6b20cc228ffc11"><td class="mdescLeft"> </td><td class="mdescRight">ECDSA signature size for a given curve bit size. <a href="#ga10c472a35f04051add6b20cc228ffc11">More...</a><br /></td></tr> |
| 74 | <tr class="separator:ga10c472a35f04051add6b20cc228ffc11"><td class="memSeparator" colspan="2"> </td></tr> |
| 75 | <tr class="memitem:gaec0bcba60e7514b83f967b171d494ed3"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><b>PSA_RSA_MINIMUM_PADDING_SIZE</b>(alg)</td></tr> |
| 76 | <tr class="separator:gaec0bcba60e7514b83f967b171d494ed3"><td class="memSeparator" colspan="2"> </td></tr> |
| 77 | </table><table class="memberdecls"> |
| 78 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> |
| 79 | Functions</h2></td></tr> |
| 80 | <tr class="memitem:ga48091460d1ead078d93caa3611aec976"><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__asymmetric.html#ga48091460d1ead078d93caa3611aec976">psa_asymmetric_sign</a> (<a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a> key, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg, const uint8_t *hash, size_t hash_length, uint8_t *signature, size_t signature_size, size_t *signature_length)</td></tr> |
| 81 | <tr class="memdesc:ga48091460d1ead078d93caa3611aec976"><td class="mdescLeft"> </td><td class="mdescRight">Sign a hash or short message with a private key. <a href="#ga48091460d1ead078d93caa3611aec976">More...</a><br /></td></tr> |
| 82 | <tr class="separator:ga48091460d1ead078d93caa3611aec976"><td class="memSeparator" colspan="2"> </td></tr> |
| 83 | <tr class="memitem:gaee3e92946c1c4b3dfa90879e2f7d1321"><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__asymmetric.html#gaee3e92946c1c4b3dfa90879e2f7d1321">psa_asymmetric_verify</a> (<a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a> key, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg, const uint8_t *hash, size_t hash_length, const uint8_t *signature, size_t signature_length)</td></tr> |
| 84 | <tr class="memdesc:gaee3e92946c1c4b3dfa90879e2f7d1321"><td class="mdescLeft"> </td><td class="mdescRight">Verify the signature a hash or short message using a public key. <a href="#gaee3e92946c1c4b3dfa90879e2f7d1321">More...</a><br /></td></tr> |
| 85 | <tr class="separator:gaee3e92946c1c4b3dfa90879e2f7d1321"><td class="memSeparator" colspan="2"> </td></tr> |
| 86 | <tr class="memitem:ga3c0ba402bac217d623dba8320c2240c2"><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__asymmetric.html#ga3c0ba402bac217d623dba8320c2240c2">psa_asymmetric_encrypt</a> (<a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a> key, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg, const uint8_t *input, size_t input_length, const uint8_t *salt, size_t salt_length, uint8_t *output, size_t output_size, size_t *output_length)</td></tr> |
| 87 | <tr class="memdesc:ga3c0ba402bac217d623dba8320c2240c2"><td class="mdescLeft"> </td><td class="mdescRight">Encrypt a short message with a public key. <a href="#ga3c0ba402bac217d623dba8320c2240c2">More...</a><br /></td></tr> |
| 88 | <tr class="separator:ga3c0ba402bac217d623dba8320c2240c2"><td class="memSeparator" colspan="2"> </td></tr> |
| 89 | <tr class="memitem:ga3094be979f37aa2865c283167ba907e6"><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__asymmetric.html#ga3094be979f37aa2865c283167ba907e6">psa_asymmetric_decrypt</a> (<a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a> key, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg, const uint8_t *input, size_t input_length, const uint8_t *salt, size_t salt_length, uint8_t *output, size_t output_size, size_t *output_length)</td></tr> |
| 90 | <tr class="memdesc:ga3094be979f37aa2865c283167ba907e6"><td class="mdescLeft"> </td><td class="mdescRight">Decrypt a short message with a private key. <a href="#ga3094be979f37aa2865c283167ba907e6">More...</a><br /></td></tr> |
| 91 | <tr class="separator:ga3094be979f37aa2865c283167ba907e6"><td class="memSeparator" colspan="2"> </td></tr> |
| 92 | </table> |
| 93 | <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> |
| 94 | <h2 class="groupheader">Macro Definition Documentation</h2> |
| 95 | <a id="ga10c472a35f04051add6b20cc228ffc11"></a> |
| 96 | <h2 class="memtitle"><span class="permalink"><a href="#ga10c472a35f04051add6b20cc228ffc11">◆ </a></span>PSA_ECDSA_SIGNATURE_SIZE</h2> |
| 97 | |
| 98 | <div class="memitem"> |
| 99 | <div class="memproto"> |
| 100 | <table class="memname"> |
| 101 | <tr> |
| 102 | <td class="memname">#define PSA_ECDSA_SIGNATURE_SIZE</td> |
| 103 | <td>(</td> |
| 104 | <td class="paramtype"> </td> |
| 105 | <td class="paramname">curve_bits</td><td>)</td> |
| 106 | <td>   (PSA_BITS_TO_BYTES(curve_bits) * 2)</td> |
| 107 | </tr> |
| 108 | </table> |
| 109 | </div><div class="memdoc"> |
| 110 | |
| 111 | <p>ECDSA signature size for a given curve bit size. </p> |
| 112 | <dl class="params"><dt>Parameters</dt><dd> |
| 113 | <table class="params"> |
| 114 | <tr><td class="paramname">curve_bits</td><td>Curve size in bits. </td></tr> |
| 115 | </table> |
| 116 | </dd> |
| 117 | </dl> |
| 118 | <dl class="section return"><dt>Returns</dt><dd>Signature size in bytes.</dd></dl> |
| 119 | <dl class="section note"><dt>Note</dt><dd>This macro returns a compile-time constant if its argument is one. </dd></dl> |
| 120 | |
| 121 | </div> |
| 122 | </div> |
| 123 | <a id="gaec0bcba60e7514b83f967b171d494ed3"></a> |
| 124 | <h2 class="memtitle"><span class="permalink"><a href="#gaec0bcba60e7514b83f967b171d494ed3">◆ </a></span>PSA_RSA_MINIMUM_PADDING_SIZE</h2> |
| 125 | |
| 126 | <div class="memitem"> |
| 127 | <div class="memproto"> |
| 128 | <table class="memname"> |
| 129 | <tr> |
| 130 | <td class="memname">#define PSA_RSA_MINIMUM_PADDING_SIZE</td> |
| 131 | <td>(</td> |
| 132 | <td class="paramtype"> </td> |
| 133 | <td class="paramname">alg</td><td>)</td> |
| 134 | <td></td> |
| 135 | </tr> |
| 136 | </table> |
| 137 | </div><div class="memdoc"> |
| 138 | <b>Value:</b><div class="fragment"><div class="line">(PSA_ALG_IS_RSA_OAEP(alg) ? \</div><div class="line"> 2 * PSA_HASH_FINAL_SIZE(PSA_ALG_RSA_OAEP_GET_HASH(alg)) + 1 : \</div><div class="line"> 11 <span class="comment">/*PKCS#1v1.5*/</span>)</div></div><!-- fragment --> |
| 139 | </div> |
| 140 | </div> |
| 141 | <h2 class="groupheader">Function Documentation</h2> |
| 142 | <a id="ga3094be979f37aa2865c283167ba907e6"></a> |
| 143 | <h2 class="memtitle"><span class="permalink"><a href="#ga3094be979f37aa2865c283167ba907e6">◆ </a></span>psa_asymmetric_decrypt()</h2> |
| 144 | |
| 145 | <div class="memitem"> |
| 146 | <div class="memproto"> |
| 147 | <table class="memname"> |
| 148 | <tr> |
| 149 | <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_asymmetric_decrypt </td> |
| 150 | <td>(</td> |
| 151 | <td class="paramtype"><a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a> </td> |
| 152 | <td class="paramname"><em>key</em>, </td> |
| 153 | </tr> |
| 154 | <tr> |
| 155 | <td class="paramkey"></td> |
| 156 | <td></td> |
| 157 | <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> </td> |
| 158 | <td class="paramname"><em>alg</em>, </td> |
| 159 | </tr> |
| 160 | <tr> |
| 161 | <td class="paramkey"></td> |
| 162 | <td></td> |
| 163 | <td class="paramtype">const uint8_t * </td> |
| 164 | <td class="paramname"><em>input</em>, </td> |
| 165 | </tr> |
| 166 | <tr> |
| 167 | <td class="paramkey"></td> |
| 168 | <td></td> |
| 169 | <td class="paramtype">size_t </td> |
| 170 | <td class="paramname"><em>input_length</em>, </td> |
| 171 | </tr> |
| 172 | <tr> |
| 173 | <td class="paramkey"></td> |
| 174 | <td></td> |
| 175 | <td class="paramtype">const uint8_t * </td> |
| 176 | <td class="paramname"><em>salt</em>, </td> |
| 177 | </tr> |
| 178 | <tr> |
| 179 | <td class="paramkey"></td> |
| 180 | <td></td> |
| 181 | <td class="paramtype">size_t </td> |
| 182 | <td class="paramname"><em>salt_length</em>, </td> |
| 183 | </tr> |
| 184 | <tr> |
| 185 | <td class="paramkey"></td> |
| 186 | <td></td> |
| 187 | <td class="paramtype">uint8_t * </td> |
| 188 | <td class="paramname"><em>output</em>, </td> |
| 189 | </tr> |
| 190 | <tr> |
| 191 | <td class="paramkey"></td> |
| 192 | <td></td> |
| 193 | <td class="paramtype">size_t </td> |
| 194 | <td class="paramname"><em>output_size</em>, </td> |
| 195 | </tr> |
| 196 | <tr> |
| 197 | <td class="paramkey"></td> |
| 198 | <td></td> |
| 199 | <td class="paramtype">size_t * </td> |
| 200 | <td class="paramname"><em>output_length</em> </td> |
| 201 | </tr> |
| 202 | <tr> |
| 203 | <td></td> |
| 204 | <td>)</td> |
| 205 | <td></td><td></td> |
| 206 | </tr> |
| 207 | </table> |
| 208 | </div><div class="memdoc"> |
| 209 | |
| 210 | <p>Decrypt a short message with a private key. </p> |
| 211 | <dl class="params"><dt>Parameters</dt><dd> |
| 212 | <table class="params"> |
| 213 | <tr><td class="paramdir"></td><td class="paramname">key</td><td>Key slot containing an asymmetric key pair. </td></tr> |
| 214 | <tr><td class="paramdir"></td><td class="paramname">alg</td><td>An asymmetric encryption algorithm that is compatible with the type of <code>key</code>. </td></tr> |
| 215 | <tr><td class="paramdir">[in]</td><td class="paramname">input</td><td>The message to decrypt. </td></tr> |
| 216 | <tr><td class="paramdir"></td><td class="paramname">input_length</td><td>Size of the <code>input</code> buffer in bytes. </td></tr> |
| 217 | <tr><td class="paramdir">[in]</td><td class="paramname">salt</td><td>A salt or label, if supported by the encryption algorithm. If the algorithm does not support a salt, pass <code>NULL</code>. If the algorithm supports an optional salt and you do not want to pass a salt, pass <code>NULL</code>.</td></tr> |
| 218 | </table> |
| 219 | </dd> |
| 220 | </dl> |
| 221 | <ul> |
| 222 | <li>For <a class="el" href="group__crypto__types.html#ga4c540d3abe43fb9abcb94f2bc51acef9">PSA_ALG_RSA_PKCS1V15_CRYPT</a>, no salt is supported. <dl class="params"><dt>Parameters</dt><dd> |
| 223 | <table class="params"> |
| 224 | <tr><td class="paramdir"></td><td class="paramname">salt_length</td><td>Size of the <code>salt</code> buffer in bytes. If <code>salt</code> is <code>NULL</code>, pass 0. </td></tr> |
| 225 | <tr><td class="paramdir">[out]</td><td class="paramname">output</td><td>Buffer where the decrypted message is to be written. </td></tr> |
| 226 | <tr><td class="paramdir"></td><td class="paramname">output_size</td><td>Size of the <code>output</code> buffer in bytes. </td></tr> |
| 227 | <tr><td class="paramdir">[out]</td><td class="paramname">output_length</td><td>On success, the number of bytes that make up the returned output.</td></tr> |
| 228 | </table> |
| 229 | </dd> |
| 230 | </dl> |
| 231 | <dl class="retval"><dt>Return values</dt><dd> |
| 232 | <table class="retval"> |
| 233 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td></td></tr> |
| 234 | <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>output</code> buffer is too small. You can determine a sufficient buffer size by calling <a class="el" href="crypto__sizes_8h.html#a61a246f3eac41989821d982e56fea6c1">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</a>(<code>key_type</code>, <code>key_bits</code>, <code>alg</code>) where <code>key_type</code> and <code>key_bits</code> are the type and bit-size respectively of <code>key</code>. </td></tr> |
| 235 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td></td></tr> |
| 236 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td></td></tr> |
| 237 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| 238 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 239 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 240 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 241 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4deb59fec02297ec5d8b42178323f675">PSA_ERROR_INSUFFICIENT_ENTROPY</a></td><td></td></tr> |
| 242 | <tr><td class="paramname"><a class="el" href="group__basic.html#gabe29594edbfb152cf153975b0597ac48">PSA_ERROR_INVALID_PADDING</a></td><td></td></tr> |
| 243 | </table> |
| 244 | </dd> |
| 245 | </dl> |
| 246 | </li> |
| 247 | </ul> |
| 248 | |
| 249 | </div> |
| 250 | </div> |
| 251 | <a id="ga3c0ba402bac217d623dba8320c2240c2"></a> |
| 252 | <h2 class="memtitle"><span class="permalink"><a href="#ga3c0ba402bac217d623dba8320c2240c2">◆ </a></span>psa_asymmetric_encrypt()</h2> |
| 253 | |
| 254 | <div class="memitem"> |
| 255 | <div class="memproto"> |
| 256 | <table class="memname"> |
| 257 | <tr> |
| 258 | <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_asymmetric_encrypt </td> |
| 259 | <td>(</td> |
| 260 | <td class="paramtype"><a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a> </td> |
| 261 | <td class="paramname"><em>key</em>, </td> |
| 262 | </tr> |
| 263 | <tr> |
| 264 | <td class="paramkey"></td> |
| 265 | <td></td> |
| 266 | <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> </td> |
| 267 | <td class="paramname"><em>alg</em>, </td> |
| 268 | </tr> |
| 269 | <tr> |
| 270 | <td class="paramkey"></td> |
| 271 | <td></td> |
| 272 | <td class="paramtype">const uint8_t * </td> |
| 273 | <td class="paramname"><em>input</em>, </td> |
| 274 | </tr> |
| 275 | <tr> |
| 276 | <td class="paramkey"></td> |
| 277 | <td></td> |
| 278 | <td class="paramtype">size_t </td> |
| 279 | <td class="paramname"><em>input_length</em>, </td> |
| 280 | </tr> |
| 281 | <tr> |
| 282 | <td class="paramkey"></td> |
| 283 | <td></td> |
| 284 | <td class="paramtype">const uint8_t * </td> |
| 285 | <td class="paramname"><em>salt</em>, </td> |
| 286 | </tr> |
| 287 | <tr> |
| 288 | <td class="paramkey"></td> |
| 289 | <td></td> |
| 290 | <td class="paramtype">size_t </td> |
| 291 | <td class="paramname"><em>salt_length</em>, </td> |
| 292 | </tr> |
| 293 | <tr> |
| 294 | <td class="paramkey"></td> |
| 295 | <td></td> |
| 296 | <td class="paramtype">uint8_t * </td> |
| 297 | <td class="paramname"><em>output</em>, </td> |
| 298 | </tr> |
| 299 | <tr> |
| 300 | <td class="paramkey"></td> |
| 301 | <td></td> |
| 302 | <td class="paramtype">size_t </td> |
| 303 | <td class="paramname"><em>output_size</em>, </td> |
| 304 | </tr> |
| 305 | <tr> |
| 306 | <td class="paramkey"></td> |
| 307 | <td></td> |
| 308 | <td class="paramtype">size_t * </td> |
| 309 | <td class="paramname"><em>output_length</em> </td> |
| 310 | </tr> |
| 311 | <tr> |
| 312 | <td></td> |
| 313 | <td>)</td> |
| 314 | <td></td><td></td> |
| 315 | </tr> |
| 316 | </table> |
| 317 | </div><div class="memdoc"> |
| 318 | |
| 319 | <p>Encrypt a short message with a public key. </p> |
| 320 | <dl class="params"><dt>Parameters</dt><dd> |
| 321 | <table class="params"> |
| 322 | <tr><td class="paramdir"></td><td class="paramname">key</td><td>Key slot containing a public key or an asymmetric key pair. </td></tr> |
| 323 | <tr><td class="paramdir"></td><td class="paramname">alg</td><td>An asymmetric encryption algorithm that is compatible with the type of <code>key</code>. </td></tr> |
| 324 | <tr><td class="paramdir">[in]</td><td class="paramname">input</td><td>The message to encrypt. </td></tr> |
| 325 | <tr><td class="paramdir"></td><td class="paramname">input_length</td><td>Size of the <code>input</code> buffer in bytes. </td></tr> |
| 326 | <tr><td class="paramdir">[in]</td><td class="paramname">salt</td><td>A salt or label, if supported by the encryption algorithm. If the algorithm does not support a salt, pass <code>NULL</code>. If the algorithm supports an optional salt and you do not want to pass a salt, pass <code>NULL</code>.</td></tr> |
| 327 | </table> |
| 328 | </dd> |
| 329 | </dl> |
| 330 | <ul> |
| 331 | <li>For <a class="el" href="group__crypto__types.html#ga4c540d3abe43fb9abcb94f2bc51acef9">PSA_ALG_RSA_PKCS1V15_CRYPT</a>, no salt is supported. <dl class="params"><dt>Parameters</dt><dd> |
| 332 | <table class="params"> |
| 333 | <tr><td class="paramdir"></td><td class="paramname">salt_length</td><td>Size of the <code>salt</code> buffer in bytes. If <code>salt</code> is <code>NULL</code>, pass 0. </td></tr> |
| 334 | <tr><td class="paramdir">[out]</td><td class="paramname">output</td><td>Buffer where the encrypted message is to be written. </td></tr> |
| 335 | <tr><td class="paramdir"></td><td class="paramname">output_size</td><td>Size of the <code>output</code> buffer in bytes. </td></tr> |
| 336 | <tr><td class="paramdir">[out]</td><td class="paramname">output_length</td><td>On success, the number of bytes that make up the returned output.</td></tr> |
| 337 | </table> |
| 338 | </dd> |
| 339 | </dl> |
| 340 | <dl class="retval"><dt>Return values</dt><dd> |
| 341 | <table class="retval"> |
| 342 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td></td></tr> |
| 343 | <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>output</code> buffer is too small. You can determine a sufficient buffer size by calling <a class="el" href="crypto__sizes_8h.html#a66ba3bd93e5ec52870ccc3848778bad8">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</a>(<code>key_type</code>, <code>key_bits</code>, <code>alg</code>) where <code>key_type</code> and <code>key_bits</code> are the type and bit-size respectively of <code>key</code>. </td></tr> |
| 344 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td></td></tr> |
| 345 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td></td></tr> |
| 346 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| 347 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 348 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 349 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 350 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4deb59fec02297ec5d8b42178323f675">PSA_ERROR_INSUFFICIENT_ENTROPY</a></td><td></td></tr> |
| 351 | </table> |
| 352 | </dd> |
| 353 | </dl> |
| 354 | </li> |
| 355 | </ul> |
| 356 | |
| 357 | </div> |
| 358 | </div> |
| 359 | <a id="ga48091460d1ead078d93caa3611aec976"></a> |
| 360 | <h2 class="memtitle"><span class="permalink"><a href="#ga48091460d1ead078d93caa3611aec976">◆ </a></span>psa_asymmetric_sign()</h2> |
| 361 | |
| 362 | <div class="memitem"> |
| 363 | <div class="memproto"> |
| 364 | <table class="memname"> |
| 365 | <tr> |
| 366 | <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_asymmetric_sign </td> |
| 367 | <td>(</td> |
| 368 | <td class="paramtype"><a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a> </td> |
| 369 | <td class="paramname"><em>key</em>, </td> |
| 370 | </tr> |
| 371 | <tr> |
| 372 | <td class="paramkey"></td> |
| 373 | <td></td> |
| 374 | <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> </td> |
| 375 | <td class="paramname"><em>alg</em>, </td> |
| 376 | </tr> |
| 377 | <tr> |
| 378 | <td class="paramkey"></td> |
| 379 | <td></td> |
| 380 | <td class="paramtype">const uint8_t * </td> |
| 381 | <td class="paramname"><em>hash</em>, </td> |
| 382 | </tr> |
| 383 | <tr> |
| 384 | <td class="paramkey"></td> |
| 385 | <td></td> |
| 386 | <td class="paramtype">size_t </td> |
| 387 | <td class="paramname"><em>hash_length</em>, </td> |
| 388 | </tr> |
| 389 | <tr> |
| 390 | <td class="paramkey"></td> |
| 391 | <td></td> |
| 392 | <td class="paramtype">uint8_t * </td> |
| 393 | <td class="paramname"><em>signature</em>, </td> |
| 394 | </tr> |
| 395 | <tr> |
| 396 | <td class="paramkey"></td> |
| 397 | <td></td> |
| 398 | <td class="paramtype">size_t </td> |
| 399 | <td class="paramname"><em>signature_size</em>, </td> |
| 400 | </tr> |
| 401 | <tr> |
| 402 | <td class="paramkey"></td> |
| 403 | <td></td> |
| 404 | <td class="paramtype">size_t * </td> |
| 405 | <td class="paramname"><em>signature_length</em> </td> |
| 406 | </tr> |
| 407 | <tr> |
| 408 | <td></td> |
| 409 | <td>)</td> |
| 410 | <td></td><td></td> |
| 411 | </tr> |
| 412 | </table> |
| 413 | </div><div class="memdoc"> |
| 414 | |
| 415 | <p>Sign a hash or short message with a private key. </p> |
| 416 | <p>Note that to perform a hash-and-sign signature algorithm, you must first calculate the hash by calling <a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup()</a>, <a class="el" href="group__hash.html#ga65b16ef97d7f650899b7db4b7d1112ff">psa_hash_update()</a> and <a class="el" href="group__hash.html#ga4795fd06a0067b0adcd92e9627b8c97e">psa_hash_finish()</a>. Then pass the resulting hash as the <code>hash</code> parameter to this function. You can use <a class="el" href="group__crypto__types.html#ga24cf6d7bcd2b9aeeeff86f07b6c674e3">PSA_ALG_SIGN_GET_HASH</a>(<code>alg</code>) to determine the hash algorithm to use.</p> |
| 417 | <dl class="params"><dt>Parameters</dt><dd> |
| 418 | <table class="params"> |
| 419 | <tr><td class="paramdir"></td><td class="paramname">key</td><td>Key slot containing an asymmetric key pair. </td></tr> |
| 420 | <tr><td class="paramdir"></td><td class="paramname">alg</td><td>A signature algorithm that is compatible with the type of <code>key</code>. </td></tr> |
| 421 | <tr><td class="paramdir">[in]</td><td class="paramname">hash</td><td>The hash or message to sign. </td></tr> |
| 422 | <tr><td class="paramdir"></td><td class="paramname">hash_length</td><td>Size of the <code>hash</code> buffer in bytes. </td></tr> |
| 423 | <tr><td class="paramdir">[out]</td><td class="paramname">signature</td><td>Buffer where the signature is to be written. </td></tr> |
| 424 | <tr><td class="paramdir"></td><td class="paramname">signature_size</td><td>Size of the <code>signature</code> buffer in bytes. </td></tr> |
| 425 | <tr><td class="paramdir">[out]</td><td class="paramname">signature_length</td><td>On success, the number of bytes that make up the returned signature value.</td></tr> |
| 426 | </table> |
| 427 | </dd> |
| 428 | </dl> |
| 429 | <dl class="retval"><dt>Return values</dt><dd> |
| 430 | <table class="retval"> |
| 431 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td></td></tr> |
| 432 | <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>signature</code> buffer is too small. You can determine a sufficient buffer size by calling <a class="el" href="crypto__sizes_8h.html#a77565b9b4fe6d8730fd2120f4c8378ab">PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE</a>(<code>key_type</code>, <code>key_bits</code>, <code>alg</code>) where <code>key_type</code> and <code>key_bits</code> are the type and bit-size respectively of <code>key</code>. </td></tr> |
| 433 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td></td></tr> |
| 434 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td></td></tr> |
| 435 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| 436 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 437 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 438 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 439 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4deb59fec02297ec5d8b42178323f675">PSA_ERROR_INSUFFICIENT_ENTROPY</a></td><td></td></tr> |
| 440 | </table> |
| 441 | </dd> |
| 442 | </dl> |
| 443 | |
| 444 | </div> |
| 445 | </div> |
| 446 | <a id="gaee3e92946c1c4b3dfa90879e2f7d1321"></a> |
| 447 | <h2 class="memtitle"><span class="permalink"><a href="#gaee3e92946c1c4b3dfa90879e2f7d1321">◆ </a></span>psa_asymmetric_verify()</h2> |
| 448 | |
| 449 | <div class="memitem"> |
| 450 | <div class="memproto"> |
| 451 | <table class="memname"> |
| 452 | <tr> |
| 453 | <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_asymmetric_verify </td> |
| 454 | <td>(</td> |
| 455 | <td class="paramtype"><a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a> </td> |
| 456 | <td class="paramname"><em>key</em>, </td> |
| 457 | </tr> |
| 458 | <tr> |
| 459 | <td class="paramkey"></td> |
| 460 | <td></td> |
| 461 | <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> </td> |
| 462 | <td class="paramname"><em>alg</em>, </td> |
| 463 | </tr> |
| 464 | <tr> |
| 465 | <td class="paramkey"></td> |
| 466 | <td></td> |
| 467 | <td class="paramtype">const uint8_t * </td> |
| 468 | <td class="paramname"><em>hash</em>, </td> |
| 469 | </tr> |
| 470 | <tr> |
| 471 | <td class="paramkey"></td> |
| 472 | <td></td> |
| 473 | <td class="paramtype">size_t </td> |
| 474 | <td class="paramname"><em>hash_length</em>, </td> |
| 475 | </tr> |
| 476 | <tr> |
| 477 | <td class="paramkey"></td> |
| 478 | <td></td> |
| 479 | <td class="paramtype">const uint8_t * </td> |
| 480 | <td class="paramname"><em>signature</em>, </td> |
| 481 | </tr> |
| 482 | <tr> |
| 483 | <td class="paramkey"></td> |
| 484 | <td></td> |
| 485 | <td class="paramtype">size_t </td> |
| 486 | <td class="paramname"><em>signature_length</em> </td> |
| 487 | </tr> |
| 488 | <tr> |
| 489 | <td></td> |
| 490 | <td>)</td> |
| 491 | <td></td><td></td> |
| 492 | </tr> |
| 493 | </table> |
| 494 | </div><div class="memdoc"> |
| 495 | |
| 496 | <p>Verify the signature a hash or short message using a public key. </p> |
| 497 | <p>Note that to perform a hash-and-sign signature algorithm, you must first calculate the hash by calling <a class="el" href="group__hash.html#ga8d72896cf70fc4d514c5c6b978912515">psa_hash_setup()</a>, <a class="el" href="group__hash.html#ga65b16ef97d7f650899b7db4b7d1112ff">psa_hash_update()</a> and <a class="el" href="group__hash.html#ga4795fd06a0067b0adcd92e9627b8c97e">psa_hash_finish()</a>. Then pass the resulting hash as the <code>hash</code> parameter to this function. You can use <a class="el" href="group__crypto__types.html#ga24cf6d7bcd2b9aeeeff86f07b6c674e3">PSA_ALG_SIGN_GET_HASH</a>(<code>alg</code>) to determine the hash algorithm to use.</p> |
| 498 | <dl class="params"><dt>Parameters</dt><dd> |
| 499 | <table class="params"> |
| 500 | <tr><td class="paramdir"></td><td class="paramname">key</td><td>Key slot containing a public key or an asymmetric key pair. </td></tr> |
| 501 | <tr><td class="paramdir"></td><td class="paramname">alg</td><td>A signature algorithm that is compatible with the type of <code>key</code>. </td></tr> |
| 502 | <tr><td class="paramdir">[in]</td><td class="paramname">hash</td><td>The hash or message whose signature is to be verified. </td></tr> |
| 503 | <tr><td class="paramdir"></td><td class="paramname">hash_length</td><td>Size of the <code>hash</code> buffer in bytes. </td></tr> |
| 504 | <tr><td class="paramdir">[in]</td><td class="paramname">signature</td><td>Buffer containing the signature to verify. </td></tr> |
| 505 | <tr><td class="paramdir"></td><td class="paramname">signature_length</td><td>Size of the <code>signature</code> buffer in bytes.</td></tr> |
| 506 | </table> |
| 507 | </dd> |
| 508 | </dl> |
| 509 | <dl class="retval"><dt>Return values</dt><dd> |
| 510 | <table class="retval"> |
| 511 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>The signature is valid. </td></tr> |
| 512 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga35927f755d232c4766de600f2c49e9f2">PSA_ERROR_INVALID_SIGNATURE</a></td><td>The calculation was perfomed successfully, but the passed signature is not a valid signature. </td></tr> |
| 513 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td></td></tr> |
| 514 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td></td></tr> |
| 515 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| 516 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| 517 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| 518 | <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| 519 | </table> |
| 520 | </dd> |
| 521 | </dl> |
| 522 | |
| 523 | </div> |
| 524 | </div> |
| 525 | </div><!-- contents --> |
| 526 | <!-- start footer part --> |
| 527 | <hr class="footer"/><address class="footer"><small> |
| 528 | Generated by  <a href="http://www.doxygen.org/index.html"> |
| 529 | <img class="footer" src="doxygen.png" alt="doxygen"/> |
| 530 | </a> 1.8.13 |
| 531 | </small></address> |
| 532 | </body> |
| 533 | </html> |