| <!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>Platform Security Architecture — cryptography and keystore interface: Symmetric ciphers</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="search/search.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="search/searchdata.js"></script> |
| <script type="text/javascript" src="search/search.js"></script> |
| <script type="text/javascript"> |
| $(document).ready(function() { init_search(); }); |
| </script> |
| <link href="doxygen.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">Platform Security Architecture — cryptography and keystore interface |
|  <span id="projectnumber">beta 2 — 2019-02-22</span> |
| </div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <!-- end header part --> |
| <!-- Generated by Doxygen 1.8.11 --> |
| <script type="text/javascript"> |
| var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| </script> |
| <div id="navrow1" class="tabs"> |
| <ul class="tablist"> |
| <li><a href="index.html"><span>Main Page</span></a></li> |
| <li class="current"><a href="modules.html"><span>Modules</span></a></li> |
| <li><a href="annotated.html"><span>Classes</span></a></li> |
| <li><a href="files.html"><span>Files</span></a></li> |
| <li> |
| <div id="MSearchBox" class="MSearchBoxInactive"> |
| <span class="left"> |
| <img id="MSearchSelect" src="search/mag_sel.png" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| alt=""/> |
| <input type="text" id="MSearchField" value="Search" accesskey="S" |
| onfocus="searchBox.OnSearchFieldFocus(true)" |
| onblur="searchBox.OnSearchFieldFocus(false)" |
| onkeyup="searchBox.OnSearchFieldChange(event)"/> |
| </span><span class="right"> |
| <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> |
| </span> |
| </div> |
| </li> |
| </ul> |
| </div> |
| </div><!-- top --> |
| <!-- window showing the filter options --> |
| <div id="MSearchSelectWindow" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| </div> |
| |
| <!-- iframe showing the search results (closed by default) --> |
| <div id="MSearchResultsWindow"> |
| <iframe src="javascript:void(0)" frameborder="0" |
| name="MSearchResults" id="MSearchResults"> |
| </iframe> |
| </div> |
| |
| <div class="header"> |
| <div class="summary"> |
| <a href="#define-members">Macros</a> | |
| <a href="#typedef-members">Typedefs</a> | |
| <a href="#func-members">Functions</a> </div> |
| <div class="headertitle"> |
| <div class="title">Symmetric ciphers</div> </div> |
| </div><!--header--> |
| <div class="contents"> |
| <table class="memberdecls"> |
| <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a> |
| Macros</h2></td></tr> |
| <tr class="memitem:ga2da0541aabf9a4995cf2004e36311919"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__cipher.html#ga2da0541aabf9a4995cf2004e36311919">PSA_CIPHER_OPERATION_INIT</a>   {0}</td></tr> |
| <tr class="separator:ga2da0541aabf9a4995cf2004e36311919"><td class="memSeparator" colspan="2"> </td></tr> |
| </table><table class="memberdecls"> |
| <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a> |
| Typedefs</h2></td></tr> |
| <tr class="memitem:ga1399de29db657e3737bb09927aae51fa"><td class="memItemLeft" align="right" valign="top">typedef struct psa_cipher_operation_s </td><td class="memItemRight" valign="bottom"><a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a></td></tr> |
| <tr class="separator:ga1399de29db657e3737bb09927aae51fa"><td class="memSeparator" colspan="2"> </td></tr> |
| </table><table class="memberdecls"> |
| <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> |
| Functions</h2></td></tr> |
| <tr class="memitem:gac76dda492d9a1ba6b327bff610ec17b2"><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__cipher.html#gac76dda492d9a1ba6b327bff610ec17b2">psa_cipher_encrypt</a> (<a class="el" href="group__platform.html#gabf6d5fd4e2ea89ecd425c88f057e7f75">psa_key_handle_t</a> handle, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)</td></tr> |
| <tr class="separator:gac76dda492d9a1ba6b327bff610ec17b2"><td class="memSeparator" colspan="2"> </td></tr> |
| <tr class="memitem:ga43d5991711ec45c98af0c1d99f6e0216"><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__cipher.html#ga43d5991711ec45c98af0c1d99f6e0216">psa_cipher_decrypt</a> (<a class="el" href="group__platform.html#gabf6d5fd4e2ea89ecd425c88f057e7f75">psa_key_handle_t</a> handle, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)</td></tr> |
| <tr class="separator:ga43d5991711ec45c98af0c1d99f6e0216"><td class="memSeparator" colspan="2"> </td></tr> |
| <tr class="memitem:ga2a7fc79a9d150d42dba99f40ee3a185e"><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__cipher.html#ga2a7fc79a9d150d42dba99f40ee3a185e">psa_cipher_encrypt_setup</a> (<a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> *operation, <a class="el" href="group__platform.html#gabf6d5fd4e2ea89ecd425c88f057e7f75">psa_key_handle_t</a> handle, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg)</td></tr> |
| <tr class="separator:ga2a7fc79a9d150d42dba99f40ee3a185e"><td class="memSeparator" colspan="2"> </td></tr> |
| <tr class="memitem:gaddf8504e5367cd0efb4415bdec004f44"><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__cipher.html#gaddf8504e5367cd0efb4415bdec004f44">psa_cipher_decrypt_setup</a> (<a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> *operation, <a class="el" href="group__platform.html#gabf6d5fd4e2ea89ecd425c88f057e7f75">psa_key_handle_t</a> handle, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg)</td></tr> |
| <tr class="separator:gaddf8504e5367cd0efb4415bdec004f44"><td class="memSeparator" colspan="2"> </td></tr> |
| <tr class="memitem:ga44857cf5e0c3d134a3c560f8ff5b50aa"><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__cipher.html#ga44857cf5e0c3d134a3c560f8ff5b50aa">psa_cipher_generate_iv</a> (<a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> *operation, unsigned char *iv, size_t iv_size, size_t *iv_length)</td></tr> |
| <tr class="separator:ga44857cf5e0c3d134a3c560f8ff5b50aa"><td class="memSeparator" colspan="2"> </td></tr> |
| <tr class="memitem:ga1359b2101f31637496ce7cc36c6e3d42"><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__cipher.html#ga1359b2101f31637496ce7cc36c6e3d42">psa_cipher_set_iv</a> (<a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> *operation, const unsigned char *iv, size_t iv_length)</td></tr> |
| <tr class="separator:ga1359b2101f31637496ce7cc36c6e3d42"><td class="memSeparator" colspan="2"> </td></tr> |
| <tr class="memitem:gafd0caea99cf1052527e4089d37f5ab91"><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__cipher.html#gafd0caea99cf1052527e4089d37f5ab91">psa_cipher_update</a> (<a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> *operation, const uint8_t *input, size_t input_length, unsigned char *output, size_t output_size, size_t *output_length)</td></tr> |
| <tr class="separator:gafd0caea99cf1052527e4089d37f5ab91"><td class="memSeparator" colspan="2"> </td></tr> |
| <tr class="memitem:ga1dcb58b8befe23f8a4d7a1d49c99249b"><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__cipher.html#ga1dcb58b8befe23f8a4d7a1d49c99249b">psa_cipher_finish</a> (<a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> *operation, uint8_t *output, size_t output_size, size_t *output_length)</td></tr> |
| <tr class="separator:ga1dcb58b8befe23f8a4d7a1d49c99249b"><td class="memSeparator" colspan="2"> </td></tr> |
| <tr class="memitem:gaad482cdca2098bca0620596aaa02eaa4"><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__cipher.html#gaad482cdca2098bca0620596aaa02eaa4">psa_cipher_abort</a> (<a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> *operation)</td></tr> |
| <tr class="separator:gaad482cdca2098bca0620596aaa02eaa4"><td class="memSeparator" colspan="2"> </td></tr> |
| </table> |
| <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> |
| <h2 class="groupheader">Macro Definition Documentation</h2> |
| <a class="anchor" id="ga2da0541aabf9a4995cf2004e36311919"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname">#define PSA_CIPHER_OPERATION_INIT   {0}</td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>This macro returns a suitable initializer for a cipher operation object of type <a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a>. </p> |
| |
| </div> |
| </div> |
| <h2 class="groupheader">Typedef Documentation</h2> |
| <a class="anchor" id="ga1399de29db657e3737bb09927aae51fa"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname">typedef struct psa_cipher_operation_s <a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a></td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>The type of the state data structure for multipart cipher operations.</p> |
| <p>Before calling any function on a cipher operation object, the application must initialize it by any of the following means:</p><ul> |
| <li>Set the structure to all-bits-zero, for example: <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> psa_cipher_operation_t operation;</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> memset(&operation, 0, sizeof(operation));</div></div><!-- fragment --></li> |
| <li>Initialize the structure to logical zero values, for example: <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> psa_cipher_operation_t operation = {0};</div></div><!-- fragment --></li> |
| <li>Initialize the structure to the initializer <a class="el" href="group__cipher.html#ga2da0541aabf9a4995cf2004e36311919">PSA_CIPHER_OPERATION_INIT</a>, for example: <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> psa_cipher_operation_t operation = PSA_CIPHER_OPERATION_INIT;</div></div><!-- fragment --></li> |
| <li>Assign the result of the function psa_cipher_operation_init() to the structure, for example: <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> psa_cipher_operation_t operation;</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> operation = psa_cipher_operation_init();</div></div><!-- fragment --></li> |
| </ul> |
| <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> |
| |
| </div> |
| </div> |
| <h2 class="groupheader">Function Documentation</h2> |
| <a class="anchor" id="gaad482cdca2098bca0620596aaa02eaa4"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_cipher_abort </td> |
| <td>(</td> |
| <td class="paramtype"><a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> * </td> |
| <td class="paramname"><em>operation</em></td><td>)</td> |
| <td></td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>Abort a cipher operation.</p> |
| <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__cipher.html#ga2a7fc79a9d150d42dba99f40ee3a185e">psa_cipher_encrypt_setup()</a> or <a class="el" href="group__cipher.html#gaddf8504e5367cd0efb4415bdec004f44">psa_cipher_decrypt_setup()</a> again.</p> |
| <p>You may call this function any time after the operation object has been initialized by any of the following methods:</p><ul> |
| <li>A call to <a class="el" href="group__cipher.html#ga2a7fc79a9d150d42dba99f40ee3a185e">psa_cipher_encrypt_setup()</a> or <a class="el" href="group__cipher.html#gaddf8504e5367cd0efb4415bdec004f44">psa_cipher_decrypt_setup()</a>, whether it succeeds or not.</li> |
| <li>Initializing the <code>struct</code> to all-bits-zero.</li> |
| <li>Initializing the <code>struct</code> to logical zeros, e.g. <code>psa_cipher_operation_t operation = {0}</code>.</li> |
| </ul> |
| <p>In particular, calling <a class="el" href="group__cipher.html#gaad482cdca2098bca0620596aaa02eaa4">psa_cipher_abort()</a> after the operation has been terminated by a call to <a class="el" href="group__cipher.html#gaad482cdca2098bca0620596aaa02eaa4">psa_cipher_abort()</a> or <a class="el" href="group__cipher.html#ga1dcb58b8befe23f8a4d7a1d49c99249b">psa_cipher_finish()</a> is safe and has no effect.</p> |
| <dl class="params"><dt>Parameters</dt><dd> |
| <table class="params"> |
| <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Initialized cipher operation.</td></tr> |
| </table> |
| </dd> |
| </dl> |
| <dl class="retval"><dt>Return values</dt><dd> |
| <table class="retval"> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td><code>operation</code> is not an active cipher operation. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| </table> |
| </dd> |
| </dl> |
| |
| </div> |
| </div> |
| <a class="anchor" id="ga43d5991711ec45c98af0c1d99f6e0216"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_cipher_decrypt </td> |
| <td>(</td> |
| <td class="paramtype"><a class="el" href="group__platform.html#gabf6d5fd4e2ea89ecd425c88f057e7f75">psa_key_handle_t</a> </td> |
| <td class="paramname"><em>handle</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> </td> |
| <td class="paramname"><em>alg</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">const uint8_t * </td> |
| <td class="paramname"><em>input</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t </td> |
| <td class="paramname"><em>input_length</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">uint8_t * </td> |
| <td class="paramname"><em>output</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t </td> |
| <td class="paramname"><em>output_size</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t * </td> |
| <td class="paramname"><em>output_length</em> </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td>)</td> |
| <td></td><td></td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>Decrypt a message using a symmetric cipher.</p> |
| <p>This function decrypts a message encrypted with a symmetric cipher.</p> |
| <dl class="params"><dt>Parameters</dt><dd> |
| <table class="params"> |
| <tr><td class="paramdir"></td><td class="paramname">handle</td><td>Handle to the key to use for the operation. It must remain valid until the operation terminates. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">alg</td><td>The cipher algorithm to compute (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#ga1d1a5a402ad89a2e68f12bfb535490eb">PSA_ALG_IS_CIPHER</a>(<code>alg</code>) is true). </td></tr> |
| <tr><td class="paramdir">[in]</td><td class="paramname">input</td><td>Buffer containing the message to decrypt. This consists of the IV followed by the ciphertext proper. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">input_length</td><td>Size of the <code>input</code> buffer in bytes. </td></tr> |
| <tr><td class="paramdir">[out]</td><td class="paramname">output</td><td>Buffer where the plaintext is to be written. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">output_size</td><td>Size of the <code>output</code> buffer in bytes. </td></tr> |
| <tr><td class="paramdir">[out]</td><td class="paramname">output_length</td><td>On success, the number of bytes that make up the output.</td></tr> |
| </table> |
| </dd> |
| </dl> |
| <dl class="retval"><dt>Return values</dt><dd> |
| <table class="retval"> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#gadf22718935657c2c3168c228204085f9">PSA_ERROR_INVALID_HANDLE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#gaba00e3e6ceb2b12965a81e5ac02ae040">PSA_ERROR_EMPTY_SLOT</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4d1b8dd8526177a15a210b7afc1accb1">PSA_ERROR_NOT_PERMITTED</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td><code>key</code> is not compatible with <code>alg</code>. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td><code>alg</code> is not supported or is not a cipher algorithm. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga695025f4ec11249aee7ea3d0f65e01c8">PSA_ERROR_BUFFER_TOO_SMALL</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| </table> |
| </dd> |
| </dl> |
| |
| </div> |
| </div> |
| <a class="anchor" id="gaddf8504e5367cd0efb4415bdec004f44"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_cipher_decrypt_setup </td> |
| <td>(</td> |
| <td class="paramtype"><a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> * </td> |
| <td class="paramname"><em>operation</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype"><a class="el" href="group__platform.html#gabf6d5fd4e2ea89ecd425c88f057e7f75">psa_key_handle_t</a> </td> |
| <td class="paramname"><em>handle</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> </td> |
| <td class="paramname"><em>alg</em> </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td>)</td> |
| <td></td><td></td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>Set the key for a multipart symmetric decryption operation.</p> |
| <p>The sequence of operations to decrypt a message with a symmetric cipher is as follows:</p><ol type="1"> |
| <li>Allocate an operation object which will be passed to all the functions listed here.</li> |
| <li>Initialize the operation object with one of the methods described in the documentation for <a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a>, e.g. PSA_CIPHER_OPERATION_INIT.</li> |
| <li>Call <a class="el" href="group__cipher.html#gaddf8504e5367cd0efb4415bdec004f44">psa_cipher_decrypt_setup()</a> to specify the algorithm and key.</li> |
| <li>Call <a class="el" href="group__cipher.html#ga1359b2101f31637496ce7cc36c6e3d42">psa_cipher_set_iv()</a> with the IV (initialization vector) for the decryption. If the IV is prepended to the ciphertext, you can call <a class="el" href="group__cipher.html#gafd0caea99cf1052527e4089d37f5ab91">psa_cipher_update()</a> on a buffer containing the IV followed by the beginning of the message.</li> |
| <li>Call <a class="el" href="group__cipher.html#gafd0caea99cf1052527e4089d37f5ab91">psa_cipher_update()</a> zero, one or more times, passing a fragment of the message each time.</li> |
| <li>Call <a class="el" href="group__cipher.html#ga1dcb58b8befe23f8a4d7a1d49c99249b">psa_cipher_finish()</a>.</li> |
| </ol> |
| <p>The application may call <a class="el" href="group__cipher.html#gaad482cdca2098bca0620596aaa02eaa4">psa_cipher_abort()</a> at any time after the operation has been initialized.</p> |
| <p>After a successful call to <a class="el" href="group__cipher.html#gaddf8504e5367cd0efb4415bdec004f44">psa_cipher_decrypt_setup()</a>, the application must eventually terminate the operation. The following events terminate an operation:</p><ul> |
| <li>A failed call to any of the <code>psa_cipher_xxx</code> functions.</li> |
| <li>A call to <a class="el" href="group__cipher.html#ga1dcb58b8befe23f8a4d7a1d49c99249b">psa_cipher_finish()</a> or <a class="el" href="group__cipher.html#gaad482cdca2098bca0620596aaa02eaa4">psa_cipher_abort()</a>.</li> |
| </ul> |
| <dl class="params"><dt>Parameters</dt><dd> |
| <table class="params"> |
| <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>The operation object to set up. It must have been initialized as per the documentation for <a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> and not yet in use. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">handle</td><td>Handle to the key to use for the operation. It must remain valid until the operation terminates. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">alg</td><td>The cipher algorithm to compute (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#ga1d1a5a402ad89a2e68f12bfb535490eb">PSA_ALG_IS_CIPHER</a>(<code>alg</code>) is true).</td></tr> |
| </table> |
| </dd> |
| </dl> |
| <dl class="retval"><dt>Return values</dt><dd> |
| <table class="retval"> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#gadf22718935657c2c3168c228204085f9">PSA_ERROR_INVALID_HANDLE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#gaba00e3e6ceb2b12965a81e5ac02ae040">PSA_ERROR_EMPTY_SLOT</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4d1b8dd8526177a15a210b7afc1accb1">PSA_ERROR_NOT_PERMITTED</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td><code>key</code> is not compatible with <code>alg</code>. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td><code>alg</code> is not supported or is not a cipher algorithm. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| <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> |
| </table> |
| </dd> |
| </dl> |
| |
| </div> |
| </div> |
| <a class="anchor" id="gac76dda492d9a1ba6b327bff610ec17b2"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_cipher_encrypt </td> |
| <td>(</td> |
| <td class="paramtype"><a class="el" href="group__platform.html#gabf6d5fd4e2ea89ecd425c88f057e7f75">psa_key_handle_t</a> </td> |
| <td class="paramname"><em>handle</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> </td> |
| <td class="paramname"><em>alg</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">const uint8_t * </td> |
| <td class="paramname"><em>input</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t </td> |
| <td class="paramname"><em>input_length</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">uint8_t * </td> |
| <td class="paramname"><em>output</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t </td> |
| <td class="paramname"><em>output_size</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t * </td> |
| <td class="paramname"><em>output_length</em> </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td>)</td> |
| <td></td><td></td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>Encrypt a message using a symmetric cipher.</p> |
| <p>This function encrypts a message with a random IV (initialization vector).</p> |
| <dl class="params"><dt>Parameters</dt><dd> |
| <table class="params"> |
| <tr><td class="paramdir"></td><td class="paramname">handle</td><td>Handle to the key to use for the operation. It must remain valid until the operation terminates. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">alg</td><td>The cipher algorithm to compute (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#ga1d1a5a402ad89a2e68f12bfb535490eb">PSA_ALG_IS_CIPHER</a>(<code>alg</code>) is true). </td></tr> |
| <tr><td class="paramdir">[in]</td><td class="paramname">input</td><td>Buffer containing the message to encrypt. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">input_length</td><td>Size of the <code>input</code> buffer in bytes. </td></tr> |
| <tr><td class="paramdir">[out]</td><td class="paramname">output</td><td>Buffer where the output is to be written. The output contains the IV followed by the ciphertext proper. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">output_size</td><td>Size of the <code>output</code> buffer in bytes. </td></tr> |
| <tr><td class="paramdir">[out]</td><td class="paramname">output_length</td><td>On success, the number of bytes that make up the output.</td></tr> |
| </table> |
| </dd> |
| </dl> |
| <dl class="retval"><dt>Return values</dt><dd> |
| <table class="retval"> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#gadf22718935657c2c3168c228204085f9">PSA_ERROR_INVALID_HANDLE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#gaba00e3e6ceb2b12965a81e5ac02ae040">PSA_ERROR_EMPTY_SLOT</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4d1b8dd8526177a15a210b7afc1accb1">PSA_ERROR_NOT_PERMITTED</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td><code>key</code> is not compatible with <code>alg</code>. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td><code>alg</code> is not supported or is not a cipher algorithm. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga695025f4ec11249aee7ea3d0f65e01c8">PSA_ERROR_BUFFER_TOO_SMALL</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| </table> |
| </dd> |
| </dl> |
| |
| </div> |
| </div> |
| <a class="anchor" id="ga2a7fc79a9d150d42dba99f40ee3a185e"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_cipher_encrypt_setup </td> |
| <td>(</td> |
| <td class="paramtype"><a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> * </td> |
| <td class="paramname"><em>operation</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype"><a class="el" href="group__platform.html#gabf6d5fd4e2ea89ecd425c88f057e7f75">psa_key_handle_t</a> </td> |
| <td class="paramname"><em>handle</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> </td> |
| <td class="paramname"><em>alg</em> </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td>)</td> |
| <td></td><td></td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>Set the key for a multipart symmetric encryption operation.</p> |
| <p>The sequence of operations to encrypt a message with a symmetric cipher is as follows:</p><ol type="1"> |
| <li>Allocate an operation object which will be passed to all the functions listed here.</li> |
| <li>Initialize the operation object with one of the methods described in the documentation for <a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a>, e.g. PSA_CIPHER_OPERATION_INIT.</li> |
| <li>Call <a class="el" href="group__cipher.html#ga2a7fc79a9d150d42dba99f40ee3a185e">psa_cipher_encrypt_setup()</a> to specify the algorithm and key.</li> |
| <li>Call either <a class="el" href="group__cipher.html#ga44857cf5e0c3d134a3c560f8ff5b50aa">psa_cipher_generate_iv()</a> or <a class="el" href="group__cipher.html#ga1359b2101f31637496ce7cc36c6e3d42">psa_cipher_set_iv()</a> to generate or set the IV (initialization vector). You should use <a class="el" href="group__cipher.html#ga44857cf5e0c3d134a3c560f8ff5b50aa">psa_cipher_generate_iv()</a> unless the protocol you are implementing requires a specific IV value.</li> |
| <li>Call <a class="el" href="group__cipher.html#gafd0caea99cf1052527e4089d37f5ab91">psa_cipher_update()</a> zero, one or more times, passing a fragment of the message each time.</li> |
| <li>Call <a class="el" href="group__cipher.html#ga1dcb58b8befe23f8a4d7a1d49c99249b">psa_cipher_finish()</a>.</li> |
| </ol> |
| <p>The application may call <a class="el" href="group__cipher.html#gaad482cdca2098bca0620596aaa02eaa4">psa_cipher_abort()</a> at any time after the operation has been initialized.</p> |
| <p>After a successful call to <a class="el" href="group__cipher.html#ga2a7fc79a9d150d42dba99f40ee3a185e">psa_cipher_encrypt_setup()</a>, the application must eventually terminate the operation. The following events terminate an operation:</p><ul> |
| <li>A failed call to any of the <code>psa_cipher_xxx</code> functions.</li> |
| <li>A call to <a class="el" href="group__cipher.html#ga1dcb58b8befe23f8a4d7a1d49c99249b">psa_cipher_finish()</a> or <a class="el" href="group__cipher.html#gaad482cdca2098bca0620596aaa02eaa4">psa_cipher_abort()</a>.</li> |
| </ul> |
| <dl class="params"><dt>Parameters</dt><dd> |
| <table class="params"> |
| <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>The operation object to set up. It must have been initialized as per the documentation for <a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> and not yet in use. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">handle</td><td>Handle to the key to use for the operation. It must remain valid until the operation terminates. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">alg</td><td>The cipher algorithm to compute (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#ga1d1a5a402ad89a2e68f12bfb535490eb">PSA_ALG_IS_CIPHER</a>(<code>alg</code>) is true).</td></tr> |
| </table> |
| </dd> |
| </dl> |
| <dl class="retval"><dt>Return values</dt><dd> |
| <table class="retval"> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#gadf22718935657c2c3168c228204085f9">PSA_ERROR_INVALID_HANDLE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#gaba00e3e6ceb2b12965a81e5ac02ae040">PSA_ERROR_EMPTY_SLOT</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4d1b8dd8526177a15a210b7afc1accb1">PSA_ERROR_NOT_PERMITTED</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td><code>key</code> is not compatible with <code>alg</code>. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td><code>alg</code> is not supported or is not a cipher algorithm. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| <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> |
| </table> |
| </dd> |
| </dl> |
| |
| </div> |
| </div> |
| <a class="anchor" id="ga1dcb58b8befe23f8a4d7a1d49c99249b"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_cipher_finish </td> |
| <td>(</td> |
| <td class="paramtype"><a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> * </td> |
| <td class="paramname"><em>operation</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">uint8_t * </td> |
| <td class="paramname"><em>output</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t </td> |
| <td class="paramname"><em>output_size</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t * </td> |
| <td class="paramname"><em>output_length</em> </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td>)</td> |
| <td></td><td></td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>Finish encrypting or decrypting a message in a cipher operation.</p> |
| <p>The application must call <a class="el" href="group__cipher.html#ga2a7fc79a9d150d42dba99f40ee3a185e">psa_cipher_encrypt_setup()</a> or <a class="el" href="group__cipher.html#gaddf8504e5367cd0efb4415bdec004f44">psa_cipher_decrypt_setup()</a> before calling this function. The choice of setup function determines whether this function encrypts or decrypts its input.</p> |
| <p>This function finishes the encryption or decryption of the message formed by concatenating the inputs passed to preceding calls to <a class="el" href="group__cipher.html#gafd0caea99cf1052527e4089d37f5ab91">psa_cipher_update()</a>.</p> |
| <p>When this function returns, the operation becomes inactive.</p> |
| <dl class="params"><dt>Parameters</dt><dd> |
| <table class="params"> |
| <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Active cipher operation. </td></tr> |
| <tr><td class="paramdir">[out]</td><td class="paramname">output</td><td>Buffer where the output is to be written. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">output_size</td><td>Size of the <code>output</code> buffer in bytes. </td></tr> |
| <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> |
| </table> |
| </dd> |
| </dl> |
| <dl class="retval"><dt>Return values</dt><dd> |
| <table class="retval"> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The operation state is not valid (not set up, IV required but not set, or already completed). </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga695025f4ec11249aee7ea3d0f65e01c8">PSA_ERROR_BUFFER_TOO_SMALL</a></td><td>The size of the <code>output</code> buffer is too small. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| </table> |
| </dd> |
| </dl> |
| |
| </div> |
| </div> |
| <a class="anchor" id="ga44857cf5e0c3d134a3c560f8ff5b50aa"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_cipher_generate_iv </td> |
| <td>(</td> |
| <td class="paramtype"><a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> * </td> |
| <td class="paramname"><em>operation</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">unsigned char * </td> |
| <td class="paramname"><em>iv</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t </td> |
| <td class="paramname"><em>iv_size</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t * </td> |
| <td class="paramname"><em>iv_length</em> </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td>)</td> |
| <td></td><td></td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>Generate an IV for a symmetric encryption operation.</p> |
| <p>This function generates a random IV (initialization vector), nonce or initial counter value for the encryption operation as appropriate for the chosen algorithm, key type and key size.</p> |
| <p>The application must call <a class="el" href="group__cipher.html#ga2a7fc79a9d150d42dba99f40ee3a185e">psa_cipher_encrypt_setup()</a> before calling this function.</p> |
| <p>If this function returns an error status, the operation becomes inactive.</p> |
| <dl class="params"><dt>Parameters</dt><dd> |
| <table class="params"> |
| <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Active cipher operation. </td></tr> |
| <tr><td class="paramdir">[out]</td><td class="paramname">iv</td><td>Buffer where the generated IV is to be written. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">iv_size</td><td>Size of the <code>iv</code> buffer in bytes. </td></tr> |
| <tr><td class="paramdir">[out]</td><td class="paramname">iv_length</td><td>On success, the number of bytes of the generated IV.</td></tr> |
| </table> |
| </dd> |
| </dl> |
| <dl class="retval"><dt>Return values</dt><dd> |
| <table class="retval"> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The operation state is not valid (not set up, or IV already set). </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga695025f4ec11249aee7ea3d0f65e01c8">PSA_ERROR_BUFFER_TOO_SMALL</a></td><td>The size of the <code>iv</code> buffer is too small. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| </table> |
| </dd> |
| </dl> |
| |
| </div> |
| </div> |
| <a class="anchor" id="ga1359b2101f31637496ce7cc36c6e3d42"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_cipher_set_iv </td> |
| <td>(</td> |
| <td class="paramtype"><a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> * </td> |
| <td class="paramname"><em>operation</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">const unsigned char * </td> |
| <td class="paramname"><em>iv</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t </td> |
| <td class="paramname"><em>iv_length</em> </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td>)</td> |
| <td></td><td></td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>Set the IV for a symmetric encryption or decryption operation.</p> |
| <p>This function sets the IV (initialization vector), nonce or initial counter value for the encryption or decryption operation.</p> |
| <p>The application must call <a class="el" href="group__cipher.html#ga2a7fc79a9d150d42dba99f40ee3a185e">psa_cipher_encrypt_setup()</a> before calling this function.</p> |
| <p>If this function returns an error status, the operation becomes inactive.</p> |
| <dl class="section note"><dt>Note</dt><dd>When encrypting, applications should use <a class="el" href="group__cipher.html#ga44857cf5e0c3d134a3c560f8ff5b50aa">psa_cipher_generate_iv()</a> instead of this function, unless implementing a protocol that requires a non-random IV.</dd></dl> |
| <dl class="params"><dt>Parameters</dt><dd> |
| <table class="params"> |
| <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Active cipher operation. </td></tr> |
| <tr><td class="paramdir">[in]</td><td class="paramname">iv</td><td>Buffer containing the IV to use. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">iv_length</td><td>Size of the IV in bytes.</td></tr> |
| </table> |
| </dd> |
| </dl> |
| <dl class="retval"><dt>Return values</dt><dd> |
| <table class="retval"> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The operation state is not valid (not set up, or IV already set). </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td>The size of <code>iv</code> is not acceptable for the chosen algorithm, or the chosen algorithm does not use an IV. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| </table> |
| </dd> |
| </dl> |
| |
| </div> |
| </div> |
| <a class="anchor" id="gafd0caea99cf1052527e4089d37f5ab91"></a> |
| <div class="memitem"> |
| <div class="memproto"> |
| <table class="memname"> |
| <tr> |
| <td class="memname"><a class="el" href="group__error.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_cipher_update </td> |
| <td>(</td> |
| <td class="paramtype"><a class="el" href="group__cipher.html#ga1399de29db657e3737bb09927aae51fa">psa_cipher_operation_t</a> * </td> |
| <td class="paramname"><em>operation</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">const uint8_t * </td> |
| <td class="paramname"><em>input</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t </td> |
| <td class="paramname"><em>input_length</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">unsigned char * </td> |
| <td class="paramname"><em>output</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t </td> |
| <td class="paramname"><em>output_size</em>, </td> |
| </tr> |
| <tr> |
| <td class="paramkey"></td> |
| <td></td> |
| <td class="paramtype">size_t * </td> |
| <td class="paramname"><em>output_length</em> </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td>)</td> |
| <td></td><td></td> |
| </tr> |
| </table> |
| </div><div class="memdoc"> |
| <p>Encrypt or decrypt a message fragment in an active cipher operation.</p> |
| <p>Before calling this function, you must:</p><ol type="1"> |
| <li>Call either <a class="el" href="group__cipher.html#ga2a7fc79a9d150d42dba99f40ee3a185e">psa_cipher_encrypt_setup()</a> or <a class="el" href="group__cipher.html#gaddf8504e5367cd0efb4415bdec004f44">psa_cipher_decrypt_setup()</a>. The choice of setup function determines whether this function encrypts or decrypts its input.</li> |
| <li>If the algorithm requires an IV, call <a class="el" href="group__cipher.html#ga44857cf5e0c3d134a3c560f8ff5b50aa">psa_cipher_generate_iv()</a> (recommended when encrypting) or <a class="el" href="group__cipher.html#ga1359b2101f31637496ce7cc36c6e3d42">psa_cipher_set_iv()</a>.</li> |
| </ol> |
| <p>If this function returns an error status, the operation becomes inactive.</p> |
| <dl class="params"><dt>Parameters</dt><dd> |
| <table class="params"> |
| <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Active cipher operation. </td></tr> |
| <tr><td class="paramdir">[in]</td><td class="paramname">input</td><td>Buffer containing the message fragment to encrypt or decrypt. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">input_length</td><td>Size of the <code>input</code> buffer in bytes. </td></tr> |
| <tr><td class="paramdir">[out]</td><td class="paramname">output</td><td>Buffer where the output is to be written. </td></tr> |
| <tr><td class="paramdir"></td><td class="paramname">output_size</td><td>Size of the <code>output</code> buffer in bytes. </td></tr> |
| <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> |
| </table> |
| </dd> |
| </dl> |
| <dl class="retval"><dt>Return values</dt><dd> |
| <table class="retval"> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The operation state is not valid (not set up, IV required but not set, or already completed). </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga695025f4ec11249aee7ea3d0f65e01c8">PSA_ERROR_BUFFER_TOO_SMALL</a></td><td>The size of the <code>output</code> buffer is too small. </td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr> |
| <tr><td class="paramname"><a class="el" href="group__error.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr> |
| </table> |
| </dd> |
| </dl> |
| |
| </div> |
| </div> |
| </div><!-- contents --> |
| <!-- start footer part --> |
| <hr class="footer"/><address class="footer"><small> |
| Generated by  <a href="http://www.doxygen.org/index.html"> |
| <img class="footer" src="doxygen.png" alt="doxygen"/> |
| </a> 1.8.11 |
| </small></address> |
| </body> |
| </html> |