Gilles Peskine | 882f7c7 | 2022-04-07 13:44:55 +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="Content-Type" content="text/html; charset=utf-8" /> |
| 8 | <title>10.8. Asymmetric encryption — PSA Crypto API 1.1.0 documentation</title> |
| 9 | <link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" /> |
| 10 | <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> |
| 11 | <script type="text/javascript"> |
| 12 | var DOCUMENTATION_OPTIONS = { |
| 13 | URL_ROOT: '../../', |
| 14 | VERSION: '1.1.0', |
| 15 | COLLAPSE_INDEX: false, |
| 16 | FILE_SUFFIX: '.html', |
| 17 | HAS_SOURCE: false, |
| 18 | SOURCELINK_SUFFIX: '.txt' |
| 19 | }; |
| 20 | </script> |
| 21 | <script type="text/javascript" src="../../_static/jquery.js"></script> |
| 22 | <script type="text/javascript" src="../../_static/underscore.js"></script> |
| 23 | <script type="text/javascript" src="../../_static/doctools.js"></script> |
| 24 | <link rel="author" title="About these documents" href="../../about.html" /> |
| 25 | <link rel="index" title="Index" href="../../genindex.html" /> |
| 26 | <link rel="search" title="Search" href="../../search.html" /> |
| 27 | <link rel="next" title="10.9. Key agreement" href="ka.html" /> |
| 28 | <link rel="prev" title="10.7. Asymmetric signature" href="sign.html" /> |
| 29 | |
| 30 | <link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> |
| 31 | |
| 32 | <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> |
| 33 | |
| 34 | </head> |
| 35 | <body> |
| 36 | |
| 37 | |
| 38 | <div class="document"> |
| 39 | <div class="documentwrapper"> |
| 40 | <div class="bodywrapper"> |
| 41 | <div class="body" role="main"> |
| 42 | |
| 43 | <div class="section" id="asymmetric-encryption"> |
| 44 | <span id="pke"></span><h1>10.8. Asymmetric encryption</h1> |
| 45 | <p>Asymmetric encryption is provided through the functions <a class="reference internal" href="#c.psa_asymmetric_encrypt" title="psa_asymmetric_encrypt"><code class="xref any c c-func docutils literal"><span class="pre">psa_asymmetric_encrypt()</span></code></a> and <a class="reference internal" href="#c.psa_asymmetric_decrypt" title="psa_asymmetric_decrypt"><code class="xref any c c-func docutils literal"><span class="pre">psa_asymmetric_decrypt()</span></code></a>.</p> |
| 46 | <div class="section" id="asymmetric-encryption-algorithms"> |
| 47 | <span id="id1"></span><h2>10.8.1. Asymmetric encryption algorithms</h2> |
| 48 | <div class="section" id="PSA_ALG_RSA_PKCS1V15_CRYPT"> |
| 49 | <span id="c.PSA_ALG_RSA_PKCS1V15_CRYPT"></span><h3><code class="docutils literal"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code> (macro)</h3> |
| 50 | <p>The RSA PKCS#1 v1.5 asymmetric encryption algorithm.</p> |
| 51 | <pre class="literal-block"> |
| 52 | #define <a class="reference internal" href="#c.PSA_ALG_RSA_PKCS1V15_CRYPT" title="PSA_ALG_RSA_PKCS1V15_CRYPT">PSA_ALG_RSA_PKCS1V15_CRYPT</a> ((<a class="reference internal" href="algorithms.html#c.psa_algorithm_t" title="psa_algorithm_t">psa_algorithm_t</a>)0x07000200) |
| 53 | </pre> |
| 54 | <p>This encryption scheme is defined by <span><em>PKCS #1: RSA Cryptography Specifications Version 2.2</em> <a class="reference internal" href="../../about.html#citation-rfc8017"><span class="cite">[RFC8017]</span></a></span> <a class="reference external" href="https://tools.ietf.org/html/rfc8017.html#section-7.2">§7.2</a> under the name RSAES-PKCS-v1_5.</p> |
| 55 | <p class="rubric">Compatible key types</p> |
| 56 | <div class="line-block"> |
| 57 | <div class="line"><a class="reference internal" href="../keys/types.html#c.PSA_KEY_TYPE_RSA_KEY_PAIR" title="PSA_KEY_TYPE_RSA_KEY_PAIR"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code></a></div> |
| 58 | <div class="line"><a class="reference internal" href="../keys/types.html#c.PSA_KEY_TYPE_RSA_PUBLIC_KEY" title="PSA_KEY_TYPE_RSA_PUBLIC_KEY"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_RSA_PUBLIC_KEY</span></code></a> (asymmetric encryption only)</div> |
| 59 | </div> |
| 60 | </div> |
| 61 | <div class="section" id="PSA_ALG_RSA_OAEP"> |
| 62 | <span id="c.PSA_ALG_RSA_OAEP"></span><h3><code class="docutils literal"><span class="pre">PSA_ALG_RSA_OAEP</span></code> (macro)</h3> |
| 63 | <p>The RSA OAEP asymmetric encryption algorithm.</p> |
| 64 | <pre class="literal-block"> |
| 65 | #define <a class="reference internal" href="#c.PSA_ALG_RSA_OAEP" title="PSA_ALG_RSA_OAEP">PSA_ALG_RSA_OAEP</a>(hash_alg) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em> |
| 66 | </pre> |
| 67 | <p class="rubric">Parameters</p> |
| 68 | <dl class="docutils"> |
| 69 | <dt> <code class="docutils literal"><span class="pre">hash_alg</span></code></dt> |
| 70 | <dd>A hash algorithm: a value of type <a class="reference internal" href="algorithms.html#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="algorithms.html#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="docutils literal"><span class="pre">PSA_ALG_IS_HASH</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">hash_alg</span></code><code class="docutils literal"><span class="pre">)</span></code> is true. The hash algorithm is used for <em>MGF1</em>.</dd> |
| 71 | </dl> |
| 72 | <p class="rubric">Returns</p> |
| 73 | <p>The corresponding RSA OAEP encryption algorithm.</p> |
| 74 | <p>Unspecified if <code class="docutils literal"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p> |
| 75 | <p class="rubric">Description</p> |
| 76 | <p>This encryption scheme is defined by <a class="reference internal" href="../../about.html#citation-rfc8017"><span class="cite">[RFC8017]</span></a> <a class="reference external" href="https://tools.ietf.org/html/rfc8017.html#section-7.1">§7.1</a> under the name RSAES-OAEP, with the following options:</p> |
| 77 | <ul class="simple"> |
| 78 | <li>The mask generation function <em>MGF1</em> defined in <a class="reference internal" href="../../about.html#citation-rfc8017"><span class="cite">[RFC8017]</span></a> <a class="reference external" href="https://tools.ietf.org/html/rfc8017.html#appendix-B.2.1">Appendix B.2.1</a>.</li> |
| 79 | <li>The specified hash algorithm is used to hash the label, and for the mask generation function.</li> |
| 80 | </ul> |
| 81 | <p class="rubric">Compatible key types</p> |
| 82 | <div class="line-block"> |
| 83 | <div class="line"><a class="reference internal" href="../keys/types.html#c.PSA_KEY_TYPE_RSA_KEY_PAIR" title="PSA_KEY_TYPE_RSA_KEY_PAIR"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code></a></div> |
| 84 | <div class="line"><a class="reference internal" href="../keys/types.html#c.PSA_KEY_TYPE_RSA_PUBLIC_KEY" title="PSA_KEY_TYPE_RSA_PUBLIC_KEY"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_RSA_PUBLIC_KEY</span></code></a> (asymmetric encryption only)</div> |
| 85 | </div> |
| 86 | </div> |
| 87 | </div> |
| 88 | <div class="section" id="asymmetric-encryption-functions"> |
| 89 | <h2>10.8.2. Asymmetric encryption functions</h2> |
| 90 | <div class="section" id="psa_asymmetric_encrypt"> |
| 91 | <span id="c.psa_asymmetric_encrypt"></span><h3><code class="docutils literal"><span class="pre">psa_asymmetric_encrypt</span></code> (function)</h3> |
| 92 | <p>Encrypt a short message with a public key.</p> |
| 93 | <pre class="literal-block"> |
| 94 | <a class="reference internal" href="../library/status.html#c.psa_status_t" title="psa_status_t">psa_status_t</a> <a class="reference internal" href="#c.psa_asymmetric_encrypt" title="psa_asymmetric_encrypt">psa_asymmetric_encrypt</a>(<a class="reference internal" href="../keys/ids.html#c.psa_key_id_t" title="psa_key_id_t">psa_key_id_t</a> key, |
| 95 | <a class="reference internal" href="algorithms.html#c.psa_algorithm_t" title="psa_algorithm_t">psa_algorithm_t</a> alg, |
| 96 | const uint8_t * input, |
| 97 | size_t input_length, |
| 98 | const uint8_t * salt, |
| 99 | size_t salt_length, |
| 100 | uint8_t * output, |
| 101 | size_t output_size, |
| 102 | size_t * output_length); |
| 103 | </pre> |
| 104 | <p class="rubric">Parameters</p> |
| 105 | <dl class="docutils"> |
| 106 | <dt> <code class="docutils literal"><span class="pre">key</span></code></dt> |
| 107 | <dd>Identifer of the key to use for the operation. It must be a public key or an asymmetric key pair. |
| 108 | It must allow the usage <a class="reference internal" href="../keys/policy.html#c.PSA_KEY_USAGE_ENCRYPT" title="PSA_KEY_USAGE_ENCRYPT"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_USAGE_ENCRYPT</span></code></a>.</dd> |
| 109 | <dt> <code class="docutils literal"><span class="pre">alg</span></code></dt> |
| 110 | <dd>The asymmetric encryption algorithm to compute: a value of type <a class="reference internal" href="algorithms.html#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="algorithms.html#c.PSA_ALG_IS_ASYMMETRIC_ENCRYPTION" title="PSA_ALG_IS_ASYMMETRIC_ENCRYPTION"><code class="docutils literal"><span class="pre">PSA_ALG_IS_ASYMMETRIC_ENCRYPTION</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">alg</span></code><code class="docutils literal"><span class="pre">)</span></code> is true.</dd> |
| 111 | <dt> <code class="docutils literal"><span class="pre">input</span></code></dt> |
| 112 | <dd>The message to encrypt.</dd> |
| 113 | <dt> <code class="docutils literal"><span class="pre">input_length</span></code></dt> |
| 114 | <dd>Size of the <code class="docutils literal"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 115 | <dt> <code class="docutils literal"><span class="pre">salt</span></code></dt> |
| 116 | <dd>A salt or label, if supported by the encryption algorithm. If the algorithm does not support a salt, pass <code class="docutils literal"><span class="pre">NULL</span></code>. If the algorithm supports an optional salt, pass <code class="docutils literal"><span class="pre">NULL</span></code> to indicate that there is no salt.</dd> |
| 117 | <dt> <code class="docutils literal"><span class="pre">salt_length</span></code></dt> |
| 118 | <dd>Size of the <code class="docutils literal"><span class="pre">salt</span></code> buffer in bytes. If <code class="docutils literal"><span class="pre">salt</span></code> is <code class="docutils literal"><span class="pre">NULL</span></code>, pass <code class="docutils literal"><span class="pre">0</span></code>.</dd> |
| 119 | <dt> <code class="docutils literal"><span class="pre">output</span></code></dt> |
| 120 | <dd>Buffer where the encrypted message is to be written.</dd> |
| 121 | <dt> <code class="docutils literal"><span class="pre">output_size</span></code></dt> |
| 122 | <dd><p class="first">Size of the <code class="docutils literal"><span class="pre">output</span></code> buffer in bytes. |
| 123 | This must be appropriate for the selected algorithm and key:</p> |
| 124 | <ul class="last simple"> |
| 125 | <li>The required output size is <a class="reference internal" href="#c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE" title="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE"><code class="docutils literal"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">key_type</span></code><code class="docutils literal"><span class="pre">,</span> </code><code class="docutils literal"><span class="pre">key_bits</span></code><code class="docutils literal"><span class="pre">,</span> </code><code class="docutils literal"><span class="pre">alg</span></code><code class="docutils literal"><span class="pre">)</span></code> where <code class="docutils literal"><span class="pre">key_type</span></code> and <code class="docutils literal"><span class="pre">key_bits</span></code> are the type and bit-size respectively of <code class="docutils literal"><span class="pre">key</span></code>.</li> |
| 126 | <li><a class="reference internal" href="#c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE" title="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE</span></code></a> evaluates to the maximum output size of any supported asymmetric encryption.</li> |
| 127 | </ul> |
| 128 | </dd> |
| 129 | <dt> <code class="docutils literal"><span class="pre">output_length</span></code></dt> |
| 130 | <dd>On success, the number of bytes that make up the returned output.</dd> |
| 131 | </dl> |
| 132 | <p class="rubric">Returns: <a class="reference internal" href="../library/status.html#c.psa_status_t" title="psa_status_t"><code class="docutils literal"><span class="pre">psa_status_t</span></code></a></p> |
| 133 | <dl class="docutils"> |
| 134 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal"><span class="pre">PSA_SUCCESS</span></code></a></dt> |
| 135 | <dd>Success. |
| 136 | The first <code class="docutils literal"><span class="pre">(*output_length)</span></code> bytes of <code class="docutils literal"><span class="pre">output</span></code> contain the encrypted output.</dd> |
| 137 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a></dt> |
| 138 | <dd>The library requires initializing by a call to <a class="reference internal" href="../library/library.html#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal"><span class="pre">psa_crypto_init()</span></code></a>.</dd> |
| 139 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a></dt> |
| 140 | <dd><code class="docutils literal"><span class="pre">key</span></code> is not a valid key identifier.</dd> |
| 141 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a></dt> |
| 142 | <dd>The key does not have the <a class="reference internal" href="../keys/policy.html#c.PSA_KEY_USAGE_ENCRYPT" title="PSA_KEY_USAGE_ENCRYPT"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_USAGE_ENCRYPT</span></code></a> flag, or it does not permit the requested algorithm.</dd> |
| 143 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a></dt> |
| 144 | <dd>The size of the <code class="docutils literal"><span class="pre">output</span></code> buffer is too small. |
| 145 | <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"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE()</span></code></a> or <a class="reference internal" href="#c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE" title="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE</span></code></a> can be used to determine a sufficient buffer size.</dd> |
| 146 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a></dt> |
| 147 | <dd><p class="first">The following conditions can result in this error:</p> |
| 148 | <ul class="last simple"> |
| 149 | <li><code class="docutils literal"><span class="pre">alg</span></code> is not an asymmetric encryption algorithm.</li> |
| 150 | <li><code class="docutils literal"><span class="pre">key</span></code> is not a public key or an asymmetric key pair, that is compatible with <code class="docutils literal"><span class="pre">alg</span></code>.</li> |
| 151 | <li><code class="docutils literal"><span class="pre">input_length</span></code> is not valid for the algorithm and key type.</li> |
| 152 | <li><code class="docutils literal"><span class="pre">salt_length</span></code> is not valid for the algorithm and key type.</li> |
| 153 | </ul> |
| 154 | </dd> |
| 155 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a></dt> |
| 156 | <dd><p class="first">The following conditions can result in this error:</p> |
| 157 | <ul class="last simple"> |
| 158 | <li><code class="docutils literal"><span class="pre">alg</span></code> is not supported or is not an asymmetric encryption algorithm.</li> |
| 159 | <li><code class="docutils literal"><span class="pre">key</span></code> is not supported for use with <code class="docutils literal"><span class="pre">alg</span></code>.</li> |
| 160 | <li><code class="docutils literal"><span class="pre">input_length</span></code> or <code class="docutils literal"><span class="pre">salt_length</span></code> are too large for the implementation.</li> |
| 161 | </ul> |
| 162 | </dd> |
| 163 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a></dt> |
| 164 | <dd></dd> |
| 165 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a></dt> |
| 166 | <dd></dd> |
| 167 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a></dt> |
| 168 | <dd></dd> |
| 169 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a></dt> |
| 170 | <dd></dd> |
| 171 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_STORAGE_FAILURE" title="PSA_ERROR_STORAGE_FAILURE"><code class="docutils literal"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code></a></dt> |
| 172 | <dd></dd> |
| 173 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_DATA_CORRUPT" title="PSA_ERROR_DATA_CORRUPT"><code class="docutils literal"><span class="pre">PSA_ERROR_DATA_CORRUPT</span></code></a></dt> |
| 174 | <dd></dd> |
| 175 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_DATA_INVALID" title="PSA_ERROR_DATA_INVALID"><code class="docutils literal"><span class="pre">PSA_ERROR_DATA_INVALID</span></code></a></dt> |
| 176 | <dd></dd> |
| 177 | </dl> |
| 178 | <p class="rubric">Description</p> |
| 179 | <ul class="simple"> |
| 180 | <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"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code></a>, no salt is supported.</li> |
| 181 | </ul> |
| 182 | </div> |
| 183 | <div class="section" id="psa_asymmetric_decrypt"> |
| 184 | <span id="c.psa_asymmetric_decrypt"></span><h3><code class="docutils literal"><span class="pre">psa_asymmetric_decrypt</span></code> (function)</h3> |
| 185 | <p>Decrypt a short message with a private key.</p> |
| 186 | <pre class="literal-block"> |
| 187 | <a class="reference internal" href="../library/status.html#c.psa_status_t" title="psa_status_t">psa_status_t</a> <a class="reference internal" href="#c.psa_asymmetric_decrypt" title="psa_asymmetric_decrypt">psa_asymmetric_decrypt</a>(<a class="reference internal" href="../keys/ids.html#c.psa_key_id_t" title="psa_key_id_t">psa_key_id_t</a> key, |
| 188 | <a class="reference internal" href="algorithms.html#c.psa_algorithm_t" title="psa_algorithm_t">psa_algorithm_t</a> alg, |
| 189 | const uint8_t * input, |
| 190 | size_t input_length, |
| 191 | const uint8_t * salt, |
| 192 | size_t salt_length, |
| 193 | uint8_t * output, |
| 194 | size_t output_size, |
| 195 | size_t * output_length); |
| 196 | </pre> |
| 197 | <p class="rubric">Parameters</p> |
| 198 | <dl class="docutils"> |
| 199 | <dt> <code class="docutils literal"><span class="pre">key</span></code></dt> |
| 200 | <dd>Identifier of the key to use for the operation. It must be an asymmetric key pair. |
| 201 | It must allow the usage <a class="reference internal" href="../keys/policy.html#c.PSA_KEY_USAGE_DECRYPT" title="PSA_KEY_USAGE_DECRYPT"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_USAGE_DECRYPT</span></code></a>.</dd> |
| 202 | <dt> <code class="docutils literal"><span class="pre">alg</span></code></dt> |
| 203 | <dd>The asymmetric encryption algorithm to compute: a value of type <a class="reference internal" href="algorithms.html#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="algorithms.html#c.PSA_ALG_IS_ASYMMETRIC_ENCRYPTION" title="PSA_ALG_IS_ASYMMETRIC_ENCRYPTION"><code class="docutils literal"><span class="pre">PSA_ALG_IS_ASYMMETRIC_ENCRYPTION</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">alg</span></code><code class="docutils literal"><span class="pre">)</span></code> is true.</dd> |
| 204 | <dt> <code class="docutils literal"><span class="pre">input</span></code></dt> |
| 205 | <dd>The message to decrypt.</dd> |
| 206 | <dt> <code class="docutils literal"><span class="pre">input_length</span></code></dt> |
| 207 | <dd>Size of the <code class="docutils literal"><span class="pre">input</span></code> buffer in bytes.</dd> |
| 208 | <dt> <code class="docutils literal"><span class="pre">salt</span></code></dt> |
| 209 | <dd>A salt or label, if supported by the encryption algorithm. If the algorithm does not support a salt, pass <code class="docutils literal"><span class="pre">NULL</span></code>. If the algorithm supports an optional salt, pass <code class="docutils literal"><span class="pre">NULL</span></code> to indicate that there is no salt.</dd> |
| 210 | <dt> <code class="docutils literal"><span class="pre">salt_length</span></code></dt> |
| 211 | <dd>Size of the <code class="docutils literal"><span class="pre">salt</span></code> buffer in bytes. If <code class="docutils literal"><span class="pre">salt</span></code> is <code class="docutils literal"><span class="pre">NULL</span></code>, pass <code class="docutils literal"><span class="pre">0</span></code>.</dd> |
| 212 | <dt> <code class="docutils literal"><span class="pre">output</span></code></dt> |
| 213 | <dd>Buffer where the decrypted message is to be written.</dd> |
| 214 | <dt> <code class="docutils literal"><span class="pre">output_size</span></code></dt> |
| 215 | <dd><p class="first">Size of the <code class="docutils literal"><span class="pre">output</span></code> buffer in bytes. |
| 216 | This must be appropriate for the selected algorithm and key:</p> |
| 217 | <ul class="last simple"> |
| 218 | <li>The required output size is <a class="reference internal" href="#c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE" title="PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE"><code class="docutils literal"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">key_type</span></code><code class="docutils literal"><span class="pre">,</span> </code><code class="docutils literal"><span class="pre">key_bits</span></code><code class="docutils literal"><span class="pre">,</span> </code><code class="docutils literal"><span class="pre">alg</span></code><code class="docutils literal"><span class="pre">)</span></code> where <code class="docutils literal"><span class="pre">key_type</span></code> and <code class="docutils literal"><span class="pre">key_bits</span></code> are the type and bit-size respectively of <code class="docutils literal"><span class="pre">key</span></code>.</li> |
| 219 | <li><a class="reference internal" href="#c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE" title="PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE</span></code></a> evaluates to the maximum output size of any supported asymmetric decryption.</li> |
| 220 | </ul> |
| 221 | </dd> |
| 222 | <dt> <code class="docutils literal"><span class="pre">output_length</span></code></dt> |
| 223 | <dd>On success, the number of bytes that make up the returned output.</dd> |
| 224 | </dl> |
| 225 | <p class="rubric">Returns: <a class="reference internal" href="../library/status.html#c.psa_status_t" title="psa_status_t"><code class="docutils literal"><span class="pre">psa_status_t</span></code></a></p> |
| 226 | <dl class="docutils"> |
| 227 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal"><span class="pre">PSA_SUCCESS</span></code></a></dt> |
| 228 | <dd>Success. |
| 229 | The first <code class="docutils literal"><span class="pre">(*output_length)</span></code> bytes of <code class="docutils literal"><span class="pre">output</span></code> contain the decrypted output.</dd> |
| 230 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a></dt> |
| 231 | <dd>The library requires initializing by a call to <a class="reference internal" href="../library/library.html#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal"><span class="pre">psa_crypto_init()</span></code></a>.</dd> |
| 232 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a></dt> |
| 233 | <dd><code class="docutils literal"><span class="pre">key</span></code> is not a valid key identifier.</dd> |
| 234 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a></dt> |
| 235 | <dd>The key does not have the <a class="reference internal" href="../keys/policy.html#c.PSA_KEY_USAGE_DECRYPT" title="PSA_KEY_USAGE_DECRYPT"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_USAGE_DECRYPT</span></code></a> flag, or it does not permit the requested algorithm.</dd> |
| 236 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a></dt> |
| 237 | <dd>The size of the <code class="docutils literal"><span class="pre">output</span></code> buffer is too small. |
| 238 | <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"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE()</span></code></a> or <a class="reference internal" href="#c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE" title="PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE</span></code></a> can be used to determine a sufficient buffer size.</dd> |
| 239 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INVALID_PADDING" title="PSA_ERROR_INVALID_PADDING"><code class="docutils literal"><span class="pre">PSA_ERROR_INVALID_PADDING</span></code></a></dt> |
| 240 | <dd>The algorithm uses padding, and the input does not contain valid padding.</dd> |
| 241 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a></dt> |
| 242 | <dd><p class="first">The following conditions can result in this error:</p> |
| 243 | <ul class="last simple"> |
| 244 | <li><code class="docutils literal"><span class="pre">alg</span></code> is not an asymmetric encryption algorithm.</li> |
| 245 | <li><code class="docutils literal"><span class="pre">key</span></code> is not an asymmetric key pair, that is compatible with <code class="docutils literal"><span class="pre">alg</span></code>.</li> |
| 246 | <li><code class="docutils literal"><span class="pre">input_length</span></code> is not valid for the algorithm and key type.</li> |
| 247 | <li><code class="docutils literal"><span class="pre">salt_length</span></code> is not valid for the algorithm and key type.</li> |
| 248 | </ul> |
| 249 | </dd> |
| 250 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a></dt> |
| 251 | <dd><p class="first">The following conditions can result in this error:</p> |
| 252 | <ul class="last simple"> |
| 253 | <li><code class="docutils literal"><span class="pre">alg</span></code> is not supported or is not an asymmetric encryption algorithm.</li> |
| 254 | <li><code class="docutils literal"><span class="pre">key</span></code> is not supported for use with <code class="docutils literal"><span class="pre">alg</span></code>.</li> |
| 255 | <li><code class="docutils literal"><span class="pre">input_length</span></code> or <code class="docutils literal"><span class="pre">salt_length</span></code> are too large for the implementation.</li> |
| 256 | </ul> |
| 257 | </dd> |
| 258 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a></dt> |
| 259 | <dd></dd> |
| 260 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a></dt> |
| 261 | <dd></dd> |
| 262 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a></dt> |
| 263 | <dd></dd> |
| 264 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a></dt> |
| 265 | <dd></dd> |
| 266 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_STORAGE_FAILURE" title="PSA_ERROR_STORAGE_FAILURE"><code class="docutils literal"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code></a></dt> |
| 267 | <dd></dd> |
| 268 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_DATA_CORRUPT" title="PSA_ERROR_DATA_CORRUPT"><code class="docutils literal"><span class="pre">PSA_ERROR_DATA_CORRUPT</span></code></a></dt> |
| 269 | <dd></dd> |
| 270 | <dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_DATA_INVALID" title="PSA_ERROR_DATA_INVALID"><code class="docutils literal"><span class="pre">PSA_ERROR_DATA_INVALID</span></code></a></dt> |
| 271 | <dd></dd> |
| 272 | </dl> |
| 273 | <p class="rubric">Description</p> |
| 274 | <ul class="simple"> |
| 275 | <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"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code></a>, no salt is supported.</li> |
| 276 | </ul> |
| 277 | </div> |
| 278 | </div> |
| 279 | <div class="section" id="support-macros"> |
| 280 | <h2>10.8.3. Support macros</h2> |
| 281 | <div class="section" id="PSA_ALG_IS_RSA_OAEP"> |
| 282 | <span id="c.PSA_ALG_IS_RSA_OAEP"></span><h3><code class="docutils literal"><span class="pre">PSA_ALG_IS_RSA_OAEP</span></code> (macro)</h3> |
| 283 | <p>Whether the specified algorithm is an RSA OAEP encryption algorithm.</p> |
| 284 | <pre class="literal-block"> |
| 285 | #define <a class="reference internal" href="#c.PSA_ALG_IS_RSA_OAEP" title="PSA_ALG_IS_RSA_OAEP">PSA_ALG_IS_RSA_OAEP</a>(alg) <em><a class="reference internal" href="../../overview/implementation.html#specification-defined-value"><span class="std std-ref">/* specification-defined value */</span></a></em> |
| 286 | </pre> |
| 287 | <p class="rubric">Parameters</p> |
| 288 | <dl class="docutils"> |
| 289 | <dt> <code class="docutils literal"><span class="pre">alg</span></code></dt> |
| 290 | <dd>An algorithm identifier: a value of type <a class="reference internal" href="algorithms.html#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal"><span class="pre">psa_algorithm_t</span></code></a>.</dd> |
| 291 | </dl> |
| 292 | <p class="rubric">Returns</p> |
| 293 | <p><code class="docutils literal"><span class="pre">1</span></code> if <code class="docutils literal"><span class="pre">alg</span></code> is an RSA OAEP algorithm, <code class="docutils literal"><span class="pre">0</span></code> otherwise.</p> |
| 294 | <p>This macro can return either <code class="docutils literal"><span class="pre">0</span></code> or <code class="docutils literal"><span class="pre">1</span></code> if <code class="docutils literal"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p> |
| 295 | </div> |
| 296 | <div class="section" id="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE"> |
| 297 | <span id="c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE"></span><h3><code class="docutils literal"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</span></code> (macro)</h3> |
| 298 | <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"><span class="pre">psa_asymmetric_encrypt()</span></code></a>.</p> |
| 299 | <pre class="literal-block"> |
| 300 | #define <a class="reference internal" href="#c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE" title="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</a>(key_type, key_bits, alg) \ |
| 301 | <em><a class="reference internal" href="../../overview/implementation.html#implementation-defined-value"><span class="std std-ref">/* implementation-defined value */</span></a></em> |
| 302 | </pre> |
| 303 | <p class="rubric">Parameters</p> |
| 304 | <dl class="docutils"> |
| 305 | <dt> <code class="docutils literal"><span class="pre">key_type</span></code></dt> |
| 306 | <dd>An asymmetric key type, either a key pair or a public key.</dd> |
| 307 | <dt> <code class="docutils literal"><span class="pre">key_bits</span></code></dt> |
| 308 | <dd>The size of the key in bits.</dd> |
| 309 | <dt> <code class="docutils literal"><span class="pre">alg</span></code></dt> |
| 310 | <dd>An asymmetric encryption algorithm: a value of type <a class="reference internal" href="algorithms.html#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="algorithms.html#c.PSA_ALG_IS_ASYMMETRIC_ENCRYPTION" title="PSA_ALG_IS_ASYMMETRIC_ENCRYPTION"><code class="docutils literal"><span class="pre">PSA_ALG_IS_ASYMMETRIC_ENCRYPTION</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">alg</span></code><code class="docutils literal"><span class="pre">)</span></code> is true.</dd> |
| 311 | </dl> |
| 312 | <p class="rubric">Returns</p> |
| 313 | <p>A sufficient output buffer size for the specified asymmetric encryption algorithm and key parameters. An implementation can return either <code class="docutils literal"><span class="pre">0</span></code> or a correct size for an asymmetric encryption algorithm and key parameters that it recognizes, but does not support. If the parameters are not valid, the return value is unspecified.</p> |
| 314 | <p class="rubric">Description</p> |
| 315 | <p>If the size of the output buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_asymmetric_encrypt" title="psa_asymmetric_encrypt"><code class="xref any c c-func docutils literal"><span class="pre">psa_asymmetric_encrypt()</span></code></a> will not fail due to an insufficient buffer size. The actual size of the output might be smaller in any given call.</p> |
| 316 | <p>See also <a class="reference internal" href="#c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE" title="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE</span></code></a>.</p> |
| 317 | </div> |
| 318 | <div class="section" id="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE"> |
| 319 | <span id="c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE"></span><h3><code class="docutils literal"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE</span></code> (macro)</h3> |
| 320 | <p>A 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"><span class="pre">psa_asymmetric_encrypt()</span></code></a>, for any of the supported key types and asymmetric encryption algorithms.</p> |
| 321 | <pre class="literal-block"> |
| 322 | #define <a class="reference internal" href="#c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE" title="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE</a> \ |
| 323 | <em><a class="reference internal" href="../../overview/implementation.html#implementation-defined-value"><span class="std std-ref">/* implementation-defined value */</span></a></em> |
| 324 | </pre> |
| 325 | <p>If the size of the output buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_asymmetric_encrypt" title="psa_asymmetric_encrypt"><code class="xref any c c-func docutils literal"><span class="pre">psa_asymmetric_encrypt()</span></code></a> will not fail due to an insufficient buffer size.</p> |
| 326 | <p>See also <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"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE()</span></code></a>.</p> |
| 327 | </div> |
| 328 | <div class="section" id="PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE"> |
| 329 | <span id="c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE"></span><h3><code class="docutils literal"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</span></code> (macro)</h3> |
| 330 | <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"><span class="pre">psa_asymmetric_decrypt()</span></code></a>.</p> |
| 331 | <pre class="literal-block"> |
| 332 | #define <a class="reference internal" href="#c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE" title="PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</a>(key_type, key_bits, alg) \ |
| 333 | <em><a class="reference internal" href="../../overview/implementation.html#implementation-defined-value"><span class="std std-ref">/* implementation-defined value */</span></a></em> |
| 334 | </pre> |
| 335 | <p class="rubric">Parameters</p> |
| 336 | <dl class="docutils"> |
| 337 | <dt> <code class="docutils literal"><span class="pre">key_type</span></code></dt> |
| 338 | <dd>An asymmetric key type, either a key pair or a public key.</dd> |
| 339 | <dt> <code class="docutils literal"><span class="pre">key_bits</span></code></dt> |
| 340 | <dd>The size of the key in bits.</dd> |
| 341 | <dt> <code class="docutils literal"><span class="pre">alg</span></code></dt> |
| 342 | <dd>An asymmetric encryption algorithm: a value of type <a class="reference internal" href="algorithms.html#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="algorithms.html#c.PSA_ALG_IS_ASYMMETRIC_ENCRYPTION" title="PSA_ALG_IS_ASYMMETRIC_ENCRYPTION"><code class="docutils literal"><span class="pre">PSA_ALG_IS_ASYMMETRIC_ENCRYPTION</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">alg</span></code><code class="docutils literal"><span class="pre">)</span></code> is true.</dd> |
| 343 | </dl> |
| 344 | <p class="rubric">Returns</p> |
| 345 | <p>A sufficient output buffer size for the specified asymmetric encryption algorithm and key parameters. An implementation can return either <code class="docutils literal"><span class="pre">0</span></code> or a correct size for an asymmetric encryption algorithm and key parameters that it recognizes, but does not support. If the parameters are not valid, the return value is unspecified.</p> |
| 346 | <p class="rubric">Description</p> |
| 347 | <p>If the size of the output buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_asymmetric_decrypt" title="psa_asymmetric_decrypt"><code class="xref any c c-func docutils literal"><span class="pre">psa_asymmetric_decrypt()</span></code></a> will not fail due to an insufficient buffer size. The actual size of the output might be smaller in any given call.</p> |
| 348 | <p>See also <a class="reference internal" href="#c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE" title="PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE</span></code></a>.</p> |
| 349 | </div> |
| 350 | <div class="section" id="PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE"> |
| 351 | <span id="c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE"></span><h3><code class="docutils literal"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE</span></code> (macro)</h3> |
| 352 | <p>A 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"><span class="pre">psa_asymmetric_decrypt()</span></code></a>, for any of the supported key types and asymmetric encryption algorithms.</p> |
| 353 | <pre class="literal-block"> |
| 354 | #define <a class="reference internal" href="#c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE" title="PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE">PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE</a> \ |
| 355 | <em><a class="reference internal" href="../../overview/implementation.html#implementation-defined-value"><span class="std std-ref">/* implementation-defined value */</span></a></em> |
| 356 | </pre> |
| 357 | <p>If the size of the output buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_asymmetric_decrypt" title="psa_asymmetric_decrypt"><code class="xref any c c-func docutils literal"><span class="pre">psa_asymmetric_decrypt()</span></code></a> will not fail due to an insufficient buffer size.</p> |
| 358 | <p>See also <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"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE()</span></code></a>.</p> |
| 359 | </div> |
| 360 | </div> |
| 361 | </div> |
| 362 | |
| 363 | |
| 364 | </div> |
| 365 | </div> |
| 366 | </div> |
| 367 | <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> |
| 368 | <div class="sphinxsidebarwrapper"><h3><a href="../../index.html"><b>PSA Crypto API</b></a></h3> |
| 369 | IHI 0086<br/> |
| 370 | Non-confidential<br/> |
| 371 | Version 1.1.0 |
| 372 | <span style="color: red; font-weight: bold;"></span> |
| 373 | <ul> |
| 374 | <li class="toctree-l1"><a class="reference internal" href="../../about.html">About this document</a></li> |
| 375 | </ul> |
| 376 | <ul class="current"> |
| 377 | <li class="toctree-l1"><a class="reference internal" href="../../overview/intro.html">1. Introduction</a></li> |
| 378 | <li class="toctree-l1"><a class="reference internal" href="../../overview/goals.html">2. Design goals</a></li> |
| 379 | <li class="toctree-l1"><a class="reference internal" href="../../overview/functionality.html">3. Functionality overview</a></li> |
| 380 | <li class="toctree-l1"><a class="reference internal" href="../../overview/sample-arch.html">4. Sample architectures</a></li> |
| 381 | <li class="toctree-l1"><a class="reference internal" href="../../overview/conventions.html">5. Library conventions</a></li> |
| 382 | <li class="toctree-l1"><a class="reference internal" href="../../overview/implementation.html">6. Implementation considerations</a></li> |
| 383 | <li class="toctree-l1"><a class="reference internal" href="../../overview/usage.html">7. Usage considerations</a></li> |
| 384 | <li class="toctree-l1"><a class="reference internal" href="../library/index.html">8. Library management reference</a></li> |
| 385 | <li class="toctree-l1"><a class="reference internal" href="../keys/index.html">9. Key management reference</a></li> |
| 386 | <li class="toctree-l1 current"><a class="reference internal" href="index.html">10. Cryptographic operation reference</a><ul class="current"> |
| 387 | <li class="toctree-l2"><a class="reference internal" href="algorithms.html">10.1. Algorithms</a></li> |
| 388 | <li class="toctree-l2"><a class="reference internal" href="hashes.html">10.2. Message digests (Hashes)</a></li> |
| 389 | <li class="toctree-l2"><a class="reference internal" href="macs.html">10.3. Message authentication codes (MAC)</a></li> |
| 390 | <li class="toctree-l2"><a class="reference internal" href="ciphers.html">10.4. Unauthenticated ciphers</a></li> |
| 391 | <li class="toctree-l2"><a class="reference internal" href="aead.html">10.5. Authenticated encryption with associated data (AEAD)</a></li> |
| 392 | <li class="toctree-l2"><a class="reference internal" href="kdf.html">10.6. Key derivation</a></li> |
| 393 | <li class="toctree-l2"><a class="reference internal" href="sign.html">10.7. Asymmetric signature</a></li> |
| 394 | <li class="toctree-l2 current"><a class="current reference internal" href="#">10.8. Asymmetric encryption</a><ul> |
| 395 | <li class="toctree-l3"><a class="reference internal" href="#asymmetric-encryption-algorithms">10.8.1. Asymmetric encryption algorithms</a></li> |
| 396 | <li class="toctree-l3"><a class="reference internal" href="#asymmetric-encryption-functions">10.8.2. Asymmetric encryption functions</a></li> |
| 397 | <li class="toctree-l3"><a class="reference internal" href="#support-macros">10.8.3. Support macros</a></li> |
| 398 | </ul> |
| 399 | </li> |
| 400 | <li class="toctree-l2"><a class="reference internal" href="ka.html">10.9. Key agreement</a></li> |
| 401 | <li class="toctree-l2"><a class="reference internal" href="rng.html">10.10. Other cryptographic services</a></li> |
| 402 | </ul> |
| 403 | </li> |
| 404 | </ul> |
| 405 | <ul> |
| 406 | <li class="toctree-l1"><a class="reference internal" href="../../appendix/example_header.html">Example header file</a></li> |
| 407 | <li class="toctree-l1"><a class="reference internal" href="../../appendix/encodings.html">Algorithm and key type encoding</a></li> |
| 408 | <li class="toctree-l1"><a class="reference internal" href="../../appendix/specdef_values.html">Example macro implementations</a></li> |
| 409 | <li class="toctree-l1"><a class="reference internal" href="../../appendix/sra.html">Security Risk Assessment</a></li> |
| 410 | <li class="toctree-l1"><a class="reference internal" href="../../appendix/history.html">Changes to the API</a></li> |
| 411 | </ul> |
| 412 | <ul> |
| 413 | <li class="toctree-l1"><a class="reference internal" href="../../psa_c-identifiers.html">Index of API elements</a></li> |
| 414 | </ul> |
| 415 | <div id="searchbox" style="display: none" role="search"> |
| 416 | <h3>Quick search</h3> |
| 417 | <form class="search" action="../../search.html" method="get"> |
| 418 | <div><input type="text" name="q" /></div> |
| 419 | <div><input type="submit" value="Go" /></div> |
| 420 | <input type="hidden" name="check_keywords" value="yes" /> |
| 421 | <input type="hidden" name="area" value="default" /> |
| 422 | </form> |
| 423 | </div> |
| 424 | <script type="text/javascript">$('#searchbox').show(0);</script> |
| 425 | </div> |
| 426 | </div> |
| 427 | <div class="clearer"></div> |
| 428 | </div> |
| 429 | <div class="footer"> |
| 430 | © 2018-2022, Arm Limited or its affiliates. All rights reserved. |
| 431 | |
| 432 | | |
| 433 | Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.7</a> |
| 434 | & <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.8</a> |
| 435 | |
| 436 | </div> |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | </body> |
| 442 | </html> |