Gilles Peskine | 06995ff | 2019-05-21 19:50:19 +0200 | [diff] [blame] | 1 | |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 3 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 4 | |
| 5 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 6 | <head> |
| 7 | <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> |
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 9 | <title>Implementation-specific definitions — psa_crypto_api 1.0 beta3 documentation</title> |
| 10 | <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> |
| 11 | <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> |
| 12 | <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> |
| 13 | <script type="text/javascript" src="_static/jquery.js"></script> |
| 14 | <script type="text/javascript" src="_static/underscore.js"></script> |
| 15 | <script type="text/javascript" src="_static/doctools.js"></script> |
| 16 | <script type="text/javascript" src="_static/language_data.js"></script> |
| 17 | <link rel="index" title="Index" href="genindex.html" /> |
| 18 | <link rel="search" title="Search" href="search.html" /> |
| 19 | <link rel="prev" title="Introduction" href="general.html" /> |
| 20 | |
| 21 | <link rel="stylesheet" href="_static/custom.css" type="text/css" /> |
| 22 | |
| 23 | |
| 24 | <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> |
| 25 | |
| 26 | </head><body> |
| 27 | |
| 28 | |
| 29 | <div class="document"> |
| 30 | <div class="documentwrapper"> |
| 31 | <div class="bodywrapper"> |
| 32 | |
| 33 | |
| 34 | <div class="body" role="main"> |
| 35 | |
| 36 | <div class="section" id="implementation-specific-definitions"> |
| 37 | <h1>Implementation-specific definitions</h1> |
| 38 | <div class="section" id="psa_key_handle_t"> |
| 39 | <span id="c.psa_key_handle_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_handle_t</span></code> (type)</h2> |
| 40 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="n">_unsigned_integral_type_</span> <span class="n">psa_key_handle_t</span><span class="p">;</span> |
| 41 | </pre></div> |
| 42 | </div> |
| 43 | <p>Key handle.</p> |
| 44 | <p>This type represents open handles to keys. It must be an unsigned integral type. The choice of type is implementation-dependent.</p> |
| 45 | <p>0 is not a valid key handle. How other handle values are assigned is implementation-dependent.</p> |
| 46 | </div> |
| 47 | </div> |
| 48 | <div class="section" id="library-initialization"> |
| 49 | <h1>Library initialization</h1> |
| 50 | <div class="section" id="psa_crypto_init"> |
| 51 | <span id="c.psa_crypto_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_crypto_init</span></code> (function)</h2> |
| 52 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_crypto_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> |
| 53 | </pre></div> |
| 54 | </div> |
| 55 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 56 | <dl class="docutils"> |
| 57 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 58 | <dd></dd> |
| 59 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 60 | <dd></dd> |
| 61 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 62 | <dd></dd> |
| 63 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 64 | <dd></dd> |
| 65 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 66 | <dd></dd> |
| 67 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 68 | <dd></dd> |
| 69 | </dl> |
| 70 | <p class="subitem-title"><strong>Description:</strong></p> |
| 71 | <p>Library initialization.</p> |
| 72 | <p>Applications must call this function before calling any other function in this module.</p> |
| 73 | <p>Applications may call this function more than once. Once a call succeeds, subsequent calls are guaranteed to succeed.</p> |
| 74 | <p>If the application calls other functions before calling <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>, the behavior is undefined. Implementations are encouraged to either perform the operation as if the library had been initialized or to return <a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a> or some other applicable error. In particular, implementations should not return a success status if the lack of initialization may have security implications, for example due to improper seeding of the random number generator.</p> |
| 75 | </div> |
| 76 | </div> |
| 77 | <div class="section" id="key-attributes"> |
| 78 | <h1>Key attributes</h1> |
| 79 | <div class="section" id="psa_key_attributes_t"> |
| 80 | <span id="c.psa_key_attributes_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_attributes_t</span></code> (type)</h2> |
| 81 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_key_attributes_s</span> <span class="n">psa_key_attributes_t</span><span class="p">;</span> |
| 82 | </pre></div> |
| 83 | </div> |
| 84 | <p>The type of a structure containing key attributes.</p> |
| 85 | <p>This is an opaque structure that can represent the metadata of a key object. Metadata that can be stored in attributes includes:</p> |
| 86 | <ul class="simple"> |
| 87 | <li>The location of the key in storage, indicated by its key identifier and its lifetime.</li> |
| 88 | <li>The key’s policy, comprising usage flags and a specification of the permitted algorithm(s).</li> |
| 89 | <li>Information about the key itself: the key type and its size.</li> |
| 90 | <li>Implementations may define additional attributes.</li> |
| 91 | </ul> |
| 92 | <p>The actual key material is not considered an attribute of a key. Key attributes do not contain information that is generally considered highly confidential.</p> |
| 93 | <p>An attribute structure can be a simple data structure where each function <code class="docutils literal notranslate"><span class="pre">psa_set_key_xxx</span></code> sets a field and the corresponding function <code class="docutils literal notranslate"><span class="pre">psa_get_key_xxx</span></code> retrieves the value of the corresponding field. However, implementations may report values that are equivalent to the original one, but have a different encoding. For example, an implementation may use a more compact representation for types where many bit-patterns are invalid or not supported, and store all values that it does not support as a special marker value. In such an implementation, after setting an invalid value, the corresponding get function returns an invalid value which may not be the one that was originally stored.</p> |
| 94 | <p>An attribute structure may contain references to auxiliary resources, for example pointers to allocated memory or indirect references to pre-calculated values. In order to free such resources, the application must call <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a>. As an exception, calling <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a> on an attribute structure is optional if the structure has only been modified by the following functions since it was initialized or last reset with <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a>:</p> |
| 95 | <ul class="simple"> |
| 96 | <li><a class="reference internal" href="#c.psa_set_key_id" title="psa_set_key_id"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_id()</span></code></a></li> |
| 97 | <li><a class="reference internal" href="#c.psa_set_key_lifetime" title="psa_set_key_lifetime"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_lifetime()</span></code></a></li> |
| 98 | <li><a class="reference internal" href="#c.psa_set_key_type" title="psa_set_key_type"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_type()</span></code></a></li> |
| 99 | <li><a class="reference internal" href="#c.psa_set_key_bits" title="psa_set_key_bits"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_bits()</span></code></a></li> |
| 100 | <li><a class="reference internal" href="#c.psa_set_key_usage_flags" title="psa_set_key_usage_flags"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_usage_flags()</span></code></a></li> |
| 101 | <li><a class="reference internal" href="#c.psa_set_key_algorithm" title="psa_set_key_algorithm"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_algorithm()</span></code></a></li> |
| 102 | </ul> |
| 103 | <p>Before calling any function on a key attribute structure, the application must initialize it by any of the following means:</p> |
| 104 | <ul> |
| 105 | <li><p class="first">Set the structure to all-bits-zero, for example:</p> |
| 106 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span><span class="p">;</span> |
| 107 | <span class="n">memset</span><span class="p">(</span><span class="o">&</span><span class="n">attributes</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">attributes</span><span class="p">));</span> |
| 108 | </pre></div> |
| 109 | </div> |
| 110 | </li> |
| 111 | <li><p class="first">Initialize the structure to logical zero values, for example:</p> |
| 112 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span> |
| 113 | </pre></div> |
| 114 | </div> |
| 115 | </li> |
| 116 | <li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_KEY_ATTRIBUTES_INIT" title="PSA_KEY_ATTRIBUTES_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ATTRIBUTES_INIT</span></code></a>, for example:</p> |
| 117 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span> <span class="o">=</span> <span class="n">PSA_KEY_ATTRIBUTES_INIT</span><span class="p">;</span> |
| 118 | </pre></div> |
| 119 | </div> |
| 120 | </li> |
| 121 | <li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_key_attributes_init" title="psa_key_attributes_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_attributes_init()</span></code></a> to the structure, for example:</p> |
| 122 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span><span class="p">;</span> |
| 123 | <span class="n">attributes</span> <span class="o">=</span> <span class="n">psa_key_attributes_init</span><span class="p">();</span> |
| 124 | </pre></div> |
| 125 | </div> |
| 126 | </li> |
| 127 | </ul> |
| 128 | <p>A freshly initialized attribute structure contains the following values:</p> |
| 129 | <ul class="simple"> |
| 130 | <li>lifetime: <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a>.</li> |
| 131 | <li>key identifier: unspecified.</li> |
| 132 | <li>type: <code class="docutils literal notranslate"><span class="pre">0</span></code>.</li> |
| 133 | <li>key size: <code class="docutils literal notranslate"><span class="pre">0</span></code>.</li> |
| 134 | <li>usage flags: <code class="docutils literal notranslate"><span class="pre">0</span></code>.</li> |
| 135 | <li>algorithm: <code class="docutils literal notranslate"><span class="pre">0</span></code>.</li> |
| 136 | </ul> |
| 137 | <p>A typical sequence to create a key is as follows:</p> |
| 138 | <ol class="arabic simple"> |
| 139 | <li>Create and initialize an attribute structure.</li> |
| 140 | <li>If the key is persistent, call <a class="reference internal" href="#c.psa_set_key_id" title="psa_set_key_id"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_id()</span></code></a>. Also call <a class="reference internal" href="#c.psa_set_key_lifetime" title="psa_set_key_lifetime"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_lifetime()</span></code></a> to place the key in a non-default location.</li> |
| 141 | <li>Set the key policy with <a class="reference internal" href="#c.psa_set_key_usage_flags" title="psa_set_key_usage_flags"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_usage_flags()</span></code></a> and <a class="reference internal" href="#c.psa_set_key_algorithm" title="psa_set_key_algorithm"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_algorithm()</span></code></a>.</li> |
| 142 | <li>Set the key type with <a class="reference internal" href="#c.psa_set_key_type" title="psa_set_key_type"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_type()</span></code></a>. Skip this step if copying an existing key with <a class="reference internal" href="#c.psa_copy_key" title="psa_copy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_copy_key()</span></code></a>.</li> |
| 143 | <li>When generating a random key with <a class="reference internal" href="#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_generate_key()</span></code></a> or deriving a key with <a class="reference internal" href="#c.psa_key_derivation_output_key" title="psa_key_derivation_output_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_key()</span></code></a>, set the desired key size with <a class="reference internal" href="#c.psa_set_key_bits" title="psa_set_key_bits"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_bits()</span></code></a>.</li> |
| 144 | <li>Call a key creation function: <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a>, <a class="reference internal" href="#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_generate_key()</span></code></a>, <a class="reference internal" href="#c.psa_key_derivation_output_key" title="psa_key_derivation_output_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_key()</span></code></a> or <a class="reference internal" href="#c.psa_copy_key" title="psa_copy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_copy_key()</span></code></a>. This function reads the attribute structure, creates a key with these attributes, and outputs a handle to the newly created key.</li> |
| 145 | <li>The attribute structure is now no longer necessary. You may call <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a>, although this is optional with the workflow presented here because the attributes currently defined in this specification do not require any additional resources beyond the structure itself.</li> |
| 146 | </ol> |
| 147 | <p>A typical sequence to query a key’s attributes is as follows:</p> |
| 148 | <ol class="arabic simple"> |
| 149 | <li>Call <a class="reference internal" href="#c.psa_get_key_attributes" title="psa_get_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_get_key_attributes()</span></code></a>.</li> |
| 150 | <li>Call <code class="docutils literal notranslate"><span class="pre">psa_get_key_xxx</span></code> functions to retrieve the attribute(s) that you are interested in.</li> |
| 151 | <li>Call <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a> to free any resources that may be used by the attribute structure.</li> |
| 152 | </ol> |
| 153 | <p>Once a key has been created, it is impossible to change its attributes.</p> |
| 154 | </div> |
| 155 | <div class="section" id="PSA_KEY_ATTRIBUTES_INIT"> |
| 156 | <span id="c.PSA_KEY_ATTRIBUTES_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ATTRIBUTES_INIT</span></code> (macro)</h2> |
| 157 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_ATTRIBUTES_INIT {0}</span> |
| 158 | </pre></div> |
| 159 | </div> |
| 160 | <p>This macro returns a suitable initializer for a key attribute structure of type <a class="reference internal" href="#c.psa_key_attributes_t" title="psa_key_attributes_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_attributes_t</span></code></a>.</p> |
| 161 | </div> |
| 162 | <div class="section" id="psa_key_attributes_init"> |
| 163 | <span id="c.psa_key_attributes_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_attributes_init</span></code> (function)</h2> |
| 164 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="nf">psa_key_attributes_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> |
| 165 | </pre></div> |
| 166 | </div> |
| 167 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_attributes_t" title="psa_key_attributes_t"><code class="docutils literal notranslate"><span class="pre">psa_key_attributes_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 168 | <p class="subitem-title"><strong>Description:</strong></p> |
| 169 | <p>Return an initial value for a key attributes structure.</p> |
| 170 | </div> |
| 171 | <div class="section" id="psa_set_key_id"> |
| 172 | <span id="c.psa_set_key_id"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_id</span></code> (function)</h2> |
| 173 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_id</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span> |
| 174 | <span class="n">psa_key_id_t</span> <span class="n">id</span><span class="p">);</span> |
| 175 | </pre></div> |
| 176 | </div> |
| 177 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 178 | <dl class="docutils"> |
| 179 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 180 | <dd>The attribute structure to write to.</dd> |
| 181 | <dt> <code class="docutils literal notranslate"><span class="pre">id</span></code></dt> |
| 182 | <dd>The persistent identifier for the key.</dd> |
| 183 | </dl> |
| 184 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 185 | <p class="subitem-title"><strong>Description:</strong></p> |
| 186 | <p>Declare a key as persistent and set its key identifier.</p> |
| 187 | <p>If the attribute structure currently declares the key as volatile (which is the default content of an attribute structure), this function sets the lifetime attribute to <a class="reference internal" href="#c.PSA_KEY_LIFETIME_PERSISTENT" title="PSA_KEY_LIFETIME_PERSISTENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code></a>.</p> |
| 188 | <p>This function does not access storage, it merely stores the given value in the structure. The persistent key will be written to storage when the attribute structure is passed to a key creation function such as <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a>, <a class="reference internal" href="#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_generate_key()</span></code></a>, <a class="reference internal" href="#c.psa_key_derivation_output_key" title="psa_key_derivation_output_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_key()</span></code></a> or <a class="reference internal" href="#c.psa_copy_key" title="psa_copy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_copy_key()</span></code></a>.</p> |
| 189 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p> |
| 190 | </div> |
| 191 | <div class="section" id="psa_set_key_lifetime"> |
| 192 | <span id="c.psa_set_key_lifetime"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_lifetime</span></code> (function)</h2> |
| 193 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_lifetime</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span> |
| 194 | <span class="n">psa_key_lifetime_t</span> <span class="n">lifetime</span><span class="p">);</span> |
| 195 | </pre></div> |
| 196 | </div> |
| 197 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 198 | <dl class="docutils"> |
| 199 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 200 | <dd>The attribute structure to write to.</dd> |
| 201 | <dt> <code class="docutils literal notranslate"><span class="pre">lifetime</span></code></dt> |
| 202 | <dd>The lifetime for the key. If this is <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a>, the key will be volatile, and the key identifier attribute is reset to 0.</dd> |
| 203 | </dl> |
| 204 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 205 | <p class="subitem-title"><strong>Description:</strong></p> |
| 206 | <p>Set the location of a persistent key.</p> |
| 207 | <p>To make a key persistent, you must give it a persistent key identifier with <a class="reference internal" href="#c.psa_set_key_id" title="psa_set_key_id"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_id()</span></code></a>. By default, a key that has a persistent identifier is stored in the default storage area identifier by <a class="reference internal" href="#c.PSA_KEY_LIFETIME_PERSISTENT" title="PSA_KEY_LIFETIME_PERSISTENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code></a>. Call this function to choose a storage area, or to explicitly declare the key as volatile.</p> |
| 208 | <p>This function does not access storage, it merely stores the given value in the structure. The persistent key will be written to storage when the attribute structure is passed to a key creation function such as <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a>, <a class="reference internal" href="#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_generate_key()</span></code></a>, <a class="reference internal" href="#c.psa_key_derivation_output_key" title="psa_key_derivation_output_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_key()</span></code></a> or <a class="reference internal" href="#c.psa_copy_key" title="psa_copy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_copy_key()</span></code></a>.</p> |
| 209 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p> |
| 210 | </div> |
| 211 | <div class="section" id="psa_get_key_id"> |
| 212 | <span id="c.psa_get_key_id"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_id</span></code> (function)</h2> |
| 213 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_id_t</span> <span class="nf">psa_get_key_id</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span> |
| 214 | </pre></div> |
| 215 | </div> |
| 216 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 217 | <dl class="docutils"> |
| 218 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 219 | <dd>The key attribute structure to query.</dd> |
| 220 | </dl> |
| 221 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_id_t" title="psa_key_id_t"><code class="docutils literal notranslate"><span class="pre">psa_key_id_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 222 | <p>The persistent identifier stored in the attribute structure. This value is unspecified if the attribute structure declares the key as volatile.</p> |
| 223 | <p class="subitem-title"><strong>Description:</strong></p> |
| 224 | <p>Retrieve the key identifier from key attributes.</p> |
| 225 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p> |
| 226 | </div> |
| 227 | <div class="section" id="psa_get_key_lifetime"> |
| 228 | <span id="c.psa_get_key_lifetime"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_lifetime</span></code> (function)</h2> |
| 229 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_lifetime_t</span> <span class="nf">psa_get_key_lifetime</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span> |
| 230 | </pre></div> |
| 231 | </div> |
| 232 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 233 | <dl class="docutils"> |
| 234 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 235 | <dd>The key attribute structure to query.</dd> |
| 236 | </dl> |
| 237 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_lifetime_t" title="psa_key_lifetime_t"><code class="docutils literal notranslate"><span class="pre">psa_key_lifetime_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 238 | <p>The lifetime value stored in the attribute structure.</p> |
| 239 | <p class="subitem-title"><strong>Description:</strong></p> |
| 240 | <p>Retrieve the lifetime from key attributes.</p> |
| 241 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p> |
| 242 | </div> |
| 243 | <div class="section" id="psa_set_key_usage_flags"> |
| 244 | <span id="c.psa_set_key_usage_flags"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_usage_flags</span></code> (function)</h2> |
| 245 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_usage_flags</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span> |
| 246 | <span class="n">psa_key_usage_t</span> <span class="n">usage_flags</span><span class="p">);</span> |
| 247 | </pre></div> |
| 248 | </div> |
| 249 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 250 | <dl class="docutils"> |
| 251 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 252 | <dd>The attribute structure to write to.</dd> |
| 253 | <dt> <code class="docutils literal notranslate"><span class="pre">usage_flags</span></code></dt> |
| 254 | <dd>The usage flags to write.</dd> |
| 255 | </dl> |
| 256 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 257 | <p class="subitem-title"><strong>Description:</strong></p> |
| 258 | <p>Declare usage flags for a key.</p> |
| 259 | <p>Usage flags are part of a key’s usage policy. They encode what kind of operations are permitted on the key. For more details, refer to the documentation of the type <a class="reference internal" href="#c.psa_key_usage_t" title="psa_key_usage_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_usage_t</span></code></a>.</p> |
| 260 | <p>This function overwrites any usage flags previously set in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p> |
| 261 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p> |
| 262 | </div> |
| 263 | <div class="section" id="psa_get_key_usage_flags"> |
| 264 | <span id="c.psa_get_key_usage_flags"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_usage_flags</span></code> (function)</h2> |
| 265 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_usage_t</span> <span class="nf">psa_get_key_usage_flags</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span> |
| 266 | </pre></div> |
| 267 | </div> |
| 268 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 269 | <dl class="docutils"> |
| 270 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 271 | <dd>The key attribute structure to query.</dd> |
| 272 | </dl> |
| 273 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_usage_t" title="psa_key_usage_t"><code class="docutils literal notranslate"><span class="pre">psa_key_usage_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 274 | <p>The usage flags stored in the attribute structure.</p> |
| 275 | <p class="subitem-title"><strong>Description:</strong></p> |
| 276 | <p>Retrieve the usage flags from key attributes.</p> |
| 277 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p> |
| 278 | </div> |
| 279 | <div class="section" id="psa_set_key_algorithm"> |
| 280 | <span id="c.psa_set_key_algorithm"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_algorithm</span></code> (function)</h2> |
| 281 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_algorithm</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span> |
| 282 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span> |
| 283 | </pre></div> |
| 284 | </div> |
| 285 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 286 | <dl class="docutils"> |
| 287 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 288 | <dd>The attribute structure to write to.</dd> |
| 289 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 290 | <dd>The permitted algorithm policy to write.</dd> |
| 291 | </dl> |
| 292 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 293 | <p class="subitem-title"><strong>Description:</strong></p> |
| 294 | <p>Declare the permitted algorithm policy for a key.</p> |
| 295 | <p>The permitted algorithm policy of a key encodes which algorithm or algorithms are permitted to be used with this key.</p> |
| 296 | <p>This function overwrites any algorithm policy previously set in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p> |
| 297 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p> |
| 298 | </div> |
| 299 | <div class="section" id="psa_get_key_algorithm"> |
| 300 | <span id="c.psa_get_key_algorithm"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_algorithm</span></code> (function)</h2> |
| 301 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_algorithm_t</span> <span class="nf">psa_get_key_algorithm</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span> |
| 302 | </pre></div> |
| 303 | </div> |
| 304 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 305 | <dl class="docutils"> |
| 306 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 307 | <dd>The key attribute structure to query.</dd> |
| 308 | </dl> |
| 309 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 310 | <p>The algorithm stored in the attribute structure.</p> |
| 311 | <p class="subitem-title"><strong>Description:</strong></p> |
| 312 | <p>Retrieve the algorithm policy from key attributes.</p> |
| 313 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p> |
| 314 | </div> |
| 315 | <div class="section" id="psa_set_key_type"> |
| 316 | <span id="c.psa_set_key_type"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_type</span></code> (function)</h2> |
| 317 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_type</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span> |
| 318 | <span class="n">psa_key_type_t</span> <span class="n">type</span><span class="p">);</span> |
| 319 | </pre></div> |
| 320 | </div> |
| 321 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 322 | <dl class="docutils"> |
| 323 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 324 | <dd>The attribute structure to write to.</dd> |
| 325 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 326 | <dd>The key type to write.</dd> |
| 327 | </dl> |
| 328 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 329 | <p class="subitem-title"><strong>Description:</strong></p> |
| 330 | <p>Declare the type of a key.</p> |
| 331 | <p>This function overwrites any key type previously set in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p> |
| 332 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p> |
| 333 | </div> |
| 334 | <div class="section" id="psa_set_key_bits"> |
| 335 | <span id="c.psa_set_key_bits"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_bits</span></code> (function)</h2> |
| 336 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_bits</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span> |
| 337 | <span class="kt">size_t</span> <span class="n">bits</span><span class="p">);</span> |
| 338 | </pre></div> |
| 339 | </div> |
| 340 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 341 | <dl class="docutils"> |
| 342 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 343 | <dd>The attribute structure to write to.</dd> |
| 344 | <dt> <code class="docutils literal notranslate"><span class="pre">bits</span></code></dt> |
| 345 | <dd>The key size in bits.</dd> |
| 346 | </dl> |
| 347 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 348 | <p class="subitem-title"><strong>Description:</strong></p> |
| 349 | <p>Declare the size of a key.</p> |
| 350 | <p>This function overwrites any key size previously set in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p> |
| 351 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p> |
| 352 | </div> |
| 353 | <div class="section" id="psa_get_key_type"> |
| 354 | <span id="c.psa_get_key_type"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_type</span></code> (function)</h2> |
| 355 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_type_t</span> <span class="nf">psa_get_key_type</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span> |
| 356 | </pre></div> |
| 357 | </div> |
| 358 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 359 | <dl class="docutils"> |
| 360 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 361 | <dd>The key attribute structure to query.</dd> |
| 362 | </dl> |
| 363 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 364 | <p>The key type stored in the attribute structure.</p> |
| 365 | <p class="subitem-title"><strong>Description:</strong></p> |
| 366 | <p>Retrieve the key type from key attributes.</p> |
| 367 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p> |
| 368 | </div> |
| 369 | <div class="section" id="psa_get_key_bits"> |
| 370 | <span id="c.psa_get_key_bits"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_bits</span></code> (function)</h2> |
| 371 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">size_t</span> <span class="nf">psa_get_key_bits</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span> |
| 372 | </pre></div> |
| 373 | </div> |
| 374 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 375 | <dl class="docutils"> |
| 376 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 377 | <dd>The key attribute structure to query.</dd> |
| 378 | </dl> |
| 379 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">size_t</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 380 | <p>The key size stored in the attribute structure, in bits.</p> |
| 381 | <p class="subitem-title"><strong>Description:</strong></p> |
| 382 | <p>Retrieve the key size from key attributes.</p> |
| 383 | <p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p> |
| 384 | </div> |
| 385 | <div class="section" id="psa_get_key_attributes"> |
| 386 | <span id="c.psa_get_key_attributes"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_attributes</span></code> (function)</h2> |
| 387 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_get_key_attributes</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 388 | <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span> |
| 389 | </pre></div> |
| 390 | </div> |
| 391 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 392 | <dl class="docutils"> |
| 393 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 394 | <dd>Handle to the key to query.</dd> |
| 395 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 396 | <dd>On success, the attributes of the key. On failure, equivalent to a freshly-initialized structure.</dd> |
| 397 | </dl> |
| 398 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 399 | <dl class="docutils"> |
| 400 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 401 | <dd></dd> |
| 402 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 403 | <dd></dd> |
| 404 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 405 | <dd></dd> |
| 406 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 407 | <dd></dd> |
| 408 | </dl> |
| 409 | <p class="subitem-title"><strong>Description:</strong></p> |
| 410 | <p>Retrieve the attributes of a key.</p> |
| 411 | <p>This function first resets the attribute structure as with <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a>. It then copies the attributes of the given key into the given attribute structure.</p> |
| 412 | <div class="admonition note"> |
| 413 | <p class="first admonition-title">Note</p> |
| 414 | <p class="last">This function may allocate memory or other resources. Once you have called this function on an attribute structure, you must call <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a> to free these resources.</p> |
| 415 | </div> |
| 416 | </div> |
| 417 | <div class="section" id="psa_reset_key_attributes"> |
| 418 | <span id="c.psa_reset_key_attributes"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_reset_key_attributes</span></code> (function)</h2> |
| 419 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_reset_key_attributes</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span> |
| 420 | </pre></div> |
| 421 | </div> |
| 422 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 423 | <dl class="docutils"> |
| 424 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 425 | <dd>The attribute structure to reset.</dd> |
| 426 | </dl> |
| 427 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 428 | <p class="subitem-title"><strong>Description:</strong></p> |
| 429 | <p>Reset a key attribute structure to a freshly initialized state.</p> |
| 430 | <p>You must initialize the attribute structure as described in the documentation of the type <a class="reference internal" href="#c.psa_key_attributes_t" title="psa_key_attributes_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_attributes_t</span></code></a> before calling this function. Once the structure has been initialized, you may call this function at any time.</p> |
| 431 | <p>This function frees any auxiliary resources that the structure may contain.</p> |
| 432 | </div> |
| 433 | </div> |
| 434 | <div class="section" id="key-management"> |
| 435 | <h1>Key management</h1> |
| 436 | <div class="section" id="psa_open_key"> |
| 437 | <span id="c.psa_open_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_open_key</span></code> (function)</h2> |
| 438 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_open_key</span><span class="p">(</span><span class="n">psa_key_id_t</span> <span class="n">id</span><span class="p">,</span> |
| 439 | <span class="n">psa_key_handle_t</span> <span class="o">*</span> <span class="n">handle</span><span class="p">);</span> |
| 440 | </pre></div> |
| 441 | </div> |
| 442 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 443 | <dl class="docutils"> |
| 444 | <dt> <code class="docutils literal notranslate"><span class="pre">id</span></code></dt> |
| 445 | <dd>The persistent identifier of the key.</dd> |
| 446 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 447 | <dd>On success, a handle to the key.</dd> |
| 448 | </dl> |
| 449 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 450 | <dl class="docutils"> |
| 451 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 452 | <dd>Success. The application can now use the value of <code class="docutils literal notranslate"><span class="pre">*handle</span></code> to access the key.</dd> |
| 453 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 454 | <dd></dd> |
| 455 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 456 | <dd></dd> |
| 457 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 458 | <dd><code class="docutils literal notranslate"><span class="pre">id</span></code> is invalid.</dd> |
| 459 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 460 | <dd>The specified key exists, but the application does not have the permission to access it. Note that this specification does not define any way to create such a key, but it may be possible through implementation-specific means.</dd> |
| 461 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 462 | <dd></dd> |
| 463 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_STORAGE_FAILURE" title="PSA_ERROR_STORAGE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 464 | <dd></dd> |
| 465 | </dl> |
| 466 | <p class="subitem-title"><strong>Description:</strong></p> |
| 467 | <p>Open a handle to an existing persistent key.</p> |
| 468 | <p>Open a handle to a persistent key. A key is persistent if it was created with a lifetime other than <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a>. A persistent key always has a nonzero key identifier, set with <a class="reference internal" href="#c.psa_set_key_id" title="psa_set_key_id"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_id()</span></code></a> when creating the key. Implementations may provide additional pre-provisioned keys with identifiers in the range <a class="reference internal" href="#c.PSA_KEY_ID_VENDOR_MIN" title="PSA_KEY_ID_VENDOR_MIN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MIN</span></code></a>–<a class="reference internal" href="#c.PSA_KEY_ID_VENDOR_MAX" title="PSA_KEY_ID_VENDOR_MAX"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MAX</span></code></a>.</p> |
| 469 | <p>The application must eventually close the handle with <a class="reference internal" href="#c.psa_close_key" title="psa_close_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_close_key()</span></code></a> to release associated resources. If the application dies without calling <a class="reference internal" href="#c.psa_close_key" title="psa_close_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_close_key()</span></code></a>, the implementation should perform the equivalent of a call to <a class="reference internal" href="#c.psa_close_key" title="psa_close_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_close_key()</span></code></a>.</p> |
| 470 | <p>Implementations may provide additional keys that can be opened with <a class="reference internal" href="#c.psa_open_key" title="psa_open_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_open_key()</span></code></a>. Such keys have a key identifier in the vendor range, as documented in the description of <a class="reference internal" href="#c.psa_key_id_t" title="psa_key_id_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_id_t</span></code></a>.</p> |
| 471 | </div> |
| 472 | <div class="section" id="psa_close_key"> |
| 473 | <span id="c.psa_close_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_close_key</span></code> (function)</h2> |
| 474 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_close_key</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">);</span> |
| 475 | </pre></div> |
| 476 | </div> |
| 477 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 478 | <dl class="docutils"> |
| 479 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 480 | <dd>The key handle to close.</dd> |
| 481 | </dl> |
| 482 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 483 | <dl class="docutils"> |
| 484 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 485 | <dd></dd> |
| 486 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 487 | <dd></dd> |
| 488 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 489 | <dd></dd> |
| 490 | </dl> |
| 491 | <p class="subitem-title"><strong>Description:</strong></p> |
| 492 | <p>Close a key handle.</p> |
| 493 | <p>If the handle designates a volatile key, destroy the key material and free all associated resources, just like <a class="reference internal" href="#c.psa_destroy_key" title="psa_destroy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_destroy_key()</span></code></a>.</p> |
| 494 | <p>If the handle designates a persistent key, free all resources associated with the key in volatile memory. The key in persistent storage is not affected and can be opened again later with <a class="reference internal" href="#c.psa_open_key" title="psa_open_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_open_key()</span></code></a>.</p> |
| 495 | <p>If the key is currently in use in a multipart operation, the multipart operation is aborted.</p> |
| 496 | </div> |
| 497 | </div> |
| 498 | <div class="section" id="key-import-and-export"> |
| 499 | <h1>Key import and export</h1> |
| 500 | <div class="section" id="psa_import_key"> |
| 501 | <span id="c.psa_import_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_import_key</span></code> (function)</h2> |
| 502 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_import_key</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span> |
| 503 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span> |
| 504 | <span class="kt">size_t</span> <span class="n">data_length</span><span class="p">,</span> |
| 505 | <span class="n">psa_key_handle_t</span> <span class="o">*</span> <span class="n">handle</span><span class="p">);</span> |
| 506 | </pre></div> |
| 507 | </div> |
| 508 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 509 | <dl class="docutils"> |
| 510 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 511 | <dd>The attributes for the new key. The key size is always determined from the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer. If the key size in <code class="docutils literal notranslate"><span class="pre">attributes</span></code> is nonzero, it must be equal to the size from <code class="docutils literal notranslate"><span class="pre">data</span></code>.</dd> |
| 512 | <dt> <code class="docutils literal notranslate"><span class="pre">data</span></code></dt> |
| 513 | <dd>Buffer containing the key data. The content of this buffer is interpreted according to the type declared in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>. All implementations must support at least the format described in the documentation of <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a> or <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a> for the chosen type. Implementations may allow other formats, but should be conservative: implementations should err on the side of rejecting content if it may be erroneous (e.g. wrong type or truncated data).</dd> |
| 514 | <dt> <code class="docutils literal notranslate"><span class="pre">data_length</span></code></dt> |
| 515 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer in bytes.</dd> |
| 516 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 517 | <dd>On success, a handle to the newly created key. <code class="docutils literal notranslate"><span class="pre">0</span></code> on failure.</dd> |
| 518 | </dl> |
| 519 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 520 | <dl class="docutils"> |
| 521 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 522 | <dd>Success. If the key is persistent, the key material and the key’s metadata have been saved to persistent storage.</dd> |
| 523 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_ALREADY_EXISTS" title="PSA_ERROR_ALREADY_EXISTS"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 524 | <dd>This is an attempt to create a persistent key, and there is already a persistent key with the given identifier.</dd> |
| 525 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 526 | <dd>The key type or key size is not supported, either by the implementation in general or in this particular persistent location.</dd> |
| 527 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 528 | <dd>The key attributes, as a whole, are invalid.</dd> |
| 529 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 530 | <dd>The key data is not correctly formatted.</dd> |
| 531 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 532 | <dd>The size in <code class="docutils literal notranslate"><span class="pre">attributes</span></code> is nonzero and does not match the size of the key data.</dd> |
| 533 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 534 | <dd></dd> |
| 535 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_STORAGE" title="PSA_ERROR_INSUFFICIENT_STORAGE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 536 | <dd></dd> |
| 537 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 538 | <dd></dd> |
| 539 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_STORAGE_FAILURE" title="PSA_ERROR_STORAGE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 540 | <dd></dd> |
| 541 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 542 | <dd></dd> |
| 543 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 544 | <dd></dd> |
| 545 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 546 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 547 | </dl> |
| 548 | <p class="subitem-title"><strong>Description:</strong></p> |
| 549 | <p>Import a key in binary format.</p> |
| 550 | <p>This function supports any output from <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a>. Refer to the documentation of <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a> for the format of public keys and to the documentation of <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a> for the format for other key types.</p> |
| 551 | <p>This specification supports a single format for each key type. Implementations may support other formats as long as the standard format is supported. Implementations that support other formats should ensure that the formats are clearly unambiguous so as to minimize the risk that an invalid input is accidentally interpreted according to a different format.</p> |
| 552 | </div> |
| 553 | <div class="section" id="psa_destroy_key"> |
| 554 | <span id="c.psa_destroy_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_destroy_key</span></code> (function)</h2> |
| 555 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_destroy_key</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">);</span> |
| 556 | </pre></div> |
| 557 | </div> |
| 558 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 559 | <dl class="docutils"> |
| 560 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 561 | <dd>Handle to the key to erase.</dd> |
| 562 | </dl> |
| 563 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 564 | <dl class="docutils"> |
| 565 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 566 | <dd>The key material has been erased.</dd> |
| 567 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 568 | <dd>The key cannot be erased because it is read-only, either due to a policy or due to physical restrictions.</dd> |
| 569 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 570 | <dd></dd> |
| 571 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 572 | <dd>There was an failure in communication with the cryptoprocessor. The key material may still be present in the cryptoprocessor.</dd> |
| 573 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_STORAGE_FAILURE" title="PSA_ERROR_STORAGE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 574 | <dd>The storage is corrupted. Implementations shall make a best effort to erase key material even in this stage, however applications should be aware that it may be impossible to guarantee that the key material is not recoverable in such cases.</dd> |
| 575 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 576 | <dd>An unexpected condition which is not a storage corruption or a communication failure occurred. The cryptoprocessor may have been compromised.</dd> |
| 577 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 578 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 579 | </dl> |
| 580 | <p class="subitem-title"><strong>Description:</strong></p> |
| 581 | <p>Destroy a key.</p> |
| 582 | <p>This function destroys a key from both volatile memory and, if applicable, non-volatile storage. Implementations shall make a best effort to ensure that that the key material cannot be recovered.</p> |
| 583 | <p>This function also erases any metadata such as policies and frees all resources associated with the key.</p> |
| 584 | </div> |
| 585 | <div class="section" id="psa_export_key"> |
| 586 | <span id="c.psa_export_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_export_key</span></code> (function)</h2> |
| 587 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_export_key</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 588 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span> |
| 589 | <span class="kt">size_t</span> <span class="n">data_size</span><span class="p">,</span> |
| 590 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">data_length</span><span class="p">);</span> |
| 591 | </pre></div> |
| 592 | </div> |
| 593 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 594 | <dl class="docutils"> |
| 595 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 596 | <dd>Handle to the key to export.</dd> |
| 597 | <dt> <code class="docutils literal notranslate"><span class="pre">data</span></code></dt> |
| 598 | <dd>Buffer where the key data is to be written.</dd> |
| 599 | <dt> <code class="docutils literal notranslate"><span class="pre">data_size</span></code></dt> |
| 600 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer in bytes.</dd> |
| 601 | <dt> <code class="docutils literal notranslate"><span class="pre">data_length</span></code></dt> |
| 602 | <dd>On success, the number of bytes that make up the key data.</dd> |
| 603 | </dl> |
| 604 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 605 | <dl class="docutils"> |
| 606 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 607 | <dd></dd> |
| 608 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 609 | <dd></dd> |
| 610 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 611 | <dd></dd> |
| 612 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 613 | <dd>The key does not have the <a class="reference internal" href="#c.PSA_KEY_USAGE_EXPORT" title="PSA_KEY_USAGE_EXPORT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code></a> flag.</dd> |
| 614 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 615 | <dd></dd> |
| 616 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 617 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_KEY_EXPORT_MAX_SIZE" title="PSA_KEY_EXPORT_MAX_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_MAX_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">type</span></code>, <code class="docutils literal notranslate"><span class="pre">bits</span></code>) where <code class="docutils literal notranslate"><span class="pre">type</span></code> is the key type and <code class="docutils literal notranslate"><span class="pre">bits</span></code> is the key size in bits.</dd> |
| 618 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 619 | <dd></dd> |
| 620 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 621 | <dd></dd> |
| 622 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 623 | <dd></dd> |
| 624 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 625 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 626 | </dl> |
| 627 | <p class="subitem-title"><strong>Description:</strong></p> |
| 628 | <p>Export a key in binary format.</p> |
| 629 | <p>The output of this function can be passed to <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a> to create an equivalent object.</p> |
| 630 | <p>If the implementation of <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a> supports other formats beyond the format specified here, the output from <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a> must use the representation specified here, not the original representation.</p> |
| 631 | <p>For standard key types, the output format is as follows:</p> |
| 632 | <ul> |
| 633 | <li><p class="first">For symmetric keys (including MAC keys), the format is the raw bytes of the key.</p> |
| 634 | </li> |
| 635 | <li><p class="first">For DES, the key data consists of 8 bytes. The parity bits must be correct.</p> |
| 636 | </li> |
| 637 | <li><p class="first">For Triple-DES, the format is the concatenation of the two or three DES keys.</p> |
| 638 | </li> |
| 639 | <li><p class="first">For RSA key pairs (<a class="reference internal" href="#c.PSA_KEY_TYPE_RSA_KEY_PAIR" title="PSA_KEY_TYPE_RSA_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code></a>), the format is the non-encrypted DER encoding of the representation defined by PKCS#1 (RFC 8017) as <code class="docutils literal notranslate"><span class="pre">RSAPrivateKey</span></code>, version 0.</p> |
| 640 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">RSAPrivateKey</span> <span class="o">::=</span> <span class="n">SEQUENCE</span> <span class="p">{</span> |
| 641 | <span class="n">version</span> <span class="n">INTEGER</span><span class="p">,</span> <span class="o">--</span> <span class="n">must</span> <span class="n">be</span> <span class="mi">0</span> |
| 642 | <span class="n">modulus</span> <span class="n">INTEGER</span><span class="p">,</span> <span class="o">--</span> <span class="n">n</span> |
| 643 | <span class="n">publicExponent</span> <span class="n">INTEGER</span><span class="p">,</span> <span class="o">--</span> <span class="n">e</span> |
| 644 | <span class="n">privateExponent</span> <span class="n">INTEGER</span><span class="p">,</span> <span class="o">--</span> <span class="n">d</span> |
| 645 | <span class="n">prime1</span> <span class="n">INTEGER</span><span class="p">,</span> <span class="o">--</span> <span class="n">p</span> |
| 646 | <span class="n">prime2</span> <span class="n">INTEGER</span><span class="p">,</span> <span class="o">--</span> <span class="n">q</span> |
| 647 | <span class="n">exponent1</span> <span class="n">INTEGER</span><span class="p">,</span> <span class="o">--</span> <span class="n">d</span> <span class="n">mod</span> <span class="p">(</span><span class="n">p</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> |
| 648 | <span class="n">exponent2</span> <span class="n">INTEGER</span><span class="p">,</span> <span class="o">--</span> <span class="n">d</span> <span class="n">mod</span> <span class="p">(</span><span class="n">q</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> |
| 649 | <span class="n">coefficient</span> <span class="n">INTEGER</span><span class="p">,</span> <span class="o">--</span> <span class="p">(</span><span class="n">inverse</span> <span class="n">of</span> <span class="n">q</span><span class="p">)</span> <span class="n">mod</span> <span class="n">p</span> |
| 650 | <span class="p">}</span> |
| 651 | </pre></div> |
| 652 | </div> |
| 653 | </li> |
| 654 | <li><p class="first">For elliptic curve key pairs (key types for which <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_ECC_KEY_PAIR" title="PSA_KEY_TYPE_IS_ECC_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_KEY_PAIR</span></code></a> is true), the format is a representation of the private value as a <code class="docutils literal notranslate"><span class="pre">ceiling(m/8)</span></code>-byte string where <code class="docutils literal notranslate"><span class="pre">m</span></code> is the bit size associated with the curve, i.e. the bit size of the order of the curve’s coordinate field. This byte string is in little-endian order for Montgomery curves (curve types <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVEXXX</span></code>), and in big-endian order for Weierstrass curves (curve types <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECTXXX</span></code>, <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECPXXX</span></code> and <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_PXXX</span></code>). This is the content of the <code class="docutils literal notranslate"><span class="pre">privateKey</span></code> field of the <code class="docutils literal notranslate"><span class="pre">ECPrivateKey</span></code> format defined by RFC 5915.</p> |
| 655 | </li> |
| 656 | <li><p class="first">For Diffie-Hellman key exchange key pairs (key types for which <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_DH_KEY_PAIR" title="PSA_KEY_TYPE_IS_DH_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_KEY_PAIR</span></code></a> is true), the format is the representation of the private key <code class="docutils literal notranslate"><span class="pre">x</span></code> as a big-endian byte string. The length of the byte string is the private key size in bytes (leading zeroes are not stripped).</p> |
| 657 | </li> |
| 658 | <li><p class="first">For public keys (key types for which <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_PUBLIC_KEY" title="PSA_KEY_TYPE_IS_PUBLIC_KEY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_PUBLIC_KEY</span></code></a> is true), the format is the same as for <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a>.</p> |
| 659 | </li> |
| 660 | </ul> |
| 661 | <p>The policy on the key must have the usage flag <a class="reference internal" href="#c.PSA_KEY_USAGE_EXPORT" title="PSA_KEY_USAGE_EXPORT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code></a> set.</p> |
| 662 | </div> |
| 663 | <div class="section" id="psa_export_public_key"> |
| 664 | <span id="c.psa_export_public_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_export_public_key</span></code> (function)</h2> |
| 665 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_export_public_key</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 666 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span> |
| 667 | <span class="kt">size_t</span> <span class="n">data_size</span><span class="p">,</span> |
| 668 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">data_length</span><span class="p">);</span> |
| 669 | </pre></div> |
| 670 | </div> |
| 671 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 672 | <dl class="docutils"> |
| 673 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 674 | <dd>Handle to the key to export.</dd> |
| 675 | <dt> <code class="docutils literal notranslate"><span class="pre">data</span></code></dt> |
| 676 | <dd>Buffer where the key data is to be written.</dd> |
| 677 | <dt> <code class="docutils literal notranslate"><span class="pre">data_size</span></code></dt> |
| 678 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer in bytes.</dd> |
| 679 | <dt> <code class="docutils literal notranslate"><span class="pre">data_length</span></code></dt> |
| 680 | <dd>On success, the number of bytes that make up the key data.</dd> |
| 681 | </dl> |
| 682 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 683 | <dl class="docutils"> |
| 684 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 685 | <dd></dd> |
| 686 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 687 | <dd></dd> |
| 688 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 689 | <dd></dd> |
| 690 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 691 | <dd>The key is neither a public key nor a key pair.</dd> |
| 692 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 693 | <dd></dd> |
| 694 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 695 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_KEY_EXPORT_MAX_SIZE" title="PSA_KEY_EXPORT_MAX_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_MAX_SIZE</span></code></a>(<a class="reference internal" href="#c.PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR" title="PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span></code></a>(<code class="docutils literal notranslate"><span class="pre">type</span></code>), <code class="docutils literal notranslate"><span class="pre">bits</span></code>) where <code class="docutils literal notranslate"><span class="pre">type</span></code> is the key type and <code class="docutils literal notranslate"><span class="pre">bits</span></code> is the key size in bits.</dd> |
| 696 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 697 | <dd></dd> |
| 698 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 699 | <dd></dd> |
| 700 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 701 | <dd></dd> |
| 702 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 703 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 704 | </dl> |
| 705 | <p class="subitem-title"><strong>Description:</strong></p> |
| 706 | <p>Export a public key or the public part of a key pair in binary format.</p> |
| 707 | <p>The output of this function can be passed to <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a> to create an object that is equivalent to the public key.</p> |
| 708 | <p>This specification supports a single format for each key type. Implementations may support other formats as long as the standard format is supported. Implementations that support other formats should ensure that the formats are clearly unambiguous so as to minimize the risk that an invalid input is accidentally interpreted according to a different format.</p> |
| 709 | <p>For standard key types, the output format is as follows:</p> |
| 710 | <ul> |
| 711 | <li><p class="first">For RSA public keys (<a class="reference internal" href="#c.PSA_KEY_TYPE_RSA_PUBLIC_KEY" title="PSA_KEY_TYPE_RSA_PUBLIC_KEY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_PUBLIC_KEY</span></code></a>), the DER encoding of the representation defined by RFC 3279 §2.3.1 as <code class="docutils literal notranslate"><span class="pre">RSAPublicKey</span></code>.</p> |
| 712 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">RSAPublicKey</span> <span class="o">::=</span> <span class="n">SEQUENCE</span> <span class="p">{</span> |
| 713 | <span class="n">modulus</span> <span class="n">INTEGER</span><span class="p">,</span> <span class="o">--</span> <span class="n">n</span> |
| 714 | <span class="n">publicExponent</span> <span class="n">INTEGER</span> <span class="p">}</span> <span class="o">--</span> <span class="n">e</span> |
| 715 | </pre></div> |
| 716 | </div> |
| 717 | </li> |
| 718 | <li><p class="first">For elliptic curve public keys (key types for which <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY" title="PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY</span></code></a> is true), the format is the uncompressed representation defined by SEC1 §2.3.3 as the content of an ECPoint. Let <code class="docutils literal notranslate"><span class="pre">m</span></code> be the bit size associated with the curve, i.e. the bit size of <code class="docutils literal notranslate"><span class="pre">q</span></code> for a curve over <code class="docutils literal notranslate"><span class="pre">F_q</span></code>. The representation consists of:</p> |
| 719 | <ul class="simple"> |
| 720 | <li>The byte 0x04;</li> |
| 721 | <li><code class="docutils literal notranslate"><span class="pre">x_P</span></code> as a <code class="docutils literal notranslate"><span class="pre">ceiling(m/8)</span></code>-byte string, big-endian;</li> |
| 722 | <li><code class="docutils literal notranslate"><span class="pre">y_P</span></code> as a <code class="docutils literal notranslate"><span class="pre">ceiling(m/8)</span></code>-byte string, big-endian.</li> |
| 723 | </ul> |
| 724 | </li> |
| 725 | <li><p class="first">For Diffie-Hellman key exchange public keys (key types for which <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_DH_PUBLIC_KEY" title="PSA_KEY_TYPE_IS_DH_PUBLIC_KEY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_PUBLIC_KEY</span></code></a> is true), the format is the representation of the public key <code class="docutils literal notranslate"><span class="pre">y</span> <span class="pre">=</span> <span class="pre">g^x</span> <span class="pre">mod</span> <span class="pre">p</span></code> as a big-endian byte string. The length of the byte string is the length of the base prime <code class="docutils literal notranslate"><span class="pre">p</span></code> in bytes.</p> |
| 726 | </li> |
| 727 | </ul> |
| 728 | <p>Exporting a public key object or the public part of a key pair is always permitted, regardless of the key’s usage flags.</p> |
| 729 | </div> |
| 730 | <div class="section" id="psa_copy_key"> |
| 731 | <span id="c.psa_copy_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_copy_key</span></code> (function)</h2> |
| 732 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_copy_key</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">source_handle</span><span class="p">,</span> |
| 733 | <span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span> |
| 734 | <span class="n">psa_key_handle_t</span> <span class="o">*</span> <span class="n">target_handle</span><span class="p">);</span> |
| 735 | </pre></div> |
| 736 | </div> |
| 737 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 738 | <dl class="docutils"> |
| 739 | <dt> <code class="docutils literal notranslate"><span class="pre">source_handle</span></code></dt> |
| 740 | <dd>The key to copy. It must be a valid key handle.</dd> |
| 741 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 742 | <dd><p class="first">The attributes for the new key. They are used as follows:</p> |
| 743 | <ul class="last simple"> |
| 744 | <li>The key type and size may be 0. If either is nonzero, it must match the corresponding attribute of the source key.</li> |
| 745 | <li>The key location (the lifetime and, for persistent keys, the key identifier) is used directly.</li> |
| 746 | <li>The policy constraints (usage flags and algorithm policy) are combined from the source key and <code class="docutils literal notranslate"><span class="pre">attributes</span></code> so that both sets of restrictions apply, as described in the documentation of this function.</li> |
| 747 | </ul> |
| 748 | </dd> |
| 749 | <dt> <code class="docutils literal notranslate"><span class="pre">target_handle</span></code></dt> |
| 750 | <dd>On success, a handle to the newly created key. <code class="docutils literal notranslate"><span class="pre">0</span></code> on failure.</dd> |
| 751 | </dl> |
| 752 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 753 | <dl class="docutils"> |
| 754 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 755 | <dd></dd> |
| 756 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 757 | <dd><code class="docutils literal notranslate"><span class="pre">source_handle</span></code> is invalid.</dd> |
| 758 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_ALREADY_EXISTS" title="PSA_ERROR_ALREADY_EXISTS"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 759 | <dd>This is an attempt to create a persistent key, and there is already a persistent key with the given identifier.</dd> |
| 760 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 761 | <dd>The lifetime or identifier in <code class="docutils literal notranslate"><span class="pre">attributes</span></code> are invalid.</dd> |
| 762 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 763 | <dd>The policy constraints on the source and specified in <code class="docutils literal notranslate"><span class="pre">attributes</span></code> are incompatible.</dd> |
| 764 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 765 | <dd><code class="docutils literal notranslate"><span class="pre">attributes</span></code> specifies a key type or key size which does not match the attributes of the source key.</dd> |
| 766 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 767 | <dd>The source key does not have the <a class="reference internal" href="#c.PSA_KEY_USAGE_COPY" title="PSA_KEY_USAGE_COPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code></a> usage flag.</dd> |
| 768 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 769 | <dd>The source key is not exportable and its lifetime does not allow copying it to the target’s lifetime.</dd> |
| 770 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 771 | <dd></dd> |
| 772 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_STORAGE" title="PSA_ERROR_INSUFFICIENT_STORAGE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 773 | <dd></dd> |
| 774 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 775 | <dd></dd> |
| 776 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 777 | <dd></dd> |
| 778 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 779 | <dd></dd> |
| 780 | </dl> |
| 781 | <p class="subitem-title"><strong>Description:</strong></p> |
| 782 | <p>Make a copy of a key.</p> |
| 783 | <p>Copy key material from one location to another.</p> |
| 784 | <p>This function is primarily useful to copy a key from one location to another, since it populates a key using the material from another key which may have a different lifetime.</p> |
| 785 | <p>This function may be used to share a key with a different party, subject to implementation-defined restrictions on key sharing.</p> |
| 786 | <p>The policy on the source key must have the usage flag <a class="reference internal" href="#c.PSA_KEY_USAGE_COPY" title="PSA_KEY_USAGE_COPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code></a> set. This flag is sufficient to permit the copy if the key has the lifetime <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a> or <a class="reference internal" href="#c.PSA_KEY_LIFETIME_PERSISTENT" title="PSA_KEY_LIFETIME_PERSISTENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code></a>. Some secure elements do not provide a way to copy a key without making it extractable from the secure element. If a key is located in such a secure element, then the key must have both usage flags <a class="reference internal" href="#c.PSA_KEY_USAGE_COPY" title="PSA_KEY_USAGE_COPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code></a> and <a class="reference internal" href="#c.PSA_KEY_USAGE_EXPORT" title="PSA_KEY_USAGE_EXPORT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code></a> in order to make a copy of the key outside the secure element.</p> |
| 787 | <p>The resulting key may only be used in a way that conforms to both the policy of the original key and the policy specified in the <code class="docutils literal notranslate"><span class="pre">attributes</span></code> parameter:</p> |
| 788 | <ul class="simple"> |
| 789 | <li>The usage flags on the resulting key are the bitwise-and of the usage flags on the source policy and the usage flags in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</li> |
| 790 | <li>If both allow the same algorithm or wildcard-based algorithm policy, the resulting key has the same algorithm policy.</li> |
| 791 | <li>If either of the policies allows an algorithm and the other policy allows a wildcard-based algorithm policy that includes this algorithm, the resulting key allows the same algorithm.</li> |
| 792 | <li>If the policies do not allow any algorithm in common, this function fails with the status <a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a>.</li> |
| 793 | </ul> |
| 794 | <p>The effect of this function on implementation-defined attributes is implementation-defined.</p> |
| 795 | </div> |
| 796 | </div> |
| 797 | <div class="section" id="message-digests"> |
| 798 | <h1>Message digests</h1> |
| 799 | <div class="section" id="psa_hash_operation_t"> |
| 800 | <span id="c.psa_hash_operation_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code> (type)</h2> |
| 801 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_hash_operation_s</span> <span class="n">psa_hash_operation_t</span><span class="p">;</span> |
| 802 | </pre></div> |
| 803 | </div> |
| 804 | <p>The type of the state data structure for multipart hash operations.</p> |
| 805 | <p>Before calling any function on a hash operation object, the application must initialize it by any of the following means:</p> |
| 806 | <ul> |
| 807 | <li><p class="first">Set the structure to all-bits-zero, for example:</p> |
| 808 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_hash_operation_t</span> <span class="n">operation</span><span class="p">;</span> |
| 809 | <span class="n">memset</span><span class="p">(</span><span class="o">&</span><span class="n">operation</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">operation</span><span class="p">));</span> |
| 810 | </pre></div> |
| 811 | </div> |
| 812 | </li> |
| 813 | <li><p class="first">Initialize the structure to logical zero values, for example:</p> |
| 814 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_hash_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span> |
| 815 | </pre></div> |
| 816 | </div> |
| 817 | </li> |
| 818 | <li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_HASH_OPERATION_INIT" title="PSA_HASH_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_HASH_OPERATION_INIT</span></code></a>, for example:</p> |
| 819 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_hash_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="n">PSA_HASH_OPERATION_INIT</span><span class="p">;</span> |
| 820 | </pre></div> |
| 821 | </div> |
| 822 | </li> |
| 823 | <li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_hash_operation_init" title="psa_hash_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_operation_init()</span></code></a> to the structure, for example:</p> |
| 824 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_hash_operation_t</span> <span class="n">operation</span><span class="p">;</span> |
| 825 | <span class="n">operation</span> <span class="o">=</span> <span class="n">psa_hash_operation_init</span><span class="p">();</span> |
| 826 | </pre></div> |
| 827 | </div> |
| 828 | </li> |
| 829 | </ul> |
| 830 | <p>This is an implementation-defined <code class="docutils literal notranslate"><span class="pre">struct</span></code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation.</p> |
| 831 | </div> |
| 832 | <div class="section" id="PSA_HASH_OPERATION_INIT"> |
| 833 | <span id="c.PSA_HASH_OPERATION_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_HASH_OPERATION_INIT</span></code> (macro)</h2> |
| 834 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_HASH_OPERATION_INIT {0}</span> |
| 835 | </pre></div> |
| 836 | </div> |
| 837 | <p>This macro returns a suitable initializer for a hash operation object of type <a class="reference internal" href="#c.psa_hash_operation_t" title="psa_hash_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code></a>.</p> |
| 838 | </div> |
| 839 | <div class="section" id="psa_hash_compute"> |
| 840 | <span id="c.psa_hash_compute"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_compute</span></code> (function)</h2> |
| 841 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_compute</span><span class="p">(</span><span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 842 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 843 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span> |
| 844 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span> |
| 845 | <span class="kt">size_t</span> <span class="n">hash_size</span><span class="p">,</span> |
| 846 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">hash_length</span><span class="p">);</span> |
| 847 | </pre></div> |
| 848 | </div> |
| 849 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 850 | <dl class="docutils"> |
| 851 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 852 | <dd>The hash algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 853 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 854 | <dd>Buffer containing the message to hash.</dd> |
| 855 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 856 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 857 | <dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt> |
| 858 | <dd>Buffer where the hash is to be written.</dd> |
| 859 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_size</span></code></dt> |
| 860 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd> |
| 861 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt> |
| 862 | <dd>On success, the number of bytes that make up the hash value. This is always <a class="reference internal" href="#c.PSA_HASH_SIZE" title="PSA_HASH_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>).</dd> |
| 863 | </dl> |
| 864 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 865 | <dl class="docutils"> |
| 866 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 867 | <dd>Success.</dd> |
| 868 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 869 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a hash algorithm.</dd> |
| 870 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 871 | <dd></dd> |
| 872 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 873 | <dd></dd> |
| 874 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 875 | <dd></dd> |
| 876 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 877 | <dd></dd> |
| 878 | </dl> |
| 879 | <p class="subitem-title"><strong>Description:</strong></p> |
| 880 | <p>Calculate the hash (digest) of a message.</p> |
| 881 | <div class="admonition note"> |
| 882 | <p class="first admonition-title">Note</p> |
| 883 | <p class="last">To verify the hash of a message against an expected value, use <a class="reference internal" href="#c.psa_hash_compare" title="psa_hash_compare"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_compare()</span></code></a> instead.</p> |
| 884 | </div> |
| 885 | </div> |
| 886 | <div class="section" id="psa_hash_compare"> |
| 887 | <span id="c.psa_hash_compare"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_compare</span></code> (function)</h2> |
| 888 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_compare</span><span class="p">(</span><span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 889 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 890 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span> |
| 891 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span> |
| 892 | <span class="k">const</span> <span class="kt">size_t</span> <span class="n">hash_length</span><span class="p">);</span> |
| 893 | </pre></div> |
| 894 | </div> |
| 895 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 896 | <dl class="docutils"> |
| 897 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 898 | <dd>The hash algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 899 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 900 | <dd>Buffer containing the message to hash.</dd> |
| 901 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 902 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 903 | <dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt> |
| 904 | <dd>Buffer containing the expected hash value.</dd> |
| 905 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt> |
| 906 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd> |
| 907 | </dl> |
| 908 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 909 | <dl class="docutils"> |
| 910 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 911 | <dd>The expected hash is identical to the actual hash of the input.</dd> |
| 912 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 913 | <dd>The hash of the message was calculated successfully, but it differs from the expected hash.</dd> |
| 914 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 915 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a hash algorithm.</dd> |
| 916 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 917 | <dd></dd> |
| 918 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 919 | <dd></dd> |
| 920 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 921 | <dd></dd> |
| 922 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 923 | <dd></dd> |
| 924 | </dl> |
| 925 | <p class="subitem-title"><strong>Description:</strong></p> |
| 926 | <p>Calculate the hash (digest) of a message and compare it with a reference value.</p> |
| 927 | </div> |
| 928 | <div class="section" id="psa_hash_operation_init"> |
| 929 | <span id="c.psa_hash_operation_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_operation_init</span></code> (function)</h2> |
| 930 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_hash_operation_t</span> <span class="nf">psa_hash_operation_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> |
| 931 | </pre></div> |
| 932 | </div> |
| 933 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_hash_operation_t" title="psa_hash_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 934 | <p class="subitem-title"><strong>Description:</strong></p> |
| 935 | <p>Return an initial value for a hash operation object.</p> |
| 936 | </div> |
| 937 | <div class="section" id="psa_hash_setup"> |
| 938 | <span id="c.psa_hash_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_setup</span></code> (function)</h2> |
| 939 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_setup</span><span class="p">(</span><span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 940 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span> |
| 941 | </pre></div> |
| 942 | </div> |
| 943 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 944 | <dl class="docutils"> |
| 945 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 946 | <dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_hash_operation_t" title="psa_hash_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code></a> and not yet in use.</dd> |
| 947 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 948 | <dd>The hash algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 949 | </dl> |
| 950 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 951 | <dl class="docutils"> |
| 952 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 953 | <dd>Success.</dd> |
| 954 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 955 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a hash algorithm.</dd> |
| 956 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 957 | <dd>The operation state is not valid (already set up and not subsequently completed).</dd> |
| 958 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 959 | <dd></dd> |
| 960 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 961 | <dd></dd> |
| 962 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 963 | <dd></dd> |
| 964 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 965 | <dd></dd> |
| 966 | </dl> |
| 967 | <p class="subitem-title"><strong>Description:</strong></p> |
| 968 | <p>Set up a multipart hash operation.</p> |
| 969 | <p>The sequence of operations to calculate a hash (message digest) is as follows:</p> |
| 970 | <ol class="arabic simple"> |
| 971 | <li>Allocate an operation object which will be passed to all the functions listed here.</li> |
| 972 | <li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_hash_operation_t" title="psa_hash_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code></a>, e.g. PSA_HASH_OPERATION_INIT.</li> |
| 973 | <li>Call <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> to specify the algorithm.</li> |
| 974 | <li>Call <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a> zero, one or more times, passing a fragment of the message each time. The hash that is calculated is the hash of the concatenation of these messages in order.</li> |
| 975 | <li>To calculate the hash, call <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a>. To compare the hash with an expected value, call <a class="reference internal" href="#c.psa_hash_verify" title="psa_hash_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_verify()</span></code></a>.</li> |
| 976 | </ol> |
| 977 | <p>The application may call <a class="reference internal" href="#c.psa_hash_abort" title="psa_hash_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_abort()</span></code></a> at any time after the operation has been initialized.</p> |
| 978 | <p>After a successful call to <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a>, the application must eventually terminate the operation. The following events terminate an operation:</p> |
| 979 | <ul class="simple"> |
| 980 | <li>A failed call to <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a>.</li> |
| 981 | <li>A call to <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a>, <a class="reference internal" href="#c.psa_hash_verify" title="psa_hash_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_verify()</span></code></a> or <a class="reference internal" href="#c.psa_hash_abort" title="psa_hash_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_abort()</span></code></a>.</li> |
| 982 | </ul> |
| 983 | </div> |
| 984 | <div class="section" id="psa_hash_update"> |
| 985 | <span id="c.psa_hash_update"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_update</span></code> (function)</h2> |
| 986 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_update</span><span class="p">(</span><span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 987 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 988 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">);</span> |
| 989 | </pre></div> |
| 990 | </div> |
| 991 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 992 | <dl class="docutils"> |
| 993 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 994 | <dd>Active hash operation.</dd> |
| 995 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 996 | <dd>Buffer containing the message fragment to hash.</dd> |
| 997 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 998 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 999 | </dl> |
| 1000 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1001 | <dl class="docutils"> |
| 1002 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1003 | <dd>Success.</dd> |
| 1004 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1005 | <dd>The operation state is not valid (not set up, or already completed).</dd> |
| 1006 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1007 | <dd></dd> |
| 1008 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1009 | <dd></dd> |
| 1010 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1011 | <dd></dd> |
| 1012 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1013 | <dd></dd> |
| 1014 | </dl> |
| 1015 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1016 | <p>Add a message fragment to a multipart hash operation.</p> |
| 1017 | <p>The application must call <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> before calling this function.</p> |
| 1018 | <p>If this function returns an error status, the operation becomes inactive.</p> |
| 1019 | </div> |
| 1020 | <div class="section" id="psa_hash_finish"> |
| 1021 | <span id="c.psa_hash_finish"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_finish</span></code> (function)</h2> |
| 1022 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_finish</span><span class="p">(</span><span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1023 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span> |
| 1024 | <span class="kt">size_t</span> <span class="n">hash_size</span><span class="p">,</span> |
| 1025 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">hash_length</span><span class="p">);</span> |
| 1026 | </pre></div> |
| 1027 | </div> |
| 1028 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1029 | <dl class="docutils"> |
| 1030 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1031 | <dd>Active hash operation.</dd> |
| 1032 | <dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt> |
| 1033 | <dd>Buffer where the hash is to be written.</dd> |
| 1034 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_size</span></code></dt> |
| 1035 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd> |
| 1036 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt> |
| 1037 | <dd>On success, the number of bytes that make up the hash value. This is always <a class="reference internal" href="#c.PSA_HASH_SIZE" title="PSA_HASH_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the hash algorithm that is calculated.</dd> |
| 1038 | </dl> |
| 1039 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1040 | <dl class="docutils"> |
| 1041 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1042 | <dd>Success.</dd> |
| 1043 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1044 | <dd>The operation state is not valid (not set up, or already completed).</dd> |
| 1045 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1046 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_HASH_SIZE" title="PSA_HASH_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the hash algorithm that is calculated.</dd> |
| 1047 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1048 | <dd></dd> |
| 1049 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1050 | <dd></dd> |
| 1051 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1052 | <dd></dd> |
| 1053 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1054 | <dd></dd> |
| 1055 | </dl> |
| 1056 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1057 | <p>Finish the calculation of the hash of a message.</p> |
| 1058 | <p>The application must call <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> before calling this function. This function calculates the hash of the message formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a>.</p> |
| 1059 | <p>When this function returns, the operation becomes inactive.</p> |
| 1060 | <div class="admonition warning"> |
| 1061 | <p class="first admonition-title">Warning</p> |
| 1062 | <p class="last">Applications should not call this function if they expect a specific value for the hash. Call <a class="reference internal" href="#c.psa_hash_verify" title="psa_hash_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_verify()</span></code></a> instead. Beware that comparing integrity or authenticity data such as hash values with a function such as <code class="docutils literal notranslate"><span class="pre">memcmp</span></code> is risky because the time taken by the comparison may leak information about the hashed data which could allow an attacker to guess a valid hash and thereby bypass security controls.</p> |
| 1063 | </div> |
| 1064 | </div> |
| 1065 | <div class="section" id="psa_hash_verify"> |
| 1066 | <span id="c.psa_hash_verify"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_verify</span></code> (function)</h2> |
| 1067 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_verify</span><span class="p">(</span><span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1068 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span> |
| 1069 | <span class="kt">size_t</span> <span class="n">hash_length</span><span class="p">);</span> |
| 1070 | </pre></div> |
| 1071 | </div> |
| 1072 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1073 | <dl class="docutils"> |
| 1074 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1075 | <dd>Active hash operation.</dd> |
| 1076 | <dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt> |
| 1077 | <dd>Buffer containing the expected hash value.</dd> |
| 1078 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt> |
| 1079 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd> |
| 1080 | </dl> |
| 1081 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1082 | <dl class="docutils"> |
| 1083 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1084 | <dd>The expected hash is identical to the actual hash of the message.</dd> |
| 1085 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1086 | <dd>The hash of the message was calculated successfully, but it differs from the expected hash.</dd> |
| 1087 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1088 | <dd>The operation state is not valid (not set up, or already completed).</dd> |
| 1089 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1090 | <dd></dd> |
| 1091 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1092 | <dd></dd> |
| 1093 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1094 | <dd></dd> |
| 1095 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1096 | <dd></dd> |
| 1097 | </dl> |
| 1098 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1099 | <p>Finish the calculation of the hash of a message and compare it with an expected value.</p> |
| 1100 | <p>The application must call <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> before calling this function. This function calculates the hash of the message formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a>. It then compares the calculated hash with the expected hash passed as a parameter to this function.</p> |
| 1101 | <p>When this function returns, the operation becomes inactive.</p> |
| 1102 | <div class="admonition note"> |
| 1103 | <p class="first admonition-title">Note</p> |
| 1104 | <p class="last">Implementations shall make the best effort to ensure that the comparison between the actual hash and the expected hash is performed in constant time.</p> |
| 1105 | </div> |
| 1106 | </div> |
| 1107 | <div class="section" id="psa_hash_abort"> |
| 1108 | <span id="c.psa_hash_abort"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_abort</span></code> (function)</h2> |
| 1109 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_abort</span><span class="p">(</span><span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">);</span> |
| 1110 | </pre></div> |
| 1111 | </div> |
| 1112 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1113 | <dl class="docutils"> |
| 1114 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1115 | <dd>Initialized hash operation.</dd> |
| 1116 | </dl> |
| 1117 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1118 | <dl class="docutils"> |
| 1119 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1120 | <dd></dd> |
| 1121 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1122 | <dd><code class="docutils literal notranslate"><span class="pre">operation</span></code> is not an active hash operation.</dd> |
| 1123 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1124 | <dd></dd> |
| 1125 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1126 | <dd></dd> |
| 1127 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1128 | <dd></dd> |
| 1129 | </dl> |
| 1130 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1131 | <p>Abort a hash operation.</p> |
| 1132 | <p>Aborting an operation frees all associated resources except for the <code class="docutils literal notranslate"><span class="pre">operation</span></code> structure itself. Once aborted, the operation object can be reused for another operation by calling <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> again.</p> |
| 1133 | <p>You may call this function any time after the operation object has been initialized by any of the following methods:</p> |
| 1134 | <ul class="simple"> |
| 1135 | <li>A call to <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a>, whether it succeeds or not.</li> |
| 1136 | <li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to all-bits-zero.</li> |
| 1137 | <li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to logical zeros, e.g. <code class="docutils literal notranslate"><span class="pre">psa_hash_operation_t</span> <span class="pre">operation</span> <span class="pre">=</span> <span class="pre">{0}</span></code>.</li> |
| 1138 | </ul> |
| 1139 | <p>In particular, calling <a class="reference internal" href="#c.psa_hash_abort" title="psa_hash_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_abort()</span></code></a> after the operation has been terminated by a call to <a class="reference internal" href="#c.psa_hash_abort" title="psa_hash_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_abort()</span></code></a>, <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a> or <a class="reference internal" href="#c.psa_hash_verify" title="psa_hash_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_verify()</span></code></a> is safe and has no effect.</p> |
| 1140 | </div> |
| 1141 | <div class="section" id="psa_hash_clone"> |
| 1142 | <span id="c.psa_hash_clone"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_clone</span></code> (function)</h2> |
| 1143 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_clone</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">source_operation</span><span class="p">,</span> |
| 1144 | <span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">target_operation</span><span class="p">);</span> |
| 1145 | </pre></div> |
| 1146 | </div> |
| 1147 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1148 | <dl class="docutils"> |
| 1149 | <dt> <code class="docutils literal notranslate"><span class="pre">source_operation</span></code></dt> |
| 1150 | <dd>The active hash operation to clone.</dd> |
| 1151 | <dt> <code class="docutils literal notranslate"><span class="pre">target_operation</span></code></dt> |
| 1152 | <dd>The operation object to set up. It must be initialized but not active.</dd> |
| 1153 | </dl> |
| 1154 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1155 | <dl class="docutils"> |
| 1156 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1157 | <dd></dd> |
| 1158 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1159 | <dd><code class="docutils literal notranslate"><span class="pre">source_operation</span></code> is not an active hash operation.</dd> |
| 1160 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1161 | <dd><code class="docutils literal notranslate"><span class="pre">target_operation</span></code> is active.</dd> |
| 1162 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1163 | <dd></dd> |
| 1164 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1165 | <dd></dd> |
| 1166 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1167 | <dd></dd> |
| 1168 | </dl> |
| 1169 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1170 | <p>Clone a hash operation.</p> |
| 1171 | <p>This function copies the state of an ongoing hash operation to a new operation object. In other words, this function is equivalent to calling <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> on <code class="docutils literal notranslate"><span class="pre">target_operation</span></code> with the same algorithm that <code class="docutils literal notranslate"><span class="pre">source_operation</span></code> was set up for, then <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a> on <code class="docutils literal notranslate"><span class="pre">target_operation</span></code> with the same input that that was passed to <code class="docutils literal notranslate"><span class="pre">source_operation</span></code>. After this function returns, the two objects are independent, i.e. subsequent calls involving one of the objects do not affect the other object.</p> |
| 1172 | </div> |
| 1173 | </div> |
| 1174 | <div class="section" id="message-authentication-codes"> |
| 1175 | <h1>Message authentication codes</h1> |
| 1176 | <div class="section" id="psa_mac_operation_t"> |
| 1177 | <span id="c.psa_mac_operation_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code> (type)</h2> |
| 1178 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_mac_operation_s</span> <span class="n">psa_mac_operation_t</span><span class="p">;</span> |
| 1179 | </pre></div> |
| 1180 | </div> |
| 1181 | <p>The type of the state data structure for multipart MAC operations.</p> |
| 1182 | <p>Before calling any function on a MAC operation object, the application must initialize it by any of the following means:</p> |
| 1183 | <ul> |
| 1184 | <li><p class="first">Set the structure to all-bits-zero, for example:</p> |
| 1185 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_mac_operation_t</span> <span class="n">operation</span><span class="p">;</span> |
| 1186 | <span class="n">memset</span><span class="p">(</span><span class="o">&</span><span class="n">operation</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">operation</span><span class="p">));</span> |
| 1187 | </pre></div> |
| 1188 | </div> |
| 1189 | </li> |
| 1190 | <li><p class="first">Initialize the structure to logical zero values, for example:</p> |
| 1191 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_mac_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span> |
| 1192 | </pre></div> |
| 1193 | </div> |
| 1194 | </li> |
| 1195 | <li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_MAC_OPERATION_INIT" title="PSA_MAC_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_MAC_OPERATION_INIT</span></code></a>, for example:</p> |
| 1196 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_mac_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="n">PSA_MAC_OPERATION_INIT</span><span class="p">;</span> |
| 1197 | </pre></div> |
| 1198 | </div> |
| 1199 | </li> |
| 1200 | <li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_mac_operation_init" title="psa_mac_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_operation_init()</span></code></a> to the structure, for example:</p> |
| 1201 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_mac_operation_t</span> <span class="n">operation</span><span class="p">;</span> |
| 1202 | <span class="n">operation</span> <span class="o">=</span> <span class="n">psa_mac_operation_init</span><span class="p">();</span> |
| 1203 | </pre></div> |
| 1204 | </div> |
| 1205 | </li> |
| 1206 | </ul> |
| 1207 | <p>This is an implementation-defined <code class="docutils literal notranslate"><span class="pre">struct</span></code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation.</p> |
| 1208 | </div> |
| 1209 | <div class="section" id="PSA_MAC_OPERATION_INIT"> |
| 1210 | <span id="c.PSA_MAC_OPERATION_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAC_OPERATION_INIT</span></code> (macro)</h2> |
| 1211 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAC_OPERATION_INIT {0}</span> |
| 1212 | </pre></div> |
| 1213 | </div> |
| 1214 | <p>This macro returns a suitable initializer for a MAC operation object of type <a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a>.</p> |
| 1215 | </div> |
| 1216 | <div class="section" id="psa_mac_compute"> |
| 1217 | <span id="c.psa_mac_compute"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_compute</span></code> (function)</h2> |
| 1218 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_compute</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 1219 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 1220 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 1221 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span> |
| 1222 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">mac</span><span class="p">,</span> |
| 1223 | <span class="kt">size_t</span> <span class="n">mac_size</span><span class="p">,</span> |
| 1224 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">mac_length</span><span class="p">);</span> |
| 1225 | </pre></div> |
| 1226 | </div> |
| 1227 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1228 | <dl class="docutils"> |
| 1229 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 1230 | <dd>Handle to the key to use for the operation.</dd> |
| 1231 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 1232 | <dd>The MAC algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 1233 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 1234 | <dd>Buffer containing the input message.</dd> |
| 1235 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 1236 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 1237 | <dt> <code class="docutils literal notranslate"><span class="pre">mac</span></code></dt> |
| 1238 | <dd>Buffer where the MAC value is to be written.</dd> |
| 1239 | <dt> <code class="docutils literal notranslate"><span class="pre">mac_size</span></code></dt> |
| 1240 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">mac</span></code> buffer in bytes.</dd> |
| 1241 | <dt> <code class="docutils literal notranslate"><span class="pre">mac_length</span></code></dt> |
| 1242 | <dd>On success, the number of bytes that make up the MAC value.</dd> |
| 1243 | </dl> |
| 1244 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1245 | <dl class="docutils"> |
| 1246 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1247 | <dd>Success.</dd> |
| 1248 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1249 | <dd></dd> |
| 1250 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1251 | <dd></dd> |
| 1252 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1253 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 1254 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1255 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a MAC algorithm.</dd> |
| 1256 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1257 | <dd></dd> |
| 1258 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1259 | <dd></dd> |
| 1260 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1261 | <dd></dd> |
| 1262 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1263 | <dd></dd> |
| 1264 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1265 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 1266 | </dl> |
| 1267 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1268 | <p>Calculate the MAC (message authentication code) of a message.</p> |
| 1269 | <div class="admonition note"> |
| 1270 | <p class="first admonition-title">Note</p> |
| 1271 | <p class="last">To verify the MAC of a message against an expected value, use <a class="reference internal" href="#c.psa_mac_verify" title="psa_mac_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify()</span></code></a> instead. Beware that comparing integrity or authenticity data such as MAC values with a function such as <code class="docutils literal notranslate"><span class="pre">memcmp</span></code> is risky because the time taken by the comparison may leak information about the MAC value which could allow an attacker to guess a valid MAC and thereby bypass security controls.</p> |
| 1272 | </div> |
| 1273 | </div> |
| 1274 | <div class="section" id="psa_mac_verify"> |
| 1275 | <span id="c.psa_mac_verify"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_verify</span></code> (function)</h2> |
| 1276 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_verify</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 1277 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 1278 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 1279 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span> |
| 1280 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">mac</span><span class="p">,</span> |
| 1281 | <span class="k">const</span> <span class="kt">size_t</span> <span class="n">mac_length</span><span class="p">);</span> |
| 1282 | </pre></div> |
| 1283 | </div> |
| 1284 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1285 | <dl class="docutils"> |
| 1286 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 1287 | <dd>Handle to the key to use for the operation.</dd> |
| 1288 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 1289 | <dd>The MAC algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 1290 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 1291 | <dd>Buffer containing the input message.</dd> |
| 1292 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 1293 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 1294 | <dt> <code class="docutils literal notranslate"><span class="pre">mac</span></code></dt> |
| 1295 | <dd>Buffer containing the expected MAC value.</dd> |
| 1296 | <dt> <code class="docutils literal notranslate"><span class="pre">mac_length</span></code></dt> |
| 1297 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">mac</span></code> buffer in bytes.</dd> |
| 1298 | </dl> |
| 1299 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1300 | <dl class="docutils"> |
| 1301 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1302 | <dd>The expected MAC is identical to the actual MAC of the input.</dd> |
| 1303 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1304 | <dd>The MAC of the message was calculated successfully, but it differs from the expected value.</dd> |
| 1305 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1306 | <dd></dd> |
| 1307 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1308 | <dd></dd> |
| 1309 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1310 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 1311 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1312 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a MAC algorithm.</dd> |
| 1313 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1314 | <dd></dd> |
| 1315 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1316 | <dd></dd> |
| 1317 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1318 | <dd></dd> |
| 1319 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1320 | <dd></dd> |
| 1321 | </dl> |
| 1322 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1323 | <p>Calculate the MAC of a message and compare it with a reference value.</p> |
| 1324 | </div> |
| 1325 | <div class="section" id="psa_mac_operation_init"> |
| 1326 | <span id="c.psa_mac_operation_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_operation_init</span></code> (function)</h2> |
| 1327 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_mac_operation_t</span> <span class="nf">psa_mac_operation_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> |
| 1328 | </pre></div> |
| 1329 | </div> |
| 1330 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1331 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1332 | <p>Return an initial value for a MAC operation object.</p> |
| 1333 | </div> |
| 1334 | <div class="section" id="psa_mac_sign_setup"> |
| 1335 | <span id="c.psa_mac_sign_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_sign_setup</span></code> (function)</h2> |
| 1336 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_sign_setup</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1337 | <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 1338 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span> |
| 1339 | </pre></div> |
| 1340 | </div> |
| 1341 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1342 | <dl class="docutils"> |
| 1343 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1344 | <dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a> and not yet in use.</dd> |
| 1345 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 1346 | <dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd> |
| 1347 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 1348 | <dd>The MAC algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 1349 | </dl> |
| 1350 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1351 | <dl class="docutils"> |
| 1352 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1353 | <dd>Success.</dd> |
| 1354 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1355 | <dd></dd> |
| 1356 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1357 | <dd></dd> |
| 1358 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1359 | <dd></dd> |
| 1360 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1361 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 1362 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1363 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a MAC algorithm.</dd> |
| 1364 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1365 | <dd></dd> |
| 1366 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1367 | <dd></dd> |
| 1368 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1369 | <dd></dd> |
| 1370 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1371 | <dd></dd> |
| 1372 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1373 | <dd>The operation state is not valid (already set up and not subsequently completed).</dd> |
| 1374 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1375 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 1376 | </dl> |
| 1377 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1378 | <p>Set up a multipart MAC calculation operation.</p> |
| 1379 | <p>This function sets up the calculation of the MAC (message authentication code) of a byte string. To verify the MAC of a message against an expected value, use <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a> instead.</p> |
| 1380 | <p>The sequence of operations to calculate a MAC is as follows:</p> |
| 1381 | <ol class="arabic simple"> |
| 1382 | <li>Allocate an operation object which will be passed to all the functions listed here.</li> |
| 1383 | <li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a>, e.g. PSA_MAC_OPERATION_INIT.</li> |
| 1384 | <li>Call <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a> to specify the algorithm and key.</li> |
| 1385 | <li>Call <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a> zero, one or more times, passing a fragment of the message each time. The MAC that is calculated is the MAC of the concatenation of these messages in order.</li> |
| 1386 | <li>At the end of the message, call <a class="reference internal" href="#c.psa_mac_sign_finish" title="psa_mac_sign_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_finish()</span></code></a> to finish calculating the MAC value and retrieve it.</li> |
| 1387 | </ol> |
| 1388 | <p>The application may call <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a> at any time after the operation has been initialized.</p> |
| 1389 | <p>After a successful call to <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a>, the application must eventually terminate the operation through one of the following methods:</p> |
| 1390 | <ul class="simple"> |
| 1391 | <li>A failed call to <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a>.</li> |
| 1392 | <li>A call to <a class="reference internal" href="#c.psa_mac_sign_finish" title="psa_mac_sign_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_finish()</span></code></a> or <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a>.</li> |
| 1393 | </ul> |
| 1394 | </div> |
| 1395 | <div class="section" id="psa_mac_verify_setup"> |
| 1396 | <span id="c.psa_mac_verify_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_verify_setup</span></code> (function)</h2> |
| 1397 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_verify_setup</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1398 | <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 1399 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span> |
| 1400 | </pre></div> |
| 1401 | </div> |
| 1402 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1403 | <dl class="docutils"> |
| 1404 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1405 | <dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a> and not yet in use.</dd> |
| 1406 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 1407 | <dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd> |
| 1408 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 1409 | <dd>The MAC algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 1410 | </dl> |
| 1411 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1412 | <dl class="docutils"> |
| 1413 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1414 | <dd>Success.</dd> |
| 1415 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1416 | <dd></dd> |
| 1417 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1418 | <dd></dd> |
| 1419 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1420 | <dd></dd> |
| 1421 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1422 | <dd><code class="docutils literal notranslate"><span class="pre">key</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 1423 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1424 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a MAC algorithm.</dd> |
| 1425 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1426 | <dd></dd> |
| 1427 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1428 | <dd></dd> |
| 1429 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1430 | <dd></dd> |
| 1431 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1432 | <dd></dd> |
| 1433 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1434 | <dd>The operation state is not valid (already set up and not subsequently completed).</dd> |
| 1435 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1436 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 1437 | </dl> |
| 1438 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1439 | <p>Set up a multipart MAC verification operation.</p> |
| 1440 | <p>This function sets up the verification of the MAC (message authentication code) of a byte string against an expected value.</p> |
| 1441 | <p>The sequence of operations to verify a MAC is as follows:</p> |
| 1442 | <ol class="arabic simple"> |
| 1443 | <li>Allocate an operation object which will be passed to all the functions listed here.</li> |
| 1444 | <li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a>, e.g. PSA_MAC_OPERATION_INIT.</li> |
| 1445 | <li>Call <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a> to specify the algorithm and key.</li> |
| 1446 | <li>Call <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a> zero, one or more times, passing a fragment of the message each time. The MAC that is calculated is the MAC of the concatenation of these messages in order.</li> |
| 1447 | <li>At the end of the message, call <a class="reference internal" href="#c.psa_mac_verify_finish" title="psa_mac_verify_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_finish()</span></code></a> to finish calculating the actual MAC of the message and verify it against the expected value.</li> |
| 1448 | </ol> |
| 1449 | <p>The application may call <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a> at any time after the operation has been initialized.</p> |
| 1450 | <p>After a successful call to <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a>, the application must eventually terminate the operation through one of the following methods:</p> |
| 1451 | <ul class="simple"> |
| 1452 | <li>A failed call to <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a>.</li> |
| 1453 | <li>A call to <a class="reference internal" href="#c.psa_mac_verify_finish" title="psa_mac_verify_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_finish()</span></code></a> or <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a>.</li> |
| 1454 | </ul> |
| 1455 | </div> |
| 1456 | <div class="section" id="psa_mac_update"> |
| 1457 | <span id="c.psa_mac_update"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_update</span></code> (function)</h2> |
| 1458 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_update</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1459 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 1460 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">);</span> |
| 1461 | </pre></div> |
| 1462 | </div> |
| 1463 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1464 | <dl class="docutils"> |
| 1465 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1466 | <dd>Active MAC operation.</dd> |
| 1467 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 1468 | <dd>Buffer containing the message fragment to add to the MAC calculation.</dd> |
| 1469 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 1470 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 1471 | </dl> |
| 1472 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1473 | <dl class="docutils"> |
| 1474 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1475 | <dd>Success.</dd> |
| 1476 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1477 | <dd>The operation state is not valid (not set up, or already completed).</dd> |
| 1478 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1479 | <dd></dd> |
| 1480 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1481 | <dd></dd> |
| 1482 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1483 | <dd></dd> |
| 1484 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1485 | <dd></dd> |
| 1486 | </dl> |
| 1487 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1488 | <p>Add a message fragment to a multipart MAC operation.</p> |
| 1489 | <p>The application must call <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a> or <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a> before calling this function.</p> |
| 1490 | <p>If this function returns an error status, the operation becomes inactive.</p> |
| 1491 | </div> |
| 1492 | <div class="section" id="psa_mac_sign_finish"> |
| 1493 | <span id="c.psa_mac_sign_finish"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_sign_finish</span></code> (function)</h2> |
| 1494 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_sign_finish</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1495 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">mac</span><span class="p">,</span> |
| 1496 | <span class="kt">size_t</span> <span class="n">mac_size</span><span class="p">,</span> |
| 1497 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">mac_length</span><span class="p">);</span> |
| 1498 | </pre></div> |
| 1499 | </div> |
| 1500 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1501 | <dl class="docutils"> |
| 1502 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1503 | <dd>Active MAC operation.</dd> |
| 1504 | <dt> <code class="docutils literal notranslate"><span class="pre">mac</span></code></dt> |
| 1505 | <dd>Buffer where the MAC value is to be written.</dd> |
| 1506 | <dt> <code class="docutils literal notranslate"><span class="pre">mac_size</span></code></dt> |
| 1507 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">mac</span></code> buffer in bytes.</dd> |
| 1508 | <dt> <code class="docutils literal notranslate"><span class="pre">mac_length</span></code></dt> |
| 1509 | <dd>On success, the number of bytes that make up the MAC value. This is always <a class="reference internal" href="#c.PSA_MAC_FINAL_SIZE" title="PSA_MAC_FINAL_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_MAC_FINAL_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">key_type</span></code>, <code class="docutils literal notranslate"><span class="pre">key_bits</span></code>, <code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">key_type</span></code> and <code class="docutils literal notranslate"><span class="pre">key_bits</span></code> are the type and bit-size respectively of the key and <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the MAC algorithm that is calculated.</dd> |
| 1510 | </dl> |
| 1511 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1512 | <dl class="docutils"> |
| 1513 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1514 | <dd>Success.</dd> |
| 1515 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1516 | <dd>The operation state is not valid (not set up, or already completed).</dd> |
| 1517 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1518 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">mac</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_MAC_FINAL_SIZE" title="PSA_MAC_FINAL_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_MAC_FINAL_SIZE()</span></code></a>.</dd> |
| 1519 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1520 | <dd></dd> |
| 1521 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1522 | <dd></dd> |
| 1523 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1524 | <dd></dd> |
| 1525 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1526 | <dd></dd> |
| 1527 | </dl> |
| 1528 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1529 | <p>Finish the calculation of the MAC of a message.</p> |
| 1530 | <p>The application must call <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a> before calling this function. This function calculates the MAC of the message formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a>.</p> |
| 1531 | <p>When this function returns, the operation becomes inactive.</p> |
| 1532 | <div class="admonition warning"> |
| 1533 | <p class="first admonition-title">Warning</p> |
| 1534 | <p class="last">Applications should not call this function if they expect a specific value for the MAC. Call <a class="reference internal" href="#c.psa_mac_verify_finish" title="psa_mac_verify_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_finish()</span></code></a> instead. Beware that comparing integrity or authenticity data such as MAC values with a function such as <code class="docutils literal notranslate"><span class="pre">memcmp</span></code> is risky because the time taken by the comparison may leak information about the MAC value which could allow an attacker to guess a valid MAC and thereby bypass security controls.</p> |
| 1535 | </div> |
| 1536 | </div> |
| 1537 | <div class="section" id="psa_mac_verify_finish"> |
| 1538 | <span id="c.psa_mac_verify_finish"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_verify_finish</span></code> (function)</h2> |
| 1539 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_verify_finish</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1540 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">mac</span><span class="p">,</span> |
| 1541 | <span class="kt">size_t</span> <span class="n">mac_length</span><span class="p">);</span> |
| 1542 | </pre></div> |
| 1543 | </div> |
| 1544 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1545 | <dl class="docutils"> |
| 1546 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1547 | <dd>Active MAC operation.</dd> |
| 1548 | <dt> <code class="docutils literal notranslate"><span class="pre">mac</span></code></dt> |
| 1549 | <dd>Buffer containing the expected MAC value.</dd> |
| 1550 | <dt> <code class="docutils literal notranslate"><span class="pre">mac_length</span></code></dt> |
| 1551 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">mac</span></code> buffer in bytes.</dd> |
| 1552 | </dl> |
| 1553 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1554 | <dl class="docutils"> |
| 1555 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1556 | <dd>The expected MAC is identical to the actual MAC of the message.</dd> |
| 1557 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1558 | <dd>The MAC of the message was calculated successfully, but it differs from the expected MAC.</dd> |
| 1559 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1560 | <dd>The operation state is not valid (not set up, or already completed).</dd> |
| 1561 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1562 | <dd></dd> |
| 1563 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1564 | <dd></dd> |
| 1565 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1566 | <dd></dd> |
| 1567 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1568 | <dd></dd> |
| 1569 | </dl> |
| 1570 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1571 | <p>Finish the calculation of the MAC of a message and compare it with an expected value.</p> |
| 1572 | <p>The application must call <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a> before calling this function. This function calculates the MAC of the message formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a>. It then compares the calculated MAC with the expected MAC passed as a parameter to this function.</p> |
| 1573 | <p>When this function returns, the operation becomes inactive.</p> |
| 1574 | <div class="admonition note"> |
| 1575 | <p class="first admonition-title">Note</p> |
| 1576 | <p class="last">Implementations shall make the best effort to ensure that the comparison between the actual MAC and the expected MAC is performed in constant time.</p> |
| 1577 | </div> |
| 1578 | </div> |
| 1579 | <div class="section" id="psa_mac_abort"> |
| 1580 | <span id="c.psa_mac_abort"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_abort</span></code> (function)</h2> |
| 1581 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_abort</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">);</span> |
| 1582 | </pre></div> |
| 1583 | </div> |
| 1584 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1585 | <dl class="docutils"> |
| 1586 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1587 | <dd>Initialized MAC operation.</dd> |
| 1588 | </dl> |
| 1589 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1590 | <dl class="docutils"> |
| 1591 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1592 | <dd></dd> |
| 1593 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1594 | <dd><code class="docutils literal notranslate"><span class="pre">operation</span></code> is not an active MAC operation.</dd> |
| 1595 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1596 | <dd></dd> |
| 1597 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1598 | <dd></dd> |
| 1599 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1600 | <dd></dd> |
| 1601 | </dl> |
| 1602 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1603 | <p>Abort a MAC operation.</p> |
| 1604 | <p>Aborting an operation frees all associated resources except for the <code class="docutils literal notranslate"><span class="pre">operation</span></code> structure itself. Once aborted, the operation object can be reused for another operation by calling <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a> or <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a> again.</p> |
| 1605 | <p>You may call this function any time after the operation object has been initialized by any of the following methods:</p> |
| 1606 | <ul class="simple"> |
| 1607 | <li>A call to <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a> or <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a>, whether it succeeds or not.</li> |
| 1608 | <li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to all-bits-zero.</li> |
| 1609 | <li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to logical zeros, e.g. <code class="docutils literal notranslate"><span class="pre">psa_mac_operation_t</span> <span class="pre">operation</span> <span class="pre">=</span> <span class="pre">{0}</span></code>.</li> |
| 1610 | </ul> |
| 1611 | <p>In particular, calling <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a> after the operation has been terminated by a call to <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a>, <a class="reference internal" href="#c.psa_mac_sign_finish" title="psa_mac_sign_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_finish()</span></code></a> or <a class="reference internal" href="#c.psa_mac_verify_finish" title="psa_mac_verify_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_finish()</span></code></a> is safe and has no effect.</p> |
| 1612 | </div> |
| 1613 | </div> |
| 1614 | <div class="section" id="symmetric-ciphers"> |
| 1615 | <h1>Symmetric ciphers</h1> |
| 1616 | <div class="section" id="psa_cipher_operation_t"> |
| 1617 | <span id="c.psa_cipher_operation_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code> (type)</h2> |
| 1618 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_cipher_operation_s</span> <span class="n">psa_cipher_operation_t</span><span class="p">;</span> |
| 1619 | </pre></div> |
| 1620 | </div> |
| 1621 | <p>The type of the state data structure for multipart cipher operations.</p> |
| 1622 | <p>Before calling any function on a cipher operation object, the application must initialize it by any of the following means:</p> |
| 1623 | <ul> |
| 1624 | <li><p class="first">Set the structure to all-bits-zero, for example:</p> |
| 1625 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_cipher_operation_t</span> <span class="n">operation</span><span class="p">;</span> |
| 1626 | <span class="n">memset</span><span class="p">(</span><span class="o">&</span><span class="n">operation</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">operation</span><span class="p">));</span> |
| 1627 | </pre></div> |
| 1628 | </div> |
| 1629 | </li> |
| 1630 | <li><p class="first">Initialize the structure to logical zero values, for example:</p> |
| 1631 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_cipher_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span> |
| 1632 | </pre></div> |
| 1633 | </div> |
| 1634 | </li> |
| 1635 | <li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_CIPHER_OPERATION_INIT" title="PSA_CIPHER_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_CIPHER_OPERATION_INIT</span></code></a>, for example:</p> |
| 1636 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_cipher_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="n">PSA_CIPHER_OPERATION_INIT</span><span class="p">;</span> |
| 1637 | </pre></div> |
| 1638 | </div> |
| 1639 | </li> |
| 1640 | <li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_cipher_operation_init" title="psa_cipher_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_operation_init()</span></code></a> to the structure, for example:</p> |
| 1641 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_cipher_operation_t</span> <span class="n">operation</span><span class="p">;</span> |
| 1642 | <span class="n">operation</span> <span class="o">=</span> <span class="n">psa_cipher_operation_init</span><span class="p">();</span> |
| 1643 | </pre></div> |
| 1644 | </div> |
| 1645 | </li> |
| 1646 | </ul> |
| 1647 | <p>This is an implementation-defined <code class="docutils literal notranslate"><span class="pre">struct</span></code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation.</p> |
| 1648 | </div> |
| 1649 | <div class="section" id="PSA_CIPHER_OPERATION_INIT"> |
| 1650 | <span id="c.PSA_CIPHER_OPERATION_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_CIPHER_OPERATION_INIT</span></code> (macro)</h2> |
| 1651 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_CIPHER_OPERATION_INIT {0}</span> |
| 1652 | </pre></div> |
| 1653 | </div> |
| 1654 | <p>This macro returns a suitable initializer for a cipher operation object of type <a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a>.</p> |
| 1655 | </div> |
| 1656 | <div class="section" id="psa_cipher_encrypt"> |
| 1657 | <span id="c.psa_cipher_encrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_encrypt</span></code> (function)</h2> |
| 1658 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_encrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 1659 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 1660 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 1661 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span> |
| 1662 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span> |
| 1663 | <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span> |
| 1664 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span> |
| 1665 | </pre></div> |
| 1666 | </div> |
| 1667 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1668 | <dl class="docutils"> |
| 1669 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 1670 | <dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd> |
| 1671 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 1672 | <dd>The cipher algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_CIPHER" title="PSA_ALG_IS_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 1673 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 1674 | <dd>Buffer containing the message to encrypt.</dd> |
| 1675 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 1676 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 1677 | <dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt> |
| 1678 | <dd>Buffer where the output is to be written. The output contains the IV followed by the ciphertext proper.</dd> |
| 1679 | <dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt> |
| 1680 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd> |
| 1681 | <dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt> |
| 1682 | <dd>On success, the number of bytes that make up the output.</dd> |
| 1683 | </dl> |
| 1684 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1685 | <dl class="docutils"> |
| 1686 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1687 | <dd>Success.</dd> |
| 1688 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1689 | <dd></dd> |
| 1690 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1691 | <dd></dd> |
| 1692 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1693 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 1694 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1695 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a cipher algorithm.</dd> |
| 1696 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1697 | <dd></dd> |
| 1698 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1699 | <dd></dd> |
| 1700 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1701 | <dd></dd> |
| 1702 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1703 | <dd></dd> |
| 1704 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1705 | <dd></dd> |
| 1706 | </dl> |
| 1707 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1708 | <p>Encrypt a message using a symmetric cipher.</p> |
| 1709 | <p>This function encrypts a message with a random IV (initialization vector).</p> |
| 1710 | </div> |
| 1711 | <div class="section" id="psa_cipher_decrypt"> |
| 1712 | <span id="c.psa_cipher_decrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_decrypt</span></code> (function)</h2> |
| 1713 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_decrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 1714 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 1715 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 1716 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span> |
| 1717 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span> |
| 1718 | <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span> |
| 1719 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span> |
| 1720 | </pre></div> |
| 1721 | </div> |
| 1722 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1723 | <dl class="docutils"> |
| 1724 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 1725 | <dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd> |
| 1726 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 1727 | <dd>The cipher algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_CIPHER" title="PSA_ALG_IS_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 1728 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 1729 | <dd>Buffer containing the message to decrypt. This consists of the IV followed by the ciphertext proper.</dd> |
| 1730 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 1731 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 1732 | <dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt> |
| 1733 | <dd>Buffer where the plaintext is to be written.</dd> |
| 1734 | <dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt> |
| 1735 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd> |
| 1736 | <dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt> |
| 1737 | <dd>On success, the number of bytes that make up the output.</dd> |
| 1738 | </dl> |
| 1739 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1740 | <dl class="docutils"> |
| 1741 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1742 | <dd>Success.</dd> |
| 1743 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1744 | <dd></dd> |
| 1745 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1746 | <dd></dd> |
| 1747 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1748 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 1749 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1750 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a cipher algorithm.</dd> |
| 1751 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1752 | <dd></dd> |
| 1753 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1754 | <dd></dd> |
| 1755 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1756 | <dd></dd> |
| 1757 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1758 | <dd></dd> |
| 1759 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1760 | <dd></dd> |
| 1761 | </dl> |
| 1762 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1763 | <p>Decrypt a message using a symmetric cipher.</p> |
| 1764 | <p>This function decrypts a message encrypted with a symmetric cipher.</p> |
| 1765 | </div> |
| 1766 | <div class="section" id="psa_cipher_operation_init"> |
| 1767 | <span id="c.psa_cipher_operation_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_init</span></code> (function)</h2> |
| 1768 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_cipher_operation_t</span> <span class="nf">psa_cipher_operation_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> |
| 1769 | </pre></div> |
| 1770 | </div> |
| 1771 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1772 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1773 | <p>Return an initial value for a cipher operation object.</p> |
| 1774 | </div> |
| 1775 | <div class="section" id="psa_cipher_encrypt_setup"> |
| 1776 | <span id="c.psa_cipher_encrypt_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup</span></code> (function)</h2> |
| 1777 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_encrypt_setup</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1778 | <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 1779 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span> |
| 1780 | </pre></div> |
| 1781 | </div> |
| 1782 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1783 | <dl class="docutils"> |
| 1784 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1785 | <dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a> and not yet in use.</dd> |
| 1786 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 1787 | <dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd> |
| 1788 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 1789 | <dd>The cipher algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_CIPHER" title="PSA_ALG_IS_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 1790 | </dl> |
| 1791 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1792 | <dl class="docutils"> |
| 1793 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1794 | <dd>Success.</dd> |
| 1795 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1796 | <dd></dd> |
| 1797 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1798 | <dd></dd> |
| 1799 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1800 | <dd></dd> |
| 1801 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1802 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 1803 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1804 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a cipher algorithm.</dd> |
| 1805 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1806 | <dd></dd> |
| 1807 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1808 | <dd></dd> |
| 1809 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1810 | <dd></dd> |
| 1811 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1812 | <dd></dd> |
| 1813 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1814 | <dd>The operation state is not valid (already set up and not subsequently completed).</dd> |
| 1815 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1816 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 1817 | </dl> |
| 1818 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1819 | <p>Set the key for a multipart symmetric encryption operation.</p> |
| 1820 | <p>The sequence of operations to encrypt a message with a symmetric cipher is as follows:</p> |
| 1821 | <ol class="arabic simple"> |
| 1822 | <li>Allocate an operation object which will be passed to all the functions listed here.</li> |
| 1823 | <li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a>, e.g. PSA_CIPHER_OPERATION_INIT.</li> |
| 1824 | <li>Call <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> to specify the algorithm and key.</li> |
| 1825 | <li>Call either <a class="reference internal" href="#c.psa_cipher_generate_iv" title="psa_cipher_generate_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_generate_iv()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_set_iv" title="psa_cipher_set_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_set_iv()</span></code></a> to generate or set the IV (initialization vector). You should use <a class="reference internal" href="#c.psa_cipher_generate_iv" title="psa_cipher_generate_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_generate_iv()</span></code></a> unless the protocol you are implementing requires a specific IV value.</li> |
| 1826 | <li>Call <a class="reference internal" href="#c.psa_cipher_update" title="psa_cipher_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_update()</span></code></a> zero, one or more times, passing a fragment of the message each time.</li> |
| 1827 | <li>Call <a class="reference internal" href="#c.psa_cipher_finish" title="psa_cipher_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_finish()</span></code></a>.</li> |
| 1828 | </ol> |
| 1829 | <p>The application may call <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a> at any time after the operation has been initialized.</p> |
| 1830 | <p>After a successful call to <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a>, the application must eventually terminate the operation. The following events terminate an operation:</p> |
| 1831 | <ul class="simple"> |
| 1832 | <li>A failed call to any of the <code class="docutils literal notranslate"><span class="pre">psa_cipher_xxx</span></code> functions.</li> |
| 1833 | <li>A call to <a class="reference internal" href="#c.psa_cipher_finish" title="psa_cipher_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_finish()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a>.</li> |
| 1834 | </ul> |
| 1835 | </div> |
| 1836 | <div class="section" id="psa_cipher_decrypt_setup"> |
| 1837 | <span id="c.psa_cipher_decrypt_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup</span></code> (function)</h2> |
| 1838 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_decrypt_setup</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1839 | <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 1840 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span> |
| 1841 | </pre></div> |
| 1842 | </div> |
| 1843 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1844 | <dl class="docutils"> |
| 1845 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1846 | <dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a> and not yet in use.</dd> |
| 1847 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 1848 | <dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd> |
| 1849 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 1850 | <dd>The cipher algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_CIPHER" title="PSA_ALG_IS_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 1851 | </dl> |
| 1852 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1853 | <dl class="docutils"> |
| 1854 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1855 | <dd>Success.</dd> |
| 1856 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1857 | <dd></dd> |
| 1858 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1859 | <dd></dd> |
| 1860 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1861 | <dd></dd> |
| 1862 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1863 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 1864 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1865 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a cipher algorithm.</dd> |
| 1866 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1867 | <dd></dd> |
| 1868 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1869 | <dd></dd> |
| 1870 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1871 | <dd></dd> |
| 1872 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1873 | <dd></dd> |
| 1874 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1875 | <dd>The operation state is not valid (already set up and not subsequently completed).</dd> |
| 1876 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1877 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 1878 | </dl> |
| 1879 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1880 | <p>Set the key for a multipart symmetric decryption operation.</p> |
| 1881 | <p>The sequence of operations to decrypt a message with a symmetric cipher is as follows:</p> |
| 1882 | <ol class="arabic simple"> |
| 1883 | <li>Allocate an operation object which will be passed to all the functions listed here.</li> |
| 1884 | <li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a>, e.g. PSA_CIPHER_OPERATION_INIT.</li> |
| 1885 | <li>Call <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a> to specify the algorithm and key.</li> |
| 1886 | <li>Call <a class="reference internal" href="#c.psa_cipher_set_iv" title="psa_cipher_set_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_set_iv()</span></code></a> with the IV (initialization vector) for the decryption. If the IV is prepended to the ciphertext, you can call <a class="reference internal" href="#c.psa_cipher_update" title="psa_cipher_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_update()</span></code></a> on a buffer containing the IV followed by the beginning of the message.</li> |
| 1887 | <li>Call <a class="reference internal" href="#c.psa_cipher_update" title="psa_cipher_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_update()</span></code></a> zero, one or more times, passing a fragment of the message each time.</li> |
| 1888 | <li>Call <a class="reference internal" href="#c.psa_cipher_finish" title="psa_cipher_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_finish()</span></code></a>.</li> |
| 1889 | </ol> |
| 1890 | <p>The application may call <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a> at any time after the operation has been initialized.</p> |
| 1891 | <p>After a successful call to <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a>, the application must eventually terminate the operation. The following events terminate an operation:</p> |
| 1892 | <ul class="simple"> |
| 1893 | <li>A failed call to any of the <code class="docutils literal notranslate"><span class="pre">psa_cipher_xxx</span></code> functions.</li> |
| 1894 | <li>A call to <a class="reference internal" href="#c.psa_cipher_finish" title="psa_cipher_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_finish()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a>.</li> |
| 1895 | </ul> |
| 1896 | </div> |
| 1897 | <div class="section" id="psa_cipher_generate_iv"> |
| 1898 | <span id="c.psa_cipher_generate_iv"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_generate_iv</span></code> (function)</h2> |
| 1899 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_generate_iv</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1900 | <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">iv</span><span class="p">,</span> |
| 1901 | <span class="kt">size_t</span> <span class="n">iv_size</span><span class="p">,</span> |
| 1902 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">iv_length</span><span class="p">);</span> |
| 1903 | </pre></div> |
| 1904 | </div> |
| 1905 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1906 | <dl class="docutils"> |
| 1907 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1908 | <dd>Active cipher operation.</dd> |
| 1909 | <dt> <code class="docutils literal notranslate"><span class="pre">iv</span></code></dt> |
| 1910 | <dd>Buffer where the generated IV is to be written.</dd> |
| 1911 | <dt> <code class="docutils literal notranslate"><span class="pre">iv_size</span></code></dt> |
| 1912 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">iv</span></code> buffer in bytes.</dd> |
| 1913 | <dt> <code class="docutils literal notranslate"><span class="pre">iv_length</span></code></dt> |
| 1914 | <dd>On success, the number of bytes of the generated IV.</dd> |
| 1915 | </dl> |
| 1916 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1917 | <dl class="docutils"> |
| 1918 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1919 | <dd>Success.</dd> |
| 1920 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1921 | <dd>The operation state is not valid (not set up, or IV already set).</dd> |
| 1922 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1923 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">iv</span></code> buffer is too small.</dd> |
| 1924 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1925 | <dd></dd> |
| 1926 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1927 | <dd></dd> |
| 1928 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1929 | <dd></dd> |
| 1930 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1931 | <dd></dd> |
| 1932 | </dl> |
| 1933 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1934 | <p>Generate an IV for a symmetric encryption operation.</p> |
| 1935 | <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> |
| 1936 | <p>The application must call <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> before calling this function.</p> |
| 1937 | <p>If this function returns an error status, the operation becomes inactive.</p> |
| 1938 | </div> |
| 1939 | <div class="section" id="psa_cipher_set_iv"> |
| 1940 | <span id="c.psa_cipher_set_iv"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_set_iv</span></code> (function)</h2> |
| 1941 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_set_iv</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1942 | <span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">iv</span><span class="p">,</span> |
| 1943 | <span class="kt">size_t</span> <span class="n">iv_length</span><span class="p">);</span> |
| 1944 | </pre></div> |
| 1945 | </div> |
| 1946 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1947 | <dl class="docutils"> |
| 1948 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1949 | <dd>Active cipher operation.</dd> |
| 1950 | <dt> <code class="docutils literal notranslate"><span class="pre">iv</span></code></dt> |
| 1951 | <dd>Buffer containing the IV to use.</dd> |
| 1952 | <dt> <code class="docutils literal notranslate"><span class="pre">iv_length</span></code></dt> |
| 1953 | <dd>Size of the IV in bytes.</dd> |
| 1954 | </dl> |
| 1955 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 1956 | <dl class="docutils"> |
| 1957 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1958 | <dd>Success.</dd> |
| 1959 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1960 | <dd>The operation state is not valid (not set up, or IV already set).</dd> |
| 1961 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1962 | <dd>The size of <code class="docutils literal notranslate"><span class="pre">iv</span></code> is not acceptable for the chosen algorithm, or the chosen algorithm does not use an IV.</dd> |
| 1963 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1964 | <dd></dd> |
| 1965 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1966 | <dd></dd> |
| 1967 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1968 | <dd></dd> |
| 1969 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 1970 | <dd></dd> |
| 1971 | </dl> |
| 1972 | <p class="subitem-title"><strong>Description:</strong></p> |
| 1973 | <p>Set the IV for a symmetric encryption or decryption operation.</p> |
| 1974 | <p>This function sets the IV (initialization vector), nonce or initial counter value for the encryption or decryption operation.</p> |
| 1975 | <p>The application must call <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> before calling this function.</p> |
| 1976 | <p>If this function returns an error status, the operation becomes inactive.</p> |
| 1977 | <div class="admonition note"> |
| 1978 | <p class="first admonition-title">Note</p> |
| 1979 | <p class="last">When encrypting, applications should use <a class="reference internal" href="#c.psa_cipher_generate_iv" title="psa_cipher_generate_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_generate_iv()</span></code></a> instead of this function, unless implementing a protocol that requires a non-random IV.</p> |
| 1980 | </div> |
| 1981 | </div> |
| 1982 | <div class="section" id="psa_cipher_update"> |
| 1983 | <span id="c.psa_cipher_update"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_update</span></code> (function)</h2> |
| 1984 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_update</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 1985 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 1986 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span> |
| 1987 | <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span> |
| 1988 | <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span> |
| 1989 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span> |
| 1990 | </pre></div> |
| 1991 | </div> |
| 1992 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 1993 | <dl class="docutils"> |
| 1994 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 1995 | <dd>Active cipher operation.</dd> |
| 1996 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 1997 | <dd>Buffer containing the message fragment to encrypt or decrypt.</dd> |
| 1998 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 1999 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 2000 | <dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt> |
| 2001 | <dd>Buffer where the output is to be written.</dd> |
| 2002 | <dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt> |
| 2003 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd> |
| 2004 | <dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt> |
| 2005 | <dd>On success, the number of bytes that make up the returned output.</dd> |
| 2006 | </dl> |
| 2007 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2008 | <dl class="docutils"> |
| 2009 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2010 | <dd>Success.</dd> |
| 2011 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2012 | <dd>The operation state is not valid (not set up, IV required but not set, or already completed).</dd> |
| 2013 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2014 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer is too small.</dd> |
| 2015 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2016 | <dd></dd> |
| 2017 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2018 | <dd></dd> |
| 2019 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2020 | <dd></dd> |
| 2021 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2022 | <dd></dd> |
| 2023 | </dl> |
| 2024 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2025 | <p>Encrypt or decrypt a message fragment in an active cipher operation.</p> |
| 2026 | <p>Before calling this function, you must:</p> |
| 2027 | <ol class="arabic simple"> |
| 2028 | <li>Call either <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a>. The choice of setup function determines whether this function encrypts or decrypts its input.</li> |
| 2029 | <li>If the algorithm requires an IV, call <a class="reference internal" href="#c.psa_cipher_generate_iv" title="psa_cipher_generate_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_generate_iv()</span></code></a> (recommended when encrypting) or <a class="reference internal" href="#c.psa_cipher_set_iv" title="psa_cipher_set_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_set_iv()</span></code></a>.</li> |
| 2030 | </ol> |
| 2031 | <p>If this function returns an error status, the operation becomes inactive.</p> |
| 2032 | </div> |
| 2033 | <div class="section" id="psa_cipher_finish"> |
| 2034 | <span id="c.psa_cipher_finish"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_finish</span></code> (function)</h2> |
| 2035 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_finish</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 2036 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span> |
| 2037 | <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span> |
| 2038 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span> |
| 2039 | </pre></div> |
| 2040 | </div> |
| 2041 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2042 | <dl class="docutils"> |
| 2043 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2044 | <dd>Active cipher operation.</dd> |
| 2045 | <dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt> |
| 2046 | <dd>Buffer where the output is to be written.</dd> |
| 2047 | <dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt> |
| 2048 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd> |
| 2049 | <dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt> |
| 2050 | <dd>On success, the number of bytes that make up the returned output.</dd> |
| 2051 | </dl> |
| 2052 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2053 | <dl class="docutils"> |
| 2054 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2055 | <dd>Success.</dd> |
| 2056 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2057 | <dd>The operation state is not valid (not set up, IV required but not set, or already completed).</dd> |
| 2058 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2059 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer is too small.</dd> |
| 2060 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2061 | <dd></dd> |
| 2062 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2063 | <dd></dd> |
| 2064 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2065 | <dd></dd> |
| 2066 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2067 | <dd></dd> |
| 2068 | </dl> |
| 2069 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2070 | <p>Finish encrypting or decrypting a message in a cipher operation.</p> |
| 2071 | <p>The application must call <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a> before calling this function. The choice of setup function determines whether this function encrypts or decrypts its input.</p> |
| 2072 | <p>This function finishes the encryption or decryption of the message formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_cipher_update" title="psa_cipher_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_update()</span></code></a>.</p> |
| 2073 | <p>When this function returns, the operation becomes inactive.</p> |
| 2074 | </div> |
| 2075 | <div class="section" id="psa_cipher_abort"> |
| 2076 | <span id="c.psa_cipher_abort"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_abort</span></code> (function)</h2> |
| 2077 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_abort</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">);</span> |
| 2078 | </pre></div> |
| 2079 | </div> |
| 2080 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2081 | <dl class="docutils"> |
| 2082 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2083 | <dd>Initialized cipher operation.</dd> |
| 2084 | </dl> |
| 2085 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2086 | <dl class="docutils"> |
| 2087 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2088 | <dd></dd> |
| 2089 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2090 | <dd><code class="docutils literal notranslate"><span class="pre">operation</span></code> is not an active cipher operation.</dd> |
| 2091 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2092 | <dd></dd> |
| 2093 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2094 | <dd></dd> |
| 2095 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2096 | <dd></dd> |
| 2097 | </dl> |
| 2098 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2099 | <p>Abort a cipher operation.</p> |
| 2100 | <p>Aborting an operation frees all associated resources except for the <code class="docutils literal notranslate"><span class="pre">operation</span></code> structure itself. Once aborted, the operation object can be reused for another operation by calling <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a> again.</p> |
| 2101 | <p>You may call this function any time after the operation object has been initialized by any of the following methods:</p> |
| 2102 | <ul class="simple"> |
| 2103 | <li>A call to <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a>, whether it succeeds or not.</li> |
| 2104 | <li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to all-bits-zero.</li> |
| 2105 | <li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to logical zeros, e.g. <code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span> <span class="pre">operation</span> <span class="pre">=</span> <span class="pre">{0}</span></code>.</li> |
| 2106 | </ul> |
| 2107 | <p>In particular, calling <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a> after the operation has been terminated by a call to <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_finish" title="psa_cipher_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_finish()</span></code></a> is safe and has no effect.</p> |
| 2108 | </div> |
| 2109 | </div> |
| 2110 | <div class="section" id="authenticated-encryption-with-associated-data-aead"> |
| 2111 | <h1>Authenticated encryption with associated data (AEAD)</h1> |
| 2112 | <div class="section" id="psa_aead_operation_t"> |
| 2113 | <span id="c.psa_aead_operation_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code> (type)</h2> |
| 2114 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_aead_operation_s</span> <span class="n">psa_aead_operation_t</span><span class="p">;</span> |
| 2115 | </pre></div> |
| 2116 | </div> |
| 2117 | <p>The type of the state data structure for multipart AEAD operations.</p> |
| 2118 | <p>Before calling any function on an AEAD operation object, the application must initialize it by any of the following means:</p> |
| 2119 | <ul> |
| 2120 | <li><p class="first">Set the structure to all-bits-zero, for example:</p> |
| 2121 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_aead_operation_t</span> <span class="n">operation</span><span class="p">;</span> |
| 2122 | <span class="n">memset</span><span class="p">(</span><span class="o">&</span><span class="n">operation</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">operation</span><span class="p">));</span> |
| 2123 | </pre></div> |
| 2124 | </div> |
| 2125 | </li> |
| 2126 | <li><p class="first">Initialize the structure to logical zero values, for example:</p> |
| 2127 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_aead_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span> |
| 2128 | </pre></div> |
| 2129 | </div> |
| 2130 | </li> |
| 2131 | <li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_AEAD_OPERATION_INIT" title="PSA_AEAD_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_OPERATION_INIT</span></code></a>, for example:</p> |
| 2132 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_aead_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="n">PSA_AEAD_OPERATION_INIT</span><span class="p">;</span> |
| 2133 | </pre></div> |
| 2134 | </div> |
| 2135 | </li> |
| 2136 | <li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_aead_operation_init" title="psa_aead_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_operation_init()</span></code></a> to the structure, for example:</p> |
| 2137 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_aead_operation_t</span> <span class="n">operation</span><span class="p">;</span> |
| 2138 | <span class="n">operation</span> <span class="o">=</span> <span class="n">psa_aead_operation_init</span><span class="p">();</span> |
| 2139 | </pre></div> |
| 2140 | </div> |
| 2141 | </li> |
| 2142 | </ul> |
| 2143 | <p>This is an implementation-defined <code class="docutils literal notranslate"><span class="pre">struct</span></code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation.</p> |
| 2144 | </div> |
| 2145 | <div class="section" id="PSA_AEAD_OPERATION_INIT"> |
| 2146 | <span id="c.PSA_AEAD_OPERATION_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_OPERATION_INIT</span></code> (macro)</h2> |
| 2147 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_OPERATION_INIT {0}</span> |
| 2148 | </pre></div> |
| 2149 | </div> |
| 2150 | <p>This macro returns a suitable initializer for an AEAD operation object of type <a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a>.</p> |
| 2151 | </div> |
| 2152 | <div class="section" id="psa_aead_encrypt"> |
| 2153 | <span id="c.psa_aead_encrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_encrypt</span></code> (function)</h2> |
| 2154 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_encrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 2155 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 2156 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">nonce</span><span class="p">,</span> |
| 2157 | <span class="kt">size_t</span> <span class="n">nonce_length</span><span class="p">,</span> |
| 2158 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">additional_data</span><span class="p">,</span> |
| 2159 | <span class="kt">size_t</span> <span class="n">additional_data_length</span><span class="p">,</span> |
| 2160 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">plaintext</span><span class="p">,</span> |
| 2161 | <span class="kt">size_t</span> <span class="n">plaintext_length</span><span class="p">,</span> |
| 2162 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">ciphertext</span><span class="p">,</span> |
| 2163 | <span class="kt">size_t</span> <span class="n">ciphertext_size</span><span class="p">,</span> |
| 2164 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">ciphertext_length</span><span class="p">);</span> |
| 2165 | </pre></div> |
| 2166 | </div> |
| 2167 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2168 | <dl class="docutils"> |
| 2169 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 2170 | <dd>Handle to the key to use for the operation.</dd> |
| 2171 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 2172 | <dd>The AEAD algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 2173 | <dt> <code class="docutils literal notranslate"><span class="pre">nonce</span></code></dt> |
| 2174 | <dd>Nonce or IV to use.</dd> |
| 2175 | <dt> <code class="docutils literal notranslate"><span class="pre">nonce_length</span></code></dt> |
| 2176 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">nonce</span></code> buffer in bytes.</dd> |
| 2177 | <dt> <code class="docutils literal notranslate"><span class="pre">additional_data</span></code></dt> |
| 2178 | <dd>Additional data that will be authenticated but not encrypted.</dd> |
| 2179 | <dt> <code class="docutils literal notranslate"><span class="pre">additional_data_length</span></code></dt> |
| 2180 | <dd>Size of <code class="docutils literal notranslate"><span class="pre">additional_data</span></code> in bytes.</dd> |
| 2181 | <dt> <code class="docutils literal notranslate"><span class="pre">plaintext</span></code></dt> |
| 2182 | <dd>Data that will be authenticated and encrypted.</dd> |
| 2183 | <dt> <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code></dt> |
| 2184 | <dd>Size of <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> in bytes.</dd> |
| 2185 | <dt> <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code></dt> |
| 2186 | <dd>Output buffer for the authenticated and encrypted data. The additional data is not part of this output. For algorithms where the encrypted data and the authentication tag are defined as separate outputs, the authentication tag is appended to the encrypted data.</dd> |
| 2187 | <dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_size</span></code></dt> |
| 2188 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_ENCRYPT_OUTPUT_SIZE" title="PSA_AEAD_ENCRYPT_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_ENCRYPT_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>, <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code>).</dd> |
| 2189 | <dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_length</span></code></dt> |
| 2190 | <dd>On success, the size of the output in the <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> buffer.</dd> |
| 2191 | </dl> |
| 2192 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2193 | <dl class="docutils"> |
| 2194 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2195 | <dd>Success.</dd> |
| 2196 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2197 | <dd></dd> |
| 2198 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2199 | <dd></dd> |
| 2200 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2201 | <dd></dd> |
| 2202 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2203 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 2204 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2205 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not an AEAD algorithm.</dd> |
| 2206 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2207 | <dd></dd> |
| 2208 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2209 | <dd></dd> |
| 2210 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2211 | <dd></dd> |
| 2212 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2213 | <dd></dd> |
| 2214 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2215 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 2216 | </dl> |
| 2217 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2218 | <p>Process an authenticated encryption operation.</p> |
| 2219 | </div> |
| 2220 | <div class="section" id="psa_aead_decrypt"> |
| 2221 | <span id="c.psa_aead_decrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_decrypt</span></code> (function)</h2> |
| 2222 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_decrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 2223 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 2224 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">nonce</span><span class="p">,</span> |
| 2225 | <span class="kt">size_t</span> <span class="n">nonce_length</span><span class="p">,</span> |
| 2226 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">additional_data</span><span class="p">,</span> |
| 2227 | <span class="kt">size_t</span> <span class="n">additional_data_length</span><span class="p">,</span> |
| 2228 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">ciphertext</span><span class="p">,</span> |
| 2229 | <span class="kt">size_t</span> <span class="n">ciphertext_length</span><span class="p">,</span> |
| 2230 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">plaintext</span><span class="p">,</span> |
| 2231 | <span class="kt">size_t</span> <span class="n">plaintext_size</span><span class="p">,</span> |
| 2232 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">plaintext_length</span><span class="p">);</span> |
| 2233 | </pre></div> |
| 2234 | </div> |
| 2235 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2236 | <dl class="docutils"> |
| 2237 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 2238 | <dd>Handle to the key to use for the operation.</dd> |
| 2239 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 2240 | <dd>The AEAD algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 2241 | <dt> <code class="docutils literal notranslate"><span class="pre">nonce</span></code></dt> |
| 2242 | <dd>Nonce or IV to use.</dd> |
| 2243 | <dt> <code class="docutils literal notranslate"><span class="pre">nonce_length</span></code></dt> |
| 2244 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">nonce</span></code> buffer in bytes.</dd> |
| 2245 | <dt> <code class="docutils literal notranslate"><span class="pre">additional_data</span></code></dt> |
| 2246 | <dd>Additional data that has been authenticated but not encrypted.</dd> |
| 2247 | <dt> <code class="docutils literal notranslate"><span class="pre">additional_data_length</span></code></dt> |
| 2248 | <dd>Size of <code class="docutils literal notranslate"><span class="pre">additional_data</span></code> in bytes.</dd> |
| 2249 | <dt> <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code></dt> |
| 2250 | <dd>Data that has been authenticated and encrypted. For algorithms where the encrypted data and the authentication tag are defined as separate inputs, the buffer must contain the encrypted data followed by the authentication tag.</dd> |
| 2251 | <dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_length</span></code></dt> |
| 2252 | <dd>Size of <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> in bytes.</dd> |
| 2253 | <dt> <code class="docutils literal notranslate"><span class="pre">plaintext</span></code></dt> |
| 2254 | <dd>Output buffer for the decrypted data.</dd> |
| 2255 | <dt> <code class="docutils literal notranslate"><span class="pre">plaintext_size</span></code></dt> |
| 2256 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_DECRYPT_OUTPUT_SIZE" title="PSA_AEAD_DECRYPT_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_DECRYPT_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>, <code class="docutils literal notranslate"><span class="pre">ciphertext_length</span></code>).</dd> |
| 2257 | <dt> <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code></dt> |
| 2258 | <dd>On success, the size of the output in the <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> buffer.</dd> |
| 2259 | </dl> |
| 2260 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2261 | <dl class="docutils"> |
| 2262 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2263 | <dd>Success.</dd> |
| 2264 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2265 | <dd></dd> |
| 2266 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2267 | <dd></dd> |
| 2268 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2269 | <dd>The ciphertext is not authentic.</dd> |
| 2270 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2271 | <dd></dd> |
| 2272 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2273 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 2274 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2275 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not an AEAD algorithm.</dd> |
| 2276 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2277 | <dd></dd> |
| 2278 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2279 | <dd></dd> |
| 2280 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2281 | <dd></dd> |
| 2282 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2283 | <dd></dd> |
| 2284 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2285 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 2286 | </dl> |
| 2287 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2288 | <p>Process an authenticated decryption operation.</p> |
| 2289 | </div> |
| 2290 | <div class="section" id="psa_aead_operation_init"> |
| 2291 | <span id="c.psa_aead_operation_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_operation_init</span></code> (function)</h2> |
| 2292 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_aead_operation_t</span> <span class="nf">psa_aead_operation_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> |
| 2293 | </pre></div> |
| 2294 | </div> |
| 2295 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2296 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2297 | <p>Return an initial value for an AEAD operation object.</p> |
| 2298 | </div> |
| 2299 | <div class="section" id="psa_aead_encrypt_setup"> |
| 2300 | <span id="c.psa_aead_encrypt_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup</span></code> (function)</h2> |
| 2301 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_encrypt_setup</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 2302 | <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 2303 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span> |
| 2304 | </pre></div> |
| 2305 | </div> |
| 2306 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2307 | <dl class="docutils"> |
| 2308 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2309 | <dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a> and not yet in use.</dd> |
| 2310 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 2311 | <dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd> |
| 2312 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 2313 | <dd>The AEAD algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 2314 | </dl> |
| 2315 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2316 | <dl class="docutils"> |
| 2317 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2318 | <dd>Success.</dd> |
| 2319 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2320 | <dd></dd> |
| 2321 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2322 | <dd></dd> |
| 2323 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2324 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 2325 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2326 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not an AEAD algorithm.</dd> |
| 2327 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2328 | <dd></dd> |
| 2329 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2330 | <dd></dd> |
| 2331 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2332 | <dd></dd> |
| 2333 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2334 | <dd></dd> |
| 2335 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2336 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 2337 | </dl> |
| 2338 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2339 | <p>Set the key for a multipart authenticated encryption operation.</p> |
| 2340 | <p>The sequence of operations to encrypt a message with authentication is as follows:</p> |
| 2341 | <ol class="arabic simple"> |
| 2342 | <li>Allocate an operation object which will be passed to all the functions listed here.</li> |
| 2343 | <li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a>, e.g. PSA_AEAD_OPERATION_INIT.</li> |
| 2344 | <li>Call <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> to specify the algorithm and key.</li> |
| 2345 | <li>If needed, call <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a> to specify the length of the inputs to the subsequent calls to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> and <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>. See the documentation of <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a> for details.</li> |
| 2346 | <li>Call either <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a> or <a class="reference internal" href="#c.psa_aead_set_nonce" title="psa_aead_set_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_nonce()</span></code></a> to generate or set the nonce. You should use <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a> unless the protocol you are implementing requires a specific nonce value.</li> |
| 2347 | <li>Call <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> zero, one or more times, passing a fragment of the non-encrypted additional authenticated data each time.</li> |
| 2348 | <li>Call <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> zero, one or more times, passing a fragment of the message to encrypt each time.</li> |
| 2349 | <li>Call <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a>.</li> |
| 2350 | </ol> |
| 2351 | <p>The application may call <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a> at any time after the operation has been initialized.</p> |
| 2352 | <p>After a successful call to <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a>, the application must eventually terminate the operation. The following events terminate an operation:</p> |
| 2353 | <ul class="simple"> |
| 2354 | <li>A failed call to any of the <code class="docutils literal notranslate"><span class="pre">psa_aead_xxx</span></code> functions.</li> |
| 2355 | <li>A call to <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a>, <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> or <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a>.</li> |
| 2356 | </ul> |
| 2357 | </div> |
| 2358 | <div class="section" id="psa_aead_decrypt_setup"> |
| 2359 | <span id="c.psa_aead_decrypt_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup</span></code> (function)</h2> |
| 2360 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_decrypt_setup</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 2361 | <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 2362 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span> |
| 2363 | </pre></div> |
| 2364 | </div> |
| 2365 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2366 | <dl class="docutils"> |
| 2367 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2368 | <dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a> and not yet in use.</dd> |
| 2369 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 2370 | <dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd> |
| 2371 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 2372 | <dd>The AEAD algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 2373 | </dl> |
| 2374 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2375 | <dl class="docutils"> |
| 2376 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2377 | <dd>Success.</dd> |
| 2378 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2379 | <dd></dd> |
| 2380 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2381 | <dd></dd> |
| 2382 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2383 | <dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd> |
| 2384 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2385 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not an AEAD algorithm.</dd> |
| 2386 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2387 | <dd></dd> |
| 2388 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2389 | <dd></dd> |
| 2390 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2391 | <dd></dd> |
| 2392 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2393 | <dd></dd> |
| 2394 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2395 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 2396 | </dl> |
| 2397 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2398 | <p>Set the key for a multipart authenticated decryption operation.</p> |
| 2399 | <p>The sequence of operations to decrypt a message with authentication is as follows:</p> |
| 2400 | <ol class="arabic simple"> |
| 2401 | <li>Allocate an operation object which will be passed to all the functions listed here.</li> |
| 2402 | <li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a>, e.g. PSA_AEAD_OPERATION_INIT.</li> |
| 2403 | <li>Call <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a> to specify the algorithm and key.</li> |
| 2404 | <li>If needed, call <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a> to specify the length of the inputs to the subsequent calls to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> and <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>. See the documentation of <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a> for details.</li> |
| 2405 | <li>Call <a class="reference internal" href="#c.psa_aead_set_nonce" title="psa_aead_set_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_nonce()</span></code></a> with the nonce for the decryption.</li> |
| 2406 | <li>Call <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> zero, one or more times, passing a fragment of the non-encrypted additional authenticated data each time.</li> |
| 2407 | <li>Call <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> zero, one or more times, passing a fragment of the ciphertext to decrypt each time.</li> |
| 2408 | <li>Call <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a>.</li> |
| 2409 | </ol> |
| 2410 | <p>The application may call <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a> at any time after the operation has been initialized.</p> |
| 2411 | <p>After a successful call to <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a>, the application must eventually terminate the operation. The following events terminate an operation:</p> |
| 2412 | <ul class="simple"> |
| 2413 | <li>A failed call to any of the <code class="docutils literal notranslate"><span class="pre">psa_aead_xxx</span></code> functions.</li> |
| 2414 | <li>A call to <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a>, <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> or <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a>.</li> |
| 2415 | </ul> |
| 2416 | </div> |
| 2417 | <div class="section" id="psa_aead_generate_nonce"> |
| 2418 | <span id="c.psa_aead_generate_nonce"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_generate_nonce</span></code> (function)</h2> |
| 2419 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_generate_nonce</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 2420 | <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">nonce</span><span class="p">,</span> |
| 2421 | <span class="kt">size_t</span> <span class="n">nonce_size</span><span class="p">,</span> |
| 2422 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">nonce_length</span><span class="p">);</span> |
| 2423 | </pre></div> |
| 2424 | </div> |
| 2425 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2426 | <dl class="docutils"> |
| 2427 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2428 | <dd>Active AEAD operation.</dd> |
| 2429 | <dt> <code class="docutils literal notranslate"><span class="pre">nonce</span></code></dt> |
| 2430 | <dd>Buffer where the generated nonce is to be written.</dd> |
| 2431 | <dt> <code class="docutils literal notranslate"><span class="pre">nonce_size</span></code></dt> |
| 2432 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">nonce</span></code> buffer in bytes.</dd> |
| 2433 | <dt> <code class="docutils literal notranslate"><span class="pre">nonce_length</span></code></dt> |
| 2434 | <dd>On success, the number of bytes of the generated nonce.</dd> |
| 2435 | </dl> |
| 2436 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2437 | <dl class="docutils"> |
| 2438 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2439 | <dd>Success.</dd> |
| 2440 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2441 | <dd>The operation state is not valid (not set up, or nonce already set).</dd> |
| 2442 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2443 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">nonce</span></code> buffer is too small.</dd> |
| 2444 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2445 | <dd></dd> |
| 2446 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2447 | <dd></dd> |
| 2448 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2449 | <dd></dd> |
| 2450 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2451 | <dd></dd> |
| 2452 | </dl> |
| 2453 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2454 | <p>Generate a random nonce for an authenticated encryption operation.</p> |
| 2455 | <p>This function generates a random nonce for the authenticated encryption operation with an appropriate size for the chosen algorithm, key type and key size.</p> |
| 2456 | <p>The application must call <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> before calling this function.</p> |
| 2457 | <p>If this function returns an error status, the operation becomes inactive.</p> |
| 2458 | </div> |
| 2459 | <div class="section" id="psa_aead_set_nonce"> |
| 2460 | <span id="c.psa_aead_set_nonce"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_set_nonce</span></code> (function)</h2> |
| 2461 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_set_nonce</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 2462 | <span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">nonce</span><span class="p">,</span> |
| 2463 | <span class="kt">size_t</span> <span class="n">nonce_length</span><span class="p">);</span> |
| 2464 | </pre></div> |
| 2465 | </div> |
| 2466 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2467 | <dl class="docutils"> |
| 2468 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2469 | <dd>Active AEAD operation.</dd> |
| 2470 | <dt> <code class="docutils literal notranslate"><span class="pre">nonce</span></code></dt> |
| 2471 | <dd>Buffer containing the nonce to use.</dd> |
| 2472 | <dt> <code class="docutils literal notranslate"><span class="pre">nonce_length</span></code></dt> |
| 2473 | <dd>Size of the nonce in bytes.</dd> |
| 2474 | </dl> |
| 2475 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2476 | <dl class="docutils"> |
| 2477 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2478 | <dd>Success.</dd> |
| 2479 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2480 | <dd>The operation state is not valid (not set up, or nonce already set).</dd> |
| 2481 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2482 | <dd>The size of <code class="docutils literal notranslate"><span class="pre">nonce</span></code> is not acceptable for the chosen algorithm.</dd> |
| 2483 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2484 | <dd></dd> |
| 2485 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2486 | <dd></dd> |
| 2487 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2488 | <dd></dd> |
| 2489 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2490 | <dd></dd> |
| 2491 | </dl> |
| 2492 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2493 | <p>Set the nonce for an authenticated encryption or decryption operation.</p> |
| 2494 | <p>This function sets the nonce for the authenticated encryption or decryption operation.</p> |
| 2495 | <p>The application must call <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> before calling this function.</p> |
| 2496 | <p>If this function returns an error status, the operation becomes inactive.</p> |
| 2497 | <div class="admonition note"> |
| 2498 | <p class="first admonition-title">Note</p> |
| 2499 | <p class="last">When encrypting, applications should use <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a> instead of this function, unless implementing a protocol that requires a non-random IV.</p> |
| 2500 | </div> |
| 2501 | </div> |
| 2502 | <div class="section" id="psa_aead_set_lengths"> |
| 2503 | <span id="c.psa_aead_set_lengths"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_set_lengths</span></code> (function)</h2> |
| 2504 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_set_lengths</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 2505 | <span class="kt">size_t</span> <span class="n">ad_length</span><span class="p">,</span> |
| 2506 | <span class="kt">size_t</span> <span class="n">plaintext_length</span><span class="p">);</span> |
| 2507 | </pre></div> |
| 2508 | </div> |
| 2509 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2510 | <dl class="docutils"> |
| 2511 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2512 | <dd>Active AEAD operation.</dd> |
| 2513 | <dt> <code class="docutils literal notranslate"><span class="pre">ad_length</span></code></dt> |
| 2514 | <dd>Size of the non-encrypted additional authenticated data in bytes.</dd> |
| 2515 | <dt> <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code></dt> |
| 2516 | <dd>Size of the plaintext to encrypt in bytes.</dd> |
| 2517 | </dl> |
| 2518 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2519 | <dl class="docutils"> |
| 2520 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2521 | <dd>Success.</dd> |
| 2522 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2523 | <dd>The operation state is not valid (not set up, already completed, or <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> or <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> already called).</dd> |
| 2524 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2525 | <dd>At least one of the lengths is not acceptable for the chosen algorithm.</dd> |
| 2526 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2527 | <dd></dd> |
| 2528 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2529 | <dd></dd> |
| 2530 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2531 | <dd></dd> |
| 2532 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2533 | <dd></dd> |
| 2534 | </dl> |
| 2535 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2536 | <p>Declare the lengths of the message and additional data for AEAD.</p> |
| 2537 | <p>The application must call this function before calling <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> or <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> if the algorithm for the operation requires it. If the algorithm does not require it, calling this function is optional, but if this function is called then the implementation must enforce the lengths.</p> |
| 2538 | <p>You may call this function before or after setting the nonce with <a class="reference internal" href="#c.psa_aead_set_nonce" title="psa_aead_set_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_nonce()</span></code></a> or <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a>.</p> |
| 2539 | <ul class="simple"> |
| 2540 | <li>For <a class="reference internal" href="#c.PSA_ALG_CCM" title="PSA_ALG_CCM"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_CCM</span></code></a>, calling this function is required.</li> |
| 2541 | <li>For the other AEAD algorithms defined in this specification, calling this function is not required.</li> |
| 2542 | <li>For vendor-defined algorithm, refer to the vendor documentation.</li> |
| 2543 | </ul> |
| 2544 | </div> |
| 2545 | <div class="section" id="psa_aead_update_ad"> |
| 2546 | <span id="c.psa_aead_update_ad"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_update_ad</span></code> (function)</h2> |
| 2547 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_update_ad</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 2548 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 2549 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">);</span> |
| 2550 | </pre></div> |
| 2551 | </div> |
| 2552 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2553 | <dl class="docutils"> |
| 2554 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2555 | <dd>Active AEAD operation.</dd> |
| 2556 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 2557 | <dd>Buffer containing the fragment of additional data.</dd> |
| 2558 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 2559 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 2560 | </dl> |
| 2561 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2562 | <dl class="docutils"> |
| 2563 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2564 | <dd>Success.</dd> |
| 2565 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2566 | <dd>The operation state is not valid (not set up, nonce not set, <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> already called, or operation already completed).</dd> |
| 2567 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2568 | <dd>The total input length overflows the additional data length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd> |
| 2569 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2570 | <dd></dd> |
| 2571 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2572 | <dd></dd> |
| 2573 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2574 | <dd></dd> |
| 2575 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2576 | <dd></dd> |
| 2577 | </dl> |
| 2578 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2579 | <p>Pass additional data to an active AEAD operation.</p> |
| 2580 | <p>Additional data is authenticated, but not encrypted.</p> |
| 2581 | <p>You may call this function multiple times to pass successive fragments of the additional data. You may not call this function after passing data to encrypt or decrypt with <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>.</p> |
| 2582 | <p>Before calling this function, you must:</p> |
| 2583 | <ol class="arabic simple"> |
| 2584 | <li>Call either <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a>.</li> |
| 2585 | <li>Set the nonce with <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a> or <a class="reference internal" href="#c.psa_aead_set_nonce" title="psa_aead_set_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_nonce()</span></code></a>.</li> |
| 2586 | </ol> |
| 2587 | <p>If this function returns an error status, the operation becomes inactive.</p> |
| 2588 | <div class="admonition warning"> |
| 2589 | <p class="first admonition-title">Warning</p> |
| 2590 | <p class="last">When decrypting, until <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> has returned <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a>, there is no guarantee that the input is valid. Therefore, until you have called <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> and it has returned <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a>, treat the input as untrusted and prepare to undo any action that depends on the input if <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> returns an error status.</p> |
| 2591 | </div> |
| 2592 | </div> |
| 2593 | <div class="section" id="psa_aead_update"> |
| 2594 | <span id="c.psa_aead_update"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_update</span></code> (function)</h2> |
| 2595 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_update</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 2596 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 2597 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span> |
| 2598 | <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span> |
| 2599 | <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span> |
| 2600 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span> |
| 2601 | </pre></div> |
| 2602 | </div> |
| 2603 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2604 | <dl class="docutils"> |
| 2605 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2606 | <dd>Active AEAD operation.</dd> |
| 2607 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 2608 | <dd>Buffer containing the message fragment to encrypt or decrypt.</dd> |
| 2609 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 2610 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 2611 | <dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt> |
| 2612 | <dd>Buffer where the output is to be written.</dd> |
| 2613 | <dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt> |
| 2614 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_UPDATE_OUTPUT_SIZE" title="PSA_AEAD_UPDATE_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_UPDATE_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>, <code class="docutils literal notranslate"><span class="pre">input_length</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd> |
| 2615 | <dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt> |
| 2616 | <dd>On success, the number of bytes that make up the returned output.</dd> |
| 2617 | </dl> |
| 2618 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2619 | <dl class="docutils"> |
| 2620 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2621 | <dd>Success.</dd> |
| 2622 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2623 | <dd>The operation state is not valid (not set up, nonce not set or already completed).</dd> |
| 2624 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2625 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_AEAD_UPDATE_OUTPUT_SIZE" title="PSA_AEAD_UPDATE_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_UPDATE_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>, <code class="docutils literal notranslate"><span class="pre">input_length</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd> |
| 2626 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2627 | <dd>The total length of input to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> so far is less than the additional data length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd> |
| 2628 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2629 | <dd>The total input length overflows the plaintext length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd> |
| 2630 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2631 | <dd></dd> |
| 2632 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2633 | <dd></dd> |
| 2634 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2635 | <dd></dd> |
| 2636 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2637 | <dd></dd> |
| 2638 | </dl> |
| 2639 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2640 | <p>Encrypt or decrypt a message fragment in an active AEAD operation.</p> |
| 2641 | <p>Before calling this function, you must:</p> |
| 2642 | <ol class="arabic simple"> |
| 2643 | <li>Call either <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a>. The choice of setup function determines whether this function encrypts or decrypts its input.</li> |
| 2644 | <li>Set the nonce with <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a> or <a class="reference internal" href="#c.psa_aead_set_nonce" title="psa_aead_set_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_nonce()</span></code></a>.</li> |
| 2645 | <li>Call <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> to pass all the additional data.</li> |
| 2646 | </ol> |
| 2647 | <p>If this function returns an error status, the operation becomes inactive.</p> |
| 2648 | <div class="admonition warning"> |
| 2649 | <p class="first admonition-title">Warning</p> |
| 2650 | <p>When decrypting, until <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> has returned <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a>, there is no guarantee that the input is valid. Therefore, until you have called <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> and it has returned <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a>:</p> |
| 2651 | <ul class="last simple"> |
| 2652 | <li>Do not use the output in any way other than storing it in a confidential location. If you take any action that depends on the tentative decrypted data, this action will need to be undone if the input turns out not to be valid. Furthermore, if an adversary can observe that this action took place (for example through timing), they may be able to use this fact as an oracle to decrypt any message encrypted with the same key.</li> |
| 2653 | <li>In particular, do not copy the output anywhere but to a memory or storage space that you have exclusive access to.</li> |
| 2654 | </ul> |
| 2655 | </div> |
| 2656 | <p>This function does not require the input to be aligned to any particular block boundary. If the implementation can only process a whole block at a time, it must consume all the input provided, but it may delay the end of the corresponding output until a subsequent call to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>, <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a> or <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> provides sufficient input. The amount of data that can be delayed in this way is bounded by <a class="reference internal" href="#c.PSA_AEAD_UPDATE_OUTPUT_SIZE" title="PSA_AEAD_UPDATE_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_UPDATE_OUTPUT_SIZE</span></code></a>.</p> |
| 2657 | </div> |
| 2658 | <div class="section" id="psa_aead_finish"> |
| 2659 | <span id="c.psa_aead_finish"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_finish</span></code> (function)</h2> |
| 2660 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_finish</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 2661 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">ciphertext</span><span class="p">,</span> |
| 2662 | <span class="kt">size_t</span> <span class="n">ciphertext_size</span><span class="p">,</span> |
| 2663 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">ciphertext_length</span><span class="p">,</span> |
| 2664 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">tag</span><span class="p">,</span> |
| 2665 | <span class="kt">size_t</span> <span class="n">tag_size</span><span class="p">,</span> |
| 2666 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">tag_length</span><span class="p">);</span> |
| 2667 | </pre></div> |
| 2668 | </div> |
| 2669 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2670 | <dl class="docutils"> |
| 2671 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2672 | <dd>Active AEAD operation.</dd> |
| 2673 | <dt> <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code></dt> |
| 2674 | <dd>Buffer where the last part of the ciphertext is to be written.</dd> |
| 2675 | <dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_size</span></code></dt> |
| 2676 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_FINISH_OUTPUT_SIZE" title="PSA_AEAD_FINISH_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_FINISH_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd> |
| 2677 | <dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_length</span></code></dt> |
| 2678 | <dd>On success, the number of bytes of returned ciphertext.</dd> |
| 2679 | <dt> <code class="docutils literal notranslate"><span class="pre">tag</span></code></dt> |
| 2680 | <dd>Buffer where the authentication tag is to be written.</dd> |
| 2681 | <dt> <code class="docutils literal notranslate"><span class="pre">tag_size</span></code></dt> |
| 2682 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">tag</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_TAG_LENGTH" title="PSA_AEAD_TAG_LENGTH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd> |
| 2683 | <dt> <code class="docutils literal notranslate"><span class="pre">tag_length</span></code></dt> |
| 2684 | <dd>On success, the number of bytes that make up the returned tag.</dd> |
| 2685 | </dl> |
| 2686 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2687 | <dl class="docutils"> |
| 2688 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2689 | <dd>Success.</dd> |
| 2690 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2691 | <dd>The operation state is not valid (not set up, nonce not set, decryption, or already completed).</dd> |
| 2692 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2693 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> or <code class="docutils literal notranslate"><span class="pre">tag</span></code> buffer is too small. You can determine a sufficient buffer size for <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> by calling <a class="reference internal" href="#c.PSA_AEAD_FINISH_OUTPUT_SIZE" title="PSA_AEAD_FINISH_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_FINISH_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated. You can determine a sufficient buffer size for <code class="docutils literal notranslate"><span class="pre">tag</span></code> by calling <a class="reference internal" href="#c.PSA_AEAD_TAG_LENGTH" title="PSA_AEAD_TAG_LENGTH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>).</dd> |
| 2694 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2695 | <dd>The total length of input to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> so far is less than the additional data length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd> |
| 2696 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2697 | <dd>The total length of input to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> so far is less than the plaintext length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd> |
| 2698 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2699 | <dd></dd> |
| 2700 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2701 | <dd></dd> |
| 2702 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2703 | <dd></dd> |
| 2704 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2705 | <dd></dd> |
| 2706 | </dl> |
| 2707 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2708 | <p>Finish encrypting a message in an AEAD operation.</p> |
| 2709 | <p>The operation must have been set up with <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a>.</p> |
| 2710 | <p>This function finishes the authentication of the additional data formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> with the plaintext formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>.</p> |
| 2711 | <p>This function has two output buffers:</p> |
| 2712 | <ul class="simple"> |
| 2713 | <li><code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> contains trailing ciphertext that was buffered from preceding calls to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>.</li> |
| 2714 | <li><code class="docutils literal notranslate"><span class="pre">tag</span></code> contains the authentication tag. Its length is always <a class="reference internal" href="#c.PSA_AEAD_TAG_LENGTH" title="PSA_AEAD_TAG_LENGTH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the AEAD algorithm that the operation performs.</li> |
| 2715 | </ul> |
| 2716 | <p>When this function returns, the operation becomes inactive.</p> |
| 2717 | </div> |
| 2718 | <div class="section" id="psa_aead_verify"> |
| 2719 | <span id="c.psa_aead_verify"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_verify</span></code> (function)</h2> |
| 2720 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_verify</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 2721 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">plaintext</span><span class="p">,</span> |
| 2722 | <span class="kt">size_t</span> <span class="n">plaintext_size</span><span class="p">,</span> |
| 2723 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">plaintext_length</span><span class="p">,</span> |
| 2724 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">tag</span><span class="p">,</span> |
| 2725 | <span class="kt">size_t</span> <span class="n">tag_length</span><span class="p">);</span> |
| 2726 | </pre></div> |
| 2727 | </div> |
| 2728 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2729 | <dl class="docutils"> |
| 2730 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2731 | <dd>Active AEAD operation.</dd> |
| 2732 | <dt> <code class="docutils literal notranslate"><span class="pre">plaintext</span></code></dt> |
| 2733 | <dd>Buffer where the last part of the plaintext is to be written. This is the remaining data from previous calls to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> that could not be processed until the end of the input.</dd> |
| 2734 | <dt> <code class="docutils literal notranslate"><span class="pre">plaintext_size</span></code></dt> |
| 2735 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_VERIFY_OUTPUT_SIZE" title="PSA_AEAD_VERIFY_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_VERIFY_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd> |
| 2736 | <dt> <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code></dt> |
| 2737 | <dd>On success, the number of bytes of returned plaintext.</dd> |
| 2738 | <dt> <code class="docutils literal notranslate"><span class="pre">tag</span></code></dt> |
| 2739 | <dd>Buffer containing the authentication tag.</dd> |
| 2740 | <dt> <code class="docutils literal notranslate"><span class="pre">tag_length</span></code></dt> |
| 2741 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">tag</span></code> buffer in bytes.</dd> |
| 2742 | </dl> |
| 2743 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2744 | <dl class="docutils"> |
| 2745 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2746 | <dd>Success.</dd> |
| 2747 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2748 | <dd>The operation state is not valid (not set up, nonce not set, encryption, or already completed).</dd> |
| 2749 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2750 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> buffer is too small. You can determine a sufficient buffer size for <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> by calling <a class="reference internal" href="#c.PSA_AEAD_VERIFY_OUTPUT_SIZE" title="PSA_AEAD_VERIFY_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_VERIFY_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd> |
| 2751 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2752 | <dd>The total length of input to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> so far is less than the additional data length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd> |
| 2753 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2754 | <dd>The total length of input to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> so far is less than the plaintext length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd> |
| 2755 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2756 | <dd></dd> |
| 2757 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2758 | <dd></dd> |
| 2759 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2760 | <dd></dd> |
| 2761 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2762 | <dd></dd> |
| 2763 | </dl> |
| 2764 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2765 | <p>Finish authenticating and decrypting a message in an AEAD operation.</p> |
| 2766 | <p>The operation must have been set up with <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a>.</p> |
| 2767 | <p>This function finishes the authentication of the additional data formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> with the ciphertext formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>.</p> |
| 2768 | <p>When this function returns, the operation becomes inactive.</p> |
| 2769 | </div> |
| 2770 | <div class="section" id="psa_aead_abort"> |
| 2771 | <span id="c.psa_aead_abort"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_abort</span></code> (function)</h2> |
| 2772 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_abort</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">);</span> |
| 2773 | </pre></div> |
| 2774 | </div> |
| 2775 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2776 | <dl class="docutils"> |
| 2777 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 2778 | <dd>Initialized AEAD operation.</dd> |
| 2779 | </dl> |
| 2780 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2781 | <dl class="docutils"> |
| 2782 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2783 | <dd></dd> |
| 2784 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2785 | <dd><code class="docutils literal notranslate"><span class="pre">operation</span></code> is not an active AEAD operation.</dd> |
| 2786 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2787 | <dd></dd> |
| 2788 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2789 | <dd></dd> |
| 2790 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2791 | <dd></dd> |
| 2792 | </dl> |
| 2793 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2794 | <p>Abort an AEAD operation.</p> |
| 2795 | <p>Aborting an operation frees all associated resources except for the <code class="docutils literal notranslate"><span class="pre">operation</span></code> structure itself. Once aborted, the operation object can be reused for another operation by calling <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a> again.</p> |
| 2796 | <p>You may call this function any time after the operation object has been initialized by any of the following methods:</p> |
| 2797 | <ul class="simple"> |
| 2798 | <li>A call to <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a>, whether it succeeds or not.</li> |
| 2799 | <li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to all-bits-zero.</li> |
| 2800 | <li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to logical zeros, e.g. <code class="docutils literal notranslate"><span class="pre">psa_aead_operation_t</span> <span class="pre">operation</span> <span class="pre">=</span> <span class="pre">{0}</span></code>.</li> |
| 2801 | </ul> |
| 2802 | <p>In particular, calling <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a> after the operation has been terminated by a call to <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a> or <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a> is safe and has no effect.</p> |
| 2803 | </div> |
| 2804 | </div> |
| 2805 | <div class="section" id="asymmetric-cryptography"> |
| 2806 | <h1>Asymmetric cryptography</h1> |
| 2807 | <div class="section" id="psa_asymmetric_sign"> |
| 2808 | <span id="c.psa_asymmetric_sign"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_sign</span></code> (function)</h2> |
| 2809 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_asymmetric_sign</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 2810 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 2811 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span> |
| 2812 | <span class="kt">size_t</span> <span class="n">hash_length</span><span class="p">,</span> |
| 2813 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">signature</span><span class="p">,</span> |
| 2814 | <span class="kt">size_t</span> <span class="n">signature_size</span><span class="p">,</span> |
| 2815 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">signature_length</span><span class="p">);</span> |
| 2816 | </pre></div> |
| 2817 | </div> |
| 2818 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2819 | <dl class="docutils"> |
| 2820 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 2821 | <dd>Handle to the key to use for the operation. It must be an asymmetric key pair.</dd> |
| 2822 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 2823 | <dd>A signature algorithm that is compatible with the type of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd> |
| 2824 | <dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt> |
| 2825 | <dd>The hash or message to sign.</dd> |
| 2826 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt> |
| 2827 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd> |
| 2828 | <dt> <code class="docutils literal notranslate"><span class="pre">signature</span></code></dt> |
| 2829 | <dd>Buffer where the signature is to be written.</dd> |
| 2830 | <dt> <code class="docutils literal notranslate"><span class="pre">signature_size</span></code></dt> |
| 2831 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">signature</span></code> buffer in bytes.</dd> |
| 2832 | <dt> <code class="docutils literal notranslate"><span class="pre">signature_length</span></code></dt> |
| 2833 | <dd>On success, the number of bytes that make up the returned signature value.</dd> |
| 2834 | </dl> |
| 2835 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2836 | <dl class="docutils"> |
| 2837 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2838 | <dd></dd> |
| 2839 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2840 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">signature</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE" title="PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">key_type</span></code>, <code class="docutils literal notranslate"><span class="pre">key_bits</span></code>, <code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">key_type</span></code> and <code class="docutils literal notranslate"><span class="pre">key_bits</span></code> are the type and bit-size respectively of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd> |
| 2841 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2842 | <dd></dd> |
| 2843 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2844 | <dd></dd> |
| 2845 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2846 | <dd></dd> |
| 2847 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2848 | <dd></dd> |
| 2849 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2850 | <dd></dd> |
| 2851 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2852 | <dd></dd> |
| 2853 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2854 | <dd></dd> |
| 2855 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2856 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 2857 | </dl> |
| 2858 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2859 | <p>Sign a hash or short message with a private key.</p> |
| 2860 | <p>Note that to perform a hash-and-sign signature algorithm, you must first calculate the hash by calling <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a>, <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a> and <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a>. Then pass the resulting hash as the <code class="docutils literal notranslate"><span class="pre">hash</span></code> parameter to this function. You can use <a class="reference internal" href="#c.PSA_ALG_SIGN_GET_HASH" title="PSA_ALG_SIGN_GET_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_SIGN_GET_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) to determine the hash algorithm to use.</p> |
| 2861 | </div> |
| 2862 | <div class="section" id="psa_asymmetric_verify"> |
| 2863 | <span id="c.psa_asymmetric_verify"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_verify</span></code> (function)</h2> |
| 2864 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_asymmetric_verify</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 2865 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 2866 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span> |
| 2867 | <span class="kt">size_t</span> <span class="n">hash_length</span><span class="p">,</span> |
| 2868 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">signature</span><span class="p">,</span> |
| 2869 | <span class="kt">size_t</span> <span class="n">signature_length</span><span class="p">);</span> |
| 2870 | </pre></div> |
| 2871 | </div> |
| 2872 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2873 | <dl class="docutils"> |
| 2874 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 2875 | <dd>Handle to the key to use for the operation. It must be a public key or an asymmetric key pair.</dd> |
| 2876 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 2877 | <dd>A signature algorithm that is compatible with the type of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd> |
| 2878 | <dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt> |
| 2879 | <dd>The hash or message whose signature is to be verified.</dd> |
| 2880 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt> |
| 2881 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd> |
| 2882 | <dt> <code class="docutils literal notranslate"><span class="pre">signature</span></code></dt> |
| 2883 | <dd>Buffer containing the signature to verify.</dd> |
| 2884 | <dt> <code class="docutils literal notranslate"><span class="pre">signature_length</span></code></dt> |
| 2885 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">signature</span></code> buffer in bytes.</dd> |
| 2886 | </dl> |
| 2887 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2888 | <dl class="docutils"> |
| 2889 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2890 | <dd>The signature is valid.</dd> |
| 2891 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2892 | <dd>The calculation was perfomed successfully, but the passed signature is not a valid signature.</dd> |
| 2893 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2894 | <dd></dd> |
| 2895 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2896 | <dd></dd> |
| 2897 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2898 | <dd></dd> |
| 2899 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2900 | <dd></dd> |
| 2901 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2902 | <dd></dd> |
| 2903 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2904 | <dd></dd> |
| 2905 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2906 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 2907 | </dl> |
| 2908 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2909 | <p>Verify the signature a hash or short message using a public key.</p> |
| 2910 | <p>Note that to perform a hash-and-sign signature algorithm, you must first calculate the hash by calling <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a>, <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a> and <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a>. Then pass the resulting hash as the <code class="docutils literal notranslate"><span class="pre">hash</span></code> parameter to this function. You can use <a class="reference internal" href="#c.PSA_ALG_SIGN_GET_HASH" title="PSA_ALG_SIGN_GET_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_SIGN_GET_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) to determine the hash algorithm to use.</p> |
| 2911 | </div> |
| 2912 | <div class="section" id="psa_asymmetric_encrypt"> |
| 2913 | <span id="c.psa_asymmetric_encrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_encrypt</span></code> (function)</h2> |
| 2914 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_asymmetric_encrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 2915 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 2916 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 2917 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span> |
| 2918 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">salt</span><span class="p">,</span> |
| 2919 | <span class="kt">size_t</span> <span class="n">salt_length</span><span class="p">,</span> |
| 2920 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span> |
| 2921 | <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span> |
| 2922 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span> |
| 2923 | </pre></div> |
| 2924 | </div> |
| 2925 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2926 | <dl class="docutils"> |
| 2927 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 2928 | <dd>Handle to the key to use for the operation. It must be a public key or an asymmetric key pair.</dd> |
| 2929 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 2930 | <dd>An asymmetric encryption algorithm that is compatible with the type of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd> |
| 2931 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 2932 | <dd>The message to encrypt.</dd> |
| 2933 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 2934 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 2935 | <dt> <code class="docutils literal notranslate"><span class="pre">salt</span></code></dt> |
| 2936 | <dd>A salt or label, if supported by the encryption algorithm. If the algorithm does not support a salt, pass <code class="docutils literal notranslate"><span class="pre">NULL</span></code>. If the algorithm supports an optional salt and you do not want to pass a salt, pass <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</dd> |
| 2937 | <dt> <code class="docutils literal notranslate"><span class="pre">salt_length</span></code></dt> |
| 2938 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">salt</span></code> buffer in bytes. If <code class="docutils literal notranslate"><span class="pre">salt</span></code> is <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, pass 0.</dd> |
| 2939 | <dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt> |
| 2940 | <dd>Buffer where the encrypted message is to be written.</dd> |
| 2941 | <dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt> |
| 2942 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd> |
| 2943 | <dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt> |
| 2944 | <dd>On success, the number of bytes that make up the returned output.</dd> |
| 2945 | </dl> |
| 2946 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 2947 | <dl class="docutils"> |
| 2948 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2949 | <dd></dd> |
| 2950 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2951 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE" title="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">key_type</span></code>, <code class="docutils literal notranslate"><span class="pre">key_bits</span></code>, <code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">key_type</span></code> and <code class="docutils literal notranslate"><span class="pre">key_bits</span></code> are the type and bit-size respectively of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd> |
| 2952 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2953 | <dd></dd> |
| 2954 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2955 | <dd></dd> |
| 2956 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2957 | <dd></dd> |
| 2958 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2959 | <dd></dd> |
| 2960 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2961 | <dd></dd> |
| 2962 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2963 | <dd></dd> |
| 2964 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2965 | <dd></dd> |
| 2966 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 2967 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 2968 | </dl> |
| 2969 | <p class="subitem-title"><strong>Description:</strong></p> |
| 2970 | <p>Encrypt a short message with a public key.</p> |
| 2971 | <ul class="simple"> |
| 2972 | <li>For <a class="reference internal" href="#c.PSA_ALG_RSA_PKCS1V15_CRYPT" title="PSA_ALG_RSA_PKCS1V15_CRYPT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code></a>, no salt is supported.</li> |
| 2973 | </ul> |
| 2974 | </div> |
| 2975 | <div class="section" id="psa_asymmetric_decrypt"> |
| 2976 | <span id="c.psa_asymmetric_decrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_decrypt</span></code> (function)</h2> |
| 2977 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_asymmetric_decrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span> |
| 2978 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 2979 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span> |
| 2980 | <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span> |
| 2981 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">salt</span><span class="p">,</span> |
| 2982 | <span class="kt">size_t</span> <span class="n">salt_length</span><span class="p">,</span> |
| 2983 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span> |
| 2984 | <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span> |
| 2985 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span> |
| 2986 | </pre></div> |
| 2987 | </div> |
| 2988 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 2989 | <dl class="docutils"> |
| 2990 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 2991 | <dd>Handle to the key to use for the operation. It must be an asymmetric key pair.</dd> |
| 2992 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 2993 | <dd>An asymmetric encryption algorithm that is compatible with the type of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd> |
| 2994 | <dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt> |
| 2995 | <dd>The message to decrypt.</dd> |
| 2996 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 2997 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 2998 | <dt> <code class="docutils literal notranslate"><span class="pre">salt</span></code></dt> |
| 2999 | <dd>A salt or label, if supported by the encryption algorithm. If the algorithm does not support a salt, pass <code class="docutils literal notranslate"><span class="pre">NULL</span></code>. If the algorithm supports an optional salt and you do not want to pass a salt, pass <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</dd> |
| 3000 | <dt> <code class="docutils literal notranslate"><span class="pre">salt_length</span></code></dt> |
| 3001 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">salt</span></code> buffer in bytes. If <code class="docutils literal notranslate"><span class="pre">salt</span></code> is <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, pass 0.</dd> |
| 3002 | <dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt> |
| 3003 | <dd>Buffer where the decrypted message is to be written.</dd> |
| 3004 | <dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt> |
| 3005 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd> |
| 3006 | <dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt> |
| 3007 | <dd>On success, the number of bytes that make up the returned output.</dd> |
| 3008 | </dl> |
| 3009 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3010 | <dl class="docutils"> |
| 3011 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3012 | <dd></dd> |
| 3013 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3014 | <dd>The size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE" title="PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">key_type</span></code>, <code class="docutils literal notranslate"><span class="pre">key_bits</span></code>, <code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">key_type</span></code> and <code class="docutils literal notranslate"><span class="pre">key_bits</span></code> are the type and bit-size respectively of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd> |
| 3015 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3016 | <dd></dd> |
| 3017 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3018 | <dd></dd> |
| 3019 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3020 | <dd></dd> |
| 3021 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3022 | <dd></dd> |
| 3023 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3024 | <dd></dd> |
| 3025 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3026 | <dd></dd> |
| 3027 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3028 | <dd></dd> |
| 3029 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_PADDING" title="PSA_ERROR_INVALID_PADDING"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_PADDING</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3030 | <dd></dd> |
| 3031 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3032 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 3033 | </dl> |
| 3034 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3035 | <p>Decrypt a short message with a private key.</p> |
| 3036 | <ul class="simple"> |
| 3037 | <li>For <a class="reference internal" href="#c.PSA_ALG_RSA_PKCS1V15_CRYPT" title="PSA_ALG_RSA_PKCS1V15_CRYPT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code></a>, no salt is supported.</li> |
| 3038 | </ul> |
| 3039 | </div> |
| 3040 | </div> |
| 3041 | <div class="section" id="key-derivation-and-pseudorandom-generation"> |
| 3042 | <h1>Key derivation and pseudorandom generation</h1> |
| 3043 | <div class="section" id="psa_key_derivation_operation_t"> |
| 3044 | <span id="c.psa_key_derivation_operation_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_operation_t</span></code> (type)</h2> |
| 3045 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_key_derivation_s</span> <span class="n">psa_key_derivation_operation_t</span><span class="p">;</span> |
| 3046 | </pre></div> |
| 3047 | </div> |
| 3048 | <p>The type of the state data structure for key derivation operations.</p> |
| 3049 | <p>Before calling any function on a key derivation operation object, the application must initialize it by any of the following means:</p> |
| 3050 | <ul> |
| 3051 | <li><p class="first">Set the structure to all-bits-zero, for example:</p> |
| 3052 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_derivation_operation_t</span> <span class="n">operation</span><span class="p">;</span> |
| 3053 | <span class="n">memset</span><span class="p">(</span><span class="o">&</span><span class="n">operation</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">operation</span><span class="p">));</span> |
| 3054 | </pre></div> |
| 3055 | </div> |
| 3056 | </li> |
| 3057 | <li><p class="first">Initialize the structure to logical zero values, for example:</p> |
| 3058 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_derivation_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span> |
| 3059 | </pre></div> |
| 3060 | </div> |
| 3061 | </li> |
| 3062 | <li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_KEY_DERIVATION_OPERATION_INIT" title="PSA_KEY_DERIVATION_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_OPERATION_INIT</span></code></a>, for example:</p> |
| 3063 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_derivation_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="n">PSA_KEY_DERIVATION_OPERATION_INIT</span><span class="p">;</span> |
| 3064 | </pre></div> |
| 3065 | </div> |
| 3066 | </li> |
| 3067 | <li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_key_derivation_operation_init" title="psa_key_derivation_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_operation_init()</span></code></a> to the structure, for example:</p> |
| 3068 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_derivation_operation_t</span> <span class="n">operation</span><span class="p">;</span> |
| 3069 | <span class="n">operation</span> <span class="o">=</span> <span class="n">psa_key_derivation_operation_init</span><span class="p">();</span> |
| 3070 | </pre></div> |
| 3071 | </div> |
| 3072 | </li> |
| 3073 | </ul> |
| 3074 | <p>This is an implementation-defined <code class="docutils literal notranslate"><span class="pre">struct</span></code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation.</p> |
| 3075 | </div> |
| 3076 | <div class="section" id="PSA_KEY_DERIVATION_OPERATION_INIT"> |
| 3077 | <span id="c.PSA_KEY_DERIVATION_OPERATION_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_OPERATION_INIT</span></code> (macro)</h2> |
| 3078 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_OPERATION_INIT {0}</span> |
| 3079 | </pre></div> |
| 3080 | </div> |
| 3081 | <p>This macro returns a suitable initializer for a key derivation operation object of type <a class="reference internal" href="#c.psa_key_derivation_operation_t" title="psa_key_derivation_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_derivation_operation_t</span></code></a>.</p> |
| 3082 | </div> |
| 3083 | <div class="section" id="PSA_KEY_DERIVATION_UNLIMITED_CAPACITY"> |
| 3084 | <span id="c.PSA_KEY_DERIVATION_UNLIMITED_CAPACITY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_UNLIMITED_CAPACITY</span></code> (macro)</h2> |
| 3085 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_UNLIMITED_CAPACITY ((size_t)(-1))</span> |
| 3086 | </pre></div> |
| 3087 | </div> |
| 3088 | <p>Use the maximum possible capacity for a key derivation operation.</p> |
| 3089 | <p>Use this value as the capacity argument when setting up a key derivation to indicate that the operation should have the maximum possible capacity. The value of the maximum possible capacity depends on the key derivation algorithm.</p> |
| 3090 | </div> |
| 3091 | <div class="section" id="psa_key_derivation_operation_init"> |
| 3092 | <span id="c.psa_key_derivation_operation_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_operation_init</span></code> (function)</h2> |
| 3093 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_derivation_operation_t</span> <span class="nf">psa_key_derivation_operation_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> |
| 3094 | </pre></div> |
| 3095 | </div> |
| 3096 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_derivation_operation_t" title="psa_key_derivation_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_operation_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3097 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3098 | <p>Return an initial value for a key derivation operation object.</p> |
| 3099 | </div> |
| 3100 | <div class="section" id="psa_key_derivation_setup"> |
| 3101 | <span id="c.psa_key_derivation_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_setup</span></code> (function)</h2> |
| 3102 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_setup</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 3103 | <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span> |
| 3104 | </pre></div> |
| 3105 | </div> |
| 3106 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3107 | <dl class="docutils"> |
| 3108 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 3109 | <dd>The key derivation operation object to set up. It must have been initialized but not set up yet.</dd> |
| 3110 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 3111 | <dd>The key derivation algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_KEY_DERIVATION" title="PSA_ALG_IS_KEY_DERIVATION"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 3112 | </dl> |
| 3113 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3114 | <dl class="docutils"> |
| 3115 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3116 | <dd>Success.</dd> |
| 3117 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3118 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a key derivation algorithm.</dd> |
| 3119 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3120 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a key derivation algorithm.</dd> |
| 3121 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3122 | <dd></dd> |
| 3123 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3124 | <dd></dd> |
| 3125 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3126 | <dd></dd> |
| 3127 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3128 | <dd></dd> |
| 3129 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3130 | <dd></dd> |
| 3131 | </dl> |
| 3132 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3133 | <p>Set up a key derivation operation.</p> |
| 3134 | <p>A key derivation algorithm takes some inputs and uses them to generate a byte stream in a deterministic way. This byte stream can be used to produce keys and other cryptographic material.</p> |
| 3135 | <p>To derive a key:</p> |
| 3136 | <ul class="simple"> |
| 3137 | <li>Start with an initialized object of type <a class="reference internal" href="#c.psa_key_derivation_operation_t" title="psa_key_derivation_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_derivation_operation_t</span></code></a>.</li> |
| 3138 | <li>Call <a class="reference internal" href="#c.psa_key_derivation_setup" title="psa_key_derivation_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_setup()</span></code></a> to select the algorithm.</li> |
| 3139 | <li>Provide the inputs for the key derivation by calling <a class="reference internal" href="#c.psa_key_derivation_input_bytes" title="psa_key_derivation_input_bytes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_input_bytes()</span></code></a> or <a class="reference internal" href="#c.psa_key_derivation_input_key" title="psa_key_derivation_input_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_input_key()</span></code></a> as appropriate. Which inputs are needed, in what order, and whether they may be keys and if so of what type depends on the algorithm.</li> |
| 3140 | <li>Optionally set the operation’s maximum capacity with <a class="reference internal" href="#c.psa_key_derivation_set_capacity" title="psa_key_derivation_set_capacity"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_set_capacity()</span></code></a>. You may do this before, in the middle of or after providing inputs. For some algorithms, this step is mandatory because the output depends on the maximum capacity.</li> |
| 3141 | <li>To derive a key, call <a class="reference internal" href="#c.psa_key_derivation_output_key" title="psa_key_derivation_output_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_key()</span></code></a>. To derive a byte string for a different purpose, call</li> |
| 3142 | <li><a class="reference internal" href="#c.psa_key_derivation_output_bytes" title="psa_key_derivation_output_bytes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_bytes()</span></code></a>. Successive calls to these functions use successive output bytes calculated by the key derivation algorithm.</li> |
| 3143 | <li>Clean up the key derivation operation object with <a class="reference internal" href="#c.psa_key_derivation_abort" title="psa_key_derivation_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_abort()</span></code></a>.</li> |
| 3144 | </ul> |
| 3145 | </div> |
| 3146 | <div class="section" id="psa_key_derivation_get_capacity"> |
| 3147 | <span id="c.psa_key_derivation_get_capacity"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_get_capacity</span></code> (function)</h2> |
| 3148 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_get_capacity</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 3149 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">capacity</span><span class="p">);</span> |
| 3150 | </pre></div> |
| 3151 | </div> |
| 3152 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3153 | <dl class="docutils"> |
| 3154 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 3155 | <dd>The operation to query.</dd> |
| 3156 | <dt> <code class="docutils literal notranslate"><span class="pre">capacity</span></code></dt> |
| 3157 | <dd>On success, the capacity of the operation.</dd> |
| 3158 | </dl> |
| 3159 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3160 | <dl class="docutils"> |
| 3161 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3162 | <dd></dd> |
| 3163 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3164 | <dd></dd> |
| 3165 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3166 | <dd></dd> |
| 3167 | </dl> |
| 3168 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3169 | <p>Retrieve the current capacity of a key derivation operation.</p> |
| 3170 | <p>The capacity of a key derivation is the maximum number of bytes that it can return. When you get <em>N</em> bytes of output from a key derivation operation, this reduces its capacity by <em>N</em>.</p> |
| 3171 | </div> |
| 3172 | <div class="section" id="psa_key_derivation_set_capacity"> |
| 3173 | <span id="c.psa_key_derivation_set_capacity"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_set_capacity</span></code> (function)</h2> |
| 3174 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_set_capacity</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 3175 | <span class="kt">size_t</span> <span class="n">capacity</span><span class="p">);</span> |
| 3176 | </pre></div> |
| 3177 | </div> |
| 3178 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3179 | <dl class="docutils"> |
| 3180 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 3181 | <dd>The key derivation operation object to modify.</dd> |
| 3182 | <dt> <code class="docutils literal notranslate"><span class="pre">capacity</span></code></dt> |
| 3183 | <dd>The new capacity of the operation. It must be less or equal to the operation’s current capacity.</dd> |
| 3184 | </dl> |
| 3185 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3186 | <dl class="docutils"> |
| 3187 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3188 | <dd></dd> |
| 3189 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3190 | <dd><code class="docutils literal notranslate"><span class="pre">capacity</span></code> is larger than the operation’s current capacity. In this case, the operation object remains valid and its capacity remains unchanged.</dd> |
| 3191 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3192 | <dd></dd> |
| 3193 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3194 | <dd></dd> |
| 3195 | </dl> |
| 3196 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3197 | <p>Set the maximum capacity of a key derivation operation.</p> |
| 3198 | <p>The capacity of a key derivation operation is the maximum number of bytes that the key derivation operation can return from this point onwards.</p> |
| 3199 | </div> |
| 3200 | <div class="section" id="psa_key_derivation_input_bytes"> |
| 3201 | <span id="c.psa_key_derivation_input_bytes"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_input_bytes</span></code> (function)</h2> |
| 3202 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_input_bytes</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 3203 | <span class="n">psa_key_derivation_step_t</span> <span class="n">step</span><span class="p">,</span> |
| 3204 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span> |
| 3205 | <span class="kt">size_t</span> <span class="n">data_length</span><span class="p">);</span> |
| 3206 | </pre></div> |
| 3207 | </div> |
| 3208 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3209 | <dl class="docutils"> |
| 3210 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 3211 | <dd>The key derivation operation object to use. It must have been set up with <a class="reference internal" href="#c.psa_key_derivation_setup" title="psa_key_derivation_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_setup()</span></code></a> and must not have produced any output yet.</dd> |
| 3212 | <dt> <code class="docutils literal notranslate"><span class="pre">step</span></code></dt> |
| 3213 | <dd>Which step the input data is for.</dd> |
| 3214 | <dt> <code class="docutils literal notranslate"><span class="pre">data</span></code></dt> |
| 3215 | <dd>Input data to use.</dd> |
| 3216 | <dt> <code class="docutils literal notranslate"><span class="pre">data_length</span></code></dt> |
| 3217 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer in bytes.</dd> |
| 3218 | </dl> |
| 3219 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3220 | <dl class="docutils"> |
| 3221 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3222 | <dd>Success.</dd> |
| 3223 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3224 | <dd><code class="docutils literal notranslate"><span class="pre">step</span></code> is not compatible with the operation’s algorithm.</dd> |
| 3225 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3226 | <dd><code class="docutils literal notranslate"><span class="pre">step</span></code> does not allow direct inputs.</dd> |
| 3227 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3228 | <dd></dd> |
| 3229 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3230 | <dd></dd> |
| 3231 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3232 | <dd></dd> |
| 3233 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3234 | <dd></dd> |
| 3235 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3236 | <dd>The value of <code class="docutils literal notranslate"><span class="pre">step</span></code> is not valid given the state of <code class="docutils literal notranslate"><span class="pre">operation</span></code>.</dd> |
| 3237 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3238 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 3239 | </dl> |
| 3240 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3241 | <p>Provide an input for key derivation or key agreement.</p> |
| 3242 | <p>Which inputs are required and in what order depends on the algorithm. Refer to the documentation of each key derivation or key agreement algorithm for information.</p> |
| 3243 | <p>This function passes direct inputs. Some inputs must be passed as keys using <a class="reference internal" href="#c.psa_key_derivation_input_key" title="psa_key_derivation_input_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_input_key()</span></code></a> instead of this function. Refer to the documentation of individual step types for information.</p> |
| 3244 | </div> |
| 3245 | <div class="section" id="psa_key_derivation_input_key"> |
| 3246 | <span id="c.psa_key_derivation_input_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_input_key</span></code> (function)</h2> |
| 3247 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_input_key</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 3248 | <span class="n">psa_key_derivation_step_t</span> <span class="n">step</span><span class="p">,</span> |
| 3249 | <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">);</span> |
| 3250 | </pre></div> |
| 3251 | </div> |
| 3252 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3253 | <dl class="docutils"> |
| 3254 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 3255 | <dd>The key derivation operation object to use. It must have been set up with <a class="reference internal" href="#c.psa_key_derivation_setup" title="psa_key_derivation_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_setup()</span></code></a> and must not have produced any output yet.</dd> |
| 3256 | <dt> <code class="docutils literal notranslate"><span class="pre">step</span></code></dt> |
| 3257 | <dd>Which step the input data is for.</dd> |
| 3258 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 3259 | <dd>Handle to the key. It must have an appropriate type for <code class="docutils literal notranslate"><span class="pre">step</span></code> and must allow the usage <a class="reference internal" href="#c.PSA_KEY_USAGE_DERIVE" title="PSA_KEY_USAGE_DERIVE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_DERIVE</span></code></a>.</dd> |
| 3260 | </dl> |
| 3261 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3262 | <dl class="docutils"> |
| 3263 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3264 | <dd>Success.</dd> |
| 3265 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3266 | <dd></dd> |
| 3267 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3268 | <dd></dd> |
| 3269 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3270 | <dd></dd> |
| 3271 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3272 | <dd><code class="docutils literal notranslate"><span class="pre">step</span></code> is not compatible with the operation’s algorithm.</dd> |
| 3273 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3274 | <dd><code class="docutils literal notranslate"><span class="pre">step</span></code> does not allow key inputs.</dd> |
| 3275 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3276 | <dd></dd> |
| 3277 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3278 | <dd></dd> |
| 3279 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3280 | <dd></dd> |
| 3281 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3282 | <dd></dd> |
| 3283 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3284 | <dd>The value of <code class="docutils literal notranslate"><span class="pre">step</span></code> is not valid given the state of <code class="docutils literal notranslate"><span class="pre">operation</span></code>.</dd> |
| 3285 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3286 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 3287 | </dl> |
| 3288 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3289 | <p>Provide an input for key derivation in the form of a key.</p> |
| 3290 | <p>Which inputs are required and in what order depends on the algorithm. Refer to the documentation of each key derivation or key agreement algorithm for information.</p> |
| 3291 | <p>This function passes key inputs. Some inputs must be passed as keys of the appropriate type using this function, while others must be passed as direct inputs using <a class="reference internal" href="#c.psa_key_derivation_input_bytes" title="psa_key_derivation_input_bytes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_input_bytes()</span></code></a>. Refer to the documentation of individual step types for information.</p> |
| 3292 | </div> |
| 3293 | <div class="section" id="psa_key_derivation_key_agreement"> |
| 3294 | <span id="c.psa_key_derivation_key_agreement"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_key_agreement</span></code> (function)</h2> |
| 3295 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_key_agreement</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 3296 | <span class="n">psa_key_derivation_step_t</span> <span class="n">step</span><span class="p">,</span> |
| 3297 | <span class="n">psa_key_handle_t</span> <span class="n">private_key</span><span class="p">,</span> |
| 3298 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">peer_key</span><span class="p">,</span> |
| 3299 | <span class="kt">size_t</span> <span class="n">peer_key_length</span><span class="p">);</span> |
| 3300 | </pre></div> |
| 3301 | </div> |
| 3302 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3303 | <dl class="docutils"> |
| 3304 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 3305 | <dd>The key derivation operation object to use. It must have been set up with <a class="reference internal" href="#c.psa_key_derivation_setup" title="psa_key_derivation_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_setup()</span></code></a> with a key agreement and derivation algorithm <code class="docutils literal notranslate"><span class="pre">alg</span></code> (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_KEY_AGREEMENT" title="PSA_ALG_IS_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_AGREEMENT</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true and <a class="reference internal" href="#c.PSA_ALG_IS_RAW_KEY_AGREEMENT" title="PSA_ALG_IS_RAW_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_RAW_KEY_AGREEMENT</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is false). The operation must be ready for an input of the type given by <code class="docutils literal notranslate"><span class="pre">step</span></code>.</dd> |
| 3306 | <dt> <code class="docutils literal notranslate"><span class="pre">step</span></code></dt> |
| 3307 | <dd>Which step the input data is for.</dd> |
| 3308 | <dt> <code class="docutils literal notranslate"><span class="pre">private_key</span></code></dt> |
| 3309 | <dd>Handle to the private key to use.</dd> |
| 3310 | <dt> <code class="docutils literal notranslate"><span class="pre">peer_key</span></code></dt> |
| 3311 | <dd>Public key of the peer. The peer key must be in the same format that <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a> accepts for the public key type corresponding to the type of private_key. That is, this function performs the equivalent of <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key</span></code></a>(…, <code class="docutils literal notranslate"><span class="pre">peer_key</span></code>, <code class="docutils literal notranslate"><span class="pre">peer_key_length</span></code>) where with key attributes indicating the public key type corresponding to the type of <code class="docutils literal notranslate"><span class="pre">private_key</span></code>. For example, for EC keys, this means that peer_key is interpreted as a point on the curve that the private key is on. The standard formats for public keys are documented in the documentation of <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a>.</dd> |
| 3312 | <dt> <code class="docutils literal notranslate"><span class="pre">peer_key_length</span></code></dt> |
| 3313 | <dd>Size of <code class="docutils literal notranslate"><span class="pre">peer_key</span></code> in bytes.</dd> |
| 3314 | </dl> |
| 3315 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3316 | <dl class="docutils"> |
| 3317 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3318 | <dd>Success.</dd> |
| 3319 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3320 | <dd></dd> |
| 3321 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3322 | <dd></dd> |
| 3323 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3324 | <dd></dd> |
| 3325 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3326 | <dd><code class="docutils literal notranslate"><span class="pre">private_key</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>, or <code class="docutils literal notranslate"><span class="pre">peer_key</span></code> is not valid for <code class="docutils literal notranslate"><span class="pre">alg</span></code> or not compatible with <code class="docutils literal notranslate"><span class="pre">private_key</span></code>.</dd> |
| 3327 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3328 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a key derivation algorithm.</dd> |
| 3329 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3330 | <dd></dd> |
| 3331 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3332 | <dd></dd> |
| 3333 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3334 | <dd></dd> |
| 3335 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3336 | <dd></dd> |
| 3337 | </dl> |
| 3338 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3339 | <p>Perform a key agreement and use the shared secret as input to a key derivation.</p> |
| 3340 | <p>A key agreement algorithm takes two inputs: a private key <code class="docutils literal notranslate"><span class="pre">private_key</span></code> a public key <code class="docutils literal notranslate"><span class="pre">peer_key</span></code>. The result of this function is passed as input to a key derivation. The output of this key derivation can be extracted by reading from the resulting operation to produce keys and other cryptographic material.</p> |
| 3341 | </div> |
| 3342 | <div class="section" id="psa_key_derivation_output_bytes"> |
| 3343 | <span id="c.psa_key_derivation_output_bytes"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_output_bytes</span></code> (function)</h2> |
| 3344 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_output_bytes</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 3345 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span> |
| 3346 | <span class="kt">size_t</span> <span class="n">output_length</span><span class="p">);</span> |
| 3347 | </pre></div> |
| 3348 | </div> |
| 3349 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3350 | <dl class="docutils"> |
| 3351 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 3352 | <dd>The key derivation operation object to read from.</dd> |
| 3353 | <dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt> |
| 3354 | <dd>Buffer where the output will be written.</dd> |
| 3355 | <dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt> |
| 3356 | <dd>Number of bytes to output.</dd> |
| 3357 | </dl> |
| 3358 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3359 | <dl class="docutils"> |
| 3360 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3361 | <dd></dd> |
| 3362 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_DATA" title="PSA_ERROR_INSUFFICIENT_DATA"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_DATA</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3363 | <dd>The operation’s capacity was less than <code class="docutils literal notranslate"><span class="pre">output_length</span></code> bytes. Note that in this case, no output is written to the output buffer. The operation’s capacity is set to 0, thus subsequent calls to this function will not succeed, even with a smaller output buffer.</dd> |
| 3364 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3365 | <dd></dd> |
| 3366 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3367 | <dd></dd> |
| 3368 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3369 | <dd></dd> |
| 3370 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3371 | <dd></dd> |
| 3372 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3373 | <dd></dd> |
| 3374 | </dl> |
| 3375 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3376 | <p>Read some data from a key derivation operation.</p> |
| 3377 | <p>This function calculates output bytes from a key derivation algorithm and return those bytes. If you view the key derivation’s output as a stream of bytes, this function destructively reads the requested number of bytes from the stream. The operation’s capacity decreases by the number of bytes read.</p> |
| 3378 | </div> |
| 3379 | <div class="section" id="psa_key_derivation_output_key"> |
| 3380 | <span id="c.psa_key_derivation_output_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_output_key</span></code> (function)</h2> |
| 3381 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_output_key</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span> |
| 3382 | <span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span> |
| 3383 | <span class="n">psa_key_handle_t</span> <span class="o">*</span> <span class="n">handle</span><span class="p">);</span> |
| 3384 | </pre></div> |
| 3385 | </div> |
| 3386 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3387 | <dl class="docutils"> |
| 3388 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 3389 | <dd>The attributes for the new key.</dd> |
| 3390 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 3391 | <dd>The key derivation operation object to read from.</dd> |
| 3392 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 3393 | <dd>On success, a handle to the newly created key. <code class="docutils literal notranslate"><span class="pre">0</span></code> on failure.</dd> |
| 3394 | </dl> |
| 3395 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3396 | <dl class="docutils"> |
| 3397 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3398 | <dd>Success. If the key is persistent, the key material and the key’s metadata have been saved to persistent storage.</dd> |
| 3399 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_ALREADY_EXISTS" title="PSA_ERROR_ALREADY_EXISTS"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3400 | <dd>This is an attempt to create a persistent key, and there is already a persistent key with the given identifier.</dd> |
| 3401 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_DATA" title="PSA_ERROR_INSUFFICIENT_DATA"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_DATA</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3402 | <dd>There was not enough data to create the desired key. Note that in this case, no output is written to the output buffer. The operation’s capacity is set to 0, thus subsequent calls to this function will not succeed, even with a smaller output buffer.</dd> |
| 3403 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3404 | <dd>The key type or key size is not supported, either by the implementation in general or in this particular location.</dd> |
| 3405 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3406 | <dd></dd> |
| 3407 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3408 | <dd></dd> |
| 3409 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_STORAGE" title="PSA_ERROR_INSUFFICIENT_STORAGE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3410 | <dd></dd> |
| 3411 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3412 | <dd></dd> |
| 3413 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3414 | <dd></dd> |
| 3415 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3416 | <dd></dd> |
| 3417 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3418 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 3419 | </dl> |
| 3420 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3421 | <p>Derive a key from an ongoing key derivation operation.</p> |
| 3422 | <p>This function calculates output bytes from a key derivation algorithm and uses those bytes to generate a key deterministically. If you view the key derivation’s output as a stream of bytes, this function destructively reads as many bytes as required from the stream. The operation’s capacity decreases by the number of bytes read.</p> |
| 3423 | <p>How much output is produced and consumed from the operation, and how the key is derived, depends on the key type:</p> |
| 3424 | <ul class="simple"> |
| 3425 | <li>For key types for which the key is an arbitrary sequence of bytes of a given size, this function is functionally equivalent to calling <a class="reference internal" href="#c.psa_key_derivation_output_bytes" title="psa_key_derivation_output_bytes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_bytes</span></code></a> and passing the resulting output to <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key</span></code></a>. However, this function has a security benefit: if the implementation provides an isolation boundary then the key material is not exposed outside the isolation boundary. As a consequence, for these key types, this function always consumes exactly (<code class="docutils literal notranslate"><span class="pre">bits</span></code> / 8) bytes from the operation. The following key types defined in this specification follow this scheme:<ul> |
| 3426 | <li><a class="reference internal" href="#c.PSA_KEY_TYPE_AES" title="PSA_KEY_TYPE_AES"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_AES</span></code></a>;</li> |
| 3427 | <li><a class="reference internal" href="#c.PSA_KEY_TYPE_ARC4" title="PSA_KEY_TYPE_ARC4"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ARC4</span></code></a>;</li> |
| 3428 | <li><a class="reference internal" href="#c.PSA_KEY_TYPE_CAMELLIA" title="PSA_KEY_TYPE_CAMELLIA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CAMELLIA</span></code></a>;</li> |
| 3429 | <li><a class="reference internal" href="#c.PSA_KEY_TYPE_DERIVE" title="PSA_KEY_TYPE_DERIVE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DERIVE</span></code></a>;</li> |
| 3430 | <li><a class="reference internal" href="#c.PSA_KEY_TYPE_HMAC" title="PSA_KEY_TYPE_HMAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_HMAC</span></code></a>.</li> |
| 3431 | </ul> |
| 3432 | </li> |
| 3433 | <li>For ECC keys on a Montgomery elliptic curve (<a class="reference internal" href="#c.PSA_KEY_TYPE_ECC_KEY_PAIR" title="PSA_KEY_TYPE_ECC_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR</span></code></a>(<code class="docutils literal notranslate"><span class="pre">curve</span></code>) where <code class="docutils literal notranslate"><span class="pre">curve</span></code> designates a Montgomery curve), this function always draws a byte string whose length is determined by the curve, and sets the mandatory bits accordingly. That is:<ul> |
| 3434 | <li><a class="reference internal" href="#c.PSA_ECC_CURVE_CURVE25519" title="PSA_ECC_CURVE_CURVE25519"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE25519</span></code></a>: draw a 32-byte string and process it as specified in RFC 7748 §5.</li> |
| 3435 | <li><a class="reference internal" href="#c.PSA_ECC_CURVE_CURVE448" title="PSA_ECC_CURVE_CURVE448"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE448</span></code></a>: draw a 56-byte string and process it as specified in RFC 7748 §5.</li> |
| 3436 | </ul> |
| 3437 | </li> |
| 3438 | <li>For key types for which the key is represented by a single sequence of <code class="docutils literal notranslate"><span class="pre">bits</span></code> bits with constraints as to which bit sequences are acceptable, this function draws a byte string of length (<code class="docutils literal notranslate"><span class="pre">bits</span></code> / 8) bytes rounded up to the nearest whole number of bytes. If the resulting byte string is acceptable, it becomes the key, otherwise the drawn bytes are discarded. This process is repeated until an acceptable byte string is drawn. The byte string drawn from the operation is interpreted as specified for the output produced by <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a>. The following key types defined in this specification follow this scheme:<ul> |
| 3439 | <li><a class="reference internal" href="#c.PSA_KEY_TYPE_DES" title="PSA_KEY_TYPE_DES"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DES</span></code></a>. Force-set the parity bits, but discard forbidden weak keys. For 2-key and 3-key triple-DES, the three keys are generated successively (for example, for 3-key triple-DES, if the first 8 bytes specify a weak key and the next 8 bytes do not, discard the first 8 bytes, use the next 8 bytes as the first key, and continue reading output from the operation to derive the other two keys).</li> |
| 3440 | <li>Finite-field Diffie-Hellman keys (<a class="reference internal" href="#c.PSA_KEY_TYPE_DH_KEY_PAIR" title="PSA_KEY_TYPE_DH_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR</span></code></a>(<code class="docutils literal notranslate"><span class="pre">group</span></code>) where <code class="docutils literal notranslate"><span class="pre">group</span></code> designates any Diffie-Hellman group) and ECC keys on a Weierstrass elliptic curve (<a class="reference internal" href="#c.PSA_KEY_TYPE_ECC_KEY_PAIR" title="PSA_KEY_TYPE_ECC_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR</span></code></a>(<code class="docutils literal notranslate"><span class="pre">curve</span></code>) where <code class="docutils literal notranslate"><span class="pre">curve</span></code> designates a Weierstrass curve). For these key types, interpret the byte string as integer in big-endian order. Discard it if it is not in the range [0, <em>N</em> - 2] where <em>N</em> is the boundary of the private key domain (the prime <em>p</em> for Diffie-Hellman, the subprime <em>q</em> for DSA, or the order of the curve’s base point for ECC). Add 1 to the resulting integer and use this as the private key <em>x</em>. This method allows compliance to NIST standards, specifically the methods titled “key-pair generation by testing candidates” in NIST SP 800-56A §5.6.1.1.4 for Diffie-Hellman, in FIPS 186-4 §B.1.2 for DSA, and in NIST SP 800-56A §5.6.1.2.2 or FIPS 186-4 §B.4.2 for elliptic curve keys.</li> |
| 3441 | </ul> |
| 3442 | </li> |
| 3443 | <li>For other key types, including <a class="reference internal" href="#c.PSA_KEY_TYPE_RSA_KEY_PAIR" title="PSA_KEY_TYPE_RSA_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code></a>, the way in which the operation output is consumed is implementation-defined.</li> |
| 3444 | </ul> |
| 3445 | <p>In all cases, the data that is read is discarded from the operation. The operation’s capacity is decreased by the number of bytes read.</p> |
| 3446 | </div> |
| 3447 | <div class="section" id="psa_key_derivation_abort"> |
| 3448 | <span id="c.psa_key_derivation_abort"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_abort</span></code> (function)</h2> |
| 3449 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_abort</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">);</span> |
| 3450 | </pre></div> |
| 3451 | </div> |
| 3452 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3453 | <dl class="docutils"> |
| 3454 | <dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt> |
| 3455 | <dd>The operation to abort.</dd> |
| 3456 | </dl> |
| 3457 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3458 | <dl class="docutils"> |
| 3459 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3460 | <dd></dd> |
| 3461 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3462 | <dd></dd> |
| 3463 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3464 | <dd></dd> |
| 3465 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3466 | <dd></dd> |
| 3467 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3468 | <dd></dd> |
| 3469 | </dl> |
| 3470 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3471 | <p>Abort a key derivation operation.</p> |
| 3472 | <p>Once a key derivation operation has been aborted, its capacity is zero. Aborting an operation frees all associated resources except for the <code class="docutils literal notranslate"><span class="pre">operation</span></code> structure itself.</p> |
| 3473 | <p>This function may be called at any time as long as the operation object has been initialized to <a class="reference internal" href="#c.PSA_KEY_DERIVATION_OPERATION_INIT" title="PSA_KEY_DERIVATION_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_OPERATION_INIT</span></code></a>, to <a class="reference internal" href="#c.psa_key_derivation_operation_init" title="psa_key_derivation_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_operation_init()</span></code></a> or a zero value. In particular, it is valid to call <a class="reference internal" href="#c.psa_key_derivation_abort" title="psa_key_derivation_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_abort()</span></code></a> twice, or to call <a class="reference internal" href="#c.psa_key_derivation_abort" title="psa_key_derivation_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_abort()</span></code></a> on an operation that has not been set up.</p> |
| 3474 | <p>Once aborted, the key derivation operation object may be called.</p> |
| 3475 | </div> |
| 3476 | <div class="section" id="psa_raw_key_agreement"> |
| 3477 | <span id="c.psa_raw_key_agreement"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_raw_key_agreement</span></code> (function)</h2> |
| 3478 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_raw_key_agreement</span><span class="p">(</span><span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span> |
| 3479 | <span class="n">psa_key_handle_t</span> <span class="n">private_key</span><span class="p">,</span> |
| 3480 | <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">peer_key</span><span class="p">,</span> |
| 3481 | <span class="kt">size_t</span> <span class="n">peer_key_length</span><span class="p">,</span> |
| 3482 | <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span> |
| 3483 | <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span> |
| 3484 | <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span> |
| 3485 | </pre></div> |
| 3486 | </div> |
| 3487 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3488 | <dl class="docutils"> |
| 3489 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 3490 | <dd>The key agreement algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_RAW_KEY_AGREEMENT" title="PSA_ALG_IS_RAW_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_RAW_KEY_AGREEMENT</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 3491 | <dt> <code class="docutils literal notranslate"><span class="pre">private_key</span></code></dt> |
| 3492 | <dd>Handle to the private key to use.</dd> |
| 3493 | <dt> <code class="docutils literal notranslate"><span class="pre">peer_key</span></code></dt> |
| 3494 | <dd>Public key of the peer. It must be in the same format that <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a> accepts. The standard formats for public keys are documented in the documentation of <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a>.</dd> |
| 3495 | <dt> <code class="docutils literal notranslate"><span class="pre">peer_key_length</span></code></dt> |
| 3496 | <dd>Size of <code class="docutils literal notranslate"><span class="pre">peer_key</span></code> in bytes.</dd> |
| 3497 | <dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt> |
| 3498 | <dd>Buffer where the decrypted message is to be written.</dd> |
| 3499 | <dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt> |
| 3500 | <dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd> |
| 3501 | <dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt> |
| 3502 | <dd>On success, the number of bytes that make up the returned output.</dd> |
| 3503 | </dl> |
| 3504 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3505 | <dl class="docutils"> |
| 3506 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3507 | <dd>Success.</dd> |
| 3508 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3509 | <dd></dd> |
| 3510 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3511 | <dd></dd> |
| 3512 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3513 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a key agreement algorithm</dd> |
| 3514 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3515 | <dd><code class="docutils literal notranslate"><span class="pre">private_key</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>, or <code class="docutils literal notranslate"><span class="pre">peer_key</span></code> is not valid for <code class="docutils literal notranslate"><span class="pre">alg</span></code> or not compatible with <code class="docutils literal notranslate"><span class="pre">private_key</span></code>.</dd> |
| 3516 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3517 | <dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key agreement algorithm.</dd> |
| 3518 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3519 | <dd></dd> |
| 3520 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3521 | <dd></dd> |
| 3522 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3523 | <dd></dd> |
| 3524 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3525 | <dd></dd> |
| 3526 | </dl> |
| 3527 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3528 | <p>Perform a key agreement and return the raw shared secret.</p> |
| 3529 | <div class="admonition warning"> |
| 3530 | <p class="first admonition-title">Warning</p> |
| 3531 | <p class="last">The raw result of a key agreement algorithm such as finite-field Diffie-Hellman or elliptic curve Diffie-Hellman has biases and should not be used directly as key material. It should instead be passed as input to a key derivation algorithm. To chain a key agreement with a key derivation, use <a class="reference internal" href="#c.psa_key_derivation_key_agreement" title="psa_key_derivation_key_agreement"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_key_agreement()</span></code></a> and other functions from the key derivation interface.</p> |
| 3532 | </div> |
| 3533 | </div> |
| 3534 | </div> |
| 3535 | <div class="section" id="random-generation"> |
| 3536 | <h1>Random generation</h1> |
| 3537 | <div class="section" id="psa_generate_random"> |
| 3538 | <span id="c.psa_generate_random"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_generate_random</span></code> (function)</h2> |
| 3539 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_generate_random</span><span class="p">(</span><span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span> |
| 3540 | <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">);</span> |
| 3541 | </pre></div> |
| 3542 | </div> |
| 3543 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3544 | <dl class="docutils"> |
| 3545 | <dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt> |
| 3546 | <dd>Output buffer for the generated data.</dd> |
| 3547 | <dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt> |
| 3548 | <dd>Number of bytes to generate and output.</dd> |
| 3549 | </dl> |
| 3550 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3551 | <dl class="docutils"> |
| 3552 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3553 | <dd></dd> |
| 3554 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3555 | <dd></dd> |
| 3556 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3557 | <dd></dd> |
| 3558 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3559 | <dd></dd> |
| 3560 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3561 | <dd></dd> |
| 3562 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3563 | <dd></dd> |
| 3564 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3565 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 3566 | </dl> |
| 3567 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3568 | <p>Generate random bytes.</p> |
| 3569 | <div class="admonition warning"> |
| 3570 | <p class="first admonition-title">Warning</p> |
| 3571 | <p class="last">This function <strong>can</strong> fail! Callers MUST check the return status and MUST NOT use the content of the output buffer if the return status is not <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a>.</p> |
| 3572 | </div> |
| 3573 | <div class="admonition note"> |
| 3574 | <p class="first admonition-title">Note</p> |
| 3575 | <p class="last">To generate a key, use <a class="reference internal" href="#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_generate_key()</span></code></a> instead.</p> |
| 3576 | </div> |
| 3577 | </div> |
| 3578 | <div class="section" id="psa_generate_key"> |
| 3579 | <span id="c.psa_generate_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_generate_key</span></code> (function)</h2> |
| 3580 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_generate_key</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span> |
| 3581 | <span class="n">psa_key_handle_t</span> <span class="o">*</span> <span class="n">handle</span><span class="p">);</span> |
| 3582 | </pre></div> |
| 3583 | </div> |
| 3584 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3585 | <dl class="docutils"> |
| 3586 | <dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt> |
| 3587 | <dd>The attributes for the new key.</dd> |
| 3588 | <dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt> |
| 3589 | <dd>On success, a handle to the newly created key. <code class="docutils literal notranslate"><span class="pre">0</span></code> on failure.</dd> |
| 3590 | </dl> |
| 3591 | <p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p> |
| 3592 | <dl class="docutils"> |
| 3593 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3594 | <dd>Success. If the key is persistent, the key material and the key’s metadata have been saved to persistent storage.</dd> |
| 3595 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_ALREADY_EXISTS" title="PSA_ERROR_ALREADY_EXISTS"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3596 | <dd>This is an attempt to create a persistent key, and there is already a persistent key with the given identifier.</dd> |
| 3597 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3598 | <dd></dd> |
| 3599 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3600 | <dd></dd> |
| 3601 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3602 | <dd></dd> |
| 3603 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3604 | <dd></dd> |
| 3605 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3606 | <dd></dd> |
| 3607 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3608 | <dd></dd> |
| 3609 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3610 | <dd></dd> |
| 3611 | <dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt> |
| 3612 | <dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd> |
| 3613 | </dl> |
| 3614 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3615 | <p>Generate a key or key pair.</p> |
| 3616 | <p>The key is generated randomly. Its location, policy, type and size are taken from <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p> |
| 3617 | <p>The following type-specific considerations apply:</p> |
| 3618 | <ul class="simple"> |
| 3619 | <li>For RSA keys (<a class="reference internal" href="#c.PSA_KEY_TYPE_RSA_KEY_PAIR" title="PSA_KEY_TYPE_RSA_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code></a>), the public exponent is 65537. The modulus is a product of two probabilistic primes between 2^{n-1} and 2^n where n is the bit size specified in the attributes.</li> |
| 3620 | </ul> |
| 3621 | </div> |
| 3622 | </div> |
| 3623 | <div class="section" id="error-codes"> |
| 3624 | <h1>Error codes</h1> |
| 3625 | <div class="section" id="psa_status_t"> |
| 3626 | <span id="c.psa_status_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code> (type)</h2> |
| 3627 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">int32_t</span> <span class="n">psa_status_t</span><span class="p">;</span> |
| 3628 | </pre></div> |
| 3629 | </div> |
| 3630 | <p>Function return status.</p> |
| 3631 | <p>This is either <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a> (which is zero), indicating success, or a small negative value indicating that an error occurred. Errors are encoded as one of the <code class="docutils literal notranslate"><span class="pre">PSA_ERROR_xxx</span></code> values defined here.</p> |
| 3632 | </div> |
| 3633 | <div class="section" id="PSA_SUCCESS"> |
| 3634 | <span id="c.PSA_SUCCESS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code> (macro)</h2> |
| 3635 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_SUCCESS ((psa_status_t)0)</span> |
| 3636 | </pre></div> |
| 3637 | </div> |
| 3638 | <p>The action was completed successfully.</p> |
| 3639 | </div> |
| 3640 | <div class="section" id="PSA_ERROR_GENERIC_ERROR"> |
| 3641 | <span id="c.PSA_ERROR_GENERIC_ERROR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_GENERIC_ERROR</span></code> (macro)</h2> |
| 3642 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_GENERIC_ERROR ((psa_status_t)-132)</span> |
| 3643 | </pre></div> |
| 3644 | </div> |
| 3645 | <p>An error occurred that does not correspond to any defined failure cause.</p> |
| 3646 | <p>Implementations may use this error code if none of the other standard error codes are applicable.</p> |
| 3647 | </div> |
| 3648 | <div class="section" id="PSA_ERROR_NOT_SUPPORTED"> |
| 3649 | <span id="c.PSA_ERROR_NOT_SUPPORTED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code> (macro)</h2> |
| 3650 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_NOT_SUPPORTED ((psa_status_t)-134)</span> |
| 3651 | </pre></div> |
| 3652 | </div> |
| 3653 | <p>The requested operation or a parameter is not supported by this implementation.</p> |
| 3654 | <p>Implementations should return this error code when an enumeration parameter such as a key type, algorithm, etc. is not recognized. If a combination of parameters is recognized and identified as not valid, return <a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a> instead.</p> |
| 3655 | </div> |
| 3656 | <div class="section" id="PSA_ERROR_NOT_PERMITTED"> |
| 3657 | <span id="c.PSA_ERROR_NOT_PERMITTED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code> (macro)</h2> |
| 3658 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_NOT_PERMITTED ((psa_status_t)-133)</span> |
| 3659 | </pre></div> |
| 3660 | </div> |
| 3661 | <p>The requested action is denied by a policy.</p> |
| 3662 | <p>Implementations should return this error code when the parameters are recognized as valid and supported, and a policy explicitly denies the requested operation.</p> |
| 3663 | <p>If a subset of the parameters of a function call identify a forbidden operation, and another subset of the parameters are not valid or not supported, it is unspecified whether the function returns <a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a>, <a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a> or <a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a>.</p> |
| 3664 | </div> |
| 3665 | <div class="section" id="PSA_ERROR_BUFFER_TOO_SMALL"> |
| 3666 | <span id="c.PSA_ERROR_BUFFER_TOO_SMALL"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code> (macro)</h2> |
| 3667 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_BUFFER_TOO_SMALL ((psa_status_t)-138)</span> |
| 3668 | </pre></div> |
| 3669 | </div> |
| 3670 | <p>An output buffer is too small.</p> |
| 3671 | <p>Applications can call the <code class="docutils literal notranslate"><span class="pre">PSA_xxx_SIZE</span></code> macro listed in the function description to determine a sufficient buffer size.</p> |
| 3672 | <p>Implementations should preferably return this error code only in cases when performing the operation with a larger output buffer would succeed. However implementations may return this error if a function has invalid or unsupported parameters in addition to the parameters that determine the necessary output buffer size.</p> |
| 3673 | </div> |
| 3674 | <div class="section" id="PSA_ERROR_ALREADY_EXISTS"> |
| 3675 | <span id="c.PSA_ERROR_ALREADY_EXISTS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code> (macro)</h2> |
| 3676 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_ALREADY_EXISTS ((psa_status_t)-139)</span> |
| 3677 | </pre></div> |
| 3678 | </div> |
| 3679 | <p>Asking for an item that already exists.</p> |
| 3680 | <p>Implementations should return this error, when attempting to write an item (like a key) that already exists.</p> |
| 3681 | </div> |
| 3682 | <div class="section" id="PSA_ERROR_DOES_NOT_EXIST"> |
| 3683 | <span id="c.PSA_ERROR_DOES_NOT_EXIST"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code> (macro)</h2> |
| 3684 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_DOES_NOT_EXIST ((psa_status_t)-140)</span> |
| 3685 | </pre></div> |
| 3686 | </div> |
| 3687 | <p>Asking for an item that doesn’t exist.</p> |
| 3688 | <p>Implementations should return this error, if a requested item (like a key) does not exist.</p> |
| 3689 | </div> |
| 3690 | <div class="section" id="PSA_ERROR_BAD_STATE"> |
| 3691 | <span id="c.PSA_ERROR_BAD_STATE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code> (macro)</h2> |
| 3692 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_BAD_STATE ((psa_status_t)-137)</span> |
| 3693 | </pre></div> |
| 3694 | </div> |
| 3695 | <p>The requested action cannot be performed in the current state.</p> |
| 3696 | <p>Multipart operations return this error when one of the functions is called out of sequence. Refer to the function descriptions for permitted sequencing of functions.</p> |
| 3697 | <p>Implementations shall not return this error code to indicate that a key either exists or not, but shall instead return <a class="reference internal" href="#c.PSA_ERROR_ALREADY_EXISTS" title="PSA_ERROR_ALREADY_EXISTS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code></a> or <a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a> as applicable.</p> |
| 3698 | <p>Implementations shall not return this error code to indicate that a key handle is invalid, but shall return <a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a> instead.</p> |
| 3699 | </div> |
| 3700 | <div class="section" id="PSA_ERROR_INVALID_ARGUMENT"> |
| 3701 | <span id="c.PSA_ERROR_INVALID_ARGUMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code> (macro)</h2> |
| 3702 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INVALID_ARGUMENT ((psa_status_t)-135)</span> |
| 3703 | </pre></div> |
| 3704 | </div> |
| 3705 | <p>The parameters passed to the function are invalid.</p> |
| 3706 | <p>Implementations may return this error any time a parameter or combination of parameters are recognized as invalid.</p> |
| 3707 | <p>Implementations shall not return this error code to indicate that a key handle is invalid, but shall return <a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a> instead.</p> |
| 3708 | </div> |
| 3709 | <div class="section" id="PSA_ERROR_INSUFFICIENT_MEMORY"> |
| 3710 | <span id="c.PSA_ERROR_INSUFFICIENT_MEMORY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code> (macro)</h2> |
| 3711 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INSUFFICIENT_MEMORY ((psa_status_t)-141)</span> |
| 3712 | </pre></div> |
| 3713 | </div> |
| 3714 | <p>There is not enough runtime memory.</p> |
| 3715 | <p>If the action is carried out across multiple security realms, this error can refer to available memory in any of the security realms.</p> |
| 3716 | </div> |
| 3717 | <div class="section" id="PSA_ERROR_INSUFFICIENT_STORAGE"> |
| 3718 | <span id="c.PSA_ERROR_INSUFFICIENT_STORAGE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code> (macro)</h2> |
| 3719 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INSUFFICIENT_STORAGE ((psa_status_t)-142)</span> |
| 3720 | </pre></div> |
| 3721 | </div> |
| 3722 | <p>There is not enough persistent storage.</p> |
| 3723 | <p>Functions that modify the key storage return this error code if there is insufficient storage space on the host media. In addition, many functions that do not otherwise access storage may return this error code if the implementation requires a mandatory log entry for the requested action and the log storage space is full.</p> |
| 3724 | </div> |
| 3725 | <div class="section" id="PSA_ERROR_COMMUNICATION_FAILURE"> |
| 3726 | <span id="c.PSA_ERROR_COMMUNICATION_FAILURE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code> (macro)</h2> |
| 3727 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_COMMUNICATION_FAILURE ((psa_status_t)-145)</span> |
| 3728 | </pre></div> |
| 3729 | </div> |
| 3730 | <p>There was a communication failure inside the implementation.</p> |
| 3731 | <p>This can indicate a communication failure between the application and an external cryptoprocessor or between the cryptoprocessor and an external volatile or persistent memory. A communication failure may be transient or permanent depending on the cause.</p> |
| 3732 | <div class="admonition warning"> |
| 3733 | <p class="first admonition-title">Warning</p> |
| 3734 | <p class="last">If a function returns this error, it is undetermined whether the requested action has completed or not. Implementations should return <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a> on successful completion whenver possible, however functions may return <a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a> if the requested action was completed successfully in an external cryptoprocessor but there was a breakdown of communication before the cryptoprocessor could report the status to the application.</p> |
| 3735 | </div> |
| 3736 | </div> |
| 3737 | <div class="section" id="PSA_ERROR_STORAGE_FAILURE"> |
| 3738 | <span id="c.PSA_ERROR_STORAGE_FAILURE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code> (macro)</h2> |
| 3739 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_STORAGE_FAILURE ((psa_status_t)-146)</span> |
| 3740 | </pre></div> |
| 3741 | </div> |
| 3742 | <p>There was a storage failure that may have led to data loss.</p> |
| 3743 | <p>This error indicates that some persistent storage is corrupted. It should not be used for a corruption of volatile memory (use <a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a>), for a communication error between the cryptoprocessor and its external storage (use <a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a>), or when the storage is in a valid state but is full (use <a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_STORAGE" title="PSA_ERROR_INSUFFICIENT_STORAGE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code></a>).</p> |
| 3744 | <p>Note that a storage failure does not indicate that any data that was previously read is invalid. However this previously read data may no longer be readable from storage.</p> |
| 3745 | <p>When a storage failure occurs, it is no longer possible to ensure the global integrity of the keystore. Depending on the global integrity guarantees offered by the implementation, access to other data may or may not fail even if the data is still readable but its integrity cannot be guaranteed.</p> |
| 3746 | <p>Implementations should only use this error code to report a permanent storage corruption. However application writers should keep in mind that transient errors while reading the storage may be reported using this error code.</p> |
| 3747 | </div> |
| 3748 | <div class="section" id="PSA_ERROR_HARDWARE_FAILURE"> |
| 3749 | <span id="c.PSA_ERROR_HARDWARE_FAILURE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code> (macro)</h2> |
| 3750 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_HARDWARE_FAILURE ((psa_status_t)-147)</span> |
| 3751 | </pre></div> |
| 3752 | </div> |
| 3753 | <p>A hardware failure was detected.</p> |
| 3754 | <p>A hardware failure may be transient or permanent depending on the cause.</p> |
| 3755 | </div> |
| 3756 | <div class="section" id="PSA_ERROR_CORRUPTION_DETECTED"> |
| 3757 | <span id="c.PSA_ERROR_CORRUPTION_DETECTED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code> (macro)</h2> |
| 3758 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_CORRUPTION_DETECTED ((psa_status_t)-151)</span> |
| 3759 | </pre></div> |
| 3760 | </div> |
| 3761 | <p>A tampering attempt was detected.</p> |
| 3762 | <p>If an application receives this error code, there is no guarantee that previously accessed or computed data was correct and remains confidential. Applications should not perform any security function and should enter a safe failure state.</p> |
| 3763 | <p>Implementations may return this error code if they detect an invalid state that cannot happen during normal operation and that indicates that the implementation’s security guarantees no longer hold. Depending on the implementation architecture and on its security and safety goals, the implementation may forcibly terminate the application.</p> |
| 3764 | <p>This error code is intended as a last resort when a security breach is detected and it is unsure whether the keystore data is still protected. Implementations shall only return this error code to report an alarm from a tampering detector, to indicate that the confidentiality of stored data can no longer be guaranteed, or to indicate that the integrity of previously returned data is now considered compromised. Implementations shall not use this error code to indicate a hardware failure that merely makes it impossible to perform the requested operation (use <a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a>, <a class="reference internal" href="#c.PSA_ERROR_STORAGE_FAILURE" title="PSA_ERROR_STORAGE_FAILURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code></a>, <a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a>, <a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a> or other applicable error code instead).</p> |
| 3765 | <p>This error indicates an attack against the application. Implementations shall not return this error code as a consequence of the behavior of the application itself.</p> |
| 3766 | </div> |
| 3767 | <div class="section" id="PSA_ERROR_INSUFFICIENT_ENTROPY"> |
| 3768 | <span id="c.PSA_ERROR_INSUFFICIENT_ENTROPY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code> (macro)</h2> |
| 3769 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INSUFFICIENT_ENTROPY ((psa_status_t)-148)</span> |
| 3770 | </pre></div> |
| 3771 | </div> |
| 3772 | <p>There is not enough entropy to generate random data needed for the requested action.</p> |
| 3773 | <p>This error indicates a failure of a hardware random generator. Application writers should note that this error can be returned not only by functions whose purpose is to generate random data, such as key, IV or nonce generation, but also by functions that execute an algorithm with a randomized result, as well as functions that use randomization of intermediate computations as a countermeasure to certain attacks.</p> |
| 3774 | <p>Implementations should avoid returning this error after <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a> has succeeded. Implementations should generate sufficient entropy during initialization and subsequently use a cryptographically secure pseudorandom generator (PRNG). However implementations may return this error at any time if a policy requires the PRNG to be reseeded during normal operation.</p> |
| 3775 | </div> |
| 3776 | <div class="section" id="PSA_ERROR_INVALID_SIGNATURE"> |
| 3777 | <span id="c.PSA_ERROR_INVALID_SIGNATURE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code> (macro)</h2> |
| 3778 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INVALID_SIGNATURE ((psa_status_t)-149)</span> |
| 3779 | </pre></div> |
| 3780 | </div> |
| 3781 | <p>The signature, MAC or hash is incorrect.</p> |
| 3782 | <p>Verification functions return this error if the verification calculations completed successfully, and the value to be verified was determined to be incorrect.</p> |
| 3783 | <p>If the value to verify has an invalid size, implementations may return either <a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a> or <a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a>.</p> |
| 3784 | </div> |
| 3785 | <div class="section" id="PSA_ERROR_INVALID_PADDING"> |
| 3786 | <span id="c.PSA_ERROR_INVALID_PADDING"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_PADDING</span></code> (macro)</h2> |
| 3787 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INVALID_PADDING ((psa_status_t)-150)</span> |
| 3788 | </pre></div> |
| 3789 | </div> |
| 3790 | <p>The decrypted padding is incorrect.</p> |
| 3791 | <div class="admonition warning"> |
| 3792 | <p class="first admonition-title">Warning</p> |
| 3793 | <p class="last">In some protocols, when decrypting data, it is essential that the behavior of the application does not depend on whether the padding is correct, down to precise timing. Applications should prefer protocols that use authenticated encryption rather than plain encryption. If the application must perform a decryption of unauthenticated data, the application writer should take care not to reveal whether the padding is invalid.</p> |
| 3794 | </div> |
| 3795 | <p>Implementations should strive to make valid and invalid padding as close as possible to indistinguishable to an external observer. In particular, the timing of a decryption operation should not depend on the validity of the padding.</p> |
| 3796 | </div> |
| 3797 | <div class="section" id="PSA_ERROR_INSUFFICIENT_DATA"> |
| 3798 | <span id="c.PSA_ERROR_INSUFFICIENT_DATA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_DATA</span></code> (macro)</h2> |
| 3799 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INSUFFICIENT_DATA ((psa_status_t)-143)</span> |
| 3800 | </pre></div> |
| 3801 | </div> |
| 3802 | <p>Return this error when there’s insufficient data when attempting to read from a resource.</p> |
| 3803 | </div> |
| 3804 | <div class="section" id="PSA_ERROR_INVALID_HANDLE"> |
| 3805 | <span id="c.PSA_ERROR_INVALID_HANDLE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code> (macro)</h2> |
| 3806 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INVALID_HANDLE ((psa_status_t)-136)</span> |
| 3807 | </pre></div> |
| 3808 | </div> |
| 3809 | <p>The key handle is not valid.</p> |
| 3810 | </div> |
| 3811 | </div> |
| 3812 | <div class="section" id="key-and-algorithm-types"> |
| 3813 | <h1>Key and algorithm types</h1> |
| 3814 | <div class="section" id="psa_key_type_t"> |
| 3815 | <span id="c.psa_key_type_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_type_t</span></code> (type)</h2> |
| 3816 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint32_t</span> <span class="n">psa_key_type_t</span><span class="p">;</span> |
| 3817 | </pre></div> |
| 3818 | </div> |
| 3819 | <p>Encoding of a key type.</p> |
| 3820 | </div> |
| 3821 | <div class="section" id="psa_ecc_curve_t"> |
| 3822 | <span id="c.psa_ecc_curve_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_ecc_curve_t</span></code> (type)</h2> |
| 3823 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint16_t</span> <span class="n">psa_ecc_curve_t</span><span class="p">;</span> |
| 3824 | </pre></div> |
| 3825 | </div> |
| 3826 | <p>The type of PSA elliptic curve identifiers.</p> |
| 3827 | </div> |
| 3828 | <div class="section" id="psa_dh_group_t"> |
| 3829 | <span id="c.psa_dh_group_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_dh_group_t</span></code> (type)</h2> |
| 3830 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint16_t</span> <span class="n">psa_dh_group_t</span><span class="p">;</span> |
| 3831 | </pre></div> |
| 3832 | </div> |
| 3833 | <p>The type of PSA Diffie-Hellman group identifiers.</p> |
| 3834 | </div> |
| 3835 | <div class="section" id="psa_algorithm_t"> |
| 3836 | <span id="c.psa_algorithm_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code> (type)</h2> |
| 3837 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint32_t</span> <span class="n">psa_algorithm_t</span><span class="p">;</span> |
| 3838 | </pre></div> |
| 3839 | </div> |
| 3840 | <p>Encoding of a cryptographic algorithm.</p> |
| 3841 | <p>For algorithms that can be applied to multiple key types, this type does not encode the key type. For example, for symmetric ciphers based on a block cipher, <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a> encodes the block cipher mode and the padding mode while the block cipher itself is encoded via <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>.</p> |
| 3842 | </div> |
| 3843 | <div class="section" id="PSA_KEY_TYPE_NONE"> |
| 3844 | <span id="c.PSA_KEY_TYPE_NONE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_NONE</span></code> (macro)</h2> |
| 3845 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_NONE ((psa_key_type_t)0x00000000)</span> |
| 3846 | </pre></div> |
| 3847 | </div> |
| 3848 | <p>An invalid key type value.</p> |
| 3849 | <p>Zero is not the encoding of any key type.</p> |
| 3850 | </div> |
| 3851 | <div class="section" id="PSA_KEY_TYPE_VENDOR_FLAG"> |
| 3852 | <span id="c.PSA_KEY_TYPE_VENDOR_FLAG"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_VENDOR_FLAG</span></code> (macro)</h2> |
| 3853 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_VENDOR_FLAG ((psa_key_type_t)0x80000000)</span> |
| 3854 | </pre></div> |
| 3855 | </div> |
| 3856 | <p>Vendor-defined flag.</p> |
| 3857 | <p>Key types defined by this standard will never have the <a class="reference internal" href="#c.PSA_KEY_TYPE_VENDOR_FLAG" title="PSA_KEY_TYPE_VENDOR_FLAG"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_VENDOR_FLAG</span></code></a> bit set. Vendors who define additional key types must use an encoding with the <a class="reference internal" href="#c.PSA_KEY_TYPE_VENDOR_FLAG" title="PSA_KEY_TYPE_VENDOR_FLAG"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_VENDOR_FLAG</span></code></a> bit set and should respect the bitwise structure used by standard encodings whenever practical.</p> |
| 3858 | </div> |
| 3859 | <div class="section" id="PSA_KEY_TYPE_CATEGORY_MASK"> |
| 3860 | <span id="c.PSA_KEY_TYPE_CATEGORY_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_MASK</span></code> (macro)</h2> |
| 3861 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_MASK ((psa_key_type_t)0x70000000)</span> |
| 3862 | </pre></div> |
| 3863 | </div> |
| 3864 | </div> |
| 3865 | <div class="section" id="PSA_KEY_TYPE_CATEGORY_SYMMETRIC"> |
| 3866 | <span id="c.PSA_KEY_TYPE_CATEGORY_SYMMETRIC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_SYMMETRIC</span></code> (macro)</h2> |
| 3867 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_SYMMETRIC ((psa_key_type_t)0x40000000)</span> |
| 3868 | </pre></div> |
| 3869 | </div> |
| 3870 | </div> |
| 3871 | <div class="section" id="PSA_KEY_TYPE_CATEGORY_RAW"> |
| 3872 | <span id="c.PSA_KEY_TYPE_CATEGORY_RAW"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_RAW</span></code> (macro)</h2> |
| 3873 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_RAW ((psa_key_type_t)0x50000000)</span> |
| 3874 | </pre></div> |
| 3875 | </div> |
| 3876 | </div> |
| 3877 | <div class="section" id="PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY"> |
| 3878 | <span id="c.PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY</span></code> (macro)</h2> |
| 3879 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY ((psa_key_type_t)0x60000000)</span> |
| 3880 | </pre></div> |
| 3881 | </div> |
| 3882 | </div> |
| 3883 | <div class="section" id="PSA_KEY_TYPE_CATEGORY_KEY_PAIR"> |
| 3884 | <span id="c.PSA_KEY_TYPE_CATEGORY_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_KEY_PAIR</span></code> (macro)</h2> |
| 3885 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_KEY_PAIR ((psa_key_type_t)0x70000000)</span> |
| 3886 | </pre></div> |
| 3887 | </div> |
| 3888 | </div> |
| 3889 | <div class="section" id="PSA_KEY_TYPE_CATEGORY_FLAG_PAIR"> |
| 3890 | <span id="c.PSA_KEY_TYPE_CATEGORY_FLAG_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_FLAG_PAIR</span></code> (macro)</h2> |
| 3891 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_FLAG_PAIR ((psa_key_type_t)0x10000000)</span> |
| 3892 | </pre></div> |
| 3893 | </div> |
| 3894 | </div> |
| 3895 | <div class="section" id="PSA_KEY_TYPE_IS_VENDOR_DEFINED"> |
| 3896 | <span id="c.PSA_KEY_TYPE_IS_VENDOR_DEFINED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_VENDOR_DEFINED</span></code> (macro)</h2> |
| 3897 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_VENDOR_DEFINED(type) \</span> |
| 3898 | <span class="cp"> (((type) & PSA_KEY_TYPE_VENDOR_FLAG) != 0)</span> |
| 3899 | </pre></div> |
| 3900 | </div> |
| 3901 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3902 | <dl class="docutils"> |
| 3903 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 3904 | <dd></dd> |
| 3905 | </dl> |
| 3906 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3907 | <p>Whether a key type is vendor-defined.</p> |
| 3908 | </div> |
| 3909 | <div class="section" id="PSA_KEY_TYPE_IS_UNSTRUCTURED"> |
| 3910 | <span id="c.PSA_KEY_TYPE_IS_UNSTRUCTURED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_UNSTRUCTURED</span></code> (macro)</h2> |
| 3911 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_UNSTRUCTURED(type) \</span> |
| 3912 | <span class="cp"> (((type) & PSA_KEY_TYPE_CATEGORY_MASK & ~(psa_key_type_t)0x10000000) == PSA_KEY_TYPE_CATEGORY_SYMMETRIC)</span> |
| 3913 | </pre></div> |
| 3914 | </div> |
| 3915 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3916 | <dl class="docutils"> |
| 3917 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 3918 | <dd></dd> |
| 3919 | </dl> |
| 3920 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3921 | <p>Whether a key type is an unstructured array of bytes.</p> |
| 3922 | <p>This encompasses both symmetric keys and non-key data.</p> |
| 3923 | </div> |
| 3924 | <div class="section" id="PSA_KEY_TYPE_IS_ASYMMETRIC"> |
| 3925 | <span id="c.PSA_KEY_TYPE_IS_ASYMMETRIC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ASYMMETRIC</span></code> (macro)</h2> |
| 3926 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_ASYMMETRIC(type) \</span> |
| 3927 | <span class="cp"> (((type) & PSA_KEY_TYPE_CATEGORY_MASK & ~PSA_KEY_TYPE_CATEGORY_FLAG_PAIR) == PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY)</span> |
| 3928 | </pre></div> |
| 3929 | </div> |
| 3930 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3931 | <dl class="docutils"> |
| 3932 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 3933 | <dd></dd> |
| 3934 | </dl> |
| 3935 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3936 | <p>Whether a key type is asymmetric: either a key pair or a public key.</p> |
| 3937 | </div> |
| 3938 | <div class="section" id="PSA_KEY_TYPE_IS_PUBLIC_KEY"> |
| 3939 | <span id="c.PSA_KEY_TYPE_IS_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_PUBLIC_KEY</span></code> (macro)</h2> |
| 3940 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_PUBLIC_KEY(type) \</span> |
| 3941 | <span class="cp"> (((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY)</span> |
| 3942 | </pre></div> |
| 3943 | </div> |
| 3944 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3945 | <dl class="docutils"> |
| 3946 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 3947 | <dd></dd> |
| 3948 | </dl> |
| 3949 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3950 | <p>Whether a key type is the public part of a key pair.</p> |
| 3951 | </div> |
| 3952 | <div class="section" id="PSA_KEY_TYPE_IS_KEY_PAIR"> |
| 3953 | <span id="c.PSA_KEY_TYPE_IS_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_KEY_PAIR</span></code> (macro)</h2> |
| 3954 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_KEY_PAIR(type) \</span> |
| 3955 | <span class="cp"> (((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_KEY_PAIR)</span> |
| 3956 | </pre></div> |
| 3957 | </div> |
| 3958 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3959 | <dl class="docutils"> |
| 3960 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 3961 | <dd></dd> |
| 3962 | </dl> |
| 3963 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3964 | <p>Whether a key type is a key pair containing a private part and a public part.</p> |
| 3965 | </div> |
| 3966 | <div class="section" id="PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY"> |
| 3967 | <span id="c.PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY</span></code> (macro)</h2> |
| 3968 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY(type) \</span> |
| 3969 | <span class="cp"> ((type) | PSA_KEY_TYPE_CATEGORY_FLAG_PAIR)</span> |
| 3970 | </pre></div> |
| 3971 | </div> |
| 3972 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3973 | <dl class="docutils"> |
| 3974 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 3975 | <dd>A public key type or key pair type.</dd> |
| 3976 | </dl> |
| 3977 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 3978 | <p>The corresponding key pair type. If <code class="docutils literal notranslate"><span class="pre">type</span></code> is not a public key or a key pair, the return value is undefined.</p> |
| 3979 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3980 | <p>The key pair type corresponding to a public key type.</p> |
| 3981 | <p>You may also pass a key pair type as <code class="docutils literal notranslate"><span class="pre">type</span></code>, it will be left unchanged.</p> |
| 3982 | </div> |
| 3983 | <div class="section" id="PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR"> |
| 3984 | <span id="c.PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span></code> (macro)</h2> |
| 3985 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) \</span> |
| 3986 | <span class="cp"> ((type) & ~PSA_KEY_TYPE_CATEGORY_FLAG_PAIR)</span> |
| 3987 | </pre></div> |
| 3988 | </div> |
| 3989 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 3990 | <dl class="docutils"> |
| 3991 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 3992 | <dd>A public key type or key pair type.</dd> |
| 3993 | </dl> |
| 3994 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 3995 | <p>The corresponding public key type. If <code class="docutils literal notranslate"><span class="pre">type</span></code> is not a public key or a key pair, the return value is undefined.</p> |
| 3996 | <p class="subitem-title"><strong>Description:</strong></p> |
| 3997 | <p>The public key type corresponding to a key pair type.</p> |
| 3998 | <p>You may also pass a key pair type as <code class="docutils literal notranslate"><span class="pre">type</span></code>, it will be left unchanged.</p> |
| 3999 | </div> |
| 4000 | <div class="section" id="PSA_KEY_TYPE_RAW_DATA"> |
| 4001 | <span id="c.PSA_KEY_TYPE_RAW_DATA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RAW_DATA</span></code> (macro)</h2> |
| 4002 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_RAW_DATA ((psa_key_type_t)0x50000001)</span> |
| 4003 | </pre></div> |
| 4004 | </div> |
| 4005 | <p>Raw data.</p> |
| 4006 | <p>A “key” of this type cannot be used for any cryptographic operation. Applications may use this type to store arbitrary data in the keystore.</p> |
| 4007 | </div> |
| 4008 | <div class="section" id="PSA_KEY_TYPE_HMAC"> |
| 4009 | <span id="c.PSA_KEY_TYPE_HMAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_HMAC</span></code> (macro)</h2> |
| 4010 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_HMAC ((psa_key_type_t)0x51000000)</span> |
| 4011 | </pre></div> |
| 4012 | </div> |
| 4013 | <p>HMAC key.</p> |
| 4014 | <p>The key policy determines which underlying hash algorithm the key can be used for.</p> |
| 4015 | <p>HMAC keys should generally have the same size as the underlying hash. This size can be calculated with <a class="reference internal" href="#c.PSA_HASH_SIZE" title="PSA_HASH_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the HMAC algorithm or the underlying hash algorithm.</p> |
| 4016 | </div> |
| 4017 | <div class="section" id="PSA_KEY_TYPE_DERIVE"> |
| 4018 | <span id="c.PSA_KEY_TYPE_DERIVE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DERIVE</span></code> (macro)</h2> |
| 4019 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DERIVE ((psa_key_type_t)0x52000000)</span> |
| 4020 | </pre></div> |
| 4021 | </div> |
| 4022 | <p>A secret for key derivation.</p> |
| 4023 | <p>The key policy determines which key derivation algorithm the key can be used for.</p> |
| 4024 | </div> |
| 4025 | <div class="section" id="PSA_KEY_TYPE_AES"> |
| 4026 | <span id="c.PSA_KEY_TYPE_AES"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_AES</span></code> (macro)</h2> |
| 4027 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_AES ((psa_key_type_t)0x40000001)</span> |
| 4028 | </pre></div> |
| 4029 | </div> |
| 4030 | <p>Key for a cipher, AEAD or MAC algorithm based on the AES block cipher.</p> |
| 4031 | <p>The size of the key can be 16 bytes (AES-128), 24 bytes (AES-192) or 32 bytes (AES-256).</p> |
| 4032 | </div> |
| 4033 | <div class="section" id="PSA_KEY_TYPE_DES"> |
| 4034 | <span id="c.PSA_KEY_TYPE_DES"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DES</span></code> (macro)</h2> |
| 4035 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DES ((psa_key_type_t)0x40000002)</span> |
| 4036 | </pre></div> |
| 4037 | </div> |
| 4038 | <p>Key for a cipher or MAC algorithm based on DES or 3DES (Triple-DES).</p> |
| 4039 | <p>The size of the key can be 8 bytes (single DES), 16 bytes (2-key 3DES) or 24 bytes (3-key 3DES).</p> |
| 4040 | <p>Note that single DES and 2-key 3DES are weak and strongly deprecated and should only be used to decrypt legacy data. 3-key 3DES is weak and deprecated and should only be used in legacy protocols.</p> |
| 4041 | </div> |
| 4042 | <div class="section" id="PSA_KEY_TYPE_CAMELLIA"> |
| 4043 | <span id="c.PSA_KEY_TYPE_CAMELLIA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CAMELLIA</span></code> (macro)</h2> |
| 4044 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CAMELLIA ((psa_key_type_t)0x40000003)</span> |
| 4045 | </pre></div> |
| 4046 | </div> |
| 4047 | <p>Key for a cipher, AEAD or MAC algorithm based on the Camellia block cipher.</p> |
| 4048 | </div> |
| 4049 | <div class="section" id="PSA_KEY_TYPE_ARC4"> |
| 4050 | <span id="c.PSA_KEY_TYPE_ARC4"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ARC4</span></code> (macro)</h2> |
| 4051 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ARC4 ((psa_key_type_t)0x40000004)</span> |
| 4052 | </pre></div> |
| 4053 | </div> |
| 4054 | <p>Key for the RC4 stream cipher.</p> |
| 4055 | <p>Note that RC4 is weak and deprecated and should only be used in legacy protocols.</p> |
| 4056 | </div> |
| 4057 | <div class="section" id="PSA_KEY_TYPE_CHACHA20"> |
| 4058 | <span id="c.PSA_KEY_TYPE_CHACHA20"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CHACHA20</span></code> (macro)</h2> |
| 4059 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t)0x40000005)</span> |
| 4060 | </pre></div> |
| 4061 | </div> |
| 4062 | <p>Key for the ChaCha20 stream cipher or the Chacha20-Poly1305 AEAD algorithm.</p> |
| 4063 | <p>ChaCha20 and the ChaCha20_Poly1305 construction are defined in RFC 7539.</p> |
| 4064 | <p>Implementations must support 12-byte nonces, may support 8-byte nonces, and should reject other sizes.</p> |
| 4065 | </div> |
| 4066 | <div class="section" id="PSA_KEY_TYPE_RSA_PUBLIC_KEY"> |
| 4067 | <span id="c.PSA_KEY_TYPE_RSA_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_PUBLIC_KEY</span></code> (macro)</h2> |
| 4068 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_RSA_PUBLIC_KEY ((psa_key_type_t)0x60010000)</span> |
| 4069 | </pre></div> |
| 4070 | </div> |
| 4071 | <p>RSA public key.</p> |
| 4072 | </div> |
| 4073 | <div class="section" id="PSA_KEY_TYPE_RSA_KEY_PAIR"> |
| 4074 | <span id="c.PSA_KEY_TYPE_RSA_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code> (macro)</h2> |
| 4075 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_RSA_KEY_PAIR ((psa_key_type_t)0x70010000)</span> |
| 4076 | </pre></div> |
| 4077 | </div> |
| 4078 | <p>RSA key pair (private and public key).</p> |
| 4079 | </div> |
| 4080 | <div class="section" id="PSA_KEY_TYPE_IS_RSA"> |
| 4081 | <span id="c.PSA_KEY_TYPE_IS_RSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_RSA</span></code> (macro)</h2> |
| 4082 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_RSA(type) \</span> |
| 4083 | <span class="cp"> (PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == PSA_KEY_TYPE_RSA_PUBLIC_KEY)</span> |
| 4084 | </pre></div> |
| 4085 | </div> |
| 4086 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4087 | <dl class="docutils"> |
| 4088 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 4089 | <dd></dd> |
| 4090 | </dl> |
| 4091 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4092 | <p>Whether a key type is an RSA key (pair or public-only).</p> |
| 4093 | </div> |
| 4094 | <div class="section" id="PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE"> |
| 4095 | <span id="c.PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE</span></code> (macro)</h2> |
| 4096 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE ((psa_key_type_t)0x60030000)</span> |
| 4097 | </pre></div> |
| 4098 | </div> |
| 4099 | </div> |
| 4100 | <div class="section" id="PSA_KEY_TYPE_ECC_KEY_PAIR_BASE"> |
| 4101 | <span id="c.PSA_KEY_TYPE_ECC_KEY_PAIR_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR_BASE</span></code> (macro)</h2> |
| 4102 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ECC_KEY_PAIR_BASE ((psa_key_type_t)0x70030000)</span> |
| 4103 | </pre></div> |
| 4104 | </div> |
| 4105 | </div> |
| 4106 | <div class="section" id="PSA_KEY_TYPE_ECC_CURVE_MASK"> |
| 4107 | <span id="c.PSA_KEY_TYPE_ECC_CURVE_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_CURVE_MASK</span></code> (macro)</h2> |
| 4108 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ECC_CURVE_MASK ((psa_key_type_t)0x0000ffff)</span> |
| 4109 | </pre></div> |
| 4110 | </div> |
| 4111 | </div> |
| 4112 | <div class="section" id="PSA_KEY_TYPE_ECC_KEY_PAIR"> |
| 4113 | <span id="c.PSA_KEY_TYPE_ECC_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR</span></code> (macro)</h2> |
| 4114 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ECC_KEY_PAIR(curve) \</span> |
| 4115 | <span class="cp"> (PSA_KEY_TYPE_ECC_KEY_PAIR_BASE | (curve))</span> |
| 4116 | </pre></div> |
| 4117 | </div> |
| 4118 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4119 | <dl class="docutils"> |
| 4120 | <dt> <code class="docutils literal notranslate"><span class="pre">curve</span></code></dt> |
| 4121 | <dd></dd> |
| 4122 | </dl> |
| 4123 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4124 | <p>Elliptic curve key pair.</p> |
| 4125 | </div> |
| 4126 | <div class="section" id="PSA_KEY_TYPE_ECC_PUBLIC_KEY"> |
| 4127 | <span id="c.PSA_KEY_TYPE_ECC_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY</span></code> (macro)</h2> |
| 4128 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ECC_PUBLIC_KEY(curve) \</span> |
| 4129 | <span class="cp"> (PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE | (curve))</span> |
| 4130 | </pre></div> |
| 4131 | </div> |
| 4132 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4133 | <dl class="docutils"> |
| 4134 | <dt> <code class="docutils literal notranslate"><span class="pre">curve</span></code></dt> |
| 4135 | <dd></dd> |
| 4136 | </dl> |
| 4137 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4138 | <p>Elliptic curve public key.</p> |
| 4139 | </div> |
| 4140 | <div class="section" id="PSA_KEY_TYPE_IS_ECC"> |
| 4141 | <span id="c.PSA_KEY_TYPE_IS_ECC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC</span></code> (macro)</h2> |
| 4142 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_ECC(type) \</span> |
| 4143 | <span class="cp"> ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) & ~PSA_KEY_TYPE_ECC_CURVE_MASK) == PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE)</span> |
| 4144 | </pre></div> |
| 4145 | </div> |
| 4146 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4147 | <dl class="docutils"> |
| 4148 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 4149 | <dd></dd> |
| 4150 | </dl> |
| 4151 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4152 | <p>Whether a key type is an elliptic curve key (pair or public-only).</p> |
| 4153 | </div> |
| 4154 | <div class="section" id="PSA_KEY_TYPE_IS_ECC_KEY_PAIR"> |
| 4155 | <span id="c.PSA_KEY_TYPE_IS_ECC_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_KEY_PAIR</span></code> (macro)</h2> |
| 4156 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_ECC_KEY_PAIR(type) \</span> |
| 4157 | <span class="cp"> (((type) & ~PSA_KEY_TYPE_ECC_CURVE_MASK) == PSA_KEY_TYPE_ECC_KEY_PAIR_BASE)</span> |
| 4158 | </pre></div> |
| 4159 | </div> |
| 4160 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4161 | <dl class="docutils"> |
| 4162 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 4163 | <dd></dd> |
| 4164 | </dl> |
| 4165 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4166 | <p>Whether a key type is an elliptic curve key pair.</p> |
| 4167 | </div> |
| 4168 | <div class="section" id="PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY"> |
| 4169 | <span id="c.PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY</span></code> (macro)</h2> |
| 4170 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(type) \</span> |
| 4171 | <span class="cp"> (((type) & ~PSA_KEY_TYPE_ECC_CURVE_MASK) == PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE)</span> |
| 4172 | </pre></div> |
| 4173 | </div> |
| 4174 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4175 | <dl class="docutils"> |
| 4176 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 4177 | <dd></dd> |
| 4178 | </dl> |
| 4179 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4180 | <p>Whether a key type is an elliptic curve public key.</p> |
| 4181 | </div> |
| 4182 | <div class="section" id="PSA_KEY_TYPE_GET_CURVE"> |
| 4183 | <span id="c.PSA_KEY_TYPE_GET_CURVE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_GET_CURVE</span></code> (macro)</h2> |
| 4184 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_GET_CURVE(type) \</span> |
| 4185 | <span class="cp"> ((psa_ecc_curve_t) (PSA_KEY_TYPE_IS_ECC(type) ? ((type) & PSA_KEY_TYPE_ECC_CURVE_MASK) : 0))</span> |
| 4186 | </pre></div> |
| 4187 | </div> |
| 4188 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4189 | <dl class="docutils"> |
| 4190 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 4191 | <dd></dd> |
| 4192 | </dl> |
| 4193 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4194 | <p>Extract the curve from an elliptic curve key type.</p> |
| 4195 | </div> |
| 4196 | <div class="section" id="PSA_ECC_CURVE_SECT163K1"> |
| 4197 | <span id="c.PSA_ECC_CURVE_SECT163K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163K1</span></code> (macro)</h2> |
| 4198 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT163K1 ((psa_ecc_curve_t) 0x0001)</span> |
| 4199 | </pre></div> |
| 4200 | </div> |
| 4201 | </div> |
| 4202 | <div class="section" id="PSA_ECC_CURVE_SECT163R1"> |
| 4203 | <span id="c.PSA_ECC_CURVE_SECT163R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163R1</span></code> (macro)</h2> |
| 4204 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT163R1 ((psa_ecc_curve_t) 0x0002)</span> |
| 4205 | </pre></div> |
| 4206 | </div> |
| 4207 | </div> |
| 4208 | <div class="section" id="PSA_ECC_CURVE_SECT163R2"> |
| 4209 | <span id="c.PSA_ECC_CURVE_SECT163R2"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163R2</span></code> (macro)</h2> |
| 4210 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT163R2 ((psa_ecc_curve_t) 0x0003)</span> |
| 4211 | </pre></div> |
| 4212 | </div> |
| 4213 | </div> |
| 4214 | <div class="section" id="PSA_ECC_CURVE_SECT193R1"> |
| 4215 | <span id="c.PSA_ECC_CURVE_SECT193R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT193R1</span></code> (macro)</h2> |
| 4216 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT193R1 ((psa_ecc_curve_t) 0x0004)</span> |
| 4217 | </pre></div> |
| 4218 | </div> |
| 4219 | </div> |
| 4220 | <div class="section" id="PSA_ECC_CURVE_SECT193R2"> |
| 4221 | <span id="c.PSA_ECC_CURVE_SECT193R2"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT193R2</span></code> (macro)</h2> |
| 4222 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT193R2 ((psa_ecc_curve_t) 0x0005)</span> |
| 4223 | </pre></div> |
| 4224 | </div> |
| 4225 | </div> |
| 4226 | <div class="section" id="PSA_ECC_CURVE_SECT233K1"> |
| 4227 | <span id="c.PSA_ECC_CURVE_SECT233K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT233K1</span></code> (macro)</h2> |
| 4228 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT233K1 ((psa_ecc_curve_t) 0x0006)</span> |
| 4229 | </pre></div> |
| 4230 | </div> |
| 4231 | </div> |
| 4232 | <div class="section" id="PSA_ECC_CURVE_SECT233R1"> |
| 4233 | <span id="c.PSA_ECC_CURVE_SECT233R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT233R1</span></code> (macro)</h2> |
| 4234 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT233R1 ((psa_ecc_curve_t) 0x0007)</span> |
| 4235 | </pre></div> |
| 4236 | </div> |
| 4237 | </div> |
| 4238 | <div class="section" id="PSA_ECC_CURVE_SECT239K1"> |
| 4239 | <span id="c.PSA_ECC_CURVE_SECT239K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT239K1</span></code> (macro)</h2> |
| 4240 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT239K1 ((psa_ecc_curve_t) 0x0008)</span> |
| 4241 | </pre></div> |
| 4242 | </div> |
| 4243 | </div> |
| 4244 | <div class="section" id="PSA_ECC_CURVE_SECT283K1"> |
| 4245 | <span id="c.PSA_ECC_CURVE_SECT283K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT283K1</span></code> (macro)</h2> |
| 4246 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT283K1 ((psa_ecc_curve_t) 0x0009)</span> |
| 4247 | </pre></div> |
| 4248 | </div> |
| 4249 | </div> |
| 4250 | <div class="section" id="PSA_ECC_CURVE_SECT283R1"> |
| 4251 | <span id="c.PSA_ECC_CURVE_SECT283R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT283R1</span></code> (macro)</h2> |
| 4252 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT283R1 ((psa_ecc_curve_t) 0x000a)</span> |
| 4253 | </pre></div> |
| 4254 | </div> |
| 4255 | </div> |
| 4256 | <div class="section" id="PSA_ECC_CURVE_SECT409K1"> |
| 4257 | <span id="c.PSA_ECC_CURVE_SECT409K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT409K1</span></code> (macro)</h2> |
| 4258 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT409K1 ((psa_ecc_curve_t) 0x000b)</span> |
| 4259 | </pre></div> |
| 4260 | </div> |
| 4261 | </div> |
| 4262 | <div class="section" id="PSA_ECC_CURVE_SECT409R1"> |
| 4263 | <span id="c.PSA_ECC_CURVE_SECT409R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT409R1</span></code> (macro)</h2> |
| 4264 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT409R1 ((psa_ecc_curve_t) 0x000c)</span> |
| 4265 | </pre></div> |
| 4266 | </div> |
| 4267 | </div> |
| 4268 | <div class="section" id="PSA_ECC_CURVE_SECT571K1"> |
| 4269 | <span id="c.PSA_ECC_CURVE_SECT571K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT571K1</span></code> (macro)</h2> |
| 4270 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT571K1 ((psa_ecc_curve_t) 0x000d)</span> |
| 4271 | </pre></div> |
| 4272 | </div> |
| 4273 | </div> |
| 4274 | <div class="section" id="PSA_ECC_CURVE_SECT571R1"> |
| 4275 | <span id="c.PSA_ECC_CURVE_SECT571R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT571R1</span></code> (macro)</h2> |
| 4276 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT571R1 ((psa_ecc_curve_t) 0x000e)</span> |
| 4277 | </pre></div> |
| 4278 | </div> |
| 4279 | </div> |
| 4280 | <div class="section" id="PSA_ECC_CURVE_SECP160K1"> |
| 4281 | <span id="c.PSA_ECC_CURVE_SECP160K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160K1</span></code> (macro)</h2> |
| 4282 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP160K1 ((psa_ecc_curve_t) 0x000f)</span> |
| 4283 | </pre></div> |
| 4284 | </div> |
| 4285 | </div> |
| 4286 | <div class="section" id="PSA_ECC_CURVE_SECP160R1"> |
| 4287 | <span id="c.PSA_ECC_CURVE_SECP160R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160R1</span></code> (macro)</h2> |
| 4288 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP160R1 ((psa_ecc_curve_t) 0x0010)</span> |
| 4289 | </pre></div> |
| 4290 | </div> |
| 4291 | </div> |
| 4292 | <div class="section" id="PSA_ECC_CURVE_SECP160R2"> |
| 4293 | <span id="c.PSA_ECC_CURVE_SECP160R2"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160R2</span></code> (macro)</h2> |
| 4294 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP160R2 ((psa_ecc_curve_t) 0x0011)</span> |
| 4295 | </pre></div> |
| 4296 | </div> |
| 4297 | </div> |
| 4298 | <div class="section" id="PSA_ECC_CURVE_SECP192K1"> |
| 4299 | <span id="c.PSA_ECC_CURVE_SECP192K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP192K1</span></code> (macro)</h2> |
| 4300 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP192K1 ((psa_ecc_curve_t) 0x0012)</span> |
| 4301 | </pre></div> |
| 4302 | </div> |
| 4303 | </div> |
| 4304 | <div class="section" id="PSA_ECC_CURVE_SECP192R1"> |
| 4305 | <span id="c.PSA_ECC_CURVE_SECP192R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP192R1</span></code> (macro)</h2> |
| 4306 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP192R1 ((psa_ecc_curve_t) 0x0013)</span> |
| 4307 | </pre></div> |
| 4308 | </div> |
| 4309 | </div> |
| 4310 | <div class="section" id="PSA_ECC_CURVE_SECP224K1"> |
| 4311 | <span id="c.PSA_ECC_CURVE_SECP224K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP224K1</span></code> (macro)</h2> |
| 4312 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP224K1 ((psa_ecc_curve_t) 0x0014)</span> |
| 4313 | </pre></div> |
| 4314 | </div> |
| 4315 | </div> |
| 4316 | <div class="section" id="PSA_ECC_CURVE_SECP224R1"> |
| 4317 | <span id="c.PSA_ECC_CURVE_SECP224R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP224R1</span></code> (macro)</h2> |
| 4318 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP224R1 ((psa_ecc_curve_t) 0x0015)</span> |
| 4319 | </pre></div> |
| 4320 | </div> |
| 4321 | </div> |
| 4322 | <div class="section" id="PSA_ECC_CURVE_SECP256K1"> |
| 4323 | <span id="c.PSA_ECC_CURVE_SECP256K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP256K1</span></code> (macro)</h2> |
| 4324 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP256K1 ((psa_ecc_curve_t) 0x0016)</span> |
| 4325 | </pre></div> |
| 4326 | </div> |
| 4327 | </div> |
| 4328 | <div class="section" id="PSA_ECC_CURVE_SECP256R1"> |
| 4329 | <span id="c.PSA_ECC_CURVE_SECP256R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP256R1</span></code> (macro)</h2> |
| 4330 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP256R1 ((psa_ecc_curve_t) 0x0017)</span> |
| 4331 | </pre></div> |
| 4332 | </div> |
| 4333 | </div> |
| 4334 | <div class="section" id="PSA_ECC_CURVE_SECP384R1"> |
| 4335 | <span id="c.PSA_ECC_CURVE_SECP384R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP384R1</span></code> (macro)</h2> |
| 4336 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP384R1 ((psa_ecc_curve_t) 0x0018)</span> |
| 4337 | </pre></div> |
| 4338 | </div> |
| 4339 | </div> |
| 4340 | <div class="section" id="PSA_ECC_CURVE_SECP521R1"> |
| 4341 | <span id="c.PSA_ECC_CURVE_SECP521R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP521R1</span></code> (macro)</h2> |
| 4342 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP521R1 ((psa_ecc_curve_t) 0x0019)</span> |
| 4343 | </pre></div> |
| 4344 | </div> |
| 4345 | </div> |
| 4346 | <div class="section" id="PSA_ECC_CURVE_BRAINPOOL_P256R1"> |
| 4347 | <span id="c.PSA_ECC_CURVE_BRAINPOOL_P256R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P256R1</span></code> (macro)</h2> |
| 4348 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_BRAINPOOL_P256R1 ((psa_ecc_curve_t) 0x001a)</span> |
| 4349 | </pre></div> |
| 4350 | </div> |
| 4351 | </div> |
| 4352 | <div class="section" id="PSA_ECC_CURVE_BRAINPOOL_P384R1"> |
| 4353 | <span id="c.PSA_ECC_CURVE_BRAINPOOL_P384R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P384R1</span></code> (macro)</h2> |
| 4354 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_BRAINPOOL_P384R1 ((psa_ecc_curve_t) 0x001b)</span> |
| 4355 | </pre></div> |
| 4356 | </div> |
| 4357 | </div> |
| 4358 | <div class="section" id="PSA_ECC_CURVE_BRAINPOOL_P512R1"> |
| 4359 | <span id="c.PSA_ECC_CURVE_BRAINPOOL_P512R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P512R1</span></code> (macro)</h2> |
| 4360 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_BRAINPOOL_P512R1 ((psa_ecc_curve_t) 0x001c)</span> |
| 4361 | </pre></div> |
| 4362 | </div> |
| 4363 | </div> |
| 4364 | <div class="section" id="PSA_ECC_CURVE_CURVE25519"> |
| 4365 | <span id="c.PSA_ECC_CURVE_CURVE25519"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE25519</span></code> (macro)</h2> |
| 4366 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_CURVE25519 ((psa_ecc_curve_t) 0x001d)</span> |
| 4367 | </pre></div> |
| 4368 | </div> |
| 4369 | <p>Curve25519.</p> |
| 4370 | <p>This is the curve defined in Bernstein et al., <em>Curve25519: new Diffie-Hellman speed records</em>, LNCS 3958, 2006. The algorithm <a class="reference internal" href="#c.PSA_ALG_ECDH" title="PSA_ALG_ECDH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDH</span></code></a> performs X25519 when used with this curve.</p> |
| 4371 | </div> |
| 4372 | <div class="section" id="PSA_ECC_CURVE_CURVE448"> |
| 4373 | <span id="c.PSA_ECC_CURVE_CURVE448"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE448</span></code> (macro)</h2> |
| 4374 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_CURVE448 ((psa_ecc_curve_t) 0x001e)</span> |
| 4375 | </pre></div> |
| 4376 | </div> |
| 4377 | <p>Curve448.</p> |
| 4378 | <p>This is the curve defined in Hamburg, <em>Ed448-Goldilocks, a new elliptic curve</em>, NIST ECC Workshop, 2015. The algorithm <a class="reference internal" href="#c.PSA_ALG_ECDH" title="PSA_ALG_ECDH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDH</span></code></a> performs X448 when used with this curve.</p> |
| 4379 | </div> |
| 4380 | <div class="section" id="PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE"> |
| 4381 | <span id="c.PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE</span></code> (macro)</h2> |
| 4382 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE ((psa_key_type_t)0x60040000)</span> |
| 4383 | </pre></div> |
| 4384 | </div> |
| 4385 | </div> |
| 4386 | <div class="section" id="PSA_KEY_TYPE_DH_KEY_PAIR_BASE"> |
| 4387 | <span id="c.PSA_KEY_TYPE_DH_KEY_PAIR_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR_BASE</span></code> (macro)</h2> |
| 4388 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DH_KEY_PAIR_BASE ((psa_key_type_t)0x70040000)</span> |
| 4389 | </pre></div> |
| 4390 | </div> |
| 4391 | </div> |
| 4392 | <div class="section" id="PSA_KEY_TYPE_DH_GROUP_MASK"> |
| 4393 | <span id="c.PSA_KEY_TYPE_DH_GROUP_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_GROUP_MASK</span></code> (macro)</h2> |
| 4394 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DH_GROUP_MASK ((psa_key_type_t)0x0000ffff)</span> |
| 4395 | </pre></div> |
| 4396 | </div> |
| 4397 | </div> |
| 4398 | <div class="section" id="PSA_KEY_TYPE_DH_KEY_PAIR"> |
| 4399 | <span id="c.PSA_KEY_TYPE_DH_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR</span></code> (macro)</h2> |
| 4400 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DH_KEY_PAIR(group) \</span> |
| 4401 | <span class="cp"> (PSA_KEY_TYPE_DH_KEY_PAIR_BASE | (group))</span> |
| 4402 | </pre></div> |
| 4403 | </div> |
| 4404 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4405 | <dl class="docutils"> |
| 4406 | <dt> <code class="docutils literal notranslate"><span class="pre">group</span></code></dt> |
| 4407 | <dd></dd> |
| 4408 | </dl> |
| 4409 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4410 | <p>Diffie-Hellman key pair.</p> |
| 4411 | </div> |
| 4412 | <div class="section" id="PSA_KEY_TYPE_DH_PUBLIC_KEY"> |
| 4413 | <span id="c.PSA_KEY_TYPE_DH_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY</span></code> (macro)</h2> |
| 4414 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DH_PUBLIC_KEY(group) \</span> |
| 4415 | <span class="cp"> (PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE | (group))</span> |
| 4416 | </pre></div> |
| 4417 | </div> |
| 4418 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4419 | <dl class="docutils"> |
| 4420 | <dt> <code class="docutils literal notranslate"><span class="pre">group</span></code></dt> |
| 4421 | <dd></dd> |
| 4422 | </dl> |
| 4423 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4424 | <p>Diffie-Hellman public key.</p> |
| 4425 | </div> |
| 4426 | <div class="section" id="PSA_KEY_TYPE_IS_DH"> |
| 4427 | <span id="c.PSA_KEY_TYPE_IS_DH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH</span></code> (macro)</h2> |
| 4428 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_DH(type) \</span> |
| 4429 | <span class="cp"> ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) & ~PSA_KEY_TYPE_DH_GROUP_MASK) == PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE)</span> |
| 4430 | </pre></div> |
| 4431 | </div> |
| 4432 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4433 | <dl class="docutils"> |
| 4434 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 4435 | <dd></dd> |
| 4436 | </dl> |
| 4437 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4438 | <p>Whether a key type is a Diffie-Hellman key (pair or public-only).</p> |
| 4439 | </div> |
| 4440 | <div class="section" id="PSA_KEY_TYPE_IS_DH_KEY_PAIR"> |
| 4441 | <span id="c.PSA_KEY_TYPE_IS_DH_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_KEY_PAIR</span></code> (macro)</h2> |
| 4442 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_DH_KEY_PAIR(type) \</span> |
| 4443 | <span class="cp"> (((type) & ~PSA_KEY_TYPE_DH_GROUP_MASK) == PSA_KEY_TYPE_DH_KEY_PAIR_BASE)</span> |
| 4444 | </pre></div> |
| 4445 | </div> |
| 4446 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4447 | <dl class="docutils"> |
| 4448 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 4449 | <dd></dd> |
| 4450 | </dl> |
| 4451 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4452 | <p>Whether a key type is a Diffie-Hellman key pair.</p> |
| 4453 | </div> |
| 4454 | <div class="section" id="PSA_KEY_TYPE_IS_DH_PUBLIC_KEY"> |
| 4455 | <span id="c.PSA_KEY_TYPE_IS_DH_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_PUBLIC_KEY</span></code> (macro)</h2> |
| 4456 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_DH_PUBLIC_KEY(type) \</span> |
| 4457 | <span class="cp"> (((type) & ~PSA_KEY_TYPE_DH_GROUP_MASK) == PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE)</span> |
| 4458 | </pre></div> |
| 4459 | </div> |
| 4460 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4461 | <dl class="docutils"> |
| 4462 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 4463 | <dd></dd> |
| 4464 | </dl> |
| 4465 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4466 | <p>Whether a key type is a Diffie-Hellman public key.</p> |
| 4467 | </div> |
| 4468 | <div class="section" id="PSA_KEY_TYPE_GET_GROUP"> |
| 4469 | <span id="c.PSA_KEY_TYPE_GET_GROUP"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_GET_GROUP</span></code> (macro)</h2> |
| 4470 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_GET_GROUP(type) \</span> |
| 4471 | <span class="cp"> ((psa_dh_group_t) (PSA_KEY_TYPE_IS_DH(type) ? ((type) & PSA_KEY_TYPE_DH_GROUP_MASK) : 0))</span> |
| 4472 | </pre></div> |
| 4473 | </div> |
| 4474 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4475 | <dl class="docutils"> |
| 4476 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 4477 | <dd></dd> |
| 4478 | </dl> |
| 4479 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4480 | <p>Extract the group from a Diffie-Hellman key type.</p> |
| 4481 | </div> |
| 4482 | <div class="section" id="PSA_DH_GROUP_FFDHE2048"> |
| 4483 | <span id="c.PSA_DH_GROUP_FFDHE2048"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE2048</span></code> (macro)</h2> |
| 4484 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_DH_GROUP_FFDHE2048 ((psa_dh_group_t) 0x0100)</span> |
| 4485 | </pre></div> |
| 4486 | </div> |
| 4487 | </div> |
| 4488 | <div class="section" id="PSA_DH_GROUP_FFDHE3072"> |
| 4489 | <span id="c.PSA_DH_GROUP_FFDHE3072"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE3072</span></code> (macro)</h2> |
| 4490 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_DH_GROUP_FFDHE3072 ((psa_dh_group_t) 0x0101)</span> |
| 4491 | </pre></div> |
| 4492 | </div> |
| 4493 | </div> |
| 4494 | <div class="section" id="PSA_DH_GROUP_FFDHE4096"> |
| 4495 | <span id="c.PSA_DH_GROUP_FFDHE4096"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE4096</span></code> (macro)</h2> |
| 4496 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_DH_GROUP_FFDHE4096 ((psa_dh_group_t) 0x0102)</span> |
| 4497 | </pre></div> |
| 4498 | </div> |
| 4499 | </div> |
| 4500 | <div class="section" id="PSA_DH_GROUP_FFDHE6144"> |
| 4501 | <span id="c.PSA_DH_GROUP_FFDHE6144"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE6144</span></code> (macro)</h2> |
| 4502 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_DH_GROUP_FFDHE6144 ((psa_dh_group_t) 0x0103)</span> |
| 4503 | </pre></div> |
| 4504 | </div> |
| 4505 | </div> |
| 4506 | <div class="section" id="PSA_DH_GROUP_FFDHE8192"> |
| 4507 | <span id="c.PSA_DH_GROUP_FFDHE8192"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE8192</span></code> (macro)</h2> |
| 4508 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_DH_GROUP_FFDHE8192 ((psa_dh_group_t) 0x0104)</span> |
| 4509 | </pre></div> |
| 4510 | </div> |
| 4511 | </div> |
| 4512 | <div class="section" id="PSA_BLOCK_CIPHER_BLOCK_SIZE"> |
| 4513 | <span id="c.PSA_BLOCK_CIPHER_BLOCK_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_BLOCK_CIPHER_BLOCK_SIZE</span></code> (macro)</h2> |
| 4514 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_BLOCK_CIPHER_BLOCK_SIZE(type) \</span> |
| 4515 | <span class="cp"> ( (type) == PSA_KEY_TYPE_AES ? 16 : (type) == PSA_KEY_TYPE_DES ? 8 : (type) == PSA_KEY_TYPE_CAMELLIA ? 16 : (type) == PSA_KEY_TYPE_ARC4 ? 1 : 0)</span> |
| 4516 | </pre></div> |
| 4517 | </div> |
| 4518 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4519 | <dl class="docutils"> |
| 4520 | <dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt> |
| 4521 | <dd>A cipher key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</dd> |
| 4522 | </dl> |
| 4523 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4524 | <p>The block size for a block cipher, or 1 for a stream cipher. The return value is undefined if <code class="docutils literal notranslate"><span class="pre">type</span></code> is not a supported cipher key type.</p> |
| 4525 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4526 | <p>The block size of a block cipher.</p> |
| 4527 | <div class="admonition note"> |
| 4528 | <p class="first admonition-title">Note</p> |
| 4529 | <p class="last">It is possible to build stream cipher algorithms on top of a block cipher, for example CTR mode (<a class="reference internal" href="#c.PSA_ALG_CTR" title="PSA_ALG_CTR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_CTR</span></code></a>). This macro only takes the key type into account, so it cannot be used to determine the size of the data that <a class="reference internal" href="#c.psa_cipher_update" title="psa_cipher_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_update()</span></code></a> might buffer for future processing in general.</p> |
| 4530 | </div> |
| 4531 | <div class="admonition note"> |
| 4532 | <p class="first admonition-title">Note</p> |
| 4533 | <p class="last">This macro returns a compile-time constant if its argument is one.</p> |
| 4534 | </div> |
| 4535 | <div class="admonition warning"> |
| 4536 | <p class="first admonition-title">Warning</p> |
| 4537 | <p class="last">This macro may evaluate its argument multiple times.</p> |
| 4538 | </div> |
| 4539 | </div> |
| 4540 | <div class="section" id="PSA_ALG_VENDOR_FLAG"> |
| 4541 | <span id="c.PSA_ALG_VENDOR_FLAG"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_VENDOR_FLAG</span></code> (macro)</h2> |
| 4542 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_VENDOR_FLAG ((psa_algorithm_t)0x80000000)</span> |
| 4543 | </pre></div> |
| 4544 | </div> |
| 4545 | </div> |
| 4546 | <div class="section" id="PSA_ALG_CATEGORY_MASK"> |
| 4547 | <span id="c.PSA_ALG_CATEGORY_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_MASK</span></code> (macro)</h2> |
| 4548 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_MASK ((psa_algorithm_t)0x7f000000)</span> |
| 4549 | </pre></div> |
| 4550 | </div> |
| 4551 | </div> |
| 4552 | <div class="section" id="PSA_ALG_CATEGORY_HASH"> |
| 4553 | <span id="c.PSA_ALG_CATEGORY_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_HASH</span></code> (macro)</h2> |
| 4554 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_HASH ((psa_algorithm_t)0x01000000)</span> |
| 4555 | </pre></div> |
| 4556 | </div> |
| 4557 | </div> |
| 4558 | <div class="section" id="PSA_ALG_CATEGORY_MAC"> |
| 4559 | <span id="c.PSA_ALG_CATEGORY_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_MAC</span></code> (macro)</h2> |
| 4560 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_MAC ((psa_algorithm_t)0x02000000)</span> |
| 4561 | </pre></div> |
| 4562 | </div> |
| 4563 | </div> |
| 4564 | <div class="section" id="PSA_ALG_CATEGORY_CIPHER"> |
| 4565 | <span id="c.PSA_ALG_CATEGORY_CIPHER"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_CIPHER</span></code> (macro)</h2> |
| 4566 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_CIPHER ((psa_algorithm_t)0x04000000)</span> |
| 4567 | </pre></div> |
| 4568 | </div> |
| 4569 | </div> |
| 4570 | <div class="section" id="PSA_ALG_CATEGORY_AEAD"> |
| 4571 | <span id="c.PSA_ALG_CATEGORY_AEAD"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_AEAD</span></code> (macro)</h2> |
| 4572 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_AEAD ((psa_algorithm_t)0x06000000)</span> |
| 4573 | </pre></div> |
| 4574 | </div> |
| 4575 | </div> |
| 4576 | <div class="section" id="PSA_ALG_CATEGORY_SIGN"> |
| 4577 | <span id="c.PSA_ALG_CATEGORY_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_SIGN</span></code> (macro)</h2> |
| 4578 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_SIGN ((psa_algorithm_t)0x10000000)</span> |
| 4579 | </pre></div> |
| 4580 | </div> |
| 4581 | </div> |
| 4582 | <div class="section" id="PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION"> |
| 4583 | <span id="c.PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION</span></code> (macro)</h2> |
| 4584 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION ((psa_algorithm_t)0x12000000)</span> |
| 4585 | </pre></div> |
| 4586 | </div> |
| 4587 | </div> |
| 4588 | <div class="section" id="PSA_ALG_CATEGORY_KEY_DERIVATION"> |
| 4589 | <span id="c.PSA_ALG_CATEGORY_KEY_DERIVATION"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_KEY_DERIVATION</span></code> (macro)</h2> |
| 4590 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_KEY_DERIVATION ((psa_algorithm_t)0x20000000)</span> |
| 4591 | </pre></div> |
| 4592 | </div> |
| 4593 | </div> |
| 4594 | <div class="section" id="PSA_ALG_CATEGORY_KEY_AGREEMENT"> |
| 4595 | <span id="c.PSA_ALG_CATEGORY_KEY_AGREEMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_KEY_AGREEMENT</span></code> (macro)</h2> |
| 4596 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_KEY_AGREEMENT ((psa_algorithm_t)0x30000000)</span> |
| 4597 | </pre></div> |
| 4598 | </div> |
| 4599 | </div> |
| 4600 | <div class="section" id="PSA_ALG_IS_VENDOR_DEFINED"> |
| 4601 | <span id="c.PSA_ALG_IS_VENDOR_DEFINED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_VENDOR_DEFINED</span></code> (macro)</h2> |
| 4602 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_VENDOR_DEFINED(alg) (((alg) & PSA_ALG_VENDOR_FLAG) != 0)</span> |
| 4603 | </pre></div> |
| 4604 | </div> |
| 4605 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4606 | <dl class="docutils"> |
| 4607 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 4608 | <dd></dd> |
| 4609 | </dl> |
| 4610 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4611 | </div> |
| 4612 | <div class="section" id="PSA_ALG_IS_HASH"> |
| 4613 | <span id="c.PSA_ALG_IS_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code> (macro)</h2> |
| 4614 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_HASH(alg) \</span> |
| 4615 | <span class="cp"> (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_HASH)</span> |
| 4616 | </pre></div> |
| 4617 | </div> |
| 4618 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4619 | <dl class="docutils"> |
| 4620 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 4621 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 4622 | </dl> |
| 4623 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4624 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a hash algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 4625 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4626 | <p>Whether the specified algorithm is a hash algorithm.</p> |
| 4627 | </div> |
| 4628 | <div class="section" id="PSA_ALG_IS_MAC"> |
| 4629 | <span id="c.PSA_ALG_IS_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code> (macro)</h2> |
| 4630 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_MAC(alg) \</span> |
| 4631 | <span class="cp"> (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_MAC)</span> |
| 4632 | </pre></div> |
| 4633 | </div> |
| 4634 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4635 | <dl class="docutils"> |
| 4636 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 4637 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 4638 | </dl> |
| 4639 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4640 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a MAC algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 4641 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4642 | <p>Whether the specified algorithm is a MAC algorithm.</p> |
| 4643 | </div> |
| 4644 | <div class="section" id="PSA_ALG_IS_CIPHER"> |
| 4645 | <span id="c.PSA_ALG_IS_CIPHER"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code> (macro)</h2> |
| 4646 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_CIPHER(alg) \</span> |
| 4647 | <span class="cp"> (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_CIPHER)</span> |
| 4648 | </pre></div> |
| 4649 | </div> |
| 4650 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4651 | <dl class="docutils"> |
| 4652 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 4653 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 4654 | </dl> |
| 4655 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4656 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a symmetric cipher algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 4657 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4658 | <p>Whether the specified algorithm is a symmetric cipher algorithm.</p> |
| 4659 | </div> |
| 4660 | <div class="section" id="PSA_ALG_IS_AEAD"> |
| 4661 | <span id="c.PSA_ALG_IS_AEAD"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code> (macro)</h2> |
| 4662 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_AEAD(alg) \</span> |
| 4663 | <span class="cp"> (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_AEAD)</span> |
| 4664 | </pre></div> |
| 4665 | </div> |
| 4666 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4667 | <dl class="docutils"> |
| 4668 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 4669 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 4670 | </dl> |
| 4671 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4672 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is an AEAD algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 4673 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4674 | <p>Whether the specified algorithm is an authenticated encryption with associated data (AEAD) algorithm.</p> |
| 4675 | </div> |
| 4676 | <div class="section" id="PSA_ALG_IS_SIGN"> |
| 4677 | <span id="c.PSA_ALG_IS_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_SIGN</span></code> (macro)</h2> |
| 4678 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_SIGN(alg) \</span> |
| 4679 | <span class="cp"> (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_SIGN)</span> |
| 4680 | </pre></div> |
| 4681 | </div> |
| 4682 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4683 | <dl class="docutils"> |
| 4684 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 4685 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 4686 | </dl> |
| 4687 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4688 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a public-key signature algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 4689 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4690 | <p>Whether the specified algorithm is a public-key signature algorithm.</p> |
| 4691 | </div> |
| 4692 | <div class="section" id="PSA_ALG_IS_ASYMMETRIC_ENCRYPTION"> |
| 4693 | <span id="c.PSA_ALG_IS_ASYMMETRIC_ENCRYPTION"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ASYMMETRIC_ENCRYPTION</span></code> (macro)</h2> |
| 4694 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_ASYMMETRIC_ENCRYPTION(alg) \</span> |
| 4695 | <span class="cp"> (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION)</span> |
| 4696 | </pre></div> |
| 4697 | </div> |
| 4698 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4699 | <dl class="docutils"> |
| 4700 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 4701 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 4702 | </dl> |
| 4703 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4704 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a public-key encryption algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 4705 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4706 | <p>Whether the specified algorithm is a public-key encryption algorithm.</p> |
| 4707 | </div> |
| 4708 | <div class="section" id="PSA_ALG_IS_KEY_AGREEMENT"> |
| 4709 | <span id="c.PSA_ALG_IS_KEY_AGREEMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_AGREEMENT</span></code> (macro)</h2> |
| 4710 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_KEY_AGREEMENT(alg) \</span> |
| 4711 | <span class="cp"> (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_AGREEMENT)</span> |
| 4712 | </pre></div> |
| 4713 | </div> |
| 4714 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4715 | <dl class="docutils"> |
| 4716 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 4717 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 4718 | </dl> |
| 4719 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4720 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a key agreement algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 4721 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4722 | <p>Whether the specified algorithm is a key agreement algorithm.</p> |
| 4723 | </div> |
| 4724 | <div class="section" id="PSA_ALG_IS_KEY_DERIVATION"> |
| 4725 | <span id="c.PSA_ALG_IS_KEY_DERIVATION"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION</span></code> (macro)</h2> |
| 4726 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_KEY_DERIVATION(alg) \</span> |
| 4727 | <span class="cp"> (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_DERIVATION)</span> |
| 4728 | </pre></div> |
| 4729 | </div> |
| 4730 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4731 | <dl class="docutils"> |
| 4732 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 4733 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 4734 | </dl> |
| 4735 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4736 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a key derivation algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 4737 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4738 | <p>Whether the specified algorithm is a key derivation algorithm.</p> |
| 4739 | </div> |
| 4740 | <div class="section" id="PSA_ALG_HASH_MASK"> |
| 4741 | <span id="c.PSA_ALG_HASH_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HASH_MASK</span></code> (macro)</h2> |
| 4742 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HASH_MASK ((psa_algorithm_t)0x000000ff)</span> |
| 4743 | </pre></div> |
| 4744 | </div> |
| 4745 | </div> |
| 4746 | <div class="section" id="PSA_ALG_MD2"> |
| 4747 | <span id="c.PSA_ALG_MD2"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD2</span></code> (macro)</h2> |
| 4748 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_MD2 ((psa_algorithm_t)0x01000001)</span> |
| 4749 | </pre></div> |
| 4750 | </div> |
| 4751 | </div> |
| 4752 | <div class="section" id="PSA_ALG_MD4"> |
| 4753 | <span id="c.PSA_ALG_MD4"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD4</span></code> (macro)</h2> |
| 4754 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_MD4 ((psa_algorithm_t)0x01000002)</span> |
| 4755 | </pre></div> |
| 4756 | </div> |
| 4757 | </div> |
| 4758 | <div class="section" id="PSA_ALG_MD5"> |
| 4759 | <span id="c.PSA_ALG_MD5"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD5</span></code> (macro)</h2> |
| 4760 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_MD5 ((psa_algorithm_t)0x01000003)</span> |
| 4761 | </pre></div> |
| 4762 | </div> |
| 4763 | </div> |
| 4764 | <div class="section" id="PSA_ALG_RIPEMD160"> |
| 4765 | <span id="c.PSA_ALG_RIPEMD160"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RIPEMD160</span></code> (macro)</h2> |
| 4766 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RIPEMD160 ((psa_algorithm_t)0x01000004)</span> |
| 4767 | </pre></div> |
| 4768 | </div> |
| 4769 | </div> |
| 4770 | <div class="section" id="PSA_ALG_SHA_1"> |
| 4771 | <span id="c.PSA_ALG_SHA_1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_1</span></code> (macro)</h2> |
| 4772 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_1 ((psa_algorithm_t)0x01000005)</span> |
| 4773 | </pre></div> |
| 4774 | </div> |
| 4775 | </div> |
| 4776 | <div class="section" id="PSA_ALG_SHA_224"> |
| 4777 | <span id="c.PSA_ALG_SHA_224"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_224</span></code> (macro)</h2> |
| 4778 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_224 ((psa_algorithm_t)0x01000008)</span> |
| 4779 | </pre></div> |
| 4780 | </div> |
| 4781 | <p>SHA2-224.</p> |
| 4782 | </div> |
| 4783 | <div class="section" id="PSA_ALG_SHA_256"> |
| 4784 | <span id="c.PSA_ALG_SHA_256"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_256</span></code> (macro)</h2> |
| 4785 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_256 ((psa_algorithm_t)0x01000009)</span> |
| 4786 | </pre></div> |
| 4787 | </div> |
| 4788 | <p>SHA2-256.</p> |
| 4789 | </div> |
| 4790 | <div class="section" id="PSA_ALG_SHA_384"> |
| 4791 | <span id="c.PSA_ALG_SHA_384"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_384</span></code> (macro)</h2> |
| 4792 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_384 ((psa_algorithm_t)0x0100000a)</span> |
| 4793 | </pre></div> |
| 4794 | </div> |
| 4795 | <p>SHA2-384.</p> |
| 4796 | </div> |
| 4797 | <div class="section" id="PSA_ALG_SHA_512"> |
| 4798 | <span id="c.PSA_ALG_SHA_512"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512</span></code> (macro)</h2> |
| 4799 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_512 ((psa_algorithm_t)0x0100000b)</span> |
| 4800 | </pre></div> |
| 4801 | </div> |
| 4802 | <p>SHA2-512.</p> |
| 4803 | </div> |
| 4804 | <div class="section" id="PSA_ALG_SHA_512_224"> |
| 4805 | <span id="c.PSA_ALG_SHA_512_224"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512_224</span></code> (macro)</h2> |
| 4806 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_512_224 ((psa_algorithm_t)0x0100000c)</span> |
| 4807 | </pre></div> |
| 4808 | </div> |
| 4809 | <p>SHA2-512/224.</p> |
| 4810 | </div> |
| 4811 | <div class="section" id="PSA_ALG_SHA_512_256"> |
| 4812 | <span id="c.PSA_ALG_SHA_512_256"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512_256</span></code> (macro)</h2> |
| 4813 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_512_256 ((psa_algorithm_t)0x0100000d)</span> |
| 4814 | </pre></div> |
| 4815 | </div> |
| 4816 | <p>SHA2-512/256.</p> |
| 4817 | </div> |
| 4818 | <div class="section" id="PSA_ALG_SHA3_224"> |
| 4819 | <span id="c.PSA_ALG_SHA3_224"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_224</span></code> (macro)</h2> |
| 4820 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA3_224 ((psa_algorithm_t)0x01000010)</span> |
| 4821 | </pre></div> |
| 4822 | </div> |
| 4823 | <p>SHA3-224.</p> |
| 4824 | </div> |
| 4825 | <div class="section" id="PSA_ALG_SHA3_256"> |
| 4826 | <span id="c.PSA_ALG_SHA3_256"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_256</span></code> (macro)</h2> |
| 4827 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA3_256 ((psa_algorithm_t)0x01000011)</span> |
| 4828 | </pre></div> |
| 4829 | </div> |
| 4830 | <p>SHA3-256.</p> |
| 4831 | </div> |
| 4832 | <div class="section" id="PSA_ALG_SHA3_384"> |
| 4833 | <span id="c.PSA_ALG_SHA3_384"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_384</span></code> (macro)</h2> |
| 4834 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA3_384 ((psa_algorithm_t)0x01000012)</span> |
| 4835 | </pre></div> |
| 4836 | </div> |
| 4837 | <p>SHA3-384.</p> |
| 4838 | </div> |
| 4839 | <div class="section" id="PSA_ALG_SHA3_512"> |
| 4840 | <span id="c.PSA_ALG_SHA3_512"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_512</span></code> (macro)</h2> |
| 4841 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA3_512 ((psa_algorithm_t)0x01000013)</span> |
| 4842 | </pre></div> |
| 4843 | </div> |
| 4844 | <p>SHA3-512.</p> |
| 4845 | </div> |
| 4846 | <div class="section" id="PSA_ALG_ANY_HASH"> |
| 4847 | <span id="c.PSA_ALG_ANY_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code> (macro)</h2> |
| 4848 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ANY_HASH ((psa_algorithm_t)0x010000ff)</span> |
| 4849 | </pre></div> |
| 4850 | </div> |
| 4851 | <p>In a hash-and-sign algorithm policy, allow any hash algorithm.</p> |
| 4852 | <p>This value may be used to form the algorithm usage field of a policy for a signature algorithm that is parametrized by a hash. The key may then be used to perform operations using the same signature algorithm parametrized with any supported hash.</p> |
| 4853 | <p>That is, suppose that <code class="docutils literal notranslate"><span class="pre">PSA_xxx_SIGNATURE</span></code> is one of the following macros:</p> |
| 4854 | <ul> |
| 4855 | <li><p class="first"><a class="reference internal" href="#c.PSA_ALG_RSA_PKCS1V15_SIGN" title="PSA_ALG_RSA_PKCS1V15_SIGN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN</span></code></a>, <a class="reference internal" href="#c.PSA_ALG_RSA_PSS" title="PSA_ALG_RSA_PSS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PSS</span></code></a>,</p> |
| 4856 | </li> |
| 4857 | <li><p class="first"><a class="reference internal" href="#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA</span></code></a>, <a class="reference internal" href="#c.PSA_ALG_DETERMINISTIC_ECDSA" title="PSA_ALG_DETERMINISTIC_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA</span></code></a>. Then you may create and use a key as follows:</p> |
| 4858 | </li> |
| 4859 | <li><p class="first">Set the key usage field using <a class="reference internal" href="#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code></a>, for example:</p> |
| 4860 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_set_key_usage_flags</span><span class="p">(</span><span class="o">&</span><span class="n">attributes</span><span class="p">,</span> <span class="n">PSA_KEY_USAGE_SIGN</span><span class="p">);</span> <span class="c1">// or VERIFY</span> |
| 4861 | <span class="n">psa_set_key_algorithm</span><span class="p">(</span><span class="o">&</span><span class="n">attributes</span><span class="p">,</span> <span class="n">PSA_xxx_SIGNATURE</span><span class="p">(</span><span class="n">PSA_ALG_ANY_HASH</span><span class="p">));</span> |
| 4862 | </pre></div> |
| 4863 | </div> |
| 4864 | </li> |
| 4865 | <li><p class="first">Import or generate key material.</p> |
| 4866 | </li> |
| 4867 | <li><p class="first">Call <a class="reference internal" href="#c.psa_asymmetric_sign" title="psa_asymmetric_sign"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_sign()</span></code></a> or <a class="reference internal" href="#c.psa_asymmetric_verify" title="psa_asymmetric_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_verify()</span></code></a>, passing an algorithm built from <code class="docutils literal notranslate"><span class="pre">PSA_xxx_SIGNATURE</span></code> and a specific hash. Each call to sign or verify a message may use a different hash.</p> |
| 4868 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_asymmetric_sign</span><span class="p">(</span><span class="n">handle</span><span class="p">,</span> <span class="n">PSA_xxx_SIGNATURE</span><span class="p">(</span><span class="n">PSA_ALG_SHA_256</span><span class="p">),</span> <span class="p">...);</span> |
| 4869 | <span class="n">psa_asymmetric_sign</span><span class="p">(</span><span class="n">handle</span><span class="p">,</span> <span class="n">PSA_xxx_SIGNATURE</span><span class="p">(</span><span class="n">PSA_ALG_SHA_512</span><span class="p">),</span> <span class="p">...);</span> |
| 4870 | <span class="n">psa_asymmetric_sign</span><span class="p">(</span><span class="n">handle</span><span class="p">,</span> <span class="n">PSA_xxx_SIGNATURE</span><span class="p">(</span><span class="n">PSA_ALG_SHA3_256</span><span class="p">),</span> <span class="p">...);</span> |
| 4871 | </pre></div> |
| 4872 | </div> |
| 4873 | </li> |
| 4874 | </ul> |
| 4875 | <p>This value may not be used to build other algorithms that are parametrized over a hash. For any valid use of this macro to build an algorithm <code class="docutils literal notranslate"><span class="pre">alg</span></code>, <a class="reference internal" href="#c.PSA_ALG_IS_HASH_AND_SIGN" title="PSA_ALG_IS_HASH_AND_SIGN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH_AND_SIGN</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true.</p> |
| 4876 | <p>This value may not be used to build an algorithm specification to perform an operation. It is only valid to build policies.</p> |
| 4877 | </div> |
| 4878 | <div class="section" id="PSA_ALG_MAC_SUBCATEGORY_MASK"> |
| 4879 | <span id="c.PSA_ALG_MAC_SUBCATEGORY_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MAC_SUBCATEGORY_MASK</span></code> (macro)</h2> |
| 4880 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_MAC_SUBCATEGORY_MASK ((psa_algorithm_t)0x00c00000)</span> |
| 4881 | </pre></div> |
| 4882 | </div> |
| 4883 | </div> |
| 4884 | <div class="section" id="PSA_ALG_HMAC_BASE"> |
| 4885 | <span id="c.PSA_ALG_HMAC_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC_BASE</span></code> (macro)</h2> |
| 4886 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HMAC_BASE ((psa_algorithm_t)0x02800000)</span> |
| 4887 | </pre></div> |
| 4888 | </div> |
| 4889 | </div> |
| 4890 | <div class="section" id="PSA_ALG_HMAC"> |
| 4891 | <span id="c.PSA_ALG_HMAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC</span></code> (macro)</h2> |
| 4892 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HMAC(hash_alg) \</span> |
| 4893 | <span class="cp"> (PSA_ALG_HMAC_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))</span> |
| 4894 | </pre></div> |
| 4895 | </div> |
| 4896 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4897 | <dl class="docutils"> |
| 4898 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt> |
| 4899 | <dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true).</dd> |
| 4900 | </dl> |
| 4901 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4902 | <p>The corresponding HMAC algorithm.</p> |
| 4903 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p> |
| 4904 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4905 | <p>Macro to build an HMAC algorithm.</p> |
| 4906 | <p>For example, <a class="reference internal" href="#c.PSA_ALG_HMAC" title="PSA_ALG_HMAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_HMAC</span></code></a>(<a class="reference internal" href="#c.PSA_ALG_SHA_256" title="PSA_ALG_SHA_256"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_SHA_256</span></code></a>) is HMAC-SHA-256.</p> |
| 4907 | </div> |
| 4908 | <div class="section" id="PSA_ALG_HMAC_GET_HASH"> |
| 4909 | <span id="c.PSA_ALG_HMAC_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC_GET_HASH</span></code> (macro)</h2> |
| 4910 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HMAC_GET_HASH(hmac_alg) \</span> |
| 4911 | <span class="cp"> (PSA_ALG_CATEGORY_HASH | ((hmac_alg) & PSA_ALG_HASH_MASK))</span> |
| 4912 | </pre></div> |
| 4913 | </div> |
| 4914 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4915 | <dl class="docutils"> |
| 4916 | <dt> <code class="docutils literal notranslate"><span class="pre">hmac_alg</span></code></dt> |
| 4917 | <dd></dd> |
| 4918 | </dl> |
| 4919 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4920 | </div> |
| 4921 | <div class="section" id="PSA_ALG_IS_HMAC"> |
| 4922 | <span id="c.PSA_ALG_IS_HMAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HMAC</span></code> (macro)</h2> |
| 4923 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_HMAC(alg) \</span> |
| 4924 | <span class="cp"> (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_MAC_SUBCATEGORY_MASK)) == PSA_ALG_HMAC_BASE)</span> |
| 4925 | </pre></div> |
| 4926 | </div> |
| 4927 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4928 | <dl class="docutils"> |
| 4929 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 4930 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 4931 | </dl> |
| 4932 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4933 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is an HMAC algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 4934 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4935 | <p>Whether the specified algorithm is an HMAC algorithm.</p> |
| 4936 | <p>HMAC is a family of MAC algorithms that are based on a hash function.</p> |
| 4937 | </div> |
| 4938 | <div class="section" id="PSA_ALG_MAC_TRUNCATION_MASK"> |
| 4939 | <span id="c.PSA_ALG_MAC_TRUNCATION_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MAC_TRUNCATION_MASK</span></code> (macro)</h2> |
| 4940 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_MAC_TRUNCATION_MASK ((psa_algorithm_t)0x00003f00)</span> |
| 4941 | </pre></div> |
| 4942 | </div> |
| 4943 | </div> |
| 4944 | <div class="section" id="PSA_MAC_TRUNCATION_OFFSET"> |
| 4945 | <span id="c.PSA_MAC_TRUNCATION_OFFSET"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAC_TRUNCATION_OFFSET</span></code> (macro)</h2> |
| 4946 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAC_TRUNCATION_OFFSET 8</span> |
| 4947 | </pre></div> |
| 4948 | </div> |
| 4949 | </div> |
| 4950 | <div class="section" id="PSA_ALG_TRUNCATED_MAC"> |
| 4951 | <span id="c.PSA_ALG_TRUNCATED_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TRUNCATED_MAC</span></code> (macro)</h2> |
| 4952 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TRUNCATED_MAC(mac_alg, mac_length) \</span> |
| 4953 | <span class="cp"> (((mac_alg) & ~PSA_ALG_MAC_TRUNCATION_MASK) | ((mac_length) << PSA_MAC_TRUNCATION_OFFSET & PSA_ALG_MAC_TRUNCATION_MASK))</span> |
| 4954 | </pre></div> |
| 4955 | </div> |
| 4956 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4957 | <dl class="docutils"> |
| 4958 | <dt> <code class="docutils literal notranslate"><span class="pre">mac_alg</span></code></dt> |
| 4959 | <dd>A MAC algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true). This may be a truncated or untruncated MAC algorithm.</dd> |
| 4960 | <dt> <code class="docutils literal notranslate"><span class="pre">mac_length</span></code></dt> |
| 4961 | <dd>Desired length of the truncated MAC in bytes. This must be at most the full length of the MAC and must be at least an implementation-specified minimum. The implementation-specified minimum shall not be zero.</dd> |
| 4962 | </dl> |
| 4963 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4964 | <p>The corresponding MAC algorithm with the specified length.</p> |
| 4965 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported MAC algorithm or if <code class="docutils literal notranslate"><span class="pre">mac_length</span></code> is too small or too large for the specified MAC algorithm.</p> |
| 4966 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4967 | <p>Macro to build a truncated MAC algorithm.</p> |
| 4968 | <p>A truncated MAC algorithm is identical to the corresponding MAC algorithm except that the MAC value for the truncated algorithm consists of only the first <code class="docutils literal notranslate"><span class="pre">mac_length</span></code> bytes of the MAC value for the untruncated algorithm.</p> |
| 4969 | <div class="admonition note"> |
| 4970 | <p class="first admonition-title">Note</p> |
| 4971 | <p class="last">This macro may allow constructing algorithm identifiers that are not valid, either because the specified length is larger than the untruncated MAC or because the specified length is smaller than permitted by the implementation.</p> |
| 4972 | </div> |
| 4973 | <div class="admonition note"> |
| 4974 | <p class="first admonition-title">Note</p> |
| 4975 | <p class="last">It is implementation-defined whether a truncated MAC that is truncated to the same length as the MAC of the untruncated algorithm is considered identical to the untruncated algorithm for policy comparison purposes.</p> |
| 4976 | </div> |
| 4977 | </div> |
| 4978 | <div class="section" id="PSA_ALG_FULL_LENGTH_MAC"> |
| 4979 | <span id="c.PSA_ALG_FULL_LENGTH_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_FULL_LENGTH_MAC</span></code> (macro)</h2> |
| 4980 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_FULL_LENGTH_MAC(mac_alg) \</span> |
| 4981 | <span class="cp"> ((mac_alg) & ~PSA_ALG_MAC_TRUNCATION_MASK)</span> |
| 4982 | </pre></div> |
| 4983 | </div> |
| 4984 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 4985 | <dl class="docutils"> |
| 4986 | <dt> <code class="docutils literal notranslate"><span class="pre">mac_alg</span></code></dt> |
| 4987 | <dd>A MAC algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true). This may be a truncated or untruncated MAC algorithm.</dd> |
| 4988 | </dl> |
| 4989 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 4990 | <p>The corresponding base MAC algorithm.</p> |
| 4991 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported MAC algorithm.</p> |
| 4992 | <p class="subitem-title"><strong>Description:</strong></p> |
| 4993 | <p>Macro to build the base MAC algorithm corresponding to a truncated MAC algorithm.</p> |
| 4994 | </div> |
| 4995 | <div class="section" id="PSA_MAC_TRUNCATED_LENGTH"> |
| 4996 | <span id="c.PSA_MAC_TRUNCATED_LENGTH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAC_TRUNCATED_LENGTH</span></code> (macro)</h2> |
| 4997 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAC_TRUNCATED_LENGTH(mac_alg) \</span> |
| 4998 | <span class="cp"> (((mac_alg) & PSA_ALG_MAC_TRUNCATION_MASK) >> PSA_MAC_TRUNCATION_OFFSET)</span> |
| 4999 | </pre></div> |
| 5000 | </div> |
| 5001 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5002 | <dl class="docutils"> |
| 5003 | <dt> <code class="docutils literal notranslate"><span class="pre">mac_alg</span></code></dt> |
| 5004 | <dd>A MAC algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 5005 | </dl> |
| 5006 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5007 | <p>Length of the truncated MAC in bytes.</p> |
| 5008 | <p>0 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a non-truncated MAC algorithm.</p> |
| 5009 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported MAC algorithm.</p> |
| 5010 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5011 | <p>Length to which a MAC algorithm is truncated.</p> |
| 5012 | </div> |
| 5013 | <div class="section" id="PSA_ALG_CIPHER_MAC_BASE"> |
| 5014 | <span id="c.PSA_ALG_CIPHER_MAC_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_MAC_BASE</span></code> (macro)</h2> |
| 5015 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CIPHER_MAC_BASE ((psa_algorithm_t)0x02c00000)</span> |
| 5016 | </pre></div> |
| 5017 | </div> |
| 5018 | </div> |
| 5019 | <div class="section" id="PSA_ALG_CBC_MAC"> |
| 5020 | <span id="c.PSA_ALG_CBC_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_MAC</span></code> (macro)</h2> |
| 5021 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CBC_MAC ((psa_algorithm_t)0x02c00001)</span> |
| 5022 | </pre></div> |
| 5023 | </div> |
| 5024 | </div> |
| 5025 | <div class="section" id="PSA_ALG_CMAC"> |
| 5026 | <span id="c.PSA_ALG_CMAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CMAC</span></code> (macro)</h2> |
| 5027 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CMAC ((psa_algorithm_t)0x02c00002)</span> |
| 5028 | </pre></div> |
| 5029 | </div> |
| 5030 | </div> |
| 5031 | <div class="section" id="PSA_ALG_GMAC"> |
| 5032 | <span id="c.PSA_ALG_GMAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_GMAC</span></code> (macro)</h2> |
| 5033 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_GMAC ((psa_algorithm_t)0x02c00003)</span> |
| 5034 | </pre></div> |
| 5035 | </div> |
| 5036 | </div> |
| 5037 | <div class="section" id="PSA_ALG_IS_BLOCK_CIPHER_MAC"> |
| 5038 | <span id="c.PSA_ALG_IS_BLOCK_CIPHER_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_BLOCK_CIPHER_MAC</span></code> (macro)</h2> |
| 5039 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) \</span> |
| 5040 | <span class="cp"> (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_MAC_SUBCATEGORY_MASK)) == PSA_ALG_CIPHER_MAC_BASE)</span> |
| 5041 | </pre></div> |
| 5042 | </div> |
| 5043 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5044 | <dl class="docutils"> |
| 5045 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5046 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5047 | </dl> |
| 5048 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5049 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a MAC algorithm based on a block cipher, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 5050 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5051 | <p>Whether the specified algorithm is a MAC algorithm based on a block cipher.</p> |
| 5052 | </div> |
| 5053 | <div class="section" id="PSA_ALG_CIPHER_STREAM_FLAG"> |
| 5054 | <span id="c.PSA_ALG_CIPHER_STREAM_FLAG"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_STREAM_FLAG</span></code> (macro)</h2> |
| 5055 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CIPHER_STREAM_FLAG ((psa_algorithm_t)0x00800000)</span> |
| 5056 | </pre></div> |
| 5057 | </div> |
| 5058 | </div> |
| 5059 | <div class="section" id="PSA_ALG_CIPHER_FROM_BLOCK_FLAG"> |
| 5060 | <span id="c.PSA_ALG_CIPHER_FROM_BLOCK_FLAG"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_FROM_BLOCK_FLAG</span></code> (macro)</h2> |
| 5061 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CIPHER_FROM_BLOCK_FLAG ((psa_algorithm_t)0x00400000)</span> |
| 5062 | </pre></div> |
| 5063 | </div> |
| 5064 | </div> |
| 5065 | <div class="section" id="PSA_ALG_IS_STREAM_CIPHER"> |
| 5066 | <span id="c.PSA_ALG_IS_STREAM_CIPHER"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_STREAM_CIPHER</span></code> (macro)</h2> |
| 5067 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_STREAM_CIPHER(alg) \</span> |
| 5068 | <span class="cp"> (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_CIPHER_STREAM_FLAG)) == (PSA_ALG_CATEGORY_CIPHER | PSA_ALG_CIPHER_STREAM_FLAG))</span> |
| 5069 | </pre></div> |
| 5070 | </div> |
| 5071 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5072 | <dl class="docutils"> |
| 5073 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5074 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5075 | </dl> |
| 5076 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5077 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a stream cipher algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier or if it is not a symmetric cipher algorithm.</p> |
| 5078 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5079 | <p>Whether the specified algorithm is a stream cipher.</p> |
| 5080 | <p>A stream cipher is a symmetric cipher that encrypts or decrypts messages by applying a bitwise-xor with a stream of bytes that is generated from a key.</p> |
| 5081 | </div> |
| 5082 | <div class="section" id="PSA_ALG_ARC4"> |
| 5083 | <span id="c.PSA_ALG_ARC4"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ARC4</span></code> (macro)</h2> |
| 5084 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ARC4 ((psa_algorithm_t)0x04800001)</span> |
| 5085 | </pre></div> |
| 5086 | </div> |
| 5087 | <p>The ARC4 stream cipher algorithm.</p> |
| 5088 | </div> |
| 5089 | <div class="section" id="PSA_ALG_CHACHA20"> |
| 5090 | <span id="c.PSA_ALG_CHACHA20"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CHACHA20</span></code> (macro)</h2> |
| 5091 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CHACHA20 ((psa_algorithm_t)0x04800005)</span> |
| 5092 | </pre></div> |
| 5093 | </div> |
| 5094 | <p>The ChaCha20 stream cipher.</p> |
| 5095 | <p>ChaCha20 is defined in RFC 7539.</p> |
| 5096 | <p>The nonce size for <a class="reference internal" href="#c.psa_cipher_set_iv" title="psa_cipher_set_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_set_iv()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_generate_iv" title="psa_cipher_generate_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_generate_iv()</span></code></a> must be 12.</p> |
| 5097 | <p>The initial block counter is always 0.</p> |
| 5098 | </div> |
| 5099 | <div class="section" id="PSA_ALG_CTR"> |
| 5100 | <span id="c.PSA_ALG_CTR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CTR</span></code> (macro)</h2> |
| 5101 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CTR ((psa_algorithm_t)0x04c00001)</span> |
| 5102 | </pre></div> |
| 5103 | </div> |
| 5104 | <p>The CTR stream cipher mode.</p> |
| 5105 | <p>CTR is a stream cipher which is built from a block cipher. The underlying block cipher is determined by the key type. For example, to use AES-128-CTR, use this algorithm with a key of type <a class="reference internal" href="#c.PSA_KEY_TYPE_AES" title="PSA_KEY_TYPE_AES"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_AES</span></code></a> and a length of 128 bits (16 bytes).</p> |
| 5106 | </div> |
| 5107 | <div class="section" id="PSA_ALG_CFB"> |
| 5108 | <span id="c.PSA_ALG_CFB"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CFB</span></code> (macro)</h2> |
| 5109 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CFB ((psa_algorithm_t)0x04c00002)</span> |
| 5110 | </pre></div> |
| 5111 | </div> |
| 5112 | </div> |
| 5113 | <div class="section" id="PSA_ALG_OFB"> |
| 5114 | <span id="c.PSA_ALG_OFB"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_OFB</span></code> (macro)</h2> |
| 5115 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_OFB ((psa_algorithm_t)0x04c00003)</span> |
| 5116 | </pre></div> |
| 5117 | </div> |
| 5118 | </div> |
| 5119 | <div class="section" id="PSA_ALG_XTS"> |
| 5120 | <span id="c.PSA_ALG_XTS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_XTS</span></code> (macro)</h2> |
| 5121 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_XTS ((psa_algorithm_t)0x044000ff)</span> |
| 5122 | </pre></div> |
| 5123 | </div> |
| 5124 | <p>The XTS cipher mode.</p> |
| 5125 | <p>XTS is a cipher mode which is built from a block cipher. It requires at least one full block of input, but beyond this minimum the input does not need to be a whole number of blocks.</p> |
| 5126 | </div> |
| 5127 | <div class="section" id="PSA_ALG_CBC_NO_PADDING"> |
| 5128 | <span id="c.PSA_ALG_CBC_NO_PADDING"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_NO_PADDING</span></code> (macro)</h2> |
| 5129 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CBC_NO_PADDING ((psa_algorithm_t)0x04600100)</span> |
| 5130 | </pre></div> |
| 5131 | </div> |
| 5132 | <p>The CBC block cipher chaining mode, with no padding.</p> |
| 5133 | <p>The underlying block cipher is determined by the key type.</p> |
| 5134 | <p>This symmetric cipher mode can only be used with messages whose lengths are whole number of blocks for the chosen block cipher.</p> |
| 5135 | </div> |
| 5136 | <div class="section" id="PSA_ALG_CBC_PKCS7"> |
| 5137 | <span id="c.PSA_ALG_CBC_PKCS7"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_PKCS7</span></code> (macro)</h2> |
| 5138 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CBC_PKCS7 ((psa_algorithm_t)0x04600101)</span> |
| 5139 | </pre></div> |
| 5140 | </div> |
| 5141 | <p>The CBC block cipher chaining mode with PKCS#7 padding.</p> |
| 5142 | <p>The underlying block cipher is determined by the key type.</p> |
| 5143 | <p>This is the padding method defined by PKCS#7 (RFC 2315) §10.3.</p> |
| 5144 | </div> |
| 5145 | <div class="section" id="PSA_ALG_AEAD_FROM_BLOCK_FLAG"> |
| 5146 | <span id="c.PSA_ALG_AEAD_FROM_BLOCK_FLAG"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_FROM_BLOCK_FLAG</span></code> (macro)</h2> |
| 5147 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_AEAD_FROM_BLOCK_FLAG ((psa_algorithm_t)0x00400000)</span> |
| 5148 | </pre></div> |
| 5149 | </div> |
| 5150 | </div> |
| 5151 | <div class="section" id="PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER"> |
| 5152 | <span id="c.PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER</span></code> (macro)</h2> |
| 5153 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) \</span> |
| 5154 | <span class="cp"> (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_AEAD_FROM_BLOCK_FLAG)) == (PSA_ALG_CATEGORY_AEAD | PSA_ALG_AEAD_FROM_BLOCK_FLAG))</span> |
| 5155 | </pre></div> |
| 5156 | </div> |
| 5157 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5158 | <dl class="docutils"> |
| 5159 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5160 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5161 | </dl> |
| 5162 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5163 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is an AEAD algorithm which is an AEAD mode based on a block cipher, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 5164 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5165 | <p>Whether the specified algorithm is an AEAD mode on a block cipher.</p> |
| 5166 | </div> |
| 5167 | <div class="section" id="PSA_ALG_CCM"> |
| 5168 | <span id="c.PSA_ALG_CCM"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CCM</span></code> (macro)</h2> |
| 5169 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CCM ((psa_algorithm_t)0x06401001)</span> |
| 5170 | </pre></div> |
| 5171 | </div> |
| 5172 | <p>The CCM authenticated encryption algorithm.</p> |
| 5173 | </div> |
| 5174 | <div class="section" id="PSA_ALG_GCM"> |
| 5175 | <span id="c.PSA_ALG_GCM"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_GCM</span></code> (macro)</h2> |
| 5176 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_GCM ((psa_algorithm_t)0x06401002)</span> |
| 5177 | </pre></div> |
| 5178 | </div> |
| 5179 | <p>The GCM authenticated encryption algorithm.</p> |
| 5180 | </div> |
| 5181 | <div class="section" id="PSA_ALG_CHACHA20_POLY1305"> |
| 5182 | <span id="c.PSA_ALG_CHACHA20_POLY1305"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CHACHA20_POLY1305</span></code> (macro)</h2> |
| 5183 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CHACHA20_POLY1305 ((psa_algorithm_t)0x06001005)</span> |
| 5184 | </pre></div> |
| 5185 | </div> |
| 5186 | <p>The Chacha20-Poly1305 AEAD algorithm.</p> |
| 5187 | <p>The ChaCha20_Poly1305 construction is defined in RFC 7539.</p> |
| 5188 | <p>Implementations must support 12-byte nonces, may support 8-byte nonces, and should reject other sizes.</p> |
| 5189 | <p>Implementations must support 16-byte tags and should reject other sizes.</p> |
| 5190 | </div> |
| 5191 | <div class="section" id="PSA_ALG_AEAD_TAG_LENGTH_MASK"> |
| 5192 | <span id="c.PSA_ALG_AEAD_TAG_LENGTH_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_TAG_LENGTH_MASK</span></code> (macro)</h2> |
| 5193 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_AEAD_TAG_LENGTH_MASK ((psa_algorithm_t)0x00003f00)</span> |
| 5194 | </pre></div> |
| 5195 | </div> |
| 5196 | </div> |
| 5197 | <div class="section" id="PSA_AEAD_TAG_LENGTH_OFFSET"> |
| 5198 | <span id="c.PSA_AEAD_TAG_LENGTH_OFFSET"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH_OFFSET</span></code> (macro)</h2> |
| 5199 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_TAG_LENGTH_OFFSET 8</span> |
| 5200 | </pre></div> |
| 5201 | </div> |
| 5202 | </div> |
| 5203 | <div class="section" id="PSA_ALG_AEAD_WITH_TAG_LENGTH"> |
| 5204 | <span id="c.PSA_ALG_AEAD_WITH_TAG_LENGTH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_WITH_TAG_LENGTH</span></code> (macro)</h2> |
| 5205 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_AEAD_WITH_TAG_LENGTH(aead_alg, tag_length) \</span> |
| 5206 | <span class="cp"> (((aead_alg) & ~PSA_ALG_AEAD_TAG_LENGTH_MASK) | ((tag_length) << PSA_AEAD_TAG_LENGTH_OFFSET & PSA_ALG_AEAD_TAG_LENGTH_MASK))</span> |
| 5207 | </pre></div> |
| 5208 | </div> |
| 5209 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5210 | <dl class="docutils"> |
| 5211 | <dt> <code class="docutils literal notranslate"><span class="pre">aead_alg</span></code></dt> |
| 5212 | <dd>An AEAD algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 5213 | <dt> <code class="docutils literal notranslate"><span class="pre">tag_length</span></code></dt> |
| 5214 | <dd>Desired length of the authentication tag in bytes.</dd> |
| 5215 | </dl> |
| 5216 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5217 | <p>The corresponding AEAD algorithm with the specified length.</p> |
| 5218 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported AEAD algorithm or if <code class="docutils literal notranslate"><span class="pre">tag_length</span></code> is not valid for the specified AEAD algorithm.</p> |
| 5219 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5220 | <p>Macro to build a shortened AEAD algorithm.</p> |
| 5221 | <p>A shortened AEAD algorithm is similar to the corresponding AEAD algorithm, but has an authentication tag that consists of fewer bytes. Depending on the algorithm, the tag length may affect the calculation of the ciphertext.</p> |
| 5222 | </div> |
| 5223 | <div class="section" id="PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH"> |
| 5224 | <span id="c.PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH</span></code> (macro)</h2> |
| 5225 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(aead_alg) \</span> |
| 5226 | <span class="cp"> ( PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, PSA_ALG_CCM) PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, PSA_ALG_GCM) PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, PSA_ALG_CHACHA20_POLY1305) 0)</span> |
| 5227 | </pre></div> |
| 5228 | </div> |
| 5229 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5230 | <dl class="docutils"> |
| 5231 | <dt> <code class="docutils literal notranslate"><span class="pre">aead_alg</span></code></dt> |
| 5232 | <dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 5233 | </dl> |
| 5234 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5235 | <p>The corresponding AEAD algorithm with the default tag length for that algorithm.</p> |
| 5236 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5237 | <p>Calculate the corresponding AEAD algorithm with the default tag length.</p> |
| 5238 | </div> |
| 5239 | <div class="section" id="PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE"> |
| 5240 | <span id="c.PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE</span></code> (macro)</h2> |
| 5241 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, ref) \</span> |
| 5242 | <span class="cp"> PSA_ALG_AEAD_WITH_TAG_LENGTH(aead_alg, 0) == PSA_ALG_AEAD_WITH_TAG_LENGTH(ref, 0) ? ref :</span> |
| 5243 | </pre></div> |
| 5244 | </div> |
| 5245 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5246 | <dl class="docutils"> |
| 5247 | <dt> <code class="docutils literal notranslate"><span class="pre">aead_alg</span></code></dt> |
| 5248 | <dd></dd> |
| 5249 | <dt> <code class="docutils literal notranslate"><span class="pre">ref</span></code></dt> |
| 5250 | <dd></dd> |
| 5251 | </dl> |
| 5252 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5253 | </div> |
| 5254 | <div class="section" id="PSA_ALG_RSA_PKCS1V15_SIGN_BASE"> |
| 5255 | <span id="c.PSA_ALG_RSA_PKCS1V15_SIGN_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN_BASE</span></code> (macro)</h2> |
| 5256 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PKCS1V15_SIGN_BASE ((psa_algorithm_t)0x10020000)</span> |
| 5257 | </pre></div> |
| 5258 | </div> |
| 5259 | </div> |
| 5260 | <div class="section" id="PSA_ALG_RSA_PKCS1V15_SIGN"> |
| 5261 | <span id="c.PSA_ALG_RSA_PKCS1V15_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN</span></code> (macro)</h2> |
| 5262 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PKCS1V15_SIGN(hash_alg) \</span> |
| 5263 | <span class="cp"> (PSA_ALG_RSA_PKCS1V15_SIGN_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))</span> |
| 5264 | </pre></div> |
| 5265 | </div> |
| 5266 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5267 | <dl class="docutils"> |
| 5268 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt> |
| 5269 | <dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true). This includes <a class="reference internal" href="#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code></a> when specifying the algorithm in a usage policy.</dd> |
| 5270 | </dl> |
| 5271 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5272 | <p>The corresponding RSA PKCS#1 v1.5 signature algorithm.</p> |
| 5273 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p> |
| 5274 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5275 | <p>RSA PKCS#1 v1.5 signature with hashing.</p> |
| 5276 | <p>This is the signature scheme defined by RFC 8017 (PKCS#1: RSA Cryptography Specifications) under the name RSASSA-PKCS1-v1_5.</p> |
| 5277 | </div> |
| 5278 | <div class="section" id="PSA_ALG_RSA_PKCS1V15_SIGN_RAW"> |
| 5279 | <span id="c.PSA_ALG_RSA_PKCS1V15_SIGN_RAW"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN_RAW</span></code> (macro)</h2> |
| 5280 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PKCS1V15_SIGN_RAW PSA_ALG_RSA_PKCS1V15_SIGN_BASE</span> |
| 5281 | </pre></div> |
| 5282 | </div> |
| 5283 | <p>Raw PKCS#1 v1.5 signature.</p> |
| 5284 | <p>The input to this algorithm is the DigestInfo structure used by RFC 8017 (PKCS#1: RSA Cryptography Specifications), §9.2 steps 3–6.</p> |
| 5285 | </div> |
| 5286 | <div class="section" id="PSA_ALG_IS_RSA_PKCS1V15_SIGN"> |
| 5287 | <span id="c.PSA_ALG_IS_RSA_PKCS1V15_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_PKCS1V15_SIGN</span></code> (macro)</h2> |
| 5288 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) \</span> |
| 5289 | <span class="cp"> (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PKCS1V15_SIGN_BASE)</span> |
| 5290 | </pre></div> |
| 5291 | </div> |
| 5292 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5293 | <dl class="docutils"> |
| 5294 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5295 | <dd></dd> |
| 5296 | </dl> |
| 5297 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5298 | </div> |
| 5299 | <div class="section" id="PSA_ALG_RSA_PSS_BASE"> |
| 5300 | <span id="c.PSA_ALG_RSA_PSS_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PSS_BASE</span></code> (macro)</h2> |
| 5301 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PSS_BASE ((psa_algorithm_t)0x10030000)</span> |
| 5302 | </pre></div> |
| 5303 | </div> |
| 5304 | </div> |
| 5305 | <div class="section" id="PSA_ALG_RSA_PSS"> |
| 5306 | <span id="c.PSA_ALG_RSA_PSS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PSS</span></code> (macro)</h2> |
| 5307 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PSS(hash_alg) \</span> |
| 5308 | <span class="cp"> (PSA_ALG_RSA_PSS_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))</span> |
| 5309 | </pre></div> |
| 5310 | </div> |
| 5311 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5312 | <dl class="docutils"> |
| 5313 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt> |
| 5314 | <dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true). This includes <a class="reference internal" href="#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code></a> when specifying the algorithm in a usage policy.</dd> |
| 5315 | </dl> |
| 5316 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5317 | <p>The corresponding RSA PSS signature algorithm.</p> |
| 5318 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p> |
| 5319 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5320 | <p>RSA PSS signature with hashing.</p> |
| 5321 | <p>This is the signature scheme defined by RFC 8017 (PKCS#1: RSA Cryptography Specifications) under the name RSASSA-PSS, with the message generation function MGF1, and with a salt length equal to the length of the hash. The specified hash algorithm is used to hash the input message, to create the salted hash, and for the mask generation.</p> |
| 5322 | </div> |
| 5323 | <div class="section" id="PSA_ALG_IS_RSA_PSS"> |
| 5324 | <span id="c.PSA_ALG_IS_RSA_PSS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_PSS</span></code> (macro)</h2> |
| 5325 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_RSA_PSS(alg) \</span> |
| 5326 | <span class="cp"> (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_BASE)</span> |
| 5327 | </pre></div> |
| 5328 | </div> |
| 5329 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5330 | <dl class="docutils"> |
| 5331 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5332 | <dd></dd> |
| 5333 | </dl> |
| 5334 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5335 | </div> |
| 5336 | <div class="section" id="PSA_ALG_ECDSA_BASE"> |
| 5337 | <span id="c.PSA_ALG_ECDSA_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_BASE</span></code> (macro)</h2> |
| 5338 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ECDSA_BASE ((psa_algorithm_t)0x10060000)</span> |
| 5339 | </pre></div> |
| 5340 | </div> |
| 5341 | </div> |
| 5342 | <div class="section" id="PSA_ALG_ECDSA"> |
| 5343 | <span id="c.PSA_ALG_ECDSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA</span></code> (macro)</h2> |
| 5344 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ECDSA(hash_alg) \</span> |
| 5345 | <span class="cp"> (PSA_ALG_ECDSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))</span> |
| 5346 | </pre></div> |
| 5347 | </div> |
| 5348 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5349 | <dl class="docutils"> |
| 5350 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt> |
| 5351 | <dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true). This includes <a class="reference internal" href="#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code></a> when specifying the algorithm in a usage policy.</dd> |
| 5352 | </dl> |
| 5353 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5354 | <p>The corresponding ECDSA signature algorithm.</p> |
| 5355 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p> |
| 5356 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5357 | <p>ECDSA signature with hashing.</p> |
| 5358 | <p>This is the ECDSA signature scheme defined by ANSI X9.62, with a random per-message secret number (<em>k</em>).</p> |
| 5359 | <p>The representation of the signature as a byte string consists of the concatentation of the signature values <em>r</em> and <em>s</em>. Each of <em>r</em> and <em>s</em> is encoded as an <em>N</em>-octet string, where <em>N</em> is the length of the base point of the curve in octets. Each value is represented in big-endian order (most significant octet first).</p> |
| 5360 | </div> |
| 5361 | <div class="section" id="PSA_ALG_ECDSA_ANY"> |
| 5362 | <span id="c.PSA_ALG_ECDSA_ANY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_ANY</span></code> (macro)</h2> |
| 5363 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ECDSA_ANY PSA_ALG_ECDSA_BASE</span> |
| 5364 | </pre></div> |
| 5365 | </div> |
| 5366 | <p>ECDSA signature without hashing.</p> |
| 5367 | <p>This is the same signature scheme as <a class="reference internal" href="#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA()</span></code></a>, but without specifying a hash algorithm. This algorithm may only be used to sign or verify a sequence of bytes that should be an already-calculated hash. Note that the input is padded with zeros on the left or truncated on the left as required to fit the curve size.</p> |
| 5368 | </div> |
| 5369 | <div class="section" id="PSA_ALG_DETERMINISTIC_ECDSA_BASE"> |
| 5370 | <span id="c.PSA_ALG_DETERMINISTIC_ECDSA_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA_BASE</span></code> (macro)</h2> |
| 5371 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_DETERMINISTIC_ECDSA_BASE ((psa_algorithm_t)0x10070000)</span> |
| 5372 | </pre></div> |
| 5373 | </div> |
| 5374 | </div> |
| 5375 | <div class="section" id="PSA_ALG_DETERMINISTIC_ECDSA"> |
| 5376 | <span id="c.PSA_ALG_DETERMINISTIC_ECDSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA</span></code> (macro)</h2> |
| 5377 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_DETERMINISTIC_ECDSA(hash_alg) \</span> |
| 5378 | <span class="cp"> (PSA_ALG_DETERMINISTIC_ECDSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))</span> |
| 5379 | </pre></div> |
| 5380 | </div> |
| 5381 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5382 | <dl class="docutils"> |
| 5383 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt> |
| 5384 | <dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true). This includes <a class="reference internal" href="#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code></a> when specifying the algorithm in a usage policy.</dd> |
| 5385 | </dl> |
| 5386 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5387 | <p>The corresponding deterministic ECDSA signature algorithm.</p> |
| 5388 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p> |
| 5389 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5390 | <p>Deterministic ECDSA signature with hashing.</p> |
| 5391 | <p>This is the deterministic ECDSA signature scheme defined by RFC 6979.</p> |
| 5392 | <p>The representation of a signature is the same as with <a class="reference internal" href="#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA()</span></code></a>.</p> |
| 5393 | <p>Note that when this algorithm is used for verification, signatures made with randomized ECDSA (<a class="reference internal" href="#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>)) with the same private key are accepted. In other words, <a class="reference internal" href="#c.PSA_ALG_DETERMINISTIC_ECDSA" title="PSA_ALG_DETERMINISTIC_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) differs from <a class="reference internal" href="#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) only for signature, not for verification.</p> |
| 5394 | </div> |
| 5395 | <div class="section" id="PSA_ALG_IS_ECDSA"> |
| 5396 | <span id="c.PSA_ALG_IS_ECDSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ECDSA</span></code> (macro)</h2> |
| 5397 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_ECDSA(alg) \</span> |
| 5398 | <span class="cp"> (((alg) & ~PSA_ALG_HASH_MASK & ~PSA_ALG_DSA_DETERMINISTIC_FLAG) == PSA_ALG_ECDSA_BASE)</span> |
| 5399 | </pre></div> |
| 5400 | </div> |
| 5401 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5402 | <dl class="docutils"> |
| 5403 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5404 | <dd></dd> |
| 5405 | </dl> |
| 5406 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5407 | </div> |
| 5408 | <div class="section" id="PSA_ALG_ECDSA_IS_DETERMINISTIC"> |
| 5409 | <span id="c.PSA_ALG_ECDSA_IS_DETERMINISTIC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_IS_DETERMINISTIC</span></code> (macro)</h2> |
| 5410 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ECDSA_IS_DETERMINISTIC(alg) \</span> |
| 5411 | <span class="cp"> (((alg) & PSA_ALG_DSA_DETERMINISTIC_FLAG) != 0)</span> |
| 5412 | </pre></div> |
| 5413 | </div> |
| 5414 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5415 | <dl class="docutils"> |
| 5416 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5417 | <dd></dd> |
| 5418 | </dl> |
| 5419 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5420 | </div> |
| 5421 | <div class="section" id="PSA_ALG_IS_DETERMINISTIC_ECDSA"> |
| 5422 | <span id="c.PSA_ALG_IS_DETERMINISTIC_ECDSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_DETERMINISTIC_ECDSA</span></code> (macro)</h2> |
| 5423 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_DETERMINISTIC_ECDSA(alg) \</span> |
| 5424 | <span class="cp"> (PSA_ALG_IS_ECDSA(alg) && PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))</span> |
| 5425 | </pre></div> |
| 5426 | </div> |
| 5427 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5428 | <dl class="docutils"> |
| 5429 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5430 | <dd></dd> |
| 5431 | </dl> |
| 5432 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5433 | </div> |
| 5434 | <div class="section" id="PSA_ALG_IS_RANDOMIZED_ECDSA"> |
| 5435 | <span id="c.PSA_ALG_IS_RANDOMIZED_ECDSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RANDOMIZED_ECDSA</span></code> (macro)</h2> |
| 5436 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_RANDOMIZED_ECDSA(alg) \</span> |
| 5437 | <span class="cp"> (PSA_ALG_IS_ECDSA(alg) && !PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))</span> |
| 5438 | </pre></div> |
| 5439 | </div> |
| 5440 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5441 | <dl class="docutils"> |
| 5442 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5443 | <dd></dd> |
| 5444 | </dl> |
| 5445 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5446 | </div> |
| 5447 | <div class="section" id="PSA_ALG_IS_HASH_AND_SIGN"> |
| 5448 | <span id="c.PSA_ALG_IS_HASH_AND_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH_AND_SIGN</span></code> (macro)</h2> |
| 5449 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_HASH_AND_SIGN(alg) \</span> |
| 5450 | <span class="cp"> (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || PSA_ALG_IS_ECDSA(alg))</span> |
| 5451 | </pre></div> |
| 5452 | </div> |
| 5453 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5454 | <dl class="docutils"> |
| 5455 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5456 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5457 | </dl> |
| 5458 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5459 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a hash-and-sign algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 5460 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5461 | <p>Whether the specified algorithm is a hash-and-sign algorithm.</p> |
| 5462 | <p>Hash-and-sign algorithms are public-key signature algorithms structured in two parts: first the calculation of a hash in a way that does not depend on the key, then the calculation of a signature from the hash value and the key.</p> |
| 5463 | </div> |
| 5464 | <div class="section" id="PSA_ALG_SIGN_GET_HASH"> |
| 5465 | <span id="c.PSA_ALG_SIGN_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SIGN_GET_HASH</span></code> (macro)</h2> |
| 5466 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SIGN_GET_HASH(alg) \</span> |
| 5467 | <span class="cp"> (PSA_ALG_IS_HASH_AND_SIGN(alg) ? ((alg) & PSA_ALG_HASH_MASK) == 0 ? </span><span class="cm">/*"raw" algorithm*/</span><span class="cp"> 0 : ((alg) & PSA_ALG_HASH_MASK) | PSA_ALG_CATEGORY_HASH : 0)</span> |
| 5468 | </pre></div> |
| 5469 | </div> |
| 5470 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5471 | <dl class="docutils"> |
| 5472 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5473 | <dd>A signature algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_SIGN" title="PSA_ALG_IS_SIGN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_SIGN</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 5474 | </dl> |
| 5475 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5476 | <p>The underlying hash algorithm if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a hash-and-sign algorithm.</p> |
| 5477 | <p>0 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a signature algorithm that does not follow the hash-and-sign structure.</p> |
| 5478 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a signature algorithm or if it is not supported by the implementation.</p> |
| 5479 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5480 | <p>Get the hash used by a hash-and-sign signature algorithm.</p> |
| 5481 | <p>A hash-and-sign algorithm is a signature algorithm which is composed of two phases: first a hashing phase which does not use the key and produces a hash of the input message, then a signing phase which only uses the hash and the key and not the message itself.</p> |
| 5482 | </div> |
| 5483 | <div class="section" id="PSA_ALG_RSA_PKCS1V15_CRYPT"> |
| 5484 | <span id="c.PSA_ALG_RSA_PKCS1V15_CRYPT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code> (macro)</h2> |
| 5485 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PKCS1V15_CRYPT ((psa_algorithm_t)0x12020000)</span> |
| 5486 | </pre></div> |
| 5487 | </div> |
| 5488 | <p>RSA PKCS#1 v1.5 encryption.</p> |
| 5489 | </div> |
| 5490 | <div class="section" id="PSA_ALG_RSA_OAEP_BASE"> |
| 5491 | <span id="c.PSA_ALG_RSA_OAEP_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP_BASE</span></code> (macro)</h2> |
| 5492 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_OAEP_BASE ((psa_algorithm_t)0x12030000)</span> |
| 5493 | </pre></div> |
| 5494 | </div> |
| 5495 | </div> |
| 5496 | <div class="section" id="PSA_ALG_RSA_OAEP"> |
| 5497 | <span id="c.PSA_ALG_RSA_OAEP"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP</span></code> (macro)</h2> |
| 5498 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_OAEP(hash_alg) \</span> |
| 5499 | <span class="cp"> (PSA_ALG_RSA_OAEP_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))</span> |
| 5500 | </pre></div> |
| 5501 | </div> |
| 5502 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5503 | <dl class="docutils"> |
| 5504 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt> |
| 5505 | <dd>The hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true) to use for MGF1.</dd> |
| 5506 | </dl> |
| 5507 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5508 | <p>The corresponding RSA OAEP signature algorithm.</p> |
| 5509 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p> |
| 5510 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5511 | <p>RSA OAEP encryption.</p> |
| 5512 | <p>This is the encryption scheme defined by RFC 8017 (PKCS#1: RSA Cryptography Specifications) under the name RSAES-OAEP, with the message generation function MGF1.</p> |
| 5513 | </div> |
| 5514 | <div class="section" id="PSA_ALG_IS_RSA_OAEP"> |
| 5515 | <span id="c.PSA_ALG_IS_RSA_OAEP"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_OAEP</span></code> (macro)</h2> |
| 5516 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_RSA_OAEP(alg) \</span> |
| 5517 | <span class="cp"> (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_OAEP_BASE)</span> |
| 5518 | </pre></div> |
| 5519 | </div> |
| 5520 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5521 | <dl class="docutils"> |
| 5522 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5523 | <dd></dd> |
| 5524 | </dl> |
| 5525 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5526 | </div> |
| 5527 | <div class="section" id="PSA_ALG_RSA_OAEP_GET_HASH"> |
| 5528 | <span id="c.PSA_ALG_RSA_OAEP_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP_GET_HASH</span></code> (macro)</h2> |
| 5529 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_OAEP_GET_HASH(alg) \</span> |
| 5530 | <span class="cp"> (PSA_ALG_IS_RSA_OAEP(alg) ? ((alg) & PSA_ALG_HASH_MASK) | PSA_ALG_CATEGORY_HASH : 0)</span> |
| 5531 | </pre></div> |
| 5532 | </div> |
| 5533 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5534 | <dl class="docutils"> |
| 5535 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5536 | <dd></dd> |
| 5537 | </dl> |
| 5538 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5539 | </div> |
| 5540 | <div class="section" id="PSA_ALG_HKDF_BASE"> |
| 5541 | <span id="c.PSA_ALG_HKDF_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF_BASE</span></code> (macro)</h2> |
| 5542 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HKDF_BASE ((psa_algorithm_t)0x20000100)</span> |
| 5543 | </pre></div> |
| 5544 | </div> |
| 5545 | </div> |
| 5546 | <div class="section" id="PSA_ALG_HKDF"> |
| 5547 | <span id="c.PSA_ALG_HKDF"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF</span></code> (macro)</h2> |
| 5548 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HKDF(hash_alg) \</span> |
| 5549 | <span class="cp"> (PSA_ALG_HKDF_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))</span> |
| 5550 | </pre></div> |
| 5551 | </div> |
| 5552 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5553 | <dl class="docutils"> |
| 5554 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt> |
| 5555 | <dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true).</dd> |
| 5556 | </dl> |
| 5557 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5558 | <p>The corresponding HKDF algorithm.</p> |
| 5559 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p> |
| 5560 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5561 | <p>Macro to build an HKDF algorithm.</p> |
| 5562 | <p>For example, <code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF(PSA_ALG_SHA256)</span></code> is HKDF using HMAC-SHA-256.</p> |
| 5563 | <p>This key derivation algorithm uses the following inputs:</p> |
| 5564 | <ul class="simple"> |
| 5565 | <li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SALT" title="PSA_KEY_DERIVATION_INPUT_SALT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SALT</span></code></a> is the salt used in the “extract” step. It is optional; if omitted, the derivation uses an empty salt.</li> |
| 5566 | <li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SECRET" title="PSA_KEY_DERIVATION_INPUT_SECRET"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code></a> is the secret key used in the “extract” step.</li> |
| 5567 | <li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_INFO" title="PSA_KEY_DERIVATION_INPUT_INFO"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_INFO</span></code></a> is the info string used in the “expand” step. You must pass <a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SALT" title="PSA_KEY_DERIVATION_INPUT_SALT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SALT</span></code></a> before <a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SECRET" title="PSA_KEY_DERIVATION_INPUT_SECRET"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code></a>. You may pass <a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_INFO" title="PSA_KEY_DERIVATION_INPUT_INFO"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_INFO</span></code></a> at any time after steup and before starting to generate output.</li> |
| 5568 | </ul> |
| 5569 | </div> |
| 5570 | <div class="section" id="PSA_ALG_IS_HKDF"> |
| 5571 | <span id="c.PSA_ALG_IS_HKDF"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HKDF</span></code> (macro)</h2> |
| 5572 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_HKDF(alg) \</span> |
| 5573 | <span class="cp"> (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_BASE)</span> |
| 5574 | </pre></div> |
| 5575 | </div> |
| 5576 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5577 | <dl class="docutils"> |
| 5578 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5579 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5580 | </dl> |
| 5581 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5582 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is an HKDF algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key derivation algorithm identifier.</p> |
| 5583 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5584 | <p>Whether the specified algorithm is an HKDF algorithm.</p> |
| 5585 | <p>HKDF is a family of key derivation algorithms that are based on a hash function and the HMAC construction.</p> |
| 5586 | </div> |
| 5587 | <div class="section" id="PSA_ALG_HKDF_GET_HASH"> |
| 5588 | <span id="c.PSA_ALG_HKDF_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF_GET_HASH</span></code> (macro)</h2> |
| 5589 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HKDF_GET_HASH(hkdf_alg) \</span> |
| 5590 | <span class="cp"> (PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))</span> |
| 5591 | </pre></div> |
| 5592 | </div> |
| 5593 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5594 | <dl class="docutils"> |
| 5595 | <dt> <code class="docutils literal notranslate"><span class="pre">hkdf_alg</span></code></dt> |
| 5596 | <dd></dd> |
| 5597 | </dl> |
| 5598 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5599 | </div> |
| 5600 | <div class="section" id="PSA_ALG_TLS12_PRF_BASE"> |
| 5601 | <span id="c.PSA_ALG_TLS12_PRF_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF_BASE</span></code> (macro)</h2> |
| 5602 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PRF_BASE ((psa_algorithm_t)0x20000200)</span> |
| 5603 | </pre></div> |
| 5604 | </div> |
| 5605 | </div> |
| 5606 | <div class="section" id="PSA_ALG_TLS12_PRF"> |
| 5607 | <span id="c.PSA_ALG_TLS12_PRF"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF</span></code> (macro)</h2> |
| 5608 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PRF(hash_alg) \</span> |
| 5609 | <span class="cp"> (PSA_ALG_TLS12_PRF_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))</span> |
| 5610 | </pre></div> |
| 5611 | </div> |
| 5612 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5613 | <dl class="docutils"> |
| 5614 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt> |
| 5615 | <dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true).</dd> |
| 5616 | </dl> |
| 5617 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5618 | <p>The corresponding TLS-1.2 PRF algorithm.</p> |
| 5619 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p> |
| 5620 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5621 | <p>Macro to build a TLS-1.2 PRF algorithm.</p> |
| 5622 | <p>TLS 1.2 uses a custom pseudorandom function (PRF) for key schedule, specified in Section 5 of RFC 5246. It is based on HMAC and can be used with either SHA-256 or SHA-384.</p> |
| 5623 | <p>This key derivation algorithm uses the following inputs:</p> |
| 5624 | <ul class="simple"> |
| 5625 | <li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SECRET" title="PSA_KEY_DERIVATION_INPUT_SECRET"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code></a> is the secret key.</li> |
| 5626 | <li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_LABEL" title="PSA_KEY_DERIVATION_INPUT_LABEL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_LABEL</span></code></a> is the label.</li> |
| 5627 | <li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SEED" title="PSA_KEY_DERIVATION_INPUT_SEED"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SEED</span></code></a> is the seed.</li> |
| 5628 | </ul> |
| 5629 | <p>For the application to TLS-1.2 key expansion, the seed is the concatenation of ServerHello.Random + ClientHello.Random, and the label is “key expansion”.</p> |
| 5630 | <p>For example, <code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF(PSA_ALG_SHA256)</span></code> represents the TLS 1.2 PRF using HMAC-SHA-256.</p> |
| 5631 | </div> |
| 5632 | <div class="section" id="PSA_ALG_IS_TLS12_PRF"> |
| 5633 | <span id="c.PSA_ALG_IS_TLS12_PRF"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_TLS12_PRF</span></code> (macro)</h2> |
| 5634 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_TLS12_PRF(alg) \</span> |
| 5635 | <span class="cp"> (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_TLS12_PRF_BASE)</span> |
| 5636 | </pre></div> |
| 5637 | </div> |
| 5638 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5639 | <dl class="docutils"> |
| 5640 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5641 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5642 | </dl> |
| 5643 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5644 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a TLS-1.2 PRF algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key derivation algorithm identifier.</p> |
| 5645 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5646 | <p>Whether the specified algorithm is a TLS-1.2 PRF algorithm.</p> |
| 5647 | </div> |
| 5648 | <div class="section" id="PSA_ALG_TLS12_PRF_GET_HASH"> |
| 5649 | <span id="c.PSA_ALG_TLS12_PRF_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF_GET_HASH</span></code> (macro)</h2> |
| 5650 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PRF_GET_HASH(hkdf_alg) \</span> |
| 5651 | <span class="cp"> (PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))</span> |
| 5652 | </pre></div> |
| 5653 | </div> |
| 5654 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5655 | <dl class="docutils"> |
| 5656 | <dt> <code class="docutils literal notranslate"><span class="pre">hkdf_alg</span></code></dt> |
| 5657 | <dd></dd> |
| 5658 | </dl> |
| 5659 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5660 | </div> |
| 5661 | <div class="section" id="PSA_ALG_TLS12_PSK_TO_MS_BASE"> |
| 5662 | <span id="c.PSA_ALG_TLS12_PSK_TO_MS_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_BASE</span></code> (macro)</h2> |
| 5663 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PSK_TO_MS_BASE ((psa_algorithm_t)0x20000300)</span> |
| 5664 | </pre></div> |
| 5665 | </div> |
| 5666 | </div> |
| 5667 | <div class="section" id="PSA_ALG_TLS12_PSK_TO_MS"> |
| 5668 | <span id="c.PSA_ALG_TLS12_PSK_TO_MS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS</span></code> (macro)</h2> |
| 5669 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PSK_TO_MS(hash_alg) \</span> |
| 5670 | <span class="cp"> (PSA_ALG_TLS12_PSK_TO_MS_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))</span> |
| 5671 | </pre></div> |
| 5672 | </div> |
| 5673 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5674 | <dl class="docutils"> |
| 5675 | <dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt> |
| 5676 | <dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true).</dd> |
| 5677 | </dl> |
| 5678 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5679 | <p>The corresponding TLS-1.2 PSK to MS algorithm.</p> |
| 5680 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p> |
| 5681 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5682 | <p>Macro to build a TLS-1.2 PSK-to-MasterSecret algorithm.</p> |
| 5683 | <p>In a pure-PSK handshake in TLS 1.2, the master secret is derived from the PreSharedKey (PSK) through the application of padding (RFC 4279, Section 2) and the TLS-1.2 PRF (RFC 5246, Section 5). The latter is based on HMAC and can be used with either SHA-256 or SHA-384.</p> |
| 5684 | <p>This key derivation algorithm uses the following inputs:</p> |
| 5685 | <ul class="simple"> |
| 5686 | <li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SECRET" title="PSA_KEY_DERIVATION_INPUT_SECRET"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code></a> is the secret key.</li> |
| 5687 | <li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_LABEL" title="PSA_KEY_DERIVATION_INPUT_LABEL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_LABEL</span></code></a> is the label.</li> |
| 5688 | <li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SEED" title="PSA_KEY_DERIVATION_INPUT_SEED"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SEED</span></code></a> is the seed.</li> |
| 5689 | </ul> |
| 5690 | <p>For the application to TLS-1.2, the seed (which is forwarded to the TLS-1.2 PRF) is the concatenation of the ClientHello.Random + ServerHello.Random, and the label is “master secret” or “extended master secret”.</p> |
| 5691 | <p>For example, <code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS(PSA_ALG_SHA256)</span></code> represents the TLS-1.2 PSK to MasterSecret derivation PRF using HMAC-SHA-256.</p> |
| 5692 | </div> |
| 5693 | <div class="section" id="PSA_ALG_IS_TLS12_PSK_TO_MS"> |
| 5694 | <span id="c.PSA_ALG_IS_TLS12_PSK_TO_MS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_TLS12_PSK_TO_MS</span></code> (macro)</h2> |
| 5695 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_TLS12_PSK_TO_MS(alg) \</span> |
| 5696 | <span class="cp"> (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_TLS12_PSK_TO_MS_BASE)</span> |
| 5697 | </pre></div> |
| 5698 | </div> |
| 5699 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5700 | <dl class="docutils"> |
| 5701 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5702 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5703 | </dl> |
| 5704 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5705 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a TLS-1.2 PSK to MS algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key derivation algorithm identifier.</p> |
| 5706 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5707 | <p>Whether the specified algorithm is a TLS-1.2 PSK to MS algorithm.</p> |
| 5708 | </div> |
| 5709 | <div class="section" id="PSA_ALG_TLS12_PSK_TO_MS_GET_HASH"> |
| 5710 | <span id="c.PSA_ALG_TLS12_PSK_TO_MS_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_GET_HASH</span></code> (macro)</h2> |
| 5711 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PSK_TO_MS_GET_HASH(hkdf_alg) \</span> |
| 5712 | <span class="cp"> (PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))</span> |
| 5713 | </pre></div> |
| 5714 | </div> |
| 5715 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5716 | <dl class="docutils"> |
| 5717 | <dt> <code class="docutils literal notranslate"><span class="pre">hkdf_alg</span></code></dt> |
| 5718 | <dd></dd> |
| 5719 | </dl> |
| 5720 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5721 | </div> |
| 5722 | <div class="section" id="PSA_ALG_KEY_DERIVATION_MASK"> |
| 5723 | <span id="c.PSA_ALG_KEY_DERIVATION_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_DERIVATION_MASK</span></code> (macro)</h2> |
| 5724 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_KEY_DERIVATION_MASK ((psa_algorithm_t)0x0803ffff)</span> |
| 5725 | </pre></div> |
| 5726 | </div> |
| 5727 | </div> |
| 5728 | <div class="section" id="PSA_ALG_KEY_AGREEMENT_MASK"> |
| 5729 | <span id="c.PSA_ALG_KEY_AGREEMENT_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_MASK</span></code> (macro)</h2> |
| 5730 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_KEY_AGREEMENT_MASK ((psa_algorithm_t)0x10fc0000)</span> |
| 5731 | </pre></div> |
| 5732 | </div> |
| 5733 | </div> |
| 5734 | <div class="section" id="PSA_ALG_KEY_AGREEMENT"> |
| 5735 | <span id="c.PSA_ALG_KEY_AGREEMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT</span></code> (macro)</h2> |
| 5736 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_KEY_AGREEMENT(ka_alg, kdf_alg) ((ka_alg) | (kdf_alg))</span> |
| 5737 | </pre></div> |
| 5738 | </div> |
| 5739 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5740 | <dl class="docutils"> |
| 5741 | <dt> <code class="docutils literal notranslate"><span class="pre">ka_alg</span></code></dt> |
| 5742 | <dd>A key agreement algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_KEY_AGREEMENT" title="PSA_ALG_IS_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_AGREEMENT</span></code></a>(<code class="docutils literal notranslate"><span class="pre">ka_alg</span></code>) is true).</dd> |
| 5743 | <dt> <code class="docutils literal notranslate"><span class="pre">kdf_alg</span></code></dt> |
| 5744 | <dd>A key derivation algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_KEY_DERIVATION" title="PSA_ALG_IS_KEY_DERIVATION"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION</span></code></a>(<code class="docutils literal notranslate"><span class="pre">kdf_alg</span></code>) is true).</dd> |
| 5745 | </dl> |
| 5746 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5747 | <p>The corresponding key agreement and derivation algorithm.</p> |
| 5748 | <p>Unspecified if <code class="docutils literal notranslate"><span class="pre">ka_alg</span></code> is not a supported key agreement algorithm or <code class="docutils literal notranslate"><span class="pre">kdf_alg</span></code> is not a supported key derivation algorithm.</p> |
| 5749 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5750 | <p>Macro to build a combined algorithm that chains a key agreement with a key derivation.</p> |
| 5751 | </div> |
| 5752 | <div class="section" id="PSA_ALG_KEY_AGREEMENT_GET_KDF"> |
| 5753 | <span id="c.PSA_ALG_KEY_AGREEMENT_GET_KDF"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_GET_KDF</span></code> (macro)</h2> |
| 5754 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) \</span> |
| 5755 | <span class="cp"> (((alg) & PSA_ALG_KEY_DERIVATION_MASK) | PSA_ALG_CATEGORY_KEY_DERIVATION)</span> |
| 5756 | </pre></div> |
| 5757 | </div> |
| 5758 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5759 | <dl class="docutils"> |
| 5760 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5761 | <dd></dd> |
| 5762 | </dl> |
| 5763 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5764 | </div> |
| 5765 | <div class="section" id="PSA_ALG_KEY_AGREEMENT_GET_BASE"> |
| 5766 | <span id="c.PSA_ALG_KEY_AGREEMENT_GET_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_GET_BASE</span></code> (macro)</h2> |
| 5767 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) \</span> |
| 5768 | <span class="cp"> (((alg) & PSA_ALG_KEY_AGREEMENT_MASK) | PSA_ALG_CATEGORY_KEY_AGREEMENT)</span> |
| 5769 | </pre></div> |
| 5770 | </div> |
| 5771 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5772 | <dl class="docutils"> |
| 5773 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5774 | <dd></dd> |
| 5775 | </dl> |
| 5776 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5777 | </div> |
| 5778 | <div class="section" id="PSA_ALG_IS_RAW_KEY_AGREEMENT"> |
| 5779 | <span id="c.PSA_ALG_IS_RAW_KEY_AGREEMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RAW_KEY_AGREEMENT</span></code> (macro)</h2> |
| 5780 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_RAW_KEY_AGREEMENT(alg) \</span> |
| 5781 | <span class="cp"> (PSA_ALG_IS_KEY_AGREEMENT(alg) && PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) == PSA_ALG_CATEGORY_KEY_DERIVATION)</span> |
| 5782 | </pre></div> |
| 5783 | </div> |
| 5784 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5785 | <dl class="docutils"> |
| 5786 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5787 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5788 | </dl> |
| 5789 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5790 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a raw key agreement algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 5791 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5792 | <p>Whether the specified algorithm is a raw key agreement algorithm.</p> |
| 5793 | <p>A raw key agreement algorithm is one that does not specify a key derivation function. Usually, raw key agreement algorithms are constructed directly with a <code class="docutils literal notranslate"><span class="pre">PSA_ALG_xxx</span></code> macro while non-raw key agreement algorithms are constructed with <a class="reference internal" href="#c.PSA_ALG_KEY_AGREEMENT" title="PSA_ALG_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT()</span></code></a>.</p> |
| 5794 | </div> |
| 5795 | <div class="section" id="PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT"> |
| 5796 | <span id="c.PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT</span></code> (macro)</h2> |
| 5797 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT(alg) \</span> |
| 5798 | <span class="cp"> ((PSA_ALG_IS_KEY_DERIVATION(alg) || PSA_ALG_IS_KEY_AGREEMENT(alg)))</span> |
| 5799 | </pre></div> |
| 5800 | </div> |
| 5801 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5802 | <dl class="docutils"> |
| 5803 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5804 | <dd></dd> |
| 5805 | </dl> |
| 5806 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5807 | </div> |
| 5808 | <div class="section" id="PSA_ALG_FFDH"> |
| 5809 | <span id="c.PSA_ALG_FFDH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_FFDH</span></code> (macro)</h2> |
| 5810 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_FFDH ((psa_algorithm_t)0x30100000)</span> |
| 5811 | </pre></div> |
| 5812 | </div> |
| 5813 | <p>The finite-field Diffie-Hellman (DH) key agreement algorithm.</p> |
| 5814 | <p>The shared secret produced by key agreement is <code class="docutils literal notranslate"><span class="pre">g^{ab}</span></code> in big-endian format. It is <code class="docutils literal notranslate"><span class="pre">ceiling(m</span> <span class="pre">/</span> <span class="pre">8)</span></code> bytes long where <code class="docutils literal notranslate"><span class="pre">m</span></code> is the size of the prime <code class="docutils literal notranslate"><span class="pre">p</span></code> in bits.</p> |
| 5815 | </div> |
| 5816 | <div class="section" id="PSA_ALG_IS_FFDH"> |
| 5817 | <span id="c.PSA_ALG_IS_FFDH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_FFDH</span></code> (macro)</h2> |
| 5818 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_FFDH(alg) \</span> |
| 5819 | <span class="cp"> (PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) == PSA_ALG_FFDH)</span> |
| 5820 | </pre></div> |
| 5821 | </div> |
| 5822 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5823 | <dl class="docutils"> |
| 5824 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5825 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5826 | </dl> |
| 5827 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5828 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a finite field Diffie-Hellman algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key agreement algorithm identifier.</p> |
| 5829 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5830 | <p>Whether the specified algorithm is a finite field Diffie-Hellman algorithm.</p> |
| 5831 | <p>This includes the raw finite field Diffie-Hellman algorithm as well as finite-field Diffie-Hellman followed by any supporter key derivation algorithm.</p> |
| 5832 | </div> |
| 5833 | <div class="section" id="PSA_ALG_ECDH"> |
| 5834 | <span id="c.PSA_ALG_ECDH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDH</span></code> (macro)</h2> |
| 5835 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ECDH ((psa_algorithm_t)0x30200000)</span> |
| 5836 | </pre></div> |
| 5837 | </div> |
| 5838 | <p>The elliptic curve Diffie-Hellman (ECDH) key agreement algorithm.</p> |
| 5839 | <p>The shared secret produced by key agreement is the x-coordinate of the shared secret point. It is always <code class="docutils literal notranslate"><span class="pre">ceiling(m</span> <span class="pre">/</span> <span class="pre">8)</span></code> bytes long where <code class="docutils literal notranslate"><span class="pre">m</span></code> is the bit size associated with the curve, i.e. the bit size of the order of the curve’s coordinate field. When <code class="docutils literal notranslate"><span class="pre">m</span></code> is not a multiple of 8, the byte containing the most significant bit of the shared secret is padded with zero bits. The byte order is either little-endian or big-endian depending on the curve type.</p> |
| 5840 | <ul class="simple"> |
| 5841 | <li>For Montgomery curves (curve types <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVEXXX</span></code>), the shared secret is the x-coordinate of <code class="docutils literal notranslate"><span class="pre">d_A</span> <span class="pre">Q_B</span> <span class="pre">=</span> <span class="pre">d_B</span> <span class="pre">Q_A</span></code> in little-endian byte order. The bit size is 448 for Curve448 and 255 for Curve25519.</li> |
| 5842 | <li>For Weierstrass curves over prime fields (curve types <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECPXXX</span></code> and <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_PXXX</span></code>), the shared secret is the x-coordinate of <code class="docutils literal notranslate"><span class="pre">d_A</span> <span class="pre">Q_B</span> <span class="pre">=</span> <span class="pre">d_B</span> <span class="pre">Q_A</span></code> in big-endian byte order. The bit size is <code class="docutils literal notranslate"><span class="pre">m</span> <span class="pre">=</span> <span class="pre">ceiling(log_2(p))</span></code> for the field <code class="docutils literal notranslate"><span class="pre">F_p</span></code>.</li> |
| 5843 | <li>For Weierstrass curves over binary fields (curve types <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECTXXX</span></code>), the shared secret is the x-coordinate of <code class="docutils literal notranslate"><span class="pre">d_A</span> <span class="pre">Q_B</span> <span class="pre">=</span> <span class="pre">d_B</span> <span class="pre">Q_A</span></code> in big-endian byte order. The bit size is <code class="docutils literal notranslate"><span class="pre">m</span></code> for the field <code class="docutils literal notranslate"><span class="pre">F_{2^m}</span></code>.</li> |
| 5844 | </ul> |
| 5845 | </div> |
| 5846 | <div class="section" id="PSA_ALG_IS_ECDH"> |
| 5847 | <span id="c.PSA_ALG_IS_ECDH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ECDH</span></code> (macro)</h2> |
| 5848 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_ECDH(alg) \</span> |
| 5849 | <span class="cp"> (PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) == PSA_ALG_ECDH)</span> |
| 5850 | </pre></div> |
| 5851 | </div> |
| 5852 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5853 | <dl class="docutils"> |
| 5854 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5855 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5856 | </dl> |
| 5857 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5858 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is an elliptic curve Diffie-Hellman algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key agreement algorithm identifier.</p> |
| 5859 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5860 | <p>Whether the specified algorithm is an elliptic curve Diffie-Hellman algorithm.</p> |
| 5861 | <p>This includes the raw elliptic curve Diffie-Hellman algorithm as well as elliptic curve Diffie-Hellman followed by any supporter key derivation algorithm.</p> |
| 5862 | </div> |
| 5863 | <div class="section" id="PSA_ALG_IS_WILDCARD"> |
| 5864 | <span id="c.PSA_ALG_IS_WILDCARD"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_WILDCARD</span></code> (macro)</h2> |
| 5865 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_WILDCARD(alg) \</span> |
| 5866 | <span class="cp"> (PSA_ALG_IS_HASH_AND_SIGN(alg) ? PSA_ALG_SIGN_GET_HASH(alg) == PSA_ALG_ANY_HASH : (alg) == PSA_ALG_ANY_HASH)</span> |
| 5867 | </pre></div> |
| 5868 | </div> |
| 5869 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 5870 | <dl class="docutils"> |
| 5871 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 5872 | <dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd> |
| 5873 | </dl> |
| 5874 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 5875 | <p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a wildcard algorithm encoding.</p> |
| 5876 | <p>0 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a non-wildcard algorithm encoding (suitable for an operation).</p> |
| 5877 | <p>This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 5878 | <p class="subitem-title"><strong>Description:</strong></p> |
| 5879 | <p>Whether the specified algorithm encoding is a wildcard.</p> |
| 5880 | <p>Wildcard values may only be used to set the usage algorithm field in a policy, not to perform an operation.</p> |
| 5881 | </div> |
| 5882 | </div> |
| 5883 | <div class="section" id="key-lifetimes"> |
| 5884 | <h1>Key lifetimes</h1> |
| 5885 | <div class="section" id="psa_key_lifetime_t"> |
| 5886 | <span id="c.psa_key_lifetime_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_lifetime_t</span></code> (type)</h2> |
| 5887 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint32_t</span> <span class="n">psa_key_lifetime_t</span><span class="p">;</span> |
| 5888 | </pre></div> |
| 5889 | </div> |
| 5890 | <p>Encoding of key lifetimes.</p> |
| 5891 | <p>The lifetime of a key indicates where it is stored and what system actions may create and destroy it.</p> |
| 5892 | <p>Keys with the lifetime <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a> are automatically destroyed when the application terminates or on a power reset.</p> |
| 5893 | <p>Keys with a lifetime other than <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a> are said to be <em>persistent</em>. Persistent keys are preserved if the application or the system restarts. Persistent keys have a key identifier of type <a class="reference internal" href="#c.psa_key_id_t" title="psa_key_id_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_id_t</span></code></a>. The application can call <a class="reference internal" href="#c.psa_open_key" title="psa_open_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_open_key()</span></code></a> to open a persistent key that it created previously.</p> |
| 5894 | </div> |
| 5895 | <div class="section" id="psa_key_id_t"> |
| 5896 | <span id="c.psa_key_id_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_id_t</span></code> (type)</h2> |
| 5897 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint32_t</span> <span class="n">psa_key_id_t</span><span class="p">;</span> |
| 5898 | </pre></div> |
| 5899 | </div> |
| 5900 | <p>Encoding of identifiers of persistent keys.</p> |
| 5901 | <ul class="simple"> |
| 5902 | <li>Applications may freely choose key identifiers in the range <a class="reference internal" href="#c.PSA_KEY_ID_USER_MIN" title="PSA_KEY_ID_USER_MIN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MIN</span></code></a> to <a class="reference internal" href="#c.PSA_KEY_ID_USER_MAX" title="PSA_KEY_ID_USER_MAX"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MAX</span></code></a>.</li> |
| 5903 | <li>Implementations may define additional key identifiers in the range <a class="reference internal" href="#c.PSA_KEY_ID_VENDOR_MIN" title="PSA_KEY_ID_VENDOR_MIN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MIN</span></code></a> to <a class="reference internal" href="#c.PSA_KEY_ID_VENDOR_MAX" title="PSA_KEY_ID_VENDOR_MAX"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MAX</span></code></a>.</li> |
| 5904 | <li>0 is reserved as an invalid key identifier.</li> |
| 5905 | <li>Key identifiers outside these ranges are reserved for future use.</li> |
| 5906 | </ul> |
| 5907 | </div> |
| 5908 | <div class="section" id="PSA_KEY_LIFETIME_VOLATILE"> |
| 5909 | <span id="c.PSA_KEY_LIFETIME_VOLATILE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code> (macro)</h2> |
| 5910 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_LIFETIME_VOLATILE ((psa_key_lifetime_t)0x00000000)</span> |
| 5911 | </pre></div> |
| 5912 | </div> |
| 5913 | <p>A volatile key only exists as long as the handle to it is not closed.</p> |
| 5914 | <p>The key material is guaranteed to be erased on a power reset.</p> |
| 5915 | </div> |
| 5916 | <div class="section" id="PSA_KEY_LIFETIME_PERSISTENT"> |
| 5917 | <span id="c.PSA_KEY_LIFETIME_PERSISTENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code> (macro)</h2> |
| 5918 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_LIFETIME_PERSISTENT ((psa_key_lifetime_t)0x00000001)</span> |
| 5919 | </pre></div> |
| 5920 | </div> |
| 5921 | <p>The default storage area for persistent keys.</p> |
| 5922 | <p>A persistent key remains in storage until it is explicitly destroyed or until the corresponding storage area is wiped. This specification does not define any mechanism to wipe a storage area, but implementations may provide their own mechanism (for example to perform a factory reset, to prepare for device refurbishment, or to uninstall an application).</p> |
| 5923 | <p>This lifetime value is the default storage area for the calling application. Implementations may offer other storage areas designated by other lifetime values as implementation-specific extensions.</p> |
| 5924 | </div> |
| 5925 | <div class="section" id="PSA_KEY_ID_USER_MIN"> |
| 5926 | <span id="c.PSA_KEY_ID_USER_MIN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MIN</span></code> (macro)</h2> |
| 5927 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_ID_USER_MIN ((psa_key_id_t)0x00000001)</span> |
| 5928 | </pre></div> |
| 5929 | </div> |
| 5930 | <p>The minimum value for a key identifier chosen by the application.</p> |
| 5931 | </div> |
| 5932 | <div class="section" id="PSA_KEY_ID_USER_MAX"> |
| 5933 | <span id="c.PSA_KEY_ID_USER_MAX"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MAX</span></code> (macro)</h2> |
| 5934 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_ID_USER_MAX ((psa_key_id_t)0x3fffffff)</span> |
| 5935 | </pre></div> |
| 5936 | </div> |
| 5937 | <p>The maximum value for a key identifier chosen by the application.</p> |
| 5938 | </div> |
| 5939 | <div class="section" id="PSA_KEY_ID_VENDOR_MIN"> |
| 5940 | <span id="c.PSA_KEY_ID_VENDOR_MIN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MIN</span></code> (macro)</h2> |
| 5941 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_ID_VENDOR_MIN ((psa_key_id_t)0x40000000)</span> |
| 5942 | </pre></div> |
| 5943 | </div> |
| 5944 | <p>The minimum value for a key identifier chosen by the implementation.</p> |
| 5945 | </div> |
| 5946 | <div class="section" id="PSA_KEY_ID_VENDOR_MAX"> |
| 5947 | <span id="c.PSA_KEY_ID_VENDOR_MAX"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MAX</span></code> (macro)</h2> |
| 5948 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_ID_VENDOR_MAX ((psa_key_id_t)0x7fffffff)</span> |
| 5949 | </pre></div> |
| 5950 | </div> |
| 5951 | <p>The maximum value for a key identifier chosen by the implementation.</p> |
| 5952 | </div> |
| 5953 | </div> |
| 5954 | <div class="section" id="key-policies"> |
| 5955 | <h1>Key policies</h1> |
| 5956 | <div class="section" id="psa_key_usage_t"> |
| 5957 | <span id="c.psa_key_usage_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_usage_t</span></code> (type)</h2> |
| 5958 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint32_t</span> <span class="n">psa_key_usage_t</span><span class="p">;</span> |
| 5959 | </pre></div> |
| 5960 | </div> |
| 5961 | <p>Encoding of permitted usage on a key.</p> |
| 5962 | </div> |
| 5963 | <div class="section" id="PSA_KEY_USAGE_EXPORT"> |
| 5964 | <span id="c.PSA_KEY_USAGE_EXPORT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code> (macro)</h2> |
| 5965 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_EXPORT ((psa_key_usage_t)0x00000001)</span> |
| 5966 | </pre></div> |
| 5967 | </div> |
| 5968 | <p>Whether the key may be exported.</p> |
| 5969 | <p>A public key or the public part of a key pair may always be exported regardless of the value of this permission flag.</p> |
| 5970 | <p>If a key does not have export permission, implementations shall not allow the key to be exported in plain form from the cryptoprocessor, whether through <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a> or through a proprietary interface. The key may however be exportable in a wrapped form, i.e. in a form where it is encrypted by another key.</p> |
| 5971 | </div> |
| 5972 | <div class="section" id="PSA_KEY_USAGE_COPY"> |
| 5973 | <span id="c.PSA_KEY_USAGE_COPY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code> (macro)</h2> |
| 5974 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_COPY ((psa_key_usage_t)0x00000002)</span> |
| 5975 | </pre></div> |
| 5976 | </div> |
| 5977 | <p>Whether the key may be copied.</p> |
| 5978 | <p>This flag allows the use of <a class="reference internal" href="#c.psa_copy_key" title="psa_copy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_copy_key()</span></code></a> to make a copy of the key with the same policy or a more restrictive policy.</p> |
| 5979 | <p>For lifetimes for which the key is located in a secure element which enforce the non-exportability of keys, copying a key outside the secure element also requires the usage flag <a class="reference internal" href="#c.PSA_KEY_USAGE_EXPORT" title="PSA_KEY_USAGE_EXPORT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code></a>. Copying the key inside the secure element is permitted with just <a class="reference internal" href="#c.PSA_KEY_USAGE_COPY" title="PSA_KEY_USAGE_COPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code></a> if the secure element supports it. For keys with the lifetime <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a> or <a class="reference internal" href="#c.PSA_KEY_LIFETIME_PERSISTENT" title="PSA_KEY_LIFETIME_PERSISTENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code></a>, the usage flag <a class="reference internal" href="#c.PSA_KEY_USAGE_COPY" title="PSA_KEY_USAGE_COPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code></a> is sufficient to permit the copy.</p> |
| 5980 | </div> |
| 5981 | <div class="section" id="PSA_KEY_USAGE_ENCRYPT"> |
| 5982 | <span id="c.PSA_KEY_USAGE_ENCRYPT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_ENCRYPT</span></code> (macro)</h2> |
| 5983 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_ENCRYPT ((psa_key_usage_t)0x00000100)</span> |
| 5984 | </pre></div> |
| 5985 | </div> |
| 5986 | <p>Whether the key may be used to encrypt a message.</p> |
| 5987 | <p>This flag allows the key to be used for a symmetric encryption operation, for an AEAD encryption-and-authentication operation, or for an asymmetric encryption operation, if otherwise permitted by the key’s type and policy.</p> |
| 5988 | <p>For a key pair, this concerns the public key.</p> |
| 5989 | </div> |
| 5990 | <div class="section" id="PSA_KEY_USAGE_DECRYPT"> |
| 5991 | <span id="c.PSA_KEY_USAGE_DECRYPT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_DECRYPT</span></code> (macro)</h2> |
| 5992 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_DECRYPT ((psa_key_usage_t)0x00000200)</span> |
| 5993 | </pre></div> |
| 5994 | </div> |
| 5995 | <p>Whether the key may be used to decrypt a message.</p> |
| 5996 | <p>This flag allows the key to be used for a symmetric decryption operation, for an AEAD decryption-and-verification operation, or for an asymmetric decryption operation, if otherwise permitted by the key’s type and policy.</p> |
| 5997 | <p>For a key pair, this concerns the private key.</p> |
| 5998 | </div> |
| 5999 | <div class="section" id="PSA_KEY_USAGE_SIGN"> |
| 6000 | <span id="c.PSA_KEY_USAGE_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_SIGN</span></code> (macro)</h2> |
| 6001 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_SIGN ((psa_key_usage_t)0x00000400)</span> |
| 6002 | </pre></div> |
| 6003 | </div> |
| 6004 | <p>Whether the key may be used to sign a message.</p> |
| 6005 | <p>This flag allows the key to be used for a MAC calculation operation or for an asymmetric signature operation, if otherwise permitted by the key’s type and policy.</p> |
| 6006 | <p>For a key pair, this concerns the private key.</p> |
| 6007 | </div> |
| 6008 | <div class="section" id="PSA_KEY_USAGE_VERIFY"> |
| 6009 | <span id="c.PSA_KEY_USAGE_VERIFY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_VERIFY</span></code> (macro)</h2> |
| 6010 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_VERIFY ((psa_key_usage_t)0x00000800)</span> |
| 6011 | </pre></div> |
| 6012 | </div> |
| 6013 | <p>Whether the key may be used to verify a message signature.</p> |
| 6014 | <p>This flag allows the key to be used for a MAC verification operation or for an asymmetric signature verification operation, if otherwise permitted by by the key’s type and policy.</p> |
| 6015 | <p>For a key pair, this concerns the public key.</p> |
| 6016 | </div> |
| 6017 | <div class="section" id="PSA_KEY_USAGE_DERIVE"> |
| 6018 | <span id="c.PSA_KEY_USAGE_DERIVE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_DERIVE</span></code> (macro)</h2> |
| 6019 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_DERIVE ((psa_key_usage_t)0x00001000)</span> |
| 6020 | </pre></div> |
| 6021 | </div> |
| 6022 | <p>Whether the key may be used to derive other keys.</p> |
| 6023 | </div> |
| 6024 | </div> |
| 6025 | <div class="section" id="key-derivation"> |
| 6026 | <h1>Key derivation</h1> |
| 6027 | <div class="section" id="psa_key_derivation_step_t"> |
| 6028 | <span id="c.psa_key_derivation_step_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_step_t</span></code> (type)</h2> |
| 6029 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint16_t</span> <span class="n">psa_key_derivation_step_t</span><span class="p">;</span> |
| 6030 | </pre></div> |
| 6031 | </div> |
| 6032 | <p>Encoding of the step of a key derivation.</p> |
| 6033 | </div> |
| 6034 | <div class="section" id="PSA_KEY_DERIVATION_INPUT_SECRET"> |
| 6035 | <span id="c.PSA_KEY_DERIVATION_INPUT_SECRET"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code> (macro)</h2> |
| 6036 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_INPUT_SECRET ((psa_key_derivation_step_t)0x0101)</span> |
| 6037 | </pre></div> |
| 6038 | </div> |
| 6039 | <p>A secret input for key derivation.</p> |
| 6040 | <p>This must be a key of type <a class="reference internal" href="#c.PSA_KEY_TYPE_DERIVE" title="PSA_KEY_TYPE_DERIVE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DERIVE</span></code></a>.</p> |
| 6041 | </div> |
| 6042 | <div class="section" id="PSA_KEY_DERIVATION_INPUT_LABEL"> |
| 6043 | <span id="c.PSA_KEY_DERIVATION_INPUT_LABEL"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_LABEL</span></code> (macro)</h2> |
| 6044 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_INPUT_LABEL ((psa_key_derivation_step_t)0x0201)</span> |
| 6045 | </pre></div> |
| 6046 | </div> |
| 6047 | <p>A label for key derivation.</p> |
| 6048 | <p>This must be a direct input.</p> |
| 6049 | </div> |
| 6050 | <div class="section" id="PSA_KEY_DERIVATION_INPUT_SALT"> |
| 6051 | <span id="c.PSA_KEY_DERIVATION_INPUT_SALT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SALT</span></code> (macro)</h2> |
| 6052 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_INPUT_SALT ((psa_key_derivation_step_t)0x0202)</span> |
| 6053 | </pre></div> |
| 6054 | </div> |
| 6055 | <p>A salt for key derivation.</p> |
| 6056 | <p>This must be a direct input.</p> |
| 6057 | </div> |
| 6058 | <div class="section" id="PSA_KEY_DERIVATION_INPUT_INFO"> |
| 6059 | <span id="c.PSA_KEY_DERIVATION_INPUT_INFO"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_INFO</span></code> (macro)</h2> |
| 6060 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_INPUT_INFO ((psa_key_derivation_step_t)0x0203)</span> |
| 6061 | </pre></div> |
| 6062 | </div> |
| 6063 | <p>An information string for key derivation.</p> |
| 6064 | <p>This must be a direct input.</p> |
| 6065 | </div> |
| 6066 | <div class="section" id="PSA_KEY_DERIVATION_INPUT_SEED"> |
| 6067 | <span id="c.PSA_KEY_DERIVATION_INPUT_SEED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SEED</span></code> (macro)</h2> |
| 6068 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_INPUT_SEED ((psa_key_derivation_step_t)0x0204)</span> |
| 6069 | </pre></div> |
| 6070 | </div> |
| 6071 | <p>A seed for key derivation.</p> |
| 6072 | <p>This must be a direct input.</p> |
| 6073 | </div> |
| 6074 | </div> |
| 6075 | <div class="section" id="other-definitions"> |
| 6076 | <h1>Other definitions</h1> |
| 6077 | <div class="section" id="PSA_BITS_TO_BYTES"> |
| 6078 | <span id="c.PSA_BITS_TO_BYTES"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_BITS_TO_BYTES</span></code> (macro)</h2> |
| 6079 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_BITS_TO_BYTES(bits) (((bits) + 7) / 8)</span> |
| 6080 | </pre></div> |
| 6081 | </div> |
| 6082 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6083 | <dl class="docutils"> |
| 6084 | <dt> <code class="docutils literal notranslate"><span class="pre">bits</span></code></dt> |
| 6085 | <dd></dd> |
| 6086 | </dl> |
| 6087 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6088 | </div> |
| 6089 | <div class="section" id="PSA_BYTES_TO_BITS"> |
| 6090 | <span id="c.PSA_BYTES_TO_BITS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_BYTES_TO_BITS</span></code> (macro)</h2> |
| 6091 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_BYTES_TO_BITS(bytes) ((bytes) * 8)</span> |
| 6092 | </pre></div> |
| 6093 | </div> |
| 6094 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6095 | <dl class="docutils"> |
| 6096 | <dt> <code class="docutils literal notranslate"><span class="pre">bytes</span></code></dt> |
| 6097 | <dd></dd> |
| 6098 | </dl> |
| 6099 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6100 | </div> |
| 6101 | <div class="section" id="PSA_ROUND_UP_TO_MULTIPLE"> |
| 6102 | <span id="c.PSA_ROUND_UP_TO_MULTIPLE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ROUND_UP_TO_MULTIPLE</span></code> (macro)</h2> |
| 6103 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ROUND_UP_TO_MULTIPLE(block_size, length) \</span> |
| 6104 | <span class="cp"> (((length) + (block_size) - 1) / (block_size) * (block_size))</span> |
| 6105 | </pre></div> |
| 6106 | </div> |
| 6107 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6108 | <dl class="docutils"> |
| 6109 | <dt> <code class="docutils literal notranslate"><span class="pre">block_size</span></code></dt> |
| 6110 | <dd></dd> |
| 6111 | <dt> <code class="docutils literal notranslate"><span class="pre">length</span></code></dt> |
| 6112 | <dd></dd> |
| 6113 | </dl> |
| 6114 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6115 | </div> |
| 6116 | <div class="section" id="PSA_HASH_SIZE"> |
| 6117 | <span id="c.PSA_HASH_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code> (macro)</h2> |
| 6118 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_HASH_SIZE(alg) \</span> |
| 6119 | <span class="cp"> ( PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD2 ? 16 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD4 ? 16 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 16 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 20 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 20 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_224 ? 28 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_256 ? 32 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_384 ? 48 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512 ? 64 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_224 ? 28 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_256 ? 32 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_224 ? 28 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_256 ? 32 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_384 ? 48 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_512 ? 64 : 0)</span> |
| 6120 | </pre></div> |
| 6121 | </div> |
| 6122 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6123 | <dl class="docutils"> |
| 6124 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6125 | <dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true), or an HMAC algorithm (<a class="reference internal" href="#c.PSA_ALG_HMAC" title="PSA_ALG_HMAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_HMAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is a hash algorithm).</dd> |
| 6126 | </dl> |
| 6127 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6128 | <p>The hash size for the specified hash algorithm. If the hash algorithm is not recognized, return 0. An implementation may return either 0 or the correct size for a hash algorithm that it recognizes, but does not support.</p> |
| 6129 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6130 | <p>The size of the output of <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a>, in bytes.</p> |
| 6131 | <p>This is also the hash size that <a class="reference internal" href="#c.psa_hash_verify" title="psa_hash_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_verify()</span></code></a> expects.</p> |
| 6132 | </div> |
| 6133 | <div class="section" id="PSA_HASH_MAX_SIZE"> |
| 6134 | <span id="c.PSA_HASH_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_HASH_MAX_SIZE</span></code> (macro)</h2> |
| 6135 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_HASH_MAX_SIZE 64</span> |
| 6136 | </pre></div> |
| 6137 | </div> |
| 6138 | <p>Maximum size of a hash.</p> |
| 6139 | <p>This macro must expand to a compile-time constant integer. This value should be the maximum size of a hash supported by the implementation, in bytes, and must be no smaller than this maximum.</p> |
| 6140 | </div> |
| 6141 | <div class="section" id="PSA_HMAC_MAX_HASH_BLOCK_SIZE"> |
| 6142 | <span id="c.PSA_HMAC_MAX_HASH_BLOCK_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_HMAC_MAX_HASH_BLOCK_SIZE</span></code> (macro)</h2> |
| 6143 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128</span> |
| 6144 | </pre></div> |
| 6145 | </div> |
| 6146 | </div> |
| 6147 | <div class="section" id="PSA_MAC_MAX_SIZE"> |
| 6148 | <span id="c.PSA_MAC_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAC_MAX_SIZE</span></code> (macro)</h2> |
| 6149 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAC_MAX_SIZE PSA_HASH_MAX_SIZE</span> |
| 6150 | </pre></div> |
| 6151 | </div> |
| 6152 | <p>Maximum size of a MAC.</p> |
| 6153 | <p>This macro must expand to a compile-time constant integer. This value should be the maximum size of a MAC supported by the implementation, in bytes, and must be no smaller than this maximum.</p> |
| 6154 | </div> |
| 6155 | <div class="section" id="PSA_AEAD_TAG_LENGTH"> |
| 6156 | <span id="c.PSA_AEAD_TAG_LENGTH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH</span></code> (macro)</h2> |
| 6157 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_TAG_LENGTH(alg) \</span> |
| 6158 | <span class="cp"> (PSA_ALG_IS_AEAD(alg) ? (((alg) & PSA_ALG_AEAD_TAG_LENGTH_MASK) >> PSA_AEAD_TAG_LENGTH_OFFSET) : 0)</span> |
| 6159 | </pre></div> |
| 6160 | </div> |
| 6161 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6162 | <dl class="docutils"> |
| 6163 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6164 | <dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 6165 | </dl> |
| 6166 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6167 | <p>The tag size for the specified algorithm. If the AEAD algorithm does not have an identified tag that can be distinguished from the rest of the ciphertext, return 0. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p> |
| 6168 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6169 | <p>The tag size for an AEAD algorithm, in bytes.</p> |
| 6170 | </div> |
| 6171 | <div class="section" id="PSA_VENDOR_RSA_MAX_KEY_BITS"> |
| 6172 | <span id="c.PSA_VENDOR_RSA_MAX_KEY_BITS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_VENDOR_RSA_MAX_KEY_BITS</span></code> (macro)</h2> |
| 6173 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_VENDOR_RSA_MAX_KEY_BITS 4096</span> |
| 6174 | </pre></div> |
| 6175 | </div> |
| 6176 | </div> |
| 6177 | <div class="section" id="PSA_VENDOR_ECC_MAX_CURVE_BITS"> |
| 6178 | <span id="c.PSA_VENDOR_ECC_MAX_CURVE_BITS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_VENDOR_ECC_MAX_CURVE_BITS</span></code> (macro)</h2> |
| 6179 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_VENDOR_ECC_MAX_CURVE_BITS 521</span> |
| 6180 | </pre></div> |
| 6181 | </div> |
| 6182 | </div> |
| 6183 | <div class="section" id="PSA_ECC_CURVE_BITS"> |
| 6184 | <span id="c.PSA_ECC_CURVE_BITS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BITS</span></code> (macro)</h2> |
| 6185 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_BITS(curve) </span><span class="cm">/*...*/</span><span class="cp"></span> |
| 6186 | </pre></div> |
| 6187 | </div> |
| 6188 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6189 | <dl class="docutils"> |
| 6190 | <dt> <code class="docutils literal notranslate"><span class="pre">curve</span></code></dt> |
| 6191 | <dd>An elliptic curve (value of type <a class="reference internal" href="#c.psa_ecc_curve_t" title="psa_ecc_curve_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_ecc_curve_t</span></code></a>).</dd> |
| 6192 | </dl> |
| 6193 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6194 | <p>The size associated with <code class="docutils literal notranslate"><span class="pre">curve</span></code>, in bits. This may be 0 if the implementation does not support the specified curve.</p> |
| 6195 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6196 | <p>Bit size associated with an elliptic curve.</p> |
| 6197 | </div> |
| 6198 | <div class="section" id="PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN"> |
| 6199 | <span id="c.PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN</span></code> (macro)</h2> |
| 6200 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN 128</span> |
| 6201 | </pre></div> |
| 6202 | </div> |
| 6203 | <p>This macro returns the maximum length of the PSK supported by the TLS-1.2 PSK-to-MS key derivation.</p> |
| 6204 | <p>Quoting RFC 4279, Sect 5.3: TLS implementations supporting these ciphersuites MUST support arbitrary PSK identities up to 128 octets in length, and arbitrary PSKs up to 64 octets in length. Supporting longer identities and keys is RECOMMENDED.</p> |
| 6205 | <p>Therefore, no implementation should define a value smaller than 64 for <a class="reference internal" href="#c.PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN" title="PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN</span></code></a>.</p> |
| 6206 | </div> |
| 6207 | <div class="section" id="PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE"> |
| 6208 | <span id="c.PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE</span></code> (macro)</h2> |
| 6209 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE \</span> |
| 6210 | <span class="cp"> PSA_BITS_TO_BYTES( PSA_VENDOR_RSA_MAX_KEY_BITS > PSA_VENDOR_ECC_MAX_CURVE_BITS ? PSA_VENDOR_RSA_MAX_KEY_BITS : PSA_VENDOR_ECC_MAX_CURVE_BITS )</span> |
| 6211 | </pre></div> |
| 6212 | </div> |
| 6213 | <p>Maximum size of an asymmetric signature.</p> |
| 6214 | <p>This macro must expand to a compile-time constant integer. This value should be the maximum size of a MAC supported by the implementation, in bytes, and must be no smaller than this maximum.</p> |
| 6215 | </div> |
| 6216 | <div class="section" id="PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE"> |
| 6217 | <span id="c.PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE</span></code> (macro)</h2> |
| 6218 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE 16</span> |
| 6219 | </pre></div> |
| 6220 | </div> |
| 6221 | <p>The maximum size of a block cipher supported by the implementation.</p> |
| 6222 | </div> |
| 6223 | <div class="section" id="PSA_MAC_FINAL_SIZE"> |
| 6224 | <span id="c.PSA_MAC_FINAL_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAC_FINAL_SIZE</span></code> (macro)</h2> |
| 6225 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAC_FINAL_SIZE(key_type, key_bits, alg) \</span> |
| 6226 | <span class="cp"> ((alg) & PSA_ALG_MAC_TRUNCATION_MASK ? PSA_MAC_TRUNCATED_LENGTH(alg) : PSA_ALG_IS_HMAC(alg) ? PSA_HASH_SIZE(PSA_ALG_HMAC_GET_HASH(alg)) : PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) ? PSA_BLOCK_CIPHER_BLOCK_SIZE(key_type) : ((void)(key_type), (void)(key_bits), 0))</span> |
| 6227 | </pre></div> |
| 6228 | </div> |
| 6229 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6230 | <dl class="docutils"> |
| 6231 | <dt> <code class="docutils literal notranslate"><span class="pre">key_type</span></code></dt> |
| 6232 | <dd>The type of the MAC key.</dd> |
| 6233 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6234 | <dd>The size of the MAC key in bits.</dd> |
| 6235 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6236 | <dd>A MAC algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 6237 | </dl> |
| 6238 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6239 | <p>The MAC size for the specified algorithm with the specified key parameters.</p> |
| 6240 | <p>0 if the MAC algorithm is not recognized.</p> |
| 6241 | <p>Either 0 or the correct size for a MAC algorithm that the implementation recognizes, but does not support.</p> |
| 6242 | <p>Unspecified if the key parameters are not consistent with the algorithm.</p> |
| 6243 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6244 | <p>The size of the output of <a class="reference internal" href="#c.psa_mac_sign_finish" title="psa_mac_sign_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_finish()</span></code></a>, in bytes.</p> |
| 6245 | <p>This is also the MAC size that <a class="reference internal" href="#c.psa_mac_verify_finish" title="psa_mac_verify_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_finish()</span></code></a> expects.</p> |
| 6246 | </div> |
| 6247 | <div class="section" id="PSA_AEAD_ENCRYPT_OUTPUT_SIZE"> |
| 6248 | <span id="c.PSA_AEAD_ENCRYPT_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_ENCRYPT_OUTPUT_SIZE</span></code> (macro)</h2> |
| 6249 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE(alg, plaintext_length) \</span> |
| 6250 | <span class="cp"> (PSA_AEAD_TAG_LENGTH(alg) != 0 ? (plaintext_length) + PSA_AEAD_TAG_LENGTH(alg) : 0)</span> |
| 6251 | </pre></div> |
| 6252 | </div> |
| 6253 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6254 | <dl class="docutils"> |
| 6255 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6256 | <dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 6257 | <dt> <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code></dt> |
| 6258 | <dd>Size of the plaintext in bytes.</dd> |
| 6259 | </dl> |
| 6260 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6261 | <p>The AEAD ciphertext size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p> |
| 6262 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6263 | <p>The maximum size of the output of <a class="reference internal" href="#c.psa_aead_encrypt" title="psa_aead_encrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt()</span></code></a>, in bytes.</p> |
| 6264 | <p>If the size of the ciphertext buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_aead_encrypt" title="psa_aead_encrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt()</span></code></a> will not fail due to an insufficient buffer size. Depending on the algorithm, the actual size of the ciphertext may be smaller.</p> |
| 6265 | </div> |
| 6266 | <div class="section" id="PSA_AEAD_DECRYPT_OUTPUT_SIZE"> |
| 6267 | <span id="c.PSA_AEAD_DECRYPT_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_DECRYPT_OUTPUT_SIZE</span></code> (macro)</h2> |
| 6268 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_DECRYPT_OUTPUT_SIZE(alg, ciphertext_length) \</span> |
| 6269 | <span class="cp"> (PSA_AEAD_TAG_LENGTH(alg) != 0 ? (ciphertext_length) - PSA_AEAD_TAG_LENGTH(alg) : 0)</span> |
| 6270 | </pre></div> |
| 6271 | </div> |
| 6272 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6273 | <dl class="docutils"> |
| 6274 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6275 | <dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 6276 | <dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_length</span></code></dt> |
| 6277 | <dd>Size of the plaintext in bytes.</dd> |
| 6278 | </dl> |
| 6279 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6280 | <p>The AEAD ciphertext size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p> |
| 6281 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6282 | <p>The maximum size of the output of <a class="reference internal" href="#c.psa_aead_decrypt" title="psa_aead_decrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt()</span></code></a>, in bytes.</p> |
| 6283 | <p>If the size of the plaintext buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_aead_decrypt" title="psa_aead_decrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt()</span></code></a> will not fail due to an insufficient buffer size. Depending on the algorithm, the actual size of the plaintext may be smaller.</p> |
| 6284 | </div> |
| 6285 | <div class="section" id="PSA_AEAD_UPDATE_OUTPUT_SIZE"> |
| 6286 | <span id="c.PSA_AEAD_UPDATE_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_UPDATE_OUTPUT_SIZE</span></code> (macro)</h2> |
| 6287 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_UPDATE_OUTPUT_SIZE(alg, input_length) \</span> |
| 6288 | <span class="cp"> (PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? PSA_ROUND_UP_TO_MULTIPLE(PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE, (input_length)) : (input_length))</span> |
| 6289 | </pre></div> |
| 6290 | </div> |
| 6291 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6292 | <dl class="docutils"> |
| 6293 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6294 | <dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 6295 | <dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt> |
| 6296 | <dd>Size of the input in bytes.</dd> |
| 6297 | </dl> |
| 6298 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6299 | <p>A sufficient output buffer size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p> |
| 6300 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6301 | <p>A sufficient output buffer size for <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>.</p> |
| 6302 | <p>If the size of the output buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> will not fail due to an insufficient buffer size. The actual size of the output may be smaller in any given call.</p> |
| 6303 | </div> |
| 6304 | <div class="section" id="PSA_AEAD_FINISH_OUTPUT_SIZE"> |
| 6305 | <span id="c.PSA_AEAD_FINISH_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_FINISH_OUTPUT_SIZE</span></code> (macro)</h2> |
| 6306 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_FINISH_OUTPUT_SIZE(alg) \</span> |
| 6307 | <span class="cp"> (PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE : 0)</span> |
| 6308 | </pre></div> |
| 6309 | </div> |
| 6310 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6311 | <dl class="docutils"> |
| 6312 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6313 | <dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 6314 | </dl> |
| 6315 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6316 | <p>A sufficient ciphertext buffer size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p> |
| 6317 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6318 | <p>A sufficient ciphertext buffer size for <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a>.</p> |
| 6319 | <p>If the size of the ciphertext buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a> will not fail due to an insufficient ciphertext buffer size. The actual size of the output may be smaller in any given call.</p> |
| 6320 | </div> |
| 6321 | <div class="section" id="PSA_AEAD_VERIFY_OUTPUT_SIZE"> |
| 6322 | <span id="c.PSA_AEAD_VERIFY_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_VERIFY_OUTPUT_SIZE</span></code> (macro)</h2> |
| 6323 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_VERIFY_OUTPUT_SIZE(alg) \</span> |
| 6324 | <span class="cp"> (PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE : 0)</span> |
| 6325 | </pre></div> |
| 6326 | </div> |
| 6327 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6328 | <dl class="docutils"> |
| 6329 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6330 | <dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd> |
| 6331 | </dl> |
| 6332 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6333 | <p>A sufficient plaintext buffer size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p> |
| 6334 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6335 | <p>A sufficient plaintext buffer size for <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a>.</p> |
| 6336 | <p>If the size of the plaintext buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> will not fail due to an insufficient plaintext buffer size. The actual size of the output may be smaller in any given call.</p> |
| 6337 | </div> |
| 6338 | <div class="section" id="PSA_RSA_MINIMUM_PADDING_SIZE"> |
| 6339 | <span id="c.PSA_RSA_MINIMUM_PADDING_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_RSA_MINIMUM_PADDING_SIZE</span></code> (macro)</h2> |
| 6340 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_RSA_MINIMUM_PADDING_SIZE(alg) \</span> |
| 6341 | <span class="cp"> (PSA_ALG_IS_RSA_OAEP(alg) ? 2 * PSA_HASH_SIZE(PSA_ALG_RSA_OAEP_GET_HASH(alg)) + 1 : 11 </span><span class="cm">/*PKCS#1v1.5*/</span><span class="cp">)</span> |
| 6342 | </pre></div> |
| 6343 | </div> |
| 6344 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6345 | <dl class="docutils"> |
| 6346 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6347 | <dd></dd> |
| 6348 | </dl> |
| 6349 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6350 | </div> |
| 6351 | <div class="section" id="PSA_ECDSA_SIGNATURE_SIZE"> |
| 6352 | <span id="c.PSA_ECDSA_SIGNATURE_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECDSA_SIGNATURE_SIZE</span></code> (macro)</h2> |
| 6353 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECDSA_SIGNATURE_SIZE(curve_bits) \</span> |
| 6354 | <span class="cp"> (PSA_BITS_TO_BYTES(curve_bits) * 2)</span> |
| 6355 | </pre></div> |
| 6356 | </div> |
| 6357 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6358 | <dl class="docutils"> |
| 6359 | <dt> <code class="docutils literal notranslate"><span class="pre">curve_bits</span></code></dt> |
| 6360 | <dd>Curve size in bits.</dd> |
| 6361 | </dl> |
| 6362 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6363 | <p>Signature size in bytes.</p> |
| 6364 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6365 | <p>ECDSA signature size for a given curve bit size.</p> |
| 6366 | <div class="admonition note"> |
| 6367 | <p class="first admonition-title">Note</p> |
| 6368 | <p class="last">This macro returns a compile-time constant if its argument is one.</p> |
| 6369 | </div> |
| 6370 | </div> |
| 6371 | <div class="section" id="PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE"> |
| 6372 | <span id="c.PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE</span></code> (macro)</h2> |
| 6373 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE(key_type, key_bits, alg) \</span> |
| 6374 | <span class="cp"> (PSA_KEY_TYPE_IS_RSA(key_type) ? ((void)alg, PSA_BITS_TO_BYTES(key_bits)) : PSA_KEY_TYPE_IS_ECC(key_type) ? PSA_ECDSA_SIGNATURE_SIZE(key_bits) : ((void)alg, 0))</span> |
| 6375 | </pre></div> |
| 6376 | </div> |
| 6377 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6378 | <dl class="docutils"> |
| 6379 | <dt> <code class="docutils literal notranslate"><span class="pre">key_type</span></code></dt> |
| 6380 | <dd>An asymmetric key type (this may indifferently be a key pair type or a public key type).</dd> |
| 6381 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6382 | <dd>The size of the key in bits.</dd> |
| 6383 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6384 | <dd>The signature algorithm.</dd> |
| 6385 | </dl> |
| 6386 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6387 | <p>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="reference internal" href="#c.psa_asymmetric_sign" title="psa_asymmetric_sign"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_sign()</span></code></a> will not fail with <a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a>. If the parameters are a valid combination that is not supported by the implementation, this macro shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.</p> |
| 6388 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6389 | <p>Sufficient signature buffer size for <a class="reference internal" href="#c.psa_asymmetric_sign" title="psa_asymmetric_sign"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_sign()</span></code></a>.</p> |
| 6390 | <p>This macro returns a sufficient buffer size for a signature using a key of the specified type and size, with the specified algorithm. Note that the actual size of the signature may be smaller (some algorithms produce a variable-size signature).</p> |
| 6391 | <div class="admonition warning"> |
| 6392 | <p class="first admonition-title">Warning</p> |
| 6393 | <p class="last">This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</p> |
| 6394 | </div> |
| 6395 | </div> |
| 6396 | <div class="section" id="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE"> |
| 6397 | <span id="c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</span></code> (macro)</h2> |
| 6398 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE(key_type, key_bits, alg) \</span> |
| 6399 | <span class="cp"> (PSA_KEY_TYPE_IS_RSA(key_type) ? ((void)alg, PSA_BITS_TO_BYTES(key_bits)) : 0)</span> |
| 6400 | </pre></div> |
| 6401 | </div> |
| 6402 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6403 | <dl class="docutils"> |
| 6404 | <dt> <code class="docutils literal notranslate"><span class="pre">key_type</span></code></dt> |
| 6405 | <dd>An asymmetric key type (this may indifferently be a key pair type or a public key type).</dd> |
| 6406 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6407 | <dd>The size of the key in bits.</dd> |
| 6408 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6409 | <dd>The signature algorithm.</dd> |
| 6410 | </dl> |
| 6411 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6412 | <p>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="reference internal" href="#c.psa_asymmetric_encrypt" title="psa_asymmetric_encrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_encrypt()</span></code></a> will not fail with <a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a>. If the parameters are a valid combination that is not supported by the implementation, this macro shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.</p> |
| 6413 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6414 | <p>Sufficient output buffer size for <a class="reference internal" href="#c.psa_asymmetric_encrypt" title="psa_asymmetric_encrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_encrypt()</span></code></a>.</p> |
| 6415 | <p>This macro returns a sufficient buffer size for a ciphertext produced using a key of the specified type and size, with the specified algorithm. Note that the actual size of the ciphertext may be smaller, depending on the algorithm.</p> |
| 6416 | <div class="admonition warning"> |
| 6417 | <p class="first admonition-title">Warning</p> |
| 6418 | <p class="last">This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</p> |
| 6419 | </div> |
| 6420 | </div> |
| 6421 | <div class="section" id="PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE"> |
| 6422 | <span id="c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</span></code> (macro)</h2> |
| 6423 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE(key_type, key_bits, alg) \</span> |
| 6424 | <span class="cp"> (PSA_KEY_TYPE_IS_RSA(key_type) ? PSA_BITS_TO_BYTES(key_bits) - PSA_RSA_MINIMUM_PADDING_SIZE(alg) : 0)</span> |
| 6425 | </pre></div> |
| 6426 | </div> |
| 6427 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6428 | <dl class="docutils"> |
| 6429 | <dt> <code class="docutils literal notranslate"><span class="pre">key_type</span></code></dt> |
| 6430 | <dd>An asymmetric key type (this may indifferently be a key pair type or a public key type).</dd> |
| 6431 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6432 | <dd>The size of the key in bits.</dd> |
| 6433 | <dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt> |
| 6434 | <dd>The signature algorithm.</dd> |
| 6435 | </dl> |
| 6436 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6437 | <p>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="reference internal" href="#c.psa_asymmetric_decrypt" title="psa_asymmetric_decrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_decrypt()</span></code></a> will not fail with <a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a>. If the parameters are a valid combination that is not supported by the implementation, this macro shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.</p> |
| 6438 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6439 | <p>Sufficient output buffer size for <a class="reference internal" href="#c.psa_asymmetric_decrypt" title="psa_asymmetric_decrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_decrypt()</span></code></a>.</p> |
| 6440 | <p>This macro returns a sufficient buffer size for a ciphertext produced using a key of the specified type and size, with the specified algorithm. Note that the actual size of the ciphertext may be smaller, depending on the algorithm.</p> |
| 6441 | <div class="admonition warning"> |
| 6442 | <p class="first admonition-title">Warning</p> |
| 6443 | <p class="last">This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</p> |
| 6444 | </div> |
| 6445 | </div> |
| 6446 | <div class="section" id="PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE"> |
| 6447 | <span id="c.PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE</span></code> (macro)</h2> |
| 6448 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(bits) ((bits) / 8 + 5)</span> |
| 6449 | </pre></div> |
| 6450 | </div> |
| 6451 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6452 | <dl class="docutils"> |
| 6453 | <dt> <code class="docutils literal notranslate"><span class="pre">bits</span></code></dt> |
| 6454 | <dd></dd> |
| 6455 | </dl> |
| 6456 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6457 | </div> |
| 6458 | <div class="section" id="PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE"> |
| 6459 | <span id="c.PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</h2> |
| 6460 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(key_bits) \</span> |
| 6461 | <span class="cp"> (PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(key_bits) + 11)</span> |
| 6462 | </pre></div> |
| 6463 | </div> |
| 6464 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6465 | <dl class="docutils"> |
| 6466 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6467 | <dd></dd> |
| 6468 | </dl> |
| 6469 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6470 | </div> |
| 6471 | <div class="section" id="PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE"> |
| 6472 | <span id="c.PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE</span></code> (macro)</h2> |
| 6473 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(key_bits) \</span> |
| 6474 | <span class="cp"> (9 * PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE((key_bits) / 2 + 1) + 14)</span> |
| 6475 | </pre></div> |
| 6476 | </div> |
| 6477 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6478 | <dl class="docutils"> |
| 6479 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6480 | <dd></dd> |
| 6481 | </dl> |
| 6482 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6483 | </div> |
| 6484 | <div class="section" id="PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE"> |
| 6485 | <span id="c.PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</h2> |
| 6486 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE(key_bits) \</span> |
| 6487 | <span class="cp"> (PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(key_bits) * 3 + 59)</span> |
| 6488 | </pre></div> |
| 6489 | </div> |
| 6490 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6491 | <dl class="docutils"> |
| 6492 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6493 | <dd></dd> |
| 6494 | </dl> |
| 6495 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6496 | </div> |
| 6497 | <div class="section" id="PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE"> |
| 6498 | <span id="c.PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE</span></code> (macro)</h2> |
| 6499 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE(key_bits) \</span> |
| 6500 | <span class="cp"> (PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(key_bits) * 3 + 75)</span> |
| 6501 | </pre></div> |
| 6502 | </div> |
| 6503 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6504 | <dl class="docutils"> |
| 6505 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6506 | <dd></dd> |
| 6507 | </dl> |
| 6508 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6509 | </div> |
| 6510 | <div class="section" id="PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE"> |
| 6511 | <span id="c.PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</h2> |
| 6512 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) \</span> |
| 6513 | <span class="cp"> (2 * PSA_BITS_TO_BYTES(key_bits) + 1)</span> |
| 6514 | </pre></div> |
| 6515 | </div> |
| 6516 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6517 | <dl class="docutils"> |
| 6518 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6519 | <dd></dd> |
| 6520 | </dl> |
| 6521 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6522 | </div> |
| 6523 | <div class="section" id="PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE"> |
| 6524 | <span id="c.PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE</span></code> (macro)</h2> |
| 6525 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) \</span> |
| 6526 | <span class="cp"> (PSA_BITS_TO_BYTES(key_bits))</span> |
| 6527 | </pre></div> |
| 6528 | </div> |
| 6529 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6530 | <dl class="docutils"> |
| 6531 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6532 | <dd></dd> |
| 6533 | </dl> |
| 6534 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6535 | </div> |
| 6536 | <div class="section" id="PSA_KEY_EXPORT_MAX_SIZE"> |
| 6537 | <span id="c.PSA_KEY_EXPORT_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_MAX_SIZE</span></code> (macro)</h2> |
| 6538 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_MAX_SIZE(key_type, key_bits) \</span> |
| 6539 | <span class="cp"> (PSA_KEY_TYPE_IS_UNSTRUCTURED(key_type) ? PSA_BITS_TO_BYTES(key_bits) : (key_type) == PSA_KEY_TYPE_RSA_KEY_PAIR ? PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(key_bits) : (key_type) == PSA_KEY_TYPE_RSA_PUBLIC_KEY ? PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(key_bits) : (key_type) == PSA_KEY_TYPE_DSA_KEY_PAIR ? PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE(key_bits) : (key_type) == PSA_KEY_TYPE_DSA_PUBLIC_KEY ? PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE(key_bits) : PSA_KEY_TYPE_IS_ECC_KEY_PAIR(key_type) ? PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) : PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(key_type) ? PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) : 0)</span> |
| 6540 | </pre></div> |
| 6541 | </div> |
| 6542 | <p class="subitem-title"><strong>Parameters:</strong> </p> |
| 6543 | <dl class="docutils"> |
| 6544 | <dt> <code class="docutils literal notranslate"><span class="pre">key_type</span></code></dt> |
| 6545 | <dd>A supported key type.</dd> |
| 6546 | <dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt> |
| 6547 | <dd>The size of the key in bits.</dd> |
| 6548 | </dl> |
| 6549 | <p class="subitem-title"><strong>Returns:</strong> </p> |
| 6550 | <p>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="reference internal" href="#c.psa_asymmetric_sign" title="psa_asymmetric_sign"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_sign()</span></code></a> will not fail with <a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a>. If the parameters are a valid combination that is not supported by the implementation, this macro shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.</p> |
| 6551 | <p class="subitem-title"><strong>Description:</strong></p> |
| 6552 | <p>Sufficient output buffer size for <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a> or <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a>.</p> |
| 6553 | <p>This macro returns a compile-time constant if its arguments are compile-time constants.</p> |
| 6554 | <div class="admonition warning"> |
| 6555 | <p class="first admonition-title">Warning</p> |
| 6556 | <p class="last">This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</p> |
| 6557 | </div> |
| 6558 | <p>The following code illustrates how to allocate enough memory to export a key by querying the key type and size at runtime.</p> |
| 6559 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span> <span class="o">=</span> <span class="n">PSA_KEY_ATTRIBUTES_INIT</span><span class="p">;</span> |
| 6560 | <span class="n">psa_status_t</span> <span class="n">status</span><span class="p">;</span> |
| 6561 | <span class="n">status</span> <span class="o">=</span> <span class="n">psa_get_key_attributes</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="o">&</span><span class="n">attributes</span><span class="p">);</span> |
| 6562 | <span class="k">if</span> <span class="p">(</span><span class="n">status</span> <span class="o">!=</span> <span class="n">PSA_SUCCESS</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span> |
| 6563 | <span class="n">psa_key_type_t</span> <span class="n">key_type</span> <span class="o">=</span> <span class="n">psa_get_key_type</span><span class="p">(</span><span class="o">&</span><span class="n">attributes</span><span class="p">);</span> |
| 6564 | <span class="kt">size_t</span> <span class="n">key_bits</span> <span class="o">=</span> <span class="n">psa_get_key_bits</span><span class="p">(</span><span class="o">&</span><span class="n">attributes</span><span class="p">);</span> |
| 6565 | <span class="kt">size_t</span> <span class="n">buffer_size</span> <span class="o">=</span> <span class="n">PSA_KEY_EXPORT_MAX_SIZE</span><span class="p">(</span><span class="n">key_type</span><span class="p">,</span> <span class="n">key_bits</span><span class="p">);</span> |
| 6566 | <span class="n">psa_reset_key_attributes</span><span class="p">(</span><span class="o">&</span><span class="n">attributes</span><span class="p">);</span> |
| 6567 | <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span><span class="n">buffer</span> <span class="o">=</span> <span class="n">malloc</span><span class="p">(</span><span class="n">buffer_size</span><span class="p">);</span> |
| 6568 | <span class="k">if</span> <span class="p">(</span><span class="n">buffer</span> <span class="o">==</span> <span class="nb">NULL</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span> |
| 6569 | <span class="kt">size_t</span> <span class="n">buffer_length</span><span class="p">;</span> |
| 6570 | <span class="n">status</span> <span class="o">=</span> <span class="n">psa_export_key</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">buffer</span><span class="p">,</span> <span class="n">buffer_size</span><span class="p">,</span> <span class="o">&</span><span class="n">buffer_length</span><span class="p">);</span> |
| 6571 | <span class="k">if</span> <span class="p">(</span><span class="n">status</span> <span class="o">!=</span> <span class="n">PSA_SUCCESS</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span> |
| 6572 | </pre></div> |
| 6573 | </div> |
| 6574 | <p>For <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a>, calculate the buffer size from the public key type. You can use the macro <a class="reference internal" href="#c.PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR" title="PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span></code></a> to convert a key pair type to the corresponding public key type.</p> |
| 6575 | <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span> <span class="o">=</span> <span class="n">PSA_KEY_ATTRIBUTES_INIT</span><span class="p">;</span> |
| 6576 | <span class="n">psa_status_t</span> <span class="n">status</span><span class="p">;</span> |
| 6577 | <span class="n">status</span> <span class="o">=</span> <span class="n">psa_get_key_attributes</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="o">&</span><span class="n">attributes</span><span class="p">);</span> |
| 6578 | <span class="k">if</span> <span class="p">(</span><span class="n">status</span> <span class="o">!=</span> <span class="n">PSA_SUCCESS</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span> |
| 6579 | <span class="n">psa_key_type_t</span> <span class="n">key_type</span> <span class="o">=</span> <span class="n">psa_get_key_type</span><span class="p">(</span><span class="o">&</span><span class="n">attributes</span><span class="p">);</span> |
| 6580 | <span class="n">psa_key_type_t</span> <span class="n">public_key_type</span> <span class="o">=</span> <span class="n">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span><span class="p">(</span><span class="n">key_type</span><span class="p">);</span> |
| 6581 | <span class="kt">size_t</span> <span class="n">key_bits</span> <span class="o">=</span> <span class="n">psa_get_key_bits</span><span class="p">(</span><span class="o">&</span><span class="n">attributes</span><span class="p">);</span> |
| 6582 | <span class="kt">size_t</span> <span class="n">buffer_size</span> <span class="o">=</span> <span class="n">PSA_KEY_EXPORT_MAX_SIZE</span><span class="p">(</span><span class="n">public_key_type</span><span class="p">,</span> <span class="n">key_bits</span><span class="p">);</span> |
| 6583 | <span class="n">psa_reset_key_attributes</span><span class="p">(</span><span class="o">&</span><span class="n">attributes</span><span class="p">);</span> |
| 6584 | <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span><span class="n">buffer</span> <span class="o">=</span> <span class="n">malloc</span><span class="p">(</span><span class="n">buffer_size</span><span class="p">);</span> |
| 6585 | <span class="k">if</span> <span class="p">(</span><span class="n">buffer</span> <span class="o">==</span> <span class="nb">NULL</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span> |
| 6586 | <span class="kt">size_t</span> <span class="n">buffer_length</span><span class="p">;</span> |
| 6587 | <span class="n">status</span> <span class="o">=</span> <span class="n">psa_export_public_key</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">buffer</span><span class="p">,</span> <span class="n">buffer_size</span><span class="p">,</span> <span class="o">&</span><span class="n">buffer_length</span><span class="p">);</span> |
| 6588 | <span class="k">if</span> <span class="p">(</span><span class="n">status</span> <span class="o">!=</span> <span class="n">PSA_SUCCESS</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span> |
| 6589 | </pre></div> |
| 6590 | </div> |
| 6591 | </div> |
| 6592 | </div> |
| 6593 | |
| 6594 | |
| 6595 | </div> |
| 6596 | |
| 6597 | </div> |
| 6598 | </div> |
| 6599 | <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> |
| 6600 | <div class="sphinxsidebarwrapper"> |
| 6601 | <h1 class="logo"><a href="index.html">psa_crypto_api</a></h1> |
| 6602 | |
| 6603 | |
| 6604 | |
| 6605 | |
| 6606 | |
| 6607 | |
| 6608 | |
| 6609 | |
| 6610 | <h3>Navigation</h3> |
| 6611 | <ul class="current"> |
| 6612 | <li class="toctree-l1"><a class="reference internal" href="general.html">Introduction</a></li> |
| 6613 | <li class="toctree-l1"><a class="reference internal" href="general.html#design-goals">Design goals</a></li> |
| 6614 | <li class="toctree-l1"><a class="reference internal" href="general.html#functionality-overview">Functionality overview</a></li> |
| 6615 | <li class="toctree-l1"><a class="reference internal" href="general.html#sample-architectures">Sample architectures</a></li> |
| 6616 | <li class="toctree-l1"><a class="reference internal" href="general.html#library-conventions">Library conventions</a></li> |
| 6617 | <li class="toctree-l1"><a class="reference internal" href="general.html#implementation-considerations">Implementation considerations</a></li> |
| 6618 | <li class="toctree-l1"><a class="reference internal" href="general.html#usage-considerations">Usage considerations</a></li> |
| 6619 | <li class="toctree-l1 current"><a class="current reference internal" href="#">Implementation-specific definitions</a><ul> |
| 6620 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_handle_t"><code class="docutils literal notranslate"><span class="pre">psa_key_handle_t</span></code> (type)</a></li> |
| 6621 | </ul> |
| 6622 | </li> |
| 6623 | <li class="toctree-l1"><a class="reference internal" href="#library-initialization">Library initialization</a><ul> |
| 6624 | <li class="toctree-l2"><a class="reference internal" href="#psa_crypto_init"><code class="docutils literal notranslate"><span class="pre">psa_crypto_init</span></code> (function)</a></li> |
| 6625 | </ul> |
| 6626 | </li> |
| 6627 | <li class="toctree-l1"><a class="reference internal" href="#key-attributes">Key attributes</a><ul> |
| 6628 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_attributes_t"><code class="docutils literal notranslate"><span class="pre">psa_key_attributes_t</span></code> (type)</a></li> |
| 6629 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_ATTRIBUTES_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ATTRIBUTES_INIT</span></code> (macro)</a></li> |
| 6630 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_attributes_init"><code class="docutils literal notranslate"><span class="pre">psa_key_attributes_init</span></code> (function)</a></li> |
| 6631 | <li class="toctree-l2"><a class="reference internal" href="#psa_set_key_id"><code class="docutils literal notranslate"><span class="pre">psa_set_key_id</span></code> (function)</a></li> |
| 6632 | <li class="toctree-l2"><a class="reference internal" href="#psa_set_key_lifetime"><code class="docutils literal notranslate"><span class="pre">psa_set_key_lifetime</span></code> (function)</a></li> |
| 6633 | <li class="toctree-l2"><a class="reference internal" href="#psa_get_key_id"><code class="docutils literal notranslate"><span class="pre">psa_get_key_id</span></code> (function)</a></li> |
| 6634 | <li class="toctree-l2"><a class="reference internal" href="#psa_get_key_lifetime"><code class="docutils literal notranslate"><span class="pre">psa_get_key_lifetime</span></code> (function)</a></li> |
| 6635 | <li class="toctree-l2"><a class="reference internal" href="#psa_set_key_usage_flags"><code class="docutils literal notranslate"><span class="pre">psa_set_key_usage_flags</span></code> (function)</a></li> |
| 6636 | <li class="toctree-l2"><a class="reference internal" href="#psa_get_key_usage_flags"><code class="docutils literal notranslate"><span class="pre">psa_get_key_usage_flags</span></code> (function)</a></li> |
| 6637 | <li class="toctree-l2"><a class="reference internal" href="#psa_set_key_algorithm"><code class="docutils literal notranslate"><span class="pre">psa_set_key_algorithm</span></code> (function)</a></li> |
| 6638 | <li class="toctree-l2"><a class="reference internal" href="#psa_get_key_algorithm"><code class="docutils literal notranslate"><span class="pre">psa_get_key_algorithm</span></code> (function)</a></li> |
| 6639 | <li class="toctree-l2"><a class="reference internal" href="#psa_set_key_type"><code class="docutils literal notranslate"><span class="pre">psa_set_key_type</span></code> (function)</a></li> |
| 6640 | <li class="toctree-l2"><a class="reference internal" href="#psa_set_key_bits"><code class="docutils literal notranslate"><span class="pre">psa_set_key_bits</span></code> (function)</a></li> |
| 6641 | <li class="toctree-l2"><a class="reference internal" href="#psa_get_key_type"><code class="docutils literal notranslate"><span class="pre">psa_get_key_type</span></code> (function)</a></li> |
| 6642 | <li class="toctree-l2"><a class="reference internal" href="#psa_get_key_bits"><code class="docutils literal notranslate"><span class="pre">psa_get_key_bits</span></code> (function)</a></li> |
| 6643 | <li class="toctree-l2"><a class="reference internal" href="#psa_get_key_attributes"><code class="docutils literal notranslate"><span class="pre">psa_get_key_attributes</span></code> (function)</a></li> |
| 6644 | <li class="toctree-l2"><a class="reference internal" href="#psa_reset_key_attributes"><code class="docutils literal notranslate"><span class="pre">psa_reset_key_attributes</span></code> (function)</a></li> |
| 6645 | </ul> |
| 6646 | </li> |
| 6647 | <li class="toctree-l1"><a class="reference internal" href="#key-management">Key management</a><ul> |
| 6648 | <li class="toctree-l2"><a class="reference internal" href="#psa_open_key"><code class="docutils literal notranslate"><span class="pre">psa_open_key</span></code> (function)</a></li> |
| 6649 | <li class="toctree-l2"><a class="reference internal" href="#psa_close_key"><code class="docutils literal notranslate"><span class="pre">psa_close_key</span></code> (function)</a></li> |
| 6650 | </ul> |
| 6651 | </li> |
| 6652 | <li class="toctree-l1"><a class="reference internal" href="#key-import-and-export">Key import and export</a><ul> |
| 6653 | <li class="toctree-l2"><a class="reference internal" href="#psa_import_key"><code class="docutils literal notranslate"><span class="pre">psa_import_key</span></code> (function)</a></li> |
| 6654 | <li class="toctree-l2"><a class="reference internal" href="#psa_destroy_key"><code class="docutils literal notranslate"><span class="pre">psa_destroy_key</span></code> (function)</a></li> |
| 6655 | <li class="toctree-l2"><a class="reference internal" href="#psa_export_key"><code class="docutils literal notranslate"><span class="pre">psa_export_key</span></code> (function)</a></li> |
| 6656 | <li class="toctree-l2"><a class="reference internal" href="#psa_export_public_key"><code class="docutils literal notranslate"><span class="pre">psa_export_public_key</span></code> (function)</a></li> |
| 6657 | <li class="toctree-l2"><a class="reference internal" href="#psa_copy_key"><code class="docutils literal notranslate"><span class="pre">psa_copy_key</span></code> (function)</a></li> |
| 6658 | </ul> |
| 6659 | </li> |
| 6660 | <li class="toctree-l1"><a class="reference internal" href="#message-digests">Message digests</a><ul> |
| 6661 | <li class="toctree-l2"><a class="reference internal" href="#psa_hash_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code> (type)</a></li> |
| 6662 | <li class="toctree-l2"><a class="reference internal" href="#PSA_HASH_OPERATION_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_HASH_OPERATION_INIT</span></code> (macro)</a></li> |
| 6663 | <li class="toctree-l2"><a class="reference internal" href="#psa_hash_compute"><code class="docutils literal notranslate"><span class="pre">psa_hash_compute</span></code> (function)</a></li> |
| 6664 | <li class="toctree-l2"><a class="reference internal" href="#psa_hash_compare"><code class="docutils literal notranslate"><span class="pre">psa_hash_compare</span></code> (function)</a></li> |
| 6665 | <li class="toctree-l2"><a class="reference internal" href="#psa_hash_operation_init"><code class="docutils literal notranslate"><span class="pre">psa_hash_operation_init</span></code> (function)</a></li> |
| 6666 | <li class="toctree-l2"><a class="reference internal" href="#psa_hash_setup"><code class="docutils literal notranslate"><span class="pre">psa_hash_setup</span></code> (function)</a></li> |
| 6667 | <li class="toctree-l2"><a class="reference internal" href="#psa_hash_update"><code class="docutils literal notranslate"><span class="pre">psa_hash_update</span></code> (function)</a></li> |
| 6668 | <li class="toctree-l2"><a class="reference internal" href="#psa_hash_finish"><code class="docutils literal notranslate"><span class="pre">psa_hash_finish</span></code> (function)</a></li> |
| 6669 | <li class="toctree-l2"><a class="reference internal" href="#psa_hash_verify"><code class="docutils literal notranslate"><span class="pre">psa_hash_verify</span></code> (function)</a></li> |
| 6670 | <li class="toctree-l2"><a class="reference internal" href="#psa_hash_abort"><code class="docutils literal notranslate"><span class="pre">psa_hash_abort</span></code> (function)</a></li> |
| 6671 | <li class="toctree-l2"><a class="reference internal" href="#psa_hash_clone"><code class="docutils literal notranslate"><span class="pre">psa_hash_clone</span></code> (function)</a></li> |
| 6672 | </ul> |
| 6673 | </li> |
| 6674 | <li class="toctree-l1"><a class="reference internal" href="#message-authentication-codes">Message authentication codes</a><ul> |
| 6675 | <li class="toctree-l2"><a class="reference internal" href="#psa_mac_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code> (type)</a></li> |
| 6676 | <li class="toctree-l2"><a class="reference internal" href="#PSA_MAC_OPERATION_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_MAC_OPERATION_INIT</span></code> (macro)</a></li> |
| 6677 | <li class="toctree-l2"><a class="reference internal" href="#psa_mac_compute"><code class="docutils literal notranslate"><span class="pre">psa_mac_compute</span></code> (function)</a></li> |
| 6678 | <li class="toctree-l2"><a class="reference internal" href="#psa_mac_verify"><code class="docutils literal notranslate"><span class="pre">psa_mac_verify</span></code> (function)</a></li> |
| 6679 | <li class="toctree-l2"><a class="reference internal" href="#psa_mac_operation_init"><code class="docutils literal notranslate"><span class="pre">psa_mac_operation_init</span></code> (function)</a></li> |
| 6680 | <li class="toctree-l2"><a class="reference internal" href="#psa_mac_sign_setup"><code class="docutils literal notranslate"><span class="pre">psa_mac_sign_setup</span></code> (function)</a></li> |
| 6681 | <li class="toctree-l2"><a class="reference internal" href="#psa_mac_verify_setup"><code class="docutils literal notranslate"><span class="pre">psa_mac_verify_setup</span></code> (function)</a></li> |
| 6682 | <li class="toctree-l2"><a class="reference internal" href="#psa_mac_update"><code class="docutils literal notranslate"><span class="pre">psa_mac_update</span></code> (function)</a></li> |
| 6683 | <li class="toctree-l2"><a class="reference internal" href="#psa_mac_sign_finish"><code class="docutils literal notranslate"><span class="pre">psa_mac_sign_finish</span></code> (function)</a></li> |
| 6684 | <li class="toctree-l2"><a class="reference internal" href="#psa_mac_verify_finish"><code class="docutils literal notranslate"><span class="pre">psa_mac_verify_finish</span></code> (function)</a></li> |
| 6685 | <li class="toctree-l2"><a class="reference internal" href="#psa_mac_abort"><code class="docutils literal notranslate"><span class="pre">psa_mac_abort</span></code> (function)</a></li> |
| 6686 | </ul> |
| 6687 | </li> |
| 6688 | <li class="toctree-l1"><a class="reference internal" href="#symmetric-ciphers">Symmetric ciphers</a><ul> |
| 6689 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code> (type)</a></li> |
| 6690 | <li class="toctree-l2"><a class="reference internal" href="#PSA_CIPHER_OPERATION_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_CIPHER_OPERATION_INIT</span></code> (macro)</a></li> |
| 6691 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_encrypt"><code class="docutils literal notranslate"><span class="pre">psa_cipher_encrypt</span></code> (function)</a></li> |
| 6692 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_decrypt"><code class="docutils literal notranslate"><span class="pre">psa_cipher_decrypt</span></code> (function)</a></li> |
| 6693 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_operation_init"><code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_init</span></code> (function)</a></li> |
| 6694 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_encrypt_setup"><code class="docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup</span></code> (function)</a></li> |
| 6695 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_decrypt_setup"><code class="docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup</span></code> (function)</a></li> |
| 6696 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_generate_iv"><code class="docutils literal notranslate"><span class="pre">psa_cipher_generate_iv</span></code> (function)</a></li> |
| 6697 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_set_iv"><code class="docutils literal notranslate"><span class="pre">psa_cipher_set_iv</span></code> (function)</a></li> |
| 6698 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_update"><code class="docutils literal notranslate"><span class="pre">psa_cipher_update</span></code> (function)</a></li> |
| 6699 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_finish"><code class="docutils literal notranslate"><span class="pre">psa_cipher_finish</span></code> (function)</a></li> |
| 6700 | <li class="toctree-l2"><a class="reference internal" href="#psa_cipher_abort"><code class="docutils literal notranslate"><span class="pre">psa_cipher_abort</span></code> (function)</a></li> |
| 6701 | </ul> |
| 6702 | </li> |
| 6703 | <li class="toctree-l1"><a class="reference internal" href="#authenticated-encryption-with-associated-data-aead">Authenticated encryption with associated data (AEAD)</a><ul> |
| 6704 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code> (type)</a></li> |
| 6705 | <li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_OPERATION_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_OPERATION_INIT</span></code> (macro)</a></li> |
| 6706 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_encrypt"><code class="docutils literal notranslate"><span class="pre">psa_aead_encrypt</span></code> (function)</a></li> |
| 6707 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_decrypt"><code class="docutils literal notranslate"><span class="pre">psa_aead_decrypt</span></code> (function)</a></li> |
| 6708 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_operation_init"><code class="docutils literal notranslate"><span class="pre">psa_aead_operation_init</span></code> (function)</a></li> |
| 6709 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_encrypt_setup"><code class="docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup</span></code> (function)</a></li> |
| 6710 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_decrypt_setup"><code class="docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup</span></code> (function)</a></li> |
| 6711 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_generate_nonce"><code class="docutils literal notranslate"><span class="pre">psa_aead_generate_nonce</span></code> (function)</a></li> |
| 6712 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_set_nonce"><code class="docutils literal notranslate"><span class="pre">psa_aead_set_nonce</span></code> (function)</a></li> |
| 6713 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_set_lengths"><code class="docutils literal notranslate"><span class="pre">psa_aead_set_lengths</span></code> (function)</a></li> |
| 6714 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_update_ad"><code class="docutils literal notranslate"><span class="pre">psa_aead_update_ad</span></code> (function)</a></li> |
| 6715 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_update"><code class="docutils literal notranslate"><span class="pre">psa_aead_update</span></code> (function)</a></li> |
| 6716 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_finish"><code class="docutils literal notranslate"><span class="pre">psa_aead_finish</span></code> (function)</a></li> |
| 6717 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_verify"><code class="docutils literal notranslate"><span class="pre">psa_aead_verify</span></code> (function)</a></li> |
| 6718 | <li class="toctree-l2"><a class="reference internal" href="#psa_aead_abort"><code class="docutils literal notranslate"><span class="pre">psa_aead_abort</span></code> (function)</a></li> |
| 6719 | </ul> |
| 6720 | </li> |
| 6721 | <li class="toctree-l1"><a class="reference internal" href="#asymmetric-cryptography">Asymmetric cryptography</a><ul> |
| 6722 | <li class="toctree-l2"><a class="reference internal" href="#psa_asymmetric_sign"><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_sign</span></code> (function)</a></li> |
| 6723 | <li class="toctree-l2"><a class="reference internal" href="#psa_asymmetric_verify"><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_verify</span></code> (function)</a></li> |
| 6724 | <li class="toctree-l2"><a class="reference internal" href="#psa_asymmetric_encrypt"><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_encrypt</span></code> (function)</a></li> |
| 6725 | <li class="toctree-l2"><a class="reference internal" href="#psa_asymmetric_decrypt"><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_decrypt</span></code> (function)</a></li> |
| 6726 | </ul> |
| 6727 | </li> |
| 6728 | <li class="toctree-l1"><a class="reference internal" href="#key-derivation-and-pseudorandom-generation">Key derivation and pseudorandom generation</a><ul> |
| 6729 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_operation_t</span></code> (type)</a></li> |
| 6730 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_OPERATION_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_OPERATION_INIT</span></code> (macro)</a></li> |
| 6731 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_UNLIMITED_CAPACITY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_UNLIMITED_CAPACITY</span></code> (macro)</a></li> |
| 6732 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_operation_init"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_operation_init</span></code> (function)</a></li> |
| 6733 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_setup"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_setup</span></code> (function)</a></li> |
| 6734 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_get_capacity"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_get_capacity</span></code> (function)</a></li> |
| 6735 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_set_capacity"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_set_capacity</span></code> (function)</a></li> |
| 6736 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_input_bytes"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_input_bytes</span></code> (function)</a></li> |
| 6737 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_input_key"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_input_key</span></code> (function)</a></li> |
| 6738 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_key_agreement"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_key_agreement</span></code> (function)</a></li> |
| 6739 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_output_bytes"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_output_bytes</span></code> (function)</a></li> |
| 6740 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_output_key"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_output_key</span></code> (function)</a></li> |
| 6741 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_abort"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_abort</span></code> (function)</a></li> |
| 6742 | <li class="toctree-l2"><a class="reference internal" href="#psa_raw_key_agreement"><code class="docutils literal notranslate"><span class="pre">psa_raw_key_agreement</span></code> (function)</a></li> |
| 6743 | </ul> |
| 6744 | </li> |
| 6745 | <li class="toctree-l1"><a class="reference internal" href="#random-generation">Random generation</a><ul> |
| 6746 | <li class="toctree-l2"><a class="reference internal" href="#psa_generate_random"><code class="docutils literal notranslate"><span class="pre">psa_generate_random</span></code> (function)</a></li> |
| 6747 | <li class="toctree-l2"><a class="reference internal" href="#psa_generate_key"><code class="docutils literal notranslate"><span class="pre">psa_generate_key</span></code> (function)</a></li> |
| 6748 | </ul> |
| 6749 | </li> |
| 6750 | <li class="toctree-l1"><a class="reference internal" href="#error-codes">Error codes</a><ul> |
| 6751 | <li class="toctree-l2"><a class="reference internal" href="#psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code> (type)</a></li> |
| 6752 | <li class="toctree-l2"><a class="reference internal" href="#PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code> (macro)</a></li> |
| 6753 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_GENERIC_ERROR"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_GENERIC_ERROR</span></code> (macro)</a></li> |
| 6754 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code> (macro)</a></li> |
| 6755 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code> (macro)</a></li> |
| 6756 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code> (macro)</a></li> |
| 6757 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_ALREADY_EXISTS"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code> (macro)</a></li> |
| 6758 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code> (macro)</a></li> |
| 6759 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code> (macro)</a></li> |
| 6760 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code> (macro)</a></li> |
| 6761 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code> (macro)</a></li> |
| 6762 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INSUFFICIENT_STORAGE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code> (macro)</a></li> |
| 6763 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code> (macro)</a></li> |
| 6764 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_STORAGE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code> (macro)</a></li> |
| 6765 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code> (macro)</a></li> |
| 6766 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code> (macro)</a></li> |
| 6767 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code> (macro)</a></li> |
| 6768 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code> (macro)</a></li> |
| 6769 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INVALID_PADDING"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_PADDING</span></code> (macro)</a></li> |
| 6770 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INSUFFICIENT_DATA"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_DATA</span></code> (macro)</a></li> |
| 6771 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code> (macro)</a></li> |
| 6772 | </ul> |
| 6773 | </li> |
| 6774 | <li class="toctree-l1"><a class="reference internal" href="#key-and-algorithm-types">Key and algorithm types</a><ul> |
| 6775 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_type_t"><code class="docutils literal notranslate"><span class="pre">psa_key_type_t</span></code> (type)</a></li> |
| 6776 | <li class="toctree-l2"><a class="reference internal" href="#psa_ecc_curve_t"><code class="docutils literal notranslate"><span class="pre">psa_ecc_curve_t</span></code> (type)</a></li> |
| 6777 | <li class="toctree-l2"><a class="reference internal" href="#psa_dh_group_t"><code class="docutils literal notranslate"><span class="pre">psa_dh_group_t</span></code> (type)</a></li> |
| 6778 | <li class="toctree-l2"><a class="reference internal" href="#psa_algorithm_t"><code class="docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code> (type)</a></li> |
| 6779 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_NONE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_NONE</span></code> (macro)</a></li> |
| 6780 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_VENDOR_FLAG"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_VENDOR_FLAG</span></code> (macro)</a></li> |
| 6781 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_MASK</span></code> (macro)</a></li> |
| 6782 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_SYMMETRIC"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_SYMMETRIC</span></code> (macro)</a></li> |
| 6783 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_RAW"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_RAW</span></code> (macro)</a></li> |
| 6784 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY</span></code> (macro)</a></li> |
| 6785 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_KEY_PAIR</span></code> (macro)</a></li> |
| 6786 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_FLAG_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_FLAG_PAIR</span></code> (macro)</a></li> |
| 6787 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_VENDOR_DEFINED"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_VENDOR_DEFINED</span></code> (macro)</a></li> |
| 6788 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_UNSTRUCTURED"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_UNSTRUCTURED</span></code> (macro)</a></li> |
| 6789 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_ASYMMETRIC"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ASYMMETRIC</span></code> (macro)</a></li> |
| 6790 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_PUBLIC_KEY</span></code> (macro)</a></li> |
| 6791 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_KEY_PAIR</span></code> (macro)</a></li> |
| 6792 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY</span></code> (macro)</a></li> |
| 6793 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span></code> (macro)</a></li> |
| 6794 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_RAW_DATA"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RAW_DATA</span></code> (macro)</a></li> |
| 6795 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_HMAC"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_HMAC</span></code> (macro)</a></li> |
| 6796 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DERIVE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DERIVE</span></code> (macro)</a></li> |
| 6797 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_AES"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_AES</span></code> (macro)</a></li> |
| 6798 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DES"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DES</span></code> (macro)</a></li> |
| 6799 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CAMELLIA"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CAMELLIA</span></code> (macro)</a></li> |
| 6800 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ARC4"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ARC4</span></code> (macro)</a></li> |
| 6801 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CHACHA20"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CHACHA20</span></code> (macro)</a></li> |
| 6802 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_RSA_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_PUBLIC_KEY</span></code> (macro)</a></li> |
| 6803 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_RSA_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code> (macro)</a></li> |
| 6804 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_RSA"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_RSA</span></code> (macro)</a></li> |
| 6805 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE</span></code> (macro)</a></li> |
| 6806 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ECC_KEY_PAIR_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR_BASE</span></code> (macro)</a></li> |
| 6807 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ECC_CURVE_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_CURVE_MASK</span></code> (macro)</a></li> |
| 6808 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ECC_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR</span></code> (macro)</a></li> |
| 6809 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ECC_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY</span></code> (macro)</a></li> |
| 6810 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_ECC"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC</span></code> (macro)</a></li> |
| 6811 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_ECC_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_KEY_PAIR</span></code> (macro)</a></li> |
| 6812 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY</span></code> (macro)</a></li> |
| 6813 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_GET_CURVE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_GET_CURVE</span></code> (macro)</a></li> |
| 6814 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT163K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163K1</span></code> (macro)</a></li> |
| 6815 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT163R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163R1</span></code> (macro)</a></li> |
| 6816 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT163R2"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163R2</span></code> (macro)</a></li> |
| 6817 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT193R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT193R1</span></code> (macro)</a></li> |
| 6818 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT193R2"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT193R2</span></code> (macro)</a></li> |
| 6819 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT233K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT233K1</span></code> (macro)</a></li> |
| 6820 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT233R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT233R1</span></code> (macro)</a></li> |
| 6821 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT239K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT239K1</span></code> (macro)</a></li> |
| 6822 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT283K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT283K1</span></code> (macro)</a></li> |
| 6823 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT283R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT283R1</span></code> (macro)</a></li> |
| 6824 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT409K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT409K1</span></code> (macro)</a></li> |
| 6825 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT409R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT409R1</span></code> (macro)</a></li> |
| 6826 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT571K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT571K1</span></code> (macro)</a></li> |
| 6827 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT571R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT571R1</span></code> (macro)</a></li> |
| 6828 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP160K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160K1</span></code> (macro)</a></li> |
| 6829 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP160R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160R1</span></code> (macro)</a></li> |
| 6830 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP160R2"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160R2</span></code> (macro)</a></li> |
| 6831 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP192K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP192K1</span></code> (macro)</a></li> |
| 6832 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP192R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP192R1</span></code> (macro)</a></li> |
| 6833 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP224K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP224K1</span></code> (macro)</a></li> |
| 6834 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP224R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP224R1</span></code> (macro)</a></li> |
| 6835 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP256K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP256K1</span></code> (macro)</a></li> |
| 6836 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP256R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP256R1</span></code> (macro)</a></li> |
| 6837 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP384R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP384R1</span></code> (macro)</a></li> |
| 6838 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP521R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP521R1</span></code> (macro)</a></li> |
| 6839 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_BRAINPOOL_P256R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P256R1</span></code> (macro)</a></li> |
| 6840 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_BRAINPOOL_P384R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P384R1</span></code> (macro)</a></li> |
| 6841 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_BRAINPOOL_P512R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P512R1</span></code> (macro)</a></li> |
| 6842 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_CURVE25519"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE25519</span></code> (macro)</a></li> |
| 6843 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_CURVE448"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE448</span></code> (macro)</a></li> |
| 6844 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE</span></code> (macro)</a></li> |
| 6845 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DH_KEY_PAIR_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR_BASE</span></code> (macro)</a></li> |
| 6846 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DH_GROUP_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_GROUP_MASK</span></code> (macro)</a></li> |
| 6847 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DH_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR</span></code> (macro)</a></li> |
| 6848 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DH_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY</span></code> (macro)</a></li> |
| 6849 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_DH"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH</span></code> (macro)</a></li> |
| 6850 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_DH_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_KEY_PAIR</span></code> (macro)</a></li> |
| 6851 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_DH_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_PUBLIC_KEY</span></code> (macro)</a></li> |
| 6852 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_GET_GROUP"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_GET_GROUP</span></code> (macro)</a></li> |
| 6853 | <li class="toctree-l2"><a class="reference internal" href="#PSA_DH_GROUP_FFDHE2048"><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE2048</span></code> (macro)</a></li> |
| 6854 | <li class="toctree-l2"><a class="reference internal" href="#PSA_DH_GROUP_FFDHE3072"><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE3072</span></code> (macro)</a></li> |
| 6855 | <li class="toctree-l2"><a class="reference internal" href="#PSA_DH_GROUP_FFDHE4096"><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE4096</span></code> (macro)</a></li> |
| 6856 | <li class="toctree-l2"><a class="reference internal" href="#PSA_DH_GROUP_FFDHE6144"><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE6144</span></code> (macro)</a></li> |
| 6857 | <li class="toctree-l2"><a class="reference internal" href="#PSA_DH_GROUP_FFDHE8192"><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE8192</span></code> (macro)</a></li> |
| 6858 | <li class="toctree-l2"><a class="reference internal" href="#PSA_BLOCK_CIPHER_BLOCK_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_BLOCK_CIPHER_BLOCK_SIZE</span></code> (macro)</a></li> |
| 6859 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_VENDOR_FLAG"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_VENDOR_FLAG</span></code> (macro)</a></li> |
| 6860 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_MASK</span></code> (macro)</a></li> |
| 6861 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_HASH</span></code> (macro)</a></li> |
| 6862 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_MAC</span></code> (macro)</a></li> |
| 6863 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_CIPHER"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_CIPHER</span></code> (macro)</a></li> |
| 6864 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_AEAD"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_AEAD</span></code> (macro)</a></li> |
| 6865 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_SIGN</span></code> (macro)</a></li> |
| 6866 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION</span></code> (macro)</a></li> |
| 6867 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_KEY_DERIVATION"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_KEY_DERIVATION</span></code> (macro)</a></li> |
| 6868 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_KEY_AGREEMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_KEY_AGREEMENT</span></code> (macro)</a></li> |
| 6869 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_VENDOR_DEFINED"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_VENDOR_DEFINED</span></code> (macro)</a></li> |
| 6870 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code> (macro)</a></li> |
| 6871 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code> (macro)</a></li> |
| 6872 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_CIPHER"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code> (macro)</a></li> |
| 6873 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_AEAD"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code> (macro)</a></li> |
| 6874 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_SIGN</span></code> (macro)</a></li> |
| 6875 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_ASYMMETRIC_ENCRYPTION"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ASYMMETRIC_ENCRYPTION</span></code> (macro)</a></li> |
| 6876 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_KEY_AGREEMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_AGREEMENT</span></code> (macro)</a></li> |
| 6877 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_KEY_DERIVATION"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION</span></code> (macro)</a></li> |
| 6878 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HASH_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HASH_MASK</span></code> (macro)</a></li> |
| 6879 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_MD2"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD2</span></code> (macro)</a></li> |
| 6880 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_MD4"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD4</span></code> (macro)</a></li> |
| 6881 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_MD5"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD5</span></code> (macro)</a></li> |
| 6882 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RIPEMD160"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RIPEMD160</span></code> (macro)</a></li> |
| 6883 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_1"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_1</span></code> (macro)</a></li> |
| 6884 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_224"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_224</span></code> (macro)</a></li> |
| 6885 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_256"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_256</span></code> (macro)</a></li> |
| 6886 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_384"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_384</span></code> (macro)</a></li> |
| 6887 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_512"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512</span></code> (macro)</a></li> |
| 6888 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_512_224"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512_224</span></code> (macro)</a></li> |
| 6889 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_512_256"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512_256</span></code> (macro)</a></li> |
| 6890 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA3_224"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_224</span></code> (macro)</a></li> |
| 6891 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA3_256"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_256</span></code> (macro)</a></li> |
| 6892 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA3_384"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_384</span></code> (macro)</a></li> |
| 6893 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA3_512"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_512</span></code> (macro)</a></li> |
| 6894 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ANY_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code> (macro)</a></li> |
| 6895 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_MAC_SUBCATEGORY_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MAC_SUBCATEGORY_MASK</span></code> (macro)</a></li> |
| 6896 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HMAC_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC_BASE</span></code> (macro)</a></li> |
| 6897 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HMAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC</span></code> (macro)</a></li> |
| 6898 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HMAC_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC_GET_HASH</span></code> (macro)</a></li> |
| 6899 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_HMAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HMAC</span></code> (macro)</a></li> |
| 6900 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_MAC_TRUNCATION_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MAC_TRUNCATION_MASK</span></code> (macro)</a></li> |
| 6901 | <li class="toctree-l2"><a class="reference internal" href="#PSA_MAC_TRUNCATION_OFFSET"><code class="docutils literal notranslate"><span class="pre">PSA_MAC_TRUNCATION_OFFSET</span></code> (macro)</a></li> |
| 6902 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TRUNCATED_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TRUNCATED_MAC</span></code> (macro)</a></li> |
| 6903 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_FULL_LENGTH_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_FULL_LENGTH_MAC</span></code> (macro)</a></li> |
| 6904 | <li class="toctree-l2"><a class="reference internal" href="#PSA_MAC_TRUNCATED_LENGTH"><code class="docutils literal notranslate"><span class="pre">PSA_MAC_TRUNCATED_LENGTH</span></code> (macro)</a></li> |
| 6905 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CIPHER_MAC_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_MAC_BASE</span></code> (macro)</a></li> |
| 6906 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CBC_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_MAC</span></code> (macro)</a></li> |
| 6907 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CMAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CMAC</span></code> (macro)</a></li> |
| 6908 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_GMAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_GMAC</span></code> (macro)</a></li> |
| 6909 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_BLOCK_CIPHER_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_BLOCK_CIPHER_MAC</span></code> (macro)</a></li> |
| 6910 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CIPHER_STREAM_FLAG"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_STREAM_FLAG</span></code> (macro)</a></li> |
| 6911 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CIPHER_FROM_BLOCK_FLAG"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_FROM_BLOCK_FLAG</span></code> (macro)</a></li> |
| 6912 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_STREAM_CIPHER"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_STREAM_CIPHER</span></code> (macro)</a></li> |
| 6913 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ARC4"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ARC4</span></code> (macro)</a></li> |
| 6914 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CHACHA20"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CHACHA20</span></code> (macro)</a></li> |
| 6915 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CTR"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CTR</span></code> (macro)</a></li> |
| 6916 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CFB"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CFB</span></code> (macro)</a></li> |
| 6917 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_OFB"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_OFB</span></code> (macro)</a></li> |
| 6918 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_XTS"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_XTS</span></code> (macro)</a></li> |
| 6919 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CBC_NO_PADDING"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_NO_PADDING</span></code> (macro)</a></li> |
| 6920 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CBC_PKCS7"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_PKCS7</span></code> (macro)</a></li> |
| 6921 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_AEAD_FROM_BLOCK_FLAG"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_FROM_BLOCK_FLAG</span></code> (macro)</a></li> |
| 6922 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER</span></code> (macro)</a></li> |
| 6923 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CCM"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CCM</span></code> (macro)</a></li> |
| 6924 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_GCM"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_GCM</span></code> (macro)</a></li> |
| 6925 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CHACHA20_POLY1305"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CHACHA20_POLY1305</span></code> (macro)</a></li> |
| 6926 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_AEAD_TAG_LENGTH_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_TAG_LENGTH_MASK</span></code> (macro)</a></li> |
| 6927 | <li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_TAG_LENGTH_OFFSET"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH_OFFSET</span></code> (macro)</a></li> |
| 6928 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_AEAD_WITH_TAG_LENGTH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_WITH_TAG_LENGTH</span></code> (macro)</a></li> |
| 6929 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH</span></code> (macro)</a></li> |
| 6930 | <li class="toctree-l2"><a class="reference internal" href="#PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE"><code class="docutils literal notranslate"><span class="pre">PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE</span></code> (macro)</a></li> |
| 6931 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PKCS1V15_SIGN_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN_BASE</span></code> (macro)</a></li> |
| 6932 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PKCS1V15_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN</span></code> (macro)</a></li> |
| 6933 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PKCS1V15_SIGN_RAW"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN_RAW</span></code> (macro)</a></li> |
| 6934 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_RSA_PKCS1V15_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_PKCS1V15_SIGN</span></code> (macro)</a></li> |
| 6935 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PSS_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PSS_BASE</span></code> (macro)</a></li> |
| 6936 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PSS"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PSS</span></code> (macro)</a></li> |
| 6937 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_RSA_PSS"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_PSS</span></code> (macro)</a></li> |
| 6938 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ECDSA_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_BASE</span></code> (macro)</a></li> |
| 6939 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ECDSA"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA</span></code> (macro)</a></li> |
| 6940 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ECDSA_ANY"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_ANY</span></code> (macro)</a></li> |
| 6941 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_DETERMINISTIC_ECDSA_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA_BASE</span></code> (macro)</a></li> |
| 6942 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_DETERMINISTIC_ECDSA"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA</span></code> (macro)</a></li> |
| 6943 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_ECDSA"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ECDSA</span></code> (macro)</a></li> |
| 6944 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ECDSA_IS_DETERMINISTIC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_IS_DETERMINISTIC</span></code> (macro)</a></li> |
| 6945 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_DETERMINISTIC_ECDSA"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_DETERMINISTIC_ECDSA</span></code> (macro)</a></li> |
| 6946 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_RANDOMIZED_ECDSA"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RANDOMIZED_ECDSA</span></code> (macro)</a></li> |
| 6947 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_HASH_AND_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH_AND_SIGN</span></code> (macro)</a></li> |
| 6948 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SIGN_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SIGN_GET_HASH</span></code> (macro)</a></li> |
| 6949 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PKCS1V15_CRYPT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code> (macro)</a></li> |
| 6950 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_OAEP_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP_BASE</span></code> (macro)</a></li> |
| 6951 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_OAEP"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP</span></code> (macro)</a></li> |
| 6952 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_RSA_OAEP"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_OAEP</span></code> (macro)</a></li> |
| 6953 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_OAEP_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP_GET_HASH</span></code> (macro)</a></li> |
| 6954 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HKDF_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF_BASE</span></code> (macro)</a></li> |
| 6955 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HKDF"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF</span></code> (macro)</a></li> |
| 6956 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_HKDF"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HKDF</span></code> (macro)</a></li> |
| 6957 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HKDF_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF_GET_HASH</span></code> (macro)</a></li> |
| 6958 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PRF_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF_BASE</span></code> (macro)</a></li> |
| 6959 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PRF"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF</span></code> (macro)</a></li> |
| 6960 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_TLS12_PRF"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_TLS12_PRF</span></code> (macro)</a></li> |
| 6961 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PRF_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF_GET_HASH</span></code> (macro)</a></li> |
| 6962 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PSK_TO_MS_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_BASE</span></code> (macro)</a></li> |
| 6963 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PSK_TO_MS"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS</span></code> (macro)</a></li> |
| 6964 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_TLS12_PSK_TO_MS"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_TLS12_PSK_TO_MS</span></code> (macro)</a></li> |
| 6965 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PSK_TO_MS_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_GET_HASH</span></code> (macro)</a></li> |
| 6966 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_KEY_DERIVATION_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_DERIVATION_MASK</span></code> (macro)</a></li> |
| 6967 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_KEY_AGREEMENT_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_MASK</span></code> (macro)</a></li> |
| 6968 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_KEY_AGREEMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT</span></code> (macro)</a></li> |
| 6969 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_KEY_AGREEMENT_GET_KDF"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_GET_KDF</span></code> (macro)</a></li> |
| 6970 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_KEY_AGREEMENT_GET_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_GET_BASE</span></code> (macro)</a></li> |
| 6971 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_RAW_KEY_AGREEMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RAW_KEY_AGREEMENT</span></code> (macro)</a></li> |
| 6972 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT</span></code> (macro)</a></li> |
| 6973 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_FFDH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_FFDH</span></code> (macro)</a></li> |
| 6974 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_FFDH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_FFDH</span></code> (macro)</a></li> |
| 6975 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ECDH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDH</span></code> (macro)</a></li> |
| 6976 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_ECDH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ECDH</span></code> (macro)</a></li> |
| 6977 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_WILDCARD"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_WILDCARD</span></code> (macro)</a></li> |
| 6978 | </ul> |
| 6979 | </li> |
| 6980 | <li class="toctree-l1"><a class="reference internal" href="#key-lifetimes">Key lifetimes</a><ul> |
| 6981 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_lifetime_t"><code class="docutils literal notranslate"><span class="pre">psa_key_lifetime_t</span></code> (type)</a></li> |
| 6982 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_id_t"><code class="docutils literal notranslate"><span class="pre">psa_key_id_t</span></code> (type)</a></li> |
| 6983 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_LIFETIME_VOLATILE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code> (macro)</a></li> |
| 6984 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_LIFETIME_PERSISTENT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code> (macro)</a></li> |
| 6985 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_ID_USER_MIN"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MIN</span></code> (macro)</a></li> |
| 6986 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_ID_USER_MAX"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MAX</span></code> (macro)</a></li> |
| 6987 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_ID_VENDOR_MIN"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MIN</span></code> (macro)</a></li> |
| 6988 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_ID_VENDOR_MAX"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MAX</span></code> (macro)</a></li> |
| 6989 | </ul> |
| 6990 | </li> |
| 6991 | <li class="toctree-l1"><a class="reference internal" href="#key-policies">Key policies</a><ul> |
| 6992 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_usage_t"><code class="docutils literal notranslate"><span class="pre">psa_key_usage_t</span></code> (type)</a></li> |
| 6993 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_EXPORT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code> (macro)</a></li> |
| 6994 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_COPY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code> (macro)</a></li> |
| 6995 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_ENCRYPT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_ENCRYPT</span></code> (macro)</a></li> |
| 6996 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_DECRYPT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_DECRYPT</span></code> (macro)</a></li> |
| 6997 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_SIGN</span></code> (macro)</a></li> |
| 6998 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_VERIFY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_VERIFY</span></code> (macro)</a></li> |
| 6999 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_DERIVE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_DERIVE</span></code> (macro)</a></li> |
| 7000 | </ul> |
| 7001 | </li> |
| 7002 | <li class="toctree-l1"><a class="reference internal" href="#key-derivation">Key derivation</a><ul> |
| 7003 | <li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_step_t"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_step_t</span></code> (type)</a></li> |
| 7004 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_INPUT_SECRET"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code> (macro)</a></li> |
| 7005 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_INPUT_LABEL"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_LABEL</span></code> (macro)</a></li> |
| 7006 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_INPUT_SALT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SALT</span></code> (macro)</a></li> |
| 7007 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_INPUT_INFO"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_INFO</span></code> (macro)</a></li> |
| 7008 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_INPUT_SEED"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SEED</span></code> (macro)</a></li> |
| 7009 | </ul> |
| 7010 | </li> |
| 7011 | <li class="toctree-l1"><a class="reference internal" href="#other-definitions">Other definitions</a><ul> |
| 7012 | <li class="toctree-l2"><a class="reference internal" href="#PSA_BITS_TO_BYTES"><code class="docutils literal notranslate"><span class="pre">PSA_BITS_TO_BYTES</span></code> (macro)</a></li> |
| 7013 | <li class="toctree-l2"><a class="reference internal" href="#PSA_BYTES_TO_BITS"><code class="docutils literal notranslate"><span class="pre">PSA_BYTES_TO_BITS</span></code> (macro)</a></li> |
| 7014 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ROUND_UP_TO_MULTIPLE"><code class="docutils literal notranslate"><span class="pre">PSA_ROUND_UP_TO_MULTIPLE</span></code> (macro)</a></li> |
| 7015 | <li class="toctree-l2"><a class="reference internal" href="#PSA_HASH_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code> (macro)</a></li> |
| 7016 | <li class="toctree-l2"><a class="reference internal" href="#PSA_HASH_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_HASH_MAX_SIZE</span></code> (macro)</a></li> |
| 7017 | <li class="toctree-l2"><a class="reference internal" href="#PSA_HMAC_MAX_HASH_BLOCK_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_HMAC_MAX_HASH_BLOCK_SIZE</span></code> (macro)</a></li> |
| 7018 | <li class="toctree-l2"><a class="reference internal" href="#PSA_MAC_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_MAC_MAX_SIZE</span></code> (macro)</a></li> |
| 7019 | <li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_TAG_LENGTH"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH</span></code> (macro)</a></li> |
| 7020 | <li class="toctree-l2"><a class="reference internal" href="#PSA_VENDOR_RSA_MAX_KEY_BITS"><code class="docutils literal notranslate"><span class="pre">PSA_VENDOR_RSA_MAX_KEY_BITS</span></code> (macro)</a></li> |
| 7021 | <li class="toctree-l2"><a class="reference internal" href="#PSA_VENDOR_ECC_MAX_CURVE_BITS"><code class="docutils literal notranslate"><span class="pre">PSA_VENDOR_ECC_MAX_CURVE_BITS</span></code> (macro)</a></li> |
| 7022 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_BITS"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BITS</span></code> (macro)</a></li> |
| 7023 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN</span></code> (macro)</a></li> |
| 7024 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE</span></code> (macro)</a></li> |
| 7025 | <li class="toctree-l2"><a class="reference internal" href="#PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE</span></code> (macro)</a></li> |
| 7026 | <li class="toctree-l2"><a class="reference internal" href="#PSA_MAC_FINAL_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_MAC_FINAL_SIZE</span></code> (macro)</a></li> |
| 7027 | <li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_ENCRYPT_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_ENCRYPT_OUTPUT_SIZE</span></code> (macro)</a></li> |
| 7028 | <li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_DECRYPT_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_DECRYPT_OUTPUT_SIZE</span></code> (macro)</a></li> |
| 7029 | <li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_UPDATE_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_UPDATE_OUTPUT_SIZE</span></code> (macro)</a></li> |
| 7030 | <li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_FINISH_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_FINISH_OUTPUT_SIZE</span></code> (macro)</a></li> |
| 7031 | <li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_VERIFY_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_VERIFY_OUTPUT_SIZE</span></code> (macro)</a></li> |
| 7032 | <li class="toctree-l2"><a class="reference internal" href="#PSA_RSA_MINIMUM_PADDING_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_RSA_MINIMUM_PADDING_SIZE</span></code> (macro)</a></li> |
| 7033 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ECDSA_SIGNATURE_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_ECDSA_SIGNATURE_SIZE</span></code> (macro)</a></li> |
| 7034 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE</span></code> (macro)</a></li> |
| 7035 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</span></code> (macro)</a></li> |
| 7036 | <li class="toctree-l2"><a class="reference internal" href="#PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</span></code> (macro)</a></li> |
| 7037 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE</span></code> (macro)</a></li> |
| 7038 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</a></li> |
| 7039 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE</span></code> (macro)</a></li> |
| 7040 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</a></li> |
| 7041 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE</span></code> (macro)</a></li> |
| 7042 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</a></li> |
| 7043 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE</span></code> (macro)</a></li> |
| 7044 | <li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_MAX_SIZE</span></code> (macro)</a></li> |
| 7045 | </ul> |
| 7046 | </li> |
| 7047 | </ul> |
| 7048 | |
| 7049 | <div class="relations"> |
| 7050 | <h3>Related Topics</h3> |
| 7051 | <ul> |
| 7052 | <li><a href="index.html">Documentation overview</a><ul> |
| 7053 | <li>Previous: <a href="general.html" title="previous chapter">Introduction</a></li> |
| 7054 | </ul></li> |
| 7055 | </ul> |
| 7056 | </div> |
| 7057 | <div id="searchbox" style="display: none" role="search"> |
| 7058 | <h3>Quick search</h3> |
| 7059 | <div class="searchformwrapper"> |
| 7060 | <form class="search" action="search.html" method="get"> |
| 7061 | <input type="text" name="q" /> |
| 7062 | <input type="submit" value="Go" /> |
| 7063 | <input type="hidden" name="check_keywords" value="yes" /> |
| 7064 | <input type="hidden" name="area" value="default" /> |
| 7065 | </form> |
| 7066 | </div> |
| 7067 | </div> |
| 7068 | <script type="text/javascript">$('#searchbox').show(0);</script> |
| 7069 | |
| 7070 | |
| 7071 | |
| 7072 | |
| 7073 | |
| 7074 | |
| 7075 | |
| 7076 | |
| 7077 | </div> |
| 7078 | </div> |
| 7079 | <div class="clearer"></div> |
| 7080 | </div> |
| 7081 | <div class="footer"> |
| 7082 | ©2019, Arm. |
| 7083 | |
| 7084 | | |
| 7085 | Powered by <a href="http://sphinx-doc.org/">Sphinx 1.8.5</a> |
| 7086 | & <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> |
| 7087 | |
| 7088 | | |
| 7089 | <a href="_sources/from_doxygen.rst.txt" |
| 7090 | rel="nofollow">Page source</a> |
| 7091 | </div> |
| 7092 | |
| 7093 | |
| 7094 | |
| 7095 | |
| 7096 | </body> |
| 7097 | </html> |