blob: 6bbad22570793ae9db9cad491d6b1a31c6533825 [file] [log] [blame]
Gilles Peskine882f7c72022-04-07 13:44:55 +02001
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>Algorithm and key type encoding &#8212; 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="Example macro implementations" href="specdef_values.html" />
28 <link rel="prev" title="Example header file" href="example_header.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="algorithm-and-key-type-encoding">
44<span id="appendix-encodings"></span><h1>Algorithm and key type encoding</h1>
45<p>Algorithm identifiers (<a class="reference internal" href="../api/ops/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>) and key types (<a class="reference internal" href="../api/keys/types.html#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal"><span class="pre">psa_key_type_t</span></code></a>) in the PSA Crypto API are structured integer values.</p>
46<ul class="simple">
47<li><a class="reference internal" href="#algorithm-encoding"><span class="secref">Algorithm identifier encoding</span></a> describes the encoding scheme for algorithm identifiers</li>
48<li><a class="reference internal" href="#key-type-encoding"><span class="secref">Key type encoding</span></a> describes the encoding scheme for key types</li>
49</ul>
50<div class="section" id="algorithm-identifier-encoding">
51<span id="algorithm-encoding"></span><h2>Algorithm identifier encoding</h2>
52<p>Algorithm identifiers are 32-bit integer values of the type <a class="reference internal" href="../api/ops/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>. Algorithm identifier values have the structure shown in <span><a class="reference internal" href="#fig-algorithm-fields"><span class="numref">Figure 1</span></a></span>.</p>
53<div class="figure" id="fig-algorithm-fields">
54<img alt="../_images/algorithm_fields.svg" src="../_images/algorithm_fields.svg" /><p class="caption"><span class="caption-number">Figure 1 </span><span class="caption-text">Encoding of <a class="reference internal" href="../api/ops/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></span></p>
55</div>
56<p><span><a class="reference internal" href="#table-algorithm-fields"><span class="numref">Table 6</span></a></span> describes the meaning of the bit-fields — some of the bit-fields are used in different ways by different algorithm categories.</p>
57<table border="1" class="colwidths-given longtable docutils align-right" id="table-algorithm-fields">
58<caption><span class="caption-number">Table 6 </span><span class="caption-text">Bit fields in an algorithm identifier</span></caption>
59<colgroup>
60<col width="10%" />
61<col width="10%" />
62<col width="81%" />
63</colgroup>
64<thead valign="bottom">
65<tr class="row-odd"><th class="head">Field</th>
66<th class="head">Bits</th>
67<th class="head">Description</th>
68</tr>
69</thead>
70<tbody valign="top">
71<tr class="row-even"><td>V</td>
72<td>[31]</td>
73<td><p class="first">Flag to indicate an implementation-defined algorithm identifier, when V=1.</p>
74<p class="last">Algorithm identifiers defined by this specification always have V=0.</p>
75</td>
76</tr>
77<tr class="row-odd"><td>CAT</td>
78<td>[30:24]</td>
79<td>Algorithm category. See <a class="reference internal" href="#algorithm-category"><span class="secref">Algorithm categories</span></a>.</td>
80</tr>
81<tr class="row-even"><td>S</td>
82<td>[23]</td>
83<td><p class="first">For a cipher algorithm, this flag indicates a stream cipher when S=1.</p>
84<p class="last">For a key derivation algorithm, this flag indicates a key-stretching or password-hashing algorithm when S=1.</p>
85</td>
86</tr>
87<tr class="row-odd"><td>B</td>
88<td>[22]</td>
89<td>Flag to indicate an algorithm built on a block cipher, when B=1.</td>
90</tr>
91<tr class="row-even"><td>LEN/T2</td>
92<td>[21:16]</td>
93<td>LEN is the length of a MAC or AEAD tag, T2 is a key agreement algorithm sub-type.</td>
94</tr>
95<tr class="row-odd"><td>T1</td>
96<td>[15:8]</td>
97<td>Algorithm sub-type for most algorithm categories.</td>
98</tr>
99<tr class="row-even"><td>H</td>
100<td>[7:0]</td>
101<td>Hash algorithm sub-type, also used in any algorithm that is parameterized by a hash.</td>
102</tr>
103</tbody>
104</table>
105<div class="section" id="algorithm-categories">
106<span id="algorithm-category"></span><h3>Algorithm categories</h3>
107<p>The CAT field in an algorithm identifier takes the values shown in <span><a class="reference internal" href="#table-algorithm-category"><span class="numref">Table 7</span></a></span>.</p>
108<table border="1" class="colwidths-auto docutils align-left" id="table-algorithm-category">
109<caption><span class="caption-number">Table 7 </span><span class="caption-text">Algorithm identifier categories</span></caption>
110<thead valign="bottom">
111<tr class="row-odd"><th class="head">Algorithm category</th>
112<th class="head">CAT</th>
113<th class="head">Category details</th>
114</tr>
115</thead>
116<tbody valign="top">
117<tr class="row-even"><td>None</td>
118<td><code class="docutils literal"><span class="pre">0x00</span></code></td>
119<td>See <a class="reference internal" href="../api/ops/algorithms.html#c.PSA_ALG_NONE" title="PSA_ALG_NONE"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_NONE</span></code></a></td>
120</tr>
121<tr class="row-odd"><td>Hash</td>
122<td><code class="docutils literal"><span class="pre">0x02</span></code></td>
123<td>See <a class="reference internal" href="#hash-encoding"><span class="secref">Hash algorithm encoding</span></a></td>
124</tr>
125<tr class="row-even"><td>MAC</td>
126<td><code class="docutils literal"><span class="pre">0x03</span></code></td>
127<td>See <a class="reference internal" href="#mac-encoding"><span class="secref">MAC algorithm encoding</span></a></td>
128</tr>
129<tr class="row-odd"><td>Cipher</td>
130<td><code class="docutils literal"><span class="pre">0x04</span></code></td>
131<td>See <a class="reference internal" href="#cipher-encoding"><span class="secref">Cipher algorithm encoding</span></a></td>
132</tr>
133<tr class="row-even"><td>AEAD</td>
134<td><code class="docutils literal"><span class="pre">0x05</span></code></td>
135<td>See <a class="reference internal" href="#aead-encoding"><span class="secref">AEAD algorithm encoding</span></a></td>
136</tr>
137<tr class="row-odd"><td>Key derivation</td>
138<td><code class="docutils literal"><span class="pre">0x08</span></code></td>
139<td>See <a class="reference internal" href="#kdf-encoding"><span class="secref">Key derivation algorithm encoding</span></a></td>
140</tr>
141<tr class="row-even"><td>Asymmetric signature</td>
142<td><code class="docutils literal"><span class="pre">0x06</span></code></td>
143<td>See <a class="reference internal" href="#sign-encoding"><span class="secref">Asymmetric signature algorithm encoding</span></a></td>
144</tr>
145<tr class="row-odd"><td>Asymmetric encryption</td>
146<td><code class="docutils literal"><span class="pre">0x07</span></code></td>
147<td>See <a class="reference internal" href="#pke-encoding"><span class="secref">Asymmetric encryption algorithm encoding</span></a></td>
148</tr>
149<tr class="row-even"><td>Key agreement</td>
150<td><code class="docutils literal"><span class="pre">0x09</span></code></td>
151<td>See <a class="reference internal" href="#ka-encoding"><span class="secref">Key agreement algorithm encoding</span></a></td>
152</tr>
153</tbody>
154</table>
155</div>
156<div class="section" id="hash-algorithm-encoding">
157<span id="hash-encoding"></span><h3>Hash algorithm encoding</h3>
158<p>The algorithm identifier for hash algorithms defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-hash-fields"><span class="numref">Figure 2</span></a></span>.</p>
159<div class="figure" id="fig-hash-fields">
160<img alt="../_images/hash_fields.svg" src="../_images/hash_fields.svg" /><p class="caption"><span class="caption-number">Figure 2 </span><span class="caption-text">Hash algorithm encoding</span></p>
161</div>
162<p>The defined values for HASH-TYPE are shown in <span><a class="reference internal" href="#table-hash-type"><span class="numref">Table 8</span></a></span>.</p>
163<table border="1" class="colwidths-auto docutils align-left" id="table-hash-type">
164<caption><span class="caption-number">Table 8 </span><span class="caption-text">Hash algorithm sub-type values</span></caption>
165<thead valign="bottom">
166<tr class="row-odd"><th class="head">Hash algorithm</th>
167<th class="head">HASH-TYPE</th>
168<th class="head">Algorithm identifier</th>
169<th class="head">Algorithm value</th>
170</tr>
171</thead>
172<tbody valign="top">
173<tr class="row-even"><td>MD2</td>
174<td><code class="docutils literal"><span class="pre">0x01</span></code></td>
175<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_MD2" title="PSA_ALG_MD2"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_MD2</span></code></a></td>
176<td><code class="docutils literal"><span class="pre">0x02000001</span></code></td>
177</tr>
178<tr class="row-odd"><td>MD4</td>
179<td><code class="docutils literal"><span class="pre">0x02</span></code></td>
180<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_MD4" title="PSA_ALG_MD4"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_MD4</span></code></a></td>
181<td><code class="docutils literal"><span class="pre">0x02000002</span></code></td>
182</tr>
183<tr class="row-even"><td>MD5</td>
184<td><code class="docutils literal"><span class="pre">0x03</span></code></td>
185<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_MD5" title="PSA_ALG_MD5"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_MD5</span></code></a></td>
186<td><code class="docutils literal"><span class="pre">0x02000003</span></code></td>
187</tr>
188<tr class="row-odd"><td>RIPEMD-160</td>
189<td><code class="docutils literal"><span class="pre">0x04</span></code></td>
190<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_RIPEMD160" title="PSA_ALG_RIPEMD160"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_RIPEMD160</span></code></a></td>
191<td><code class="docutils literal"><span class="pre">0x02000004</span></code></td>
192</tr>
193<tr class="row-even"><td>SHA1</td>
194<td><code class="docutils literal"><span class="pre">0x05</span></code></td>
195<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA_1" title="PSA_ALG_SHA_1"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA_1</span></code></a></td>
196<td><code class="docutils literal"><span class="pre">0x02000005</span></code></td>
197</tr>
198<tr class="row-odd"><td>SHA-224</td>
199<td><code class="docutils literal"><span class="pre">0x08</span></code></td>
200<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA_224" title="PSA_ALG_SHA_224"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA_224</span></code></a></td>
201<td><code class="docutils literal"><span class="pre">0x02000008</span></code></td>
202</tr>
203<tr class="row-even"><td>SHA-256</td>
204<td><code class="docutils literal"><span class="pre">0x09</span></code></td>
205<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA_256" title="PSA_ALG_SHA_256"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA_256</span></code></a></td>
206<td><code class="docutils literal"><span class="pre">0x02000009</span></code></td>
207</tr>
208<tr class="row-odd"><td>SHA-384</td>
209<td><code class="docutils literal"><span class="pre">0x0A</span></code></td>
210<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA_384" title="PSA_ALG_SHA_384"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA_384</span></code></a></td>
211<td><code class="docutils literal"><span class="pre">0x0200000A</span></code></td>
212</tr>
213<tr class="row-even"><td>SHA-512</td>
214<td><code class="docutils literal"><span class="pre">0x0B</span></code></td>
215<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA_512" title="PSA_ALG_SHA_512"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA_512</span></code></a></td>
216<td><code class="docutils literal"><span class="pre">0x0200000B</span></code></td>
217</tr>
218<tr class="row-odd"><td>SHA-512/224</td>
219<td><code class="docutils literal"><span class="pre">0x0C</span></code></td>
220<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA_512_224" title="PSA_ALG_SHA_512_224"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA_512_224</span></code></a></td>
221<td><code class="docutils literal"><span class="pre">0x0200000C</span></code></td>
222</tr>
223<tr class="row-even"><td>SHA-512/256</td>
224<td><code class="docutils literal"><span class="pre">0x0D</span></code></td>
225<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA_512_256" title="PSA_ALG_SHA_512_256"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA_512_256</span></code></a></td>
226<td><code class="docutils literal"><span class="pre">0x0200000D</span></code></td>
227</tr>
228<tr class="row-odd"><td>SHA3-224</td>
229<td><code class="docutils literal"><span class="pre">0x10</span></code></td>
230<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA3_224" title="PSA_ALG_SHA3_224"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA3_224</span></code></a></td>
231<td><code class="docutils literal"><span class="pre">0x02000010</span></code></td>
232</tr>
233<tr class="row-even"><td>SHA3-256</td>
234<td><code class="docutils literal"><span class="pre">0x11</span></code></td>
235<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA3_256" title="PSA_ALG_SHA3_256"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA3_256</span></code></a></td>
236<td><code class="docutils literal"><span class="pre">0x02000011</span></code></td>
237</tr>
238<tr class="row-odd"><td>SHA3-384</td>
239<td><code class="docutils literal"><span class="pre">0x12</span></code></td>
240<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA3_384" title="PSA_ALG_SHA3_384"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA3_384</span></code></a></td>
241<td><code class="docutils literal"><span class="pre">0x02000012</span></code></td>
242</tr>
243<tr class="row-even"><td>SHA3-512</td>
244<td><code class="docutils literal"><span class="pre">0x13</span></code></td>
245<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHA3_512" title="PSA_ALG_SHA3_512"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHA3_512</span></code></a></td>
246<td><code class="docutils literal"><span class="pre">0x02000013</span></code></td>
247</tr>
248<tr class="row-odd"><td>SM3</td>
249<td><code class="docutils literal"><span class="pre">0x14</span></code></td>
250<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SM3" title="PSA_ALG_SM3"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SM3</span></code></a></td>
251<td><code class="docutils literal"><span class="pre">0x02000014</span></code></td>
252</tr>
253<tr class="row-even"><td>SHAKE256-512</td>
254<td><code class="docutils literal"><span class="pre">0x15</span></code></td>
255<td><a class="reference internal" href="../api/ops/hashes.html#c.PSA_ALG_SHAKE256_512" title="PSA_ALG_SHAKE256_512"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_SHAKE256_512</span></code></a></td>
256<td><code class="docutils literal"><span class="pre">0x02000015</span></code></td>
257</tr>
258<tr class="row-odd"><td><em>wildcard</em> <sup>a</sup></td>
259<td><code class="docutils literal"><span class="pre">0xFF</span></code></td>
260<td><a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_ANY_HASH</span></code></a></td>
261<td><code class="docutils literal"><span class="pre">0x020000FF</span></code></td>
262</tr>
263</tbody>
264</table>
265<ol class="loweralpha simple">
266<li>The wildcard hash <a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_ANY_HASH</span></code></a> can be used to parameterize a signature algorithm which defines a key usage policy, allowing any hash algorithm to be specified in a signature operation using the key.</li>
267</ol>
268</div>
269<div class="section" id="mac-algorithm-encoding">
270<span id="mac-encoding"></span><h3>MAC algorithm encoding</h3>
271<p>The algorithm identifier for MAC algorithms defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-mac-fields"><span class="numref">Figure 3</span></a></span>.</p>
272<div class="figure" id="fig-mac-fields">
273<img alt="../_images/mac_fields.svg" src="../_images/mac_fields.svg" /><p class="caption"><span class="caption-number">Figure 3 </span><span class="caption-text">MAC algorithm encoding</span></p>
274</div>
275<p>The defined values for B and MAC-TYPE are shown in <span><a class="reference internal" href="#table-mac-type"><span class="numref">Table 9</span></a></span>.</p>
276<p>LEN = 0 specifies a default length output MAC, other values for LEN specify a truncated MAC.</p>
277<p>W is a flag to indicate a wildcard permitted-algorithm policy:</p>
278<ul class="simple">
279<li>W = 0 indicates a specific MAC algorithm and MAC length.</li>
280<li>W = 1 indicates a wildcard key usage policy, which permits the MAC algorithm with a MAC length of at least LEN to be specified in a MAC operation using the key. LEN must not be zero.</li>
281</ul>
282<p>H = HASH-TYPE (see <span><a class="reference internal" href="#table-hash-type"><span class="numref">Table 8</span></a></span>) for hash-based MAC algorithms, otherwise H = 0.</p>
283<table border="1" class="colwidths-auto docutils align-left" id="table-mac-type">
284<caption><span class="caption-number">Table 9 </span><span class="caption-text">MAC algorithm sub-type values</span></caption>
285<thead valign="bottom">
286<tr class="row-odd"><th class="head">MAC algorithm</th>
287<th class="head">B</th>
288<th class="head">MAC-TYPE</th>
289<th class="head">Algorithm identifier</th>
290<th class="head">Algorithm value</th>
291</tr>
292</thead>
293<tbody valign="top">
294<tr class="row-even"><td>HMAC</td>
295<td>0</td>
296<td><code class="docutils literal"><span class="pre">0x00</span></code></td>
297<td><a class="reference internal" href="../api/ops/macs.html#c.PSA_ALG_HMAC" title="PSA_ALG_HMAC"><code class="docutils literal"><span class="pre">PSA_ALG_HMAC</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></td>
298<td><code class="docutils literal"><span class="pre">0x038000hh</span></code> <sup>a b</sup></td>
299</tr>
300<tr class="row-odd"><td>CBC-MAC <sup>c</sup></td>
301<td>1</td>
302<td><code class="docutils literal"><span class="pre">0x01</span></code></td>
303<td><a class="reference internal" href="../api/ops/macs.html#c.PSA_ALG_CBC_MAC" title="PSA_ALG_CBC_MAC"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_CBC_MAC</span></code></a></td>
304<td><code class="docutils literal"><span class="pre">0x03c00100</span></code> <sup>a</sup></td>
305</tr>
306<tr class="row-even"><td>CMAC <sup>c</sup></td>
307<td>1</td>
308<td><code class="docutils literal"><span class="pre">0x02</span></code></td>
309<td><a class="reference internal" href="../api/ops/macs.html#c.PSA_ALG_CMAC" title="PSA_ALG_CMAC"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_CMAC</span></code></a></td>
310<td><code class="docutils literal"><span class="pre">0x03c00200</span></code> <sup>a</sup></td>
311</tr>
312</tbody>
313</table>
314<ol class="loweralpha simple">
315<li>This is the default algorithm identifier, specifying a standard length tag. <a class="reference internal" href="../api/ops/macs.html#c.PSA_ALG_TRUNCATED_MAC" title="PSA_ALG_TRUNCATED_MAC"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_TRUNCATED_MAC()</span></code></a> generates identifiers with non-default LEN values. <a class="reference internal" href="../api/ops/macs.html#c.PSA_ALG_AT_LEAST_THIS_LENGTH_MAC" title="PSA_ALG_AT_LEAST_THIS_LENGTH_MAC"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_AT_LEAST_THIS_LENGTH_MAC()</span></code></a> generates permitted-algorithm policies with W = 1.</li>
316<li><code class="docutils literal"><span class="pre">hh</span></code> is the HASH-TYPE for the hash algorithm, <code class="docutils literal"><span class="pre">hash_alg</span></code>, used to construct the MAC algorithm.</li>
317<li>This is a MAC constructed using an underlying block cipher. The block cipher is determined by the key type that is provided to the MAC operation.</li>
318</ol>
319</div>
320<div class="section" id="cipher-algorithm-encoding">
321<span id="cipher-encoding"></span><h3>Cipher algorithm encoding</h3>
322<p>The algorithm identifier for CIPHER algorithms defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-cipher-fields"><span class="numref">Figure 4</span></a></span>.</p>
323<div class="figure" id="fig-cipher-fields">
324<img alt="../_images/cipher_fields.svg" src="../_images/cipher_fields.svg" /><p class="caption"><span class="caption-number">Figure 4 </span><span class="caption-text">CIPHER algorithm encoding</span></p>
325</div>
326<p>The defined values for S, B, and CIPHER-TYPE are shown in <span><a class="reference internal" href="#table-cipher-type"><span class="numref">Table 10</span></a></span>.</p>
327<table border="1" class="colwidths-auto docutils align-left" id="table-cipher-type">
328<caption><span class="caption-number">Table 10 </span><span class="caption-text">Cipher algorithm sub-type values</span></caption>
329<thead valign="bottom">
330<tr class="row-odd"><th class="head">Cipher algorithm</th>
331<th class="head">S</th>
332<th class="head">B</th>
333<th class="head">CIPHER-TYPE</th>
334<th class="head">Algorithm identifier</th>
335<th class="head">Algorithm value</th>
336</tr>
337</thead>
338<tbody valign="top">
339<tr class="row-even"><td><em>Stream cipher</em> <sup>a</sup></td>
340<td>1</td>
341<td>0</td>
342<td><code class="docutils literal"><span class="pre">0x01</span></code></td>
343<td><a class="reference internal" href="../api/ops/ciphers.html#c.PSA_ALG_STREAM_CIPHER" title="PSA_ALG_STREAM_CIPHER"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_STREAM_CIPHER</span></code></a></td>
344<td><code class="docutils literal"><span class="pre">0x04800100</span></code></td>
345</tr>
346<tr class="row-odd"><td>CTR mode <sup>b</sup></td>
347<td>1</td>
348<td>1</td>
349<td><code class="docutils literal"><span class="pre">0x10</span></code></td>
350<td><a class="reference internal" href="../api/ops/ciphers.html#c.PSA_ALG_CTR" title="PSA_ALG_CTR"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_CTR</span></code></a></td>
351<td><code class="docutils literal"><span class="pre">0x04C01000</span></code></td>
352</tr>
353<tr class="row-even"><td>CFB mode <sup>b</sup></td>
354<td>1</td>
355<td>1</td>
356<td><code class="docutils literal"><span class="pre">0x11</span></code></td>
357<td><a class="reference internal" href="../api/ops/ciphers.html#c.PSA_ALG_CFB" title="PSA_ALG_CFB"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_CFB</span></code></a></td>
358<td><code class="docutils literal"><span class="pre">0x04C01100</span></code></td>
359</tr>
360<tr class="row-odd"><td>OFB mode <sup>b</sup></td>
361<td>1</td>
362<td>1</td>
363<td><code class="docutils literal"><span class="pre">0x12</span></code></td>
364<td><a class="reference internal" href="../api/ops/ciphers.html#c.PSA_ALG_OFB" title="PSA_ALG_OFB"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_OFB</span></code></a></td>
365<td><code class="docutils literal"><span class="pre">0x04C01200</span></code></td>
366</tr>
367<tr class="row-even"><td>XTS mode <sup>b</sup></td>
368<td>0</td>
369<td>1</td>
370<td><code class="docutils literal"><span class="pre">0xFF</span></code></td>
371<td><a class="reference internal" href="../api/ops/ciphers.html#c.PSA_ALG_XTS" title="PSA_ALG_XTS"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_XTS</span></code></a></td>
372<td><code class="docutils literal"><span class="pre">0x0440FF00</span></code></td>
373</tr>
374<tr class="row-odd"><td>CBC mode without padding <sup>b</sup></td>
375<td>0</td>
376<td>1</td>
377<td><code class="docutils literal"><span class="pre">0x40</span></code></td>
378<td><a class="reference internal" href="../api/ops/ciphers.html#c.PSA_ALG_CBC_NO_PADDING" title="PSA_ALG_CBC_NO_PADDING"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_CBC_NO_PADDING</span></code></a></td>
379<td><code class="docutils literal"><span class="pre">0x04404000</span></code></td>
380</tr>
381<tr class="row-even"><td>CBC mode with PKCS#7 padding <sup>b</sup></td>
382<td>0</td>
383<td>1</td>
384<td><code class="docutils literal"><span class="pre">0x41</span></code></td>
385<td><a class="reference internal" href="../api/ops/ciphers.html#c.PSA_ALG_CBC_PKCS7" title="PSA_ALG_CBC_PKCS7"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_CBC_PKCS7</span></code></a></td>
386<td><code class="docutils literal"><span class="pre">0x04404100</span></code></td>
387</tr>
388<tr class="row-odd"><td>ECB mode without padding <sup>b</sup></td>
389<td>0</td>
390<td>1</td>
391<td><code class="docutils literal"><span class="pre">0x44</span></code></td>
392<td><a class="reference internal" href="../api/ops/ciphers.html#c.PSA_ALG_ECB_NO_PADDING" title="PSA_ALG_ECB_NO_PADDING"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_ECB_NO_PADDING</span></code></a></td>
393<td><code class="docutils literal"><span class="pre">0x04404400</span></code></td>
394</tr>
395</tbody>
396</table>
397<ol class="loweralpha simple">
398<li>The stream cipher algorithm identifier <a class="reference internal" href="../api/ops/ciphers.html#c.PSA_ALG_STREAM_CIPHER" title="PSA_ALG_STREAM_CIPHER"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_STREAM_CIPHER</span></code></a> is used with specific stream cipher key types, such as <a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_CHACHA20" title="PSA_KEY_TYPE_CHACHA20"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_CHACHA20</span></code></a>.</li>
399<li>This is a cipher mode of an underlying block cipher. The block cipher is determined by the key type that is provided to the cipher operation.</li>
400</ol>
401</div>
402<div class="section" id="aead-algorithm-encoding">
403<span id="aead-encoding"></span><h3>AEAD algorithm encoding</h3>
404<p>The algorithm identifier for AEAD algorithms defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-aead-fields"><span class="numref">Figure 5</span></a></span>.</p>
405<div class="figure" id="fig-aead-fields">
406<img alt="../_images/aead_fields.svg" src="../_images/aead_fields.svg" /><p class="caption"><span class="caption-number">Figure 5 </span><span class="caption-text">AEAD algorithm encoding</span></p>
407</div>
408<p>The defined values for B and AEAD-TYPE are shown in <span><a class="reference internal" href="#table-aead-type"><span class="numref">Table 11</span></a></span>.</p>
409<p>LEN = 1..31 specifies the output tag length.</p>
410<p>W is a flag to indicate a wildcard permitted-algorithm policy:</p>
411<ul class="simple">
412<li>W = 0 indicates a specific AEAD algorithm and tag length.</li>
413<li>W = 1 indicates a wildcard key usage policy, which permits the AEAD algorithm with a tag length of at least LEN to be specified in an AEAD operation using the key.</li>
414</ul>
415<table border="1" class="colwidths-auto docutils align-left" id="table-aead-type">
416<caption><span class="caption-number">Table 11 </span><span class="caption-text">AEAD algorithm sub-type values</span></caption>
417<thead valign="bottom">
418<tr class="row-odd"><th class="head">AEAD algorithm</th>
419<th class="head">B</th>
420<th class="head">AEAD-TYPE</th>
421<th class="head">Algorithm identifier</th>
422<th class="head">Algorithm value</th>
423</tr>
424</thead>
425<tbody valign="top">
426<tr class="row-even"><td>CCM <sup>a</sup></td>
427<td>1</td>
428<td><code class="docutils literal"><span class="pre">0x01</span></code></td>
429<td><a class="reference internal" href="../api/ops/aead.html#c.PSA_ALG_CCM" title="PSA_ALG_CCM"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_CCM</span></code></a></td>
430<td><code class="docutils literal"><span class="pre">0x05500100</span></code> <sup>b</sup></td>
431</tr>
432<tr class="row-odd"><td>GCM <sup>a</sup></td>
433<td>1</td>
434<td><code class="docutils literal"><span class="pre">0x02</span></code></td>
435<td><a class="reference internal" href="../api/ops/aead.html#c.PSA_ALG_GCM" title="PSA_ALG_GCM"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_GCM</span></code></a></td>
436<td><code class="docutils literal"><span class="pre">0x05500200</span></code> <sup>b</sup></td>
437</tr>
438<tr class="row-even"><td>ChaCha20-poly1305</td>
439<td>0</td>
440<td><code class="docutils literal"><span class="pre">0x05</span></code></td>
441<td><a class="reference internal" href="../api/ops/aead.html#c.PSA_ALG_CHACHA20_POLY1305" title="PSA_ALG_CHACHA20_POLY1305"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_CHACHA20_POLY1305</span></code></a></td>
442<td><code class="docutils literal"><span class="pre">0x05100500</span></code> <sup>b</sup></td>
443</tr>
444</tbody>
445</table>
446<ol class="loweralpha simple">
447<li>This is an AEAD mode of an underlying block cipher. The block cipher is determined by the key type that is provided to the AEAD operation.</li>
448<li>This is the default algorithm identifier, specifying the default tag length for the algorithm. <a class="reference internal" href="../api/ops/aead.html#c.PSA_ALG_AEAD_WITH_SHORTENED_TAG" title="PSA_ALG_AEAD_WITH_SHORTENED_TAG"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_AEAD_WITH_SHORTENED_TAG()</span></code></a> generates identifiers with alternative LEN values. <a class="reference internal" href="../api/ops/aead.html#c.PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG" title="PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG()</span></code></a> generates wildcard permitted-algorithm policies with W = 1.</li>
449</ol>
450</div>
451<div class="section" id="key-derivation-algorithm-encoding">
452<span id="kdf-encoding"></span><h3>Key derivation algorithm encoding</h3>
453<p>The algorithm identifier for key derivation algorithms defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-kdf-fields"><span class="numref">Figure 6</span></a></span>.</p>
454<div class="figure" id="fig-kdf-fields">
455<img alt="../_images/kdf_fields.svg" src="../_images/kdf_fields.svg" /><p class="caption"><span class="caption-number">Figure 6 </span><span class="caption-text">Key derivation algorithm encoding</span></p>
456</div>
457<p>The defined values for S and KDF-TYPE are shown in <span><a class="reference internal" href="#table-kdf-type"><span class="numref">Table 12</span></a></span>.</p>
458<p>The permitted values of HASH-TYPE (see <span><a class="reference internal" href="#table-hash-type"><span class="numref">Table 8</span></a></span>) depend on the specific KDF algorithm.</p>
459<table border="1" class="colwidths-auto docutils align-left" id="table-kdf-type">
460<caption><span class="caption-number">Table 12 </span><span class="caption-text">Key derivation algorithm sub-type values</span></caption>
461<thead valign="bottom">
462<tr class="row-odd"><th class="head">Key derivation algorithm</th>
463<th class="head">S</th>
464<th class="head">KDF-TYPE</th>
465<th class="head">Algorithm identifier</th>
466<th class="head">Algorithm value</th>
467</tr>
468</thead>
469<tbody valign="top">
470<tr class="row-even"><td>HKDF</td>
471<td>0</td>
472<td><code class="docutils literal"><span class="pre">0x01</span></code></td>
473<td><a class="reference internal" href="../api/ops/kdf.html#c.PSA_ALG_HKDF" title="PSA_ALG_HKDF"><code class="docutils literal"><span class="pre">PSA_ALG_HKDF</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></td>
474<td><code class="docutils literal"><span class="pre">0x080001hh</span></code> <sup>a</sup></td>
475</tr>
476<tr class="row-odd"><td>TLS-1.2 PRF</td>
477<td>0</td>
478<td><code class="docutils literal"><span class="pre">0x02</span></code></td>
479<td><a class="reference internal" href="../api/ops/kdf.html#c.PSA_ALG_TLS12_PRF" title="PSA_ALG_TLS12_PRF"><code class="docutils literal"><span class="pre">PSA_ALG_TLS12_PRF</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></td>
480<td><code class="docutils literal"><span class="pre">0x080002hh</span></code> <sup>a</sup></td>
481</tr>
482<tr class="row-even"><td>TLS-1.2 PSK-to-MasterSecret</td>
483<td>0</td>
484<td><code class="docutils literal"><span class="pre">0x03</span></code></td>
485<td><a class="reference internal" href="../api/ops/kdf.html#c.PSA_ALG_TLS12_PSK_TO_MS" title="PSA_ALG_TLS12_PSK_TO_MS"><code class="docutils literal"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS</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></td>
486<td><code class="docutils literal"><span class="pre">0x080003hh</span></code> <sup>a</sup></td>
487</tr>
488<tr class="row-odd"><td>PBKDF2-HMAC</td>
489<td>1</td>
490<td><code class="docutils literal"><span class="pre">0x01</span></code></td>
491<td><a class="reference internal" href="../api/ops/kdf.html#c.PSA_ALG_PBKDF2_HMAC" title="PSA_ALG_PBKDF2_HMAC"><code class="docutils literal"><span class="pre">PSA_ALG_PBKDF2_HMAC</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></td>
492<td><code class="docutils literal"><span class="pre">0x088001hh</span></code> <sup>a</sup></td>
493</tr>
494<tr class="row-even"><td>PBKDF2-AES-CMAC-PRF-128</td>
495<td>1</td>
496<td><code class="docutils literal"><span class="pre">0x02</span></code></td>
497<td><a class="reference internal" href="../api/ops/kdf.html#c.PSA_ALG_PBKDF2_AES_CMAC_PRF_128" title="PSA_ALG_PBKDF2_AES_CMAC_PRF_128"><code class="docutils literal"><span class="pre">PSA_ALG_PBKDF2_AES_CMAC_PRF_128</span></code></a></td>
498<td><code class="docutils literal"><span class="pre">0x08800200</span></code></td>
499</tr>
500</tbody>
501</table>
502<ol class="loweralpha simple">
503<li><code class="docutils literal"><span class="pre">hh</span></code> is the HASH-TYPE for the hash algorithm, <code class="docutils literal"><span class="pre">hash_alg</span></code>, used to construct the key derivation algorithm.</li>
504</ol>
505</div>
506<div class="section" id="asymmetric-signature-algorithm-encoding">
507<span id="sign-encoding"></span><h3>Asymmetric signature algorithm encoding</h3>
508<p>The algorithm identifier for asymmetric signature algorithms defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-sign-fields"><span class="numref">Figure 7</span></a></span>.</p>
509<div class="figure" id="fig-sign-fields">
510<img alt="../_images/sign_fields.svg" src="../_images/sign_fields.svg" /><p class="caption"><span class="caption-number">Figure 7 </span><span class="caption-text">Asymmetric signature algorithm encoding</span></p>
511</div>
512<p>The defined values for SIGN-TYPE are shown in <span><a class="reference internal" href="#table-sign-type"><span class="numref">Table 13</span></a></span>.</p>
513<p>H = HASH-TYPE (see <span><a class="reference internal" href="#table-hash-type"><span class="numref">Table 8</span></a></span>) for message signature algorithms that are parameterized by a hash algorithm, otherwise H = 0.</p>
514<table border="1" class="colwidths-auto docutils align-left" id="table-sign-type">
515<caption><span class="caption-number">Table 13 </span><span class="caption-text">Asymmetric signature algorithm sub-type values</span></caption>
516<thead valign="bottom">
517<tr class="row-odd"><th class="head">Signature algorithm</th>
518<th class="head">SIGN-TYPE</th>
519<th class="head">Algorithm identifier</th>
520<th class="head">Algorithm value</th>
521</tr>
522</thead>
523<tbody valign="top">
524<tr class="row-even"><td>RSA PKCS#1 v1.5</td>
525<td><code class="docutils literal"><span class="pre">0x02</span></code></td>
526<td><a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_RSA_PKCS1V15_SIGN" title="PSA_ALG_RSA_PKCS1V15_SIGN"><code class="docutils literal"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN</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></td>
527<td><code class="docutils literal"><span class="pre">0x060002hh</span></code> <sup>a</sup></td>
528</tr>
529<tr class="row-odd"><td>RSA PKCS#1 v1.5 no hash <sup>b</sup></td>
530<td><code class="docutils literal"><span class="pre">0x02</span></code></td>
531<td><a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_RSA_PKCS1V15_SIGN_RAW" title="PSA_ALG_RSA_PKCS1V15_SIGN_RAW"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN_RAW</span></code></a></td>
532<td><code class="docutils literal"><span class="pre">0x06000200</span></code></td>
533</tr>
534<tr class="row-even"><td>RSA PSS</td>
535<td><code class="docutils literal"><span class="pre">0x03</span></code></td>
536<td><a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_RSA_PSS" title="PSA_ALG_RSA_PSS"><code class="docutils literal"><span class="pre">PSA_ALG_RSA_PSS</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></td>
537<td><code class="docutils literal"><span class="pre">0x060003hh</span></code> <sup>a</sup></td>
538</tr>
539<tr class="row-odd"><td>RSA PSS any salt length</td>
540<td><code class="docutils literal"><span class="pre">0x13</span></code></td>
541<td><a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_RSA_PSS_ANY_SALT" title="PSA_ALG_RSA_PSS_ANY_SALT"><code class="docutils literal"><span class="pre">PSA_ALG_RSA_PSS_ANY_SALT</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></td>
542<td><code class="docutils literal"><span class="pre">0x060013hh</span></code> <sup>a</sup></td>
543</tr>
544<tr class="row-even"><td>Randomized ECDSA</td>
545<td><code class="docutils literal"><span class="pre">0x06</span></code></td>
546<td><a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="docutils literal"><span class="pre">PSA_ALG_ECDSA</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></td>
547<td><code class="docutils literal"><span class="pre">0x060006hh</span></code> <sup>a</sup></td>
548</tr>
549<tr class="row-odd"><td>Randomized ECDSA no hash <sup>b</sup></td>
550<td><code class="docutils literal"><span class="pre">0x06</span></code></td>
551<td><a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_ECDSA_ANY" title="PSA_ALG_ECDSA_ANY"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_ECDSA_ANY</span></code></a></td>
552<td><code class="docutils literal"><span class="pre">0x06000600</span></code></td>
553</tr>
554<tr class="row-even"><td>Deterministic ECDSA</td>
555<td><code class="docutils literal"><span class="pre">0x07</span></code></td>
556<td><a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_DETERMINISTIC_ECDSA" title="PSA_ALG_DETERMINISTIC_ECDSA"><code class="docutils literal"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA</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></td>
557<td><code class="docutils literal"><span class="pre">0x060007hh</span></code> <sup>a</sup></td>
558</tr>
559<tr class="row-odd"><td>PureEdDSA</td>
560<td><code class="docutils literal"><span class="pre">0x08</span></code></td>
561<td><a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_PURE_EDDSA" title="PSA_ALG_PURE_EDDSA"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_PURE_EDDSA</span></code></a></td>
562<td><code class="docutils literal"><span class="pre">0x06000800</span></code></td>
563</tr>
564<tr class="row-even"><td>HashEdDSA</td>
565<td><code class="docutils literal"><span class="pre">0x09</span></code></td>
566<td><a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_ED25519PH" title="PSA_ALG_ED25519PH"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_ED25519PH</span></code></a> and <a class="reference internal" href="../api/ops/sign.html#c.PSA_ALG_ED448PH" title="PSA_ALG_ED448PH"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_ED448PH</span></code></a></td>
567<td><code class="docutils literal"><span class="pre">0x060009hh</span></code> <sup>c</sup></td>
568</tr>
569</tbody>
570</table>
571<ol class="loweralpha simple">
572<li><code class="docutils literal"><span class="pre">hh</span></code> is the HASH-TYPE for the hash algorithm, <code class="docutils literal"><span class="pre">hash_alg</span></code>, used to construct the signature algorithm.</li>
573<li>Asymmetric signature algorithms without hashing can only be used with <a class="reference internal" href="../api/ops/sign.html#c.psa_sign_hash" title="psa_sign_hash"><code class="xref any c c-func docutils literal"><span class="pre">psa_sign_hash()</span></code></a> and <a class="reference internal" href="../api/ops/sign.html#c.psa_verify_hash" title="psa_verify_hash"><code class="xref any c c-func docutils literal"><span class="pre">psa_verify_hash()</span></code></a>.</li>
574<li>The HASH-TYPE for HashEdDSA is determined by the curve. SHA-512 is used for Ed25519ph, and the first 64 bytes of output from SHAKE256 is used for Ed448ph.</li>
575</ol>
576</div>
577<div class="section" id="asymmetric-encryption-algorithm-encoding">
578<span id="pke-encoding"></span><h3>Asymmetric encryption algorithm encoding</h3>
579<p>The algorithm identifier for asymmetric encryption algorithms defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-pke-fields"><span class="numref">Figure 8</span></a></span>.</p>
580<div class="figure" id="fig-pke-fields">
581<img alt="../_images/pke_fields.svg" src="../_images/pke_fields.svg" /><p class="caption"><span class="caption-number">Figure 8 </span><span class="caption-text">Asymmetric encryption algorithm encoding</span></p>
582</div>
583<p>The defined values for ENCRYPT-TYPE are shown in <span><a class="reference internal" href="#table-pke-type"><span class="numref">Table 14</span></a></span>.</p>
584<p>H = HASH-TYPE (see <span><a class="reference internal" href="#table-hash-type"><span class="numref">Table 8</span></a></span>) for asymmetric encryption algorithms that are parameterized by a hash algorithm, otherwise H = 0.</p>
585<table border="1" class="colwidths-auto docutils align-left" id="table-pke-type">
586<caption><span class="caption-number">Table 14 </span><span class="caption-text">Asymmetric encryption algorithm sub-type values</span></caption>
587<thead valign="bottom">
588<tr class="row-odd"><th class="head">Asymmetric encryption algorithm</th>
589<th class="head">ENCRYPT-TYPE</th>
590<th class="head">Algorithm identifier</th>
591<th class="head">Algorithm value</th>
592</tr>
593</thead>
594<tbody valign="top">
595<tr class="row-even"><td>RSA PKCS#1 v1.5</td>
596<td><code class="docutils literal"><span class="pre">0x02</span></code></td>
597<td><a class="reference internal" href="../api/ops/pke.html#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></td>
598<td><code class="docutils literal"><span class="pre">0x07000200</span></code></td>
599</tr>
600<tr class="row-odd"><td>RSA OAEP</td>
601<td><code class="docutils literal"><span class="pre">0x03</span></code></td>
602<td><a class="reference internal" href="../api/ops/pke.html#c.PSA_ALG_RSA_OAEP" title="PSA_ALG_RSA_OAEP"><code class="docutils literal"><span class="pre">PSA_ALG_RSA_OAEP</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></td>
603<td><code class="docutils literal"><span class="pre">0x070003hh</span></code> <sup>a</sup></td>
604</tr>
605</tbody>
606</table>
607<ol class="loweralpha simple">
608<li><code class="docutils literal"><span class="pre">hh</span></code> is the HASH-TYPE for the hash algorithm, <code class="docutils literal"><span class="pre">hash_alg</span></code>, used to construct the encryption algorithm.</li>
609</ol>
610</div>
611<div class="section" id="key-agreement-algorithm-encoding">
612<span id="ka-encoding"></span><h3>Key agreement algorithm encoding</h3>
613<p>A key agreement algorithm identifier can either be for the raw key agreement algorithm, or for a combined key agreement with key derivation algorithm. The former can only be used with <a class="reference internal" href="../api/ops/ka.html#c.psa_raw_key_agreement" title="psa_raw_key_agreement"><code class="xref any c c-func docutils literal"><span class="pre">psa_raw_key_agreement()</span></code></a>, while the latter are used with <a class="reference internal" href="../api/ops/ka.html#c.psa_key_derivation_key_agreement" title="psa_key_derivation_key_agreement"><code class="xref any c c-func docutils literal"><span class="pre">psa_key_derivation_key_agreement()</span></code></a> and the shared secret is not exposed to the client.</p>
614<p>The algorithm identifier for raw key agreement algorithms defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-ka-raw-fields"><span class="numref">Figure 9</span></a></span>.</p>
615<div class="figure" id="fig-ka-raw-fields">
616<img alt="../_images/ka_raw_fields.svg" src="../_images/ka_raw_fields.svg" /><p class="caption"><span class="caption-number">Figure 9 </span><span class="caption-text">Raw key agreement algorithm encoding</span></p>
617</div>
618<p>The defined values for KA-TYPE are shown in <span><a class="reference internal" href="#table-ka-type"><span class="numref">Table 15</span></a></span>.</p>
619<table border="1" class="colwidths-auto docutils align-left" id="table-ka-type">
620<caption><span class="caption-number">Table 15 </span><span class="caption-text">Key agreement algorithm sub-type values</span></caption>
621<thead valign="bottom">
622<tr class="row-odd"><th class="head">Key agreement algorithm</th>
623<th class="head">KA-TYPE</th>
624<th class="head">Algorithm identifier</th>
625<th class="head">Algorithm value</th>
626</tr>
627</thead>
628<tbody valign="top">
629<tr class="row-even"><td>FFDH</td>
630<td><code class="docutils literal"><span class="pre">0x01</span></code></td>
631<td><a class="reference internal" href="../api/ops/ka.html#c.PSA_ALG_FFDH" title="PSA_ALG_FFDH"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_FFDH</span></code></a></td>
632<td><code class="docutils literal"><span class="pre">0x09010000</span></code></td>
633</tr>
634<tr class="row-odd"><td>ECDH</td>
635<td><code class="docutils literal"><span class="pre">0x02</span></code></td>
636<td><a class="reference internal" href="../api/ops/ka.html#c.PSA_ALG_ECDH" title="PSA_ALG_ECDH"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_ECDH</span></code></a></td>
637<td><code class="docutils literal"><span class="pre">0x09020000</span></code></td>
638</tr>
639</tbody>
640</table>
641<p>A combined key agreement is constructed by a bitwise OR of the raw key agreement algorithm identifier and the key derivation algorithm identifier. This operation is provided by the <a class="reference internal" href="../api/ops/ka.html#c.PSA_ALG_KEY_AGREEMENT" title="PSA_ALG_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ALG_KEY_AGREEMENT()</span></code></a> macro.</p>
642<div class="figure" id="id7">
643<img alt="../_images/ka_combined_fields.svg" src="../_images/ka_combined_fields.svg" /><p class="caption"><span class="caption-number">Figure 10 </span><span class="caption-text">Combined key agreement algorithm encoding</span></p>
644</div>
645<p>The underlying raw key agreement algorithm can be extracted from the KA-TYPE field, and the key derivation algorithm from the KDF-TYPE and HASH-TYPE fields.</p>
646</div>
647</div>
648<div class="section" id="key-type-encoding">
649<span id="id1"></span><h2>Key type encoding</h2>
650<p>Key types are 16-bit integer values of the type <a class="reference internal" href="../api/keys/types.html#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal"><span class="pre">psa_key_type_t</span></code></a>. Key type values have the structure shown in <span><a class="reference internal" href="#fig-key-type-fields"><span class="numref">Figure 11</span></a></span>.</p>
651<div class="figure" id="fig-key-type-fields">
652<img alt="../_images/key_type_fields.svg" src="../_images/key_type_fields.svg" /><p class="caption"><span class="caption-number">Figure 11 </span><span class="caption-text">Encoding of <a class="reference internal" href="../api/keys/types.html#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal"><span class="pre">psa_key_type_t</span></code></a></span></p>
653</div>
654<p><span><a class="reference internal" href="#table-key-type-fields"><span class="numref">Table 16</span></a></span> describes the meaning of the bit-fields — some of bit-fields are used in different ways by different key type categories.</p>
655<table border="1" class="colwidths-given longtable docutils align-right" id="table-key-type-fields">
656<caption><span class="caption-number">Table 16 </span><span class="caption-text">Bit fields in a key type</span></caption>
657<colgroup>
658<col width="24%" />
659<col width="10%" />
660<col width="67%" />
661</colgroup>
662<thead valign="bottom">
663<tr class="row-odd"><th class="head">Field</th>
664<th class="head">Bits</th>
665<th class="head">Description</th>
666</tr>
667</thead>
668<tbody valign="top">
669<tr class="row-even"><td>V</td>
670<td>[15]</td>
671<td><p class="first">Flag to indicate an implementation-defined key type, when V=1.</p>
672<p class="last">Key types defined by this specification always have V=0.</p>
673</td>
674</tr>
675<tr class="row-odd"><td>A</td>
676<td>[14]</td>
677<td>Flag to indicate an asymmetric key type, when A=1.</td>
678</tr>
679<tr class="row-even"><td>CAT</td>
680<td>[13:12]</td>
681<td>Key type category. See <a class="reference internal" href="#key-type-categories"><span class="secref">Key type categories</span></a>.</td>
682</tr>
683<tr class="row-odd"><td><em>category-specific type</em></td>
684<td>[11:1]</td>
685<td>The meaning of this field is specific to each key category.</td>
686</tr>
687<tr class="row-even"><td>P</td>
688<td>[0]</td>
689<td>Parity bit. Valid key type values have even parity.</td>
690</tr>
691</tbody>
692</table>
693<div class="section" id="key-type-categories">
694<span id="id2"></span><h3>Key type categories</h3>
695<p>The A and CAT fields in a key type take the values shown in <span><a class="reference internal" href="#table-key-type-category"><span class="numref">Table 17</span></a></span>.</p>
696<table border="1" class="colwidths-auto docutils align-left" id="table-key-type-category">
697<caption><span class="caption-number">Table 17 </span><span class="caption-text">Key type categories</span></caption>
698<thead valign="bottom">
699<tr class="row-odd"><th class="head">Key type category</th>
700<th class="head">A</th>
701<th class="head">CAT</th>
702<th class="head">Category details</th>
703</tr>
704</thead>
705<tbody valign="top">
706<tr class="row-even"><td>None</td>
707<td>0</td>
708<td>0</td>
709<td>See <a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_NONE" title="PSA_KEY_TYPE_NONE"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_NONE</span></code></a></td>
710</tr>
711<tr class="row-odd"><td>Raw data</td>
712<td>0</td>
713<td>1</td>
714<td>See <a class="reference internal" href="#raw-key-encoding"><span class="secref">Raw key encoding</span></a></td>
715</tr>
716<tr class="row-even"><td>Symmetric key</td>
717<td>0</td>
718<td>2</td>
719<td>See <a class="reference internal" href="#symmetric-key-encoding"><span class="secref">Symmetric key encoding</span></a></td>
720</tr>
721<tr class="row-odd"><td>Asymmetric public key</td>
722<td>1</td>
723<td>0</td>
724<td>See <a class="reference internal" href="#asymmetric-key-encoding"><span class="secref">Asymmetric key encoding</span></a></td>
725</tr>
726<tr class="row-even"><td>Asymmetric key pair</td>
727<td>1</td>
728<td>3</td>
729<td>See <a class="reference internal" href="#asymmetric-key-encoding"><span class="secref">Asymmetric key encoding</span></a></td>
730</tr>
731</tbody>
732</table>
733</div>
734<div class="section" id="raw-key-encoding">
735<span id="id3"></span><h3>Raw key encoding</h3>
736<p>The key type for raw keys defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-raw-key-fields"><span class="numref">Figure 12</span></a></span>.</p>
737<div class="figure" id="fig-raw-key-fields">
738<img alt="../_images/raw_key_fields.svg" src="../_images/raw_key_fields.svg" /><p class="caption"><span class="caption-number">Figure 12 </span><span class="caption-text">Raw key encoding</span></p>
739</div>
740<p>The defined values for RAW-TYPE, SUB-TYPE, and P are shown in <span><a class="reference internal" href="#table-raw-type"><span class="numref">Table 18</span></a></span>.</p>
741<table border="1" class="colwidths-auto docutils align-left" id="table-raw-type">
742<caption><span class="caption-number">Table 18 </span><span class="caption-text">Raw key sub-type values</span></caption>
743<thead valign="bottom">
744<tr class="row-odd"><th class="head">Raw key type</th>
745<th class="head">RAW-TYPE</th>
746<th class="head">SUB-TYPE</th>
747<th class="head">P</th>
748<th class="head">Key type</th>
749<th class="head">Key type value</th>
750</tr>
751</thead>
752<tbody valign="top">
753<tr class="row-even"><td>Raw data</td>
754<td>0</td>
755<td>0</td>
756<td>1</td>
757<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_RAW_DATA" title="PSA_KEY_TYPE_RAW_DATA"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_RAW_DATA</span></code></a></td>
758<td><code class="docutils literal"><span class="pre">0x1001</span></code></td>
759</tr>
760<tr class="row-odd"><td>HMAC</td>
761<td>1</td>
762<td>0</td>
763<td>0</td>
764<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_HMAC" title="PSA_KEY_TYPE_HMAC"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_HMAC</span></code></a></td>
765<td><code class="docutils literal"><span class="pre">0x1100</span></code></td>
766</tr>
767<tr class="row-even"><td>Derivation secret</td>
768<td>2</td>
769<td>0</td>
770<td>0</td>
771<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_DERIVE" title="PSA_KEY_TYPE_DERIVE"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_DERIVE</span></code></a></td>
772<td><code class="docutils literal"><span class="pre">0x1200</span></code></td>
773</tr>
774<tr class="row-odd"><td>Password</td>
775<td>2</td>
776<td>1</td>
777<td>1</td>
778<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_PASSWORD" title="PSA_KEY_TYPE_PASSWORD"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_PASSWORD</span></code></a></td>
779<td><code class="docutils literal"><span class="pre">0x1203</span></code></td>
780</tr>
781<tr class="row-even"><td>Password hash</td>
782<td>2</td>
783<td>2</td>
784<td>1</td>
785<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_PASSWORD_HASH" title="PSA_KEY_TYPE_PASSWORD_HASH"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_PASSWORD_HASH</span></code></a></td>
786<td><code class="docutils literal"><span class="pre">0x1205</span></code></td>
787</tr>
788<tr class="row-odd"><td>Derivation pepper</td>
789<td>2</td>
790<td>3</td>
791<td>0</td>
792<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_PEPPER" title="PSA_KEY_TYPE_PEPPER"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_PEPPER</span></code></a></td>
793<td><code class="docutils literal"><span class="pre">0x1206</span></code></td>
794</tr>
795</tbody>
796</table>
797</div>
798<div class="section" id="symmetric-key-encoding">
799<span id="id4"></span><h3>Symmetric key encoding</h3>
800<p>The key type for symmetric keys defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-symmetric-key-fields"><span class="numref">Figure 13</span></a></span>.</p>
801<div class="figure" id="fig-symmetric-key-fields">
802<img alt="../_images/symmetric_key_fields.svg" src="../_images/symmetric_key_fields.svg" /><p class="caption"><span class="caption-number">Figure 13 </span><span class="caption-text">Symmetric key encoding</span></p>
803</div>
804<p>For block-based cipher keys, the block size for the cipher algorithm is 2<sup>BLK</sup>.</p>
805<p>The defined values for BLK, SYM-TYPE and P are shown in <span><a class="reference internal" href="#table-symmetric-type"><span class="numref">Table 19</span></a></span>.</p>
806<table border="1" class="colwidths-auto docutils align-left" id="table-symmetric-type">
807<caption><span class="caption-number">Table 19 </span><span class="caption-text">Symmetric key sub-type values</span></caption>
808<thead valign="bottom">
809<tr class="row-odd"><th class="head">Symmetric key type</th>
810<th class="head">BLK</th>
811<th class="head">SYM-TYPE</th>
812<th class="head">P</th>
813<th class="head">Key type</th>
814<th class="head">Key type value</th>
815</tr>
816</thead>
817<tbody valign="top">
818<tr class="row-even"><td>ARC4</td>
819<td>0</td>
820<td>1</td>
821<td>0</td>
822<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_ARC4" title="PSA_KEY_TYPE_ARC4"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_ARC4</span></code></a></td>
823<td><code class="docutils literal"><span class="pre">0x2002</span></code></td>
824</tr>
825<tr class="row-odd"><td>ChaCha20</td>
826<td>0</td>
827<td>2</td>
828<td>0</td>
829<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_CHACHA20" title="PSA_KEY_TYPE_CHACHA20"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_CHACHA20</span></code></a></td>
830<td><code class="docutils literal"><span class="pre">0x2004</span></code></td>
831</tr>
832<tr class="row-even"><td>DES</td>
833<td>3</td>
834<td>0</td>
835<td>1</td>
836<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_DES" title="PSA_KEY_TYPE_DES"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_DES</span></code></a></td>
837<td><code class="docutils literal"><span class="pre">0x2301</span></code></td>
838</tr>
839<tr class="row-odd"><td>AES</td>
840<td>4</td>
841<td>0</td>
842<td>0</td>
843<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_AES" title="PSA_KEY_TYPE_AES"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_AES</span></code></a></td>
844<td><code class="docutils literal"><span class="pre">0x2400</span></code></td>
845</tr>
846<tr class="row-even"><td>CAMELLIA</td>
847<td>4</td>
848<td>1</td>
849<td>1</td>
850<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_CAMELLIA" title="PSA_KEY_TYPE_CAMELLIA"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_CAMELLIA</span></code></a></td>
851<td><code class="docutils literal"><span class="pre">0x2403</span></code></td>
852</tr>
853<tr class="row-odd"><td>SM4</td>
854<td>4</td>
855<td>2</td>
856<td>1</td>
857<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_SM4" title="PSA_KEY_TYPE_SM4"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_SM4</span></code></a></td>
858<td><code class="docutils literal"><span class="pre">0x2405</span></code></td>
859</tr>
860<tr class="row-even"><td>ARIA</td>
861<td>4</td>
862<td>3</td>
863<td>0</td>
864<td><a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_ARIA" title="PSA_KEY_TYPE_ARIA"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_KEY_TYPE_ARIA</span></code></a></td>
865<td><code class="docutils literal"><span class="pre">0x2406</span></code></td>
866</tr>
867</tbody>
868</table>
869</div>
870<div class="section" id="asymmetric-key-encoding">
871<span id="id5"></span><h3>Asymmetric key encoding</h3>
872<p>The key type for asymmetric keys defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-asymmetric-key-fields"><span class="numref">Figure 14</span></a></span>.</p>
873<div class="figure" id="fig-asymmetric-key-fields">
874<img alt="../_images/asymmetric_key_fields.svg" src="../_images/asymmetric_key_fields.svg" /><p class="caption"><span class="caption-number">Figure 14 </span><span class="caption-text">Asymmetric key encoding</span></p>
875</div>
876<p>PAIR is either 0 for a public key, or 3 for a key pair.</p>
877<p>The defined values for ASYM-TYPE are shown in <span><a class="reference internal" href="#table-asymmetric-type"><span class="numref">Table 20</span></a></span>.</p>
878<table border="1" class="colwidths-auto docutils align-left" id="table-asymmetric-type">
879<caption><span class="caption-number">Table 20 </span><span class="caption-text">Asymmetric key sub-type values</span></caption>
880<thead valign="bottom">
881<tr class="row-odd"><th class="head">Asymmetric key type</th>
882<th class="head">ASYM-TYPE</th>
883<th class="head">Details</th>
884</tr>
885</thead>
886<tbody valign="top">
887<tr class="row-even"><td>RSA</td>
888<td>0</td>
889<td>See <a class="reference internal" href="#rsa-key-encoding"><span class="secref">RSA key encoding</span></a></td>
890</tr>
891<tr class="row-odd"><td>Elliptic Curve</td>
892<td>1</td>
893<td>See <a class="reference internal" href="#ecc-key-encoding"><span class="secref">Elliptic Curve key encoding</span></a></td>
894</tr>
895<tr class="row-even"><td>Diffie-Hellman</td>
896<td>2</td>
897<td>See <a class="reference internal" href="#dh-key-encoding"><span class="secref">Diffie Hellman key encoding</span></a></td>
898</tr>
899</tbody>
900</table>
901<div class="section" id="rsa-key-encoding">
902<span id="id6"></span><h4>RSA key encoding</h4>
903<p>The key type for RSA keys defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-rsa-key-fields"><span class="numref">Figure 15</span></a></span>.</p>
904<div class="figure" id="fig-rsa-key-fields">
905<img alt="../_images/rsa_key_fields.svg" src="../_images/rsa_key_fields.svg" /><p class="caption"><span class="caption-number">Figure 15 </span><span class="caption-text">RSA key encoding</span></p>
906</div>
907<p>PAIR is either 0 for a public key, or 3 for a key pair.</p>
908<p>The defined values for RSA keys are shown in <span><a class="reference internal" href="#table-rsa-type"><span class="numref">Table 21</span></a></span>.</p>
909<table border="1" class="colwidths-auto docutils align-left" id="table-rsa-type">
910<caption><span class="caption-number">Table 21 </span><span class="caption-text">RSA key values</span></caption>
911<thead valign="bottom">
912<tr class="row-odd"><th class="head">RSA key type</th>
913<th class="head">Key type</th>
914<th class="head">Key type value</th>
915</tr>
916</thead>
917<tbody valign="top">
918<tr class="row-even"><td>Public key</td>
919<td><a class="reference internal" href="../api/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></td>
920<td><code class="docutils literal"><span class="pre">0x4001</span></code></td>
921</tr>
922<tr class="row-odd"><td>Key pair</td>
923<td><a class="reference internal" href="../api/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></td>
924<td><code class="docutils literal"><span class="pre">0x7001</span></code></td>
925</tr>
926</tbody>
927</table>
928</div>
929<div class="section" id="elliptic-curve-key-encoding">
930<span id="ecc-key-encoding"></span><h4>Elliptic Curve key encoding</h4>
931<p>The key type for Elliptic Curve keys defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-ecc-key-fields"><span class="numref">Figure 16</span></a></span>.</p>
932<div class="figure" id="fig-ecc-key-fields">
933<img alt="../_images/ecc_key_fields.svg" src="../_images/ecc_key_fields.svg" /><p class="caption"><span class="caption-number">Figure 16 </span><span class="caption-text">Elliptic Curve key encoding</span></p>
934</div>
935<p>PAIR is either 0 for a public key, or 3 for a key pair.</p>
936<p>The defined values for ECC-FAMILY and P are shown in <span><a class="reference internal" href="#table-ecc-type"><span class="numref">Table 22</span></a></span>.</p>
937<table border="1" class="colwidths-auto docutils align-left" id="table-ecc-type">
938<caption><span class="caption-number">Table 22 </span><span class="caption-text">ECC key family values</span></caption>
939<thead valign="bottom">
940<tr class="row-odd"><th class="head">ECC key family</th>
941<th class="head">ECC-FAMILY</th>
942<th class="head">P</th>
943<th class="head">ECC family <sup>a</sup></th>
944<th class="head">Public key value</th>
945<th class="head">Key pair value</th>
946</tr>
947</thead>
948<tbody valign="top">
949<tr class="row-even"><td>SECP K1</td>
950<td>0x0B</td>
951<td>1</td>
952<td><a class="reference internal" href="../api/keys/types.html#c.PSA_ECC_FAMILY_SECP_K1" title="PSA_ECC_FAMILY_SECP_K1"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ECC_FAMILY_SECP_K1</span></code></a></td>
953<td><code class="docutils literal"><span class="pre">0x4117</span></code></td>
954<td><code class="docutils literal"><span class="pre">0x7117</span></code></td>
955</tr>
956<tr class="row-odd"><td>SECP R1</td>
957<td>0x09</td>
958<td>0</td>
959<td><a class="reference internal" href="../api/keys/types.html#c.PSA_ECC_FAMILY_SECP_R1" title="PSA_ECC_FAMILY_SECP_R1"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ECC_FAMILY_SECP_R1</span></code></a></td>
960<td><code class="docutils literal"><span class="pre">0x4112</span></code></td>
961<td><code class="docutils literal"><span class="pre">0x7112</span></code></td>
962</tr>
963<tr class="row-even"><td>SECP R2</td>
964<td>0x0D</td>
965<td>1</td>
966<td><a class="reference internal" href="../api/keys/types.html#c.PSA_ECC_FAMILY_SECP_R2" title="PSA_ECC_FAMILY_SECP_R2"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ECC_FAMILY_SECP_R2</span></code></a></td>
967<td><code class="docutils literal"><span class="pre">0x411B</span></code></td>
968<td><code class="docutils literal"><span class="pre">0x711B</span></code></td>
969</tr>
970<tr class="row-odd"><td>SECT K1</td>
971<td>0x13</td>
972<td>1</td>
973<td><a class="reference internal" href="../api/keys/types.html#c.PSA_ECC_FAMILY_SECT_K1" title="PSA_ECC_FAMILY_SECT_K1"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ECC_FAMILY_SECT_K1</span></code></a></td>
974<td><code class="docutils literal"><span class="pre">0x4127</span></code></td>
975<td><code class="docutils literal"><span class="pre">0x7127</span></code></td>
976</tr>
977<tr class="row-even"><td>SECT R1</td>
978<td>0x11</td>
979<td>0</td>
980<td><a class="reference internal" href="../api/keys/types.html#c.PSA_ECC_FAMILY_SECT_R1" title="PSA_ECC_FAMILY_SECT_R1"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ECC_FAMILY_SECT_R1</span></code></a></td>
981<td><code class="docutils literal"><span class="pre">0x4122</span></code></td>
982<td><code class="docutils literal"><span class="pre">0x7122</span></code></td>
983</tr>
984<tr class="row-odd"><td>SECT R2</td>
985<td>0x15</td>
986<td>1</td>
987<td><a class="reference internal" href="../api/keys/types.html#c.PSA_ECC_FAMILY_SECT_R2" title="PSA_ECC_FAMILY_SECT_R2"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ECC_FAMILY_SECT_R2</span></code></a></td>
988<td><code class="docutils literal"><span class="pre">0x412B</span></code></td>
989<td><code class="docutils literal"><span class="pre">0x712B</span></code></td>
990</tr>
991<tr class="row-even"><td>Brainpool-P R1</td>
992<td>0x18</td>
993<td>0</td>
994<td><a class="reference internal" href="../api/keys/types.html#c.PSA_ECC_FAMILY_BRAINPOOL_P_R1" title="PSA_ECC_FAMILY_BRAINPOOL_P_R1"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ECC_FAMILY_BRAINPOOL_P_R1</span></code></a></td>
995<td><code class="docutils literal"><span class="pre">0x4130</span></code></td>
996<td><code class="docutils literal"><span class="pre">0x7130</span></code></td>
997</tr>
998<tr class="row-odd"><td>FRP</td>
999<td>0x19</td>
1000<td>1</td>
1001<td><a class="reference internal" href="../api/keys/types.html#c.PSA_ECC_FAMILY_FRP" title="PSA_ECC_FAMILY_FRP"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ECC_FAMILY_FRP</span></code></a></td>
1002<td><code class="docutils literal"><span class="pre">0x4133</span></code></td>
1003<td><code class="docutils literal"><span class="pre">0x7133</span></code></td>
1004</tr>
1005<tr class="row-even"><td>Montgomery</td>
1006<td>0x20</td>
1007<td>1</td>
1008<td><a class="reference internal" href="../api/keys/types.html#c.PSA_ECC_FAMILY_MONTGOMERY" title="PSA_ECC_FAMILY_MONTGOMERY"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ECC_FAMILY_MONTGOMERY</span></code></a></td>
1009<td><code class="docutils literal"><span class="pre">0x4141</span></code></td>
1010<td><code class="docutils literal"><span class="pre">0x7141</span></code></td>
1011</tr>
1012<tr class="row-odd"><td>Twisted Edwards</td>
1013<td>0x21</td>
1014<td>0</td>
1015<td><a class="reference internal" href="../api/keys/types.html#c.PSA_ECC_FAMILY_TWISTED_EDWARDS" title="PSA_ECC_FAMILY_TWISTED_EDWARDS"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_ECC_FAMILY_TWISTED_EDWARDS</span></code></a></td>
1016<td><code class="docutils literal"><span class="pre">0x4142</span></code></td>
1017<td><code class="docutils literal"><span class="pre">0x7142</span></code></td>
1018</tr>
1019</tbody>
1020</table>
1021<ol class="loweralpha simple">
1022<li>The key type value is constructed from the Elliptic Curve family using either <a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_ECC_PUBLIC_KEY" title="PSA_KEY_TYPE_ECC_PUBLIC_KEY"><code class="docutils literal"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">family</span></code><code class="docutils literal"><span class="pre">)</span></code> or <a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_ECC_KEY_PAIR" title="PSA_KEY_TYPE_ECC_KEY_PAIR"><code class="docutils literal"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">family</span></code><code class="docutils literal"><span class="pre">)</span></code> as required.</li>
1023</ol>
1024</div>
1025<div class="section" id="diffie-hellman-key-encoding">
1026<span id="dh-key-encoding"></span><h4>Diffie Hellman key encoding</h4>
1027<p>The key type for Diffie Hellman keys defined in this specification are encoded as shown in <span><a class="reference internal" href="#fig-dh-key-fields"><span class="numref">Figure 17</span></a></span>.</p>
1028<div class="figure" id="fig-dh-key-fields">
1029<img alt="../_images/dh_key_fields.svg" src="../_images/dh_key_fields.svg" /><p class="caption"><span class="caption-number">Figure 17 </span><span class="caption-text">Diffie Hellman key encoding</span></p>
1030</div>
1031<p>PAIR is either 0 for a public key, or 3 for a key pair.</p>
1032<p>The defined values for DH-FAMILY and P are shown in <span><a class="reference internal" href="#table-dh-type"><span class="numref">Table 23</span></a></span>.</p>
1033<table border="1" class="colwidths-auto docutils align-left" id="table-dh-type">
1034<caption><span class="caption-number">Table 23 </span><span class="caption-text">Diffie Hellman key group values</span></caption>
1035<thead valign="bottom">
1036<tr class="row-odd"><th class="head">DH key group</th>
1037<th class="head">DH-FAMILY</th>
1038<th class="head">P</th>
1039<th class="head">DH group <sup>a</sup></th>
1040<th class="head">Public key value</th>
1041<th class="head">Key pair value</th>
1042</tr>
1043</thead>
1044<tbody valign="top">
1045<tr class="row-even"><td>RFC7919</td>
1046<td>0x01</td>
1047<td>1</td>
1048<td><a class="reference internal" href="../api/keys/types.html#c.PSA_DH_FAMILY_RFC7919" title="PSA_DH_FAMILY_RFC7919"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_DH_FAMILY_RFC7919</span></code></a></td>
1049<td><code class="docutils literal"><span class="pre">0x4203</span></code></td>
1050<td><code class="docutils literal"><span class="pre">0x7203</span></code></td>
1051</tr>
1052</tbody>
1053</table>
1054<ol class="loweralpha simple">
1055<li>The key type value is constructed from the Diffie Hellman family using either <a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_DH_PUBLIC_KEY" title="PSA_KEY_TYPE_DH_PUBLIC_KEY"><code class="docutils literal"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">family</span></code><code class="docutils literal"><span class="pre">)</span></code> or <a class="reference internal" href="../api/keys/types.html#c.PSA_KEY_TYPE_DH_KEY_PAIR" title="PSA_KEY_TYPE_DH_KEY_PAIR"><code class="docutils literal"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR</span></code></a><code class="docutils literal"><span class="pre">(</span></code><code class="docutils literal"><span class="pre">family</span></code><code class="docutils literal"><span class="pre">)</span></code> as required.</li>
1056</ol>
1057</div>
1058</div>
1059</div>
1060</div>
1061
1062
1063 </div>
1064 </div>
1065 </div>
1066 <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
1067 <div class="sphinxsidebarwrapper"><h3><a href="../index.html"><b>PSA Crypto API</b></a></h3>
1068IHI 0086<br/>
1069Non-confidential<br/>
1070Version 1.1.0
1071<span style="color: red; font-weight: bold;"></span>
1072<ul>
1073<li class="toctree-l1"><a class="reference internal" href="../about.html">About this document</a></li>
1074</ul>
1075<ul>
1076<li class="toctree-l1"><a class="reference internal" href="../overview/intro.html">1. Introduction</a></li>
1077<li class="toctree-l1"><a class="reference internal" href="../overview/goals.html">2. Design goals</a></li>
1078<li class="toctree-l1"><a class="reference internal" href="../overview/functionality.html">3. Functionality overview</a></li>
1079<li class="toctree-l1"><a class="reference internal" href="../overview/sample-arch.html">4. Sample architectures</a></li>
1080<li class="toctree-l1"><a class="reference internal" href="../overview/conventions.html">5. Library conventions</a></li>
1081<li class="toctree-l1"><a class="reference internal" href="../overview/implementation.html">6. Implementation considerations</a></li>
1082<li class="toctree-l1"><a class="reference internal" href="../overview/usage.html">7. Usage considerations</a></li>
1083<li class="toctree-l1"><a class="reference internal" href="../api/library/index.html">8. Library management reference</a></li>
1084<li class="toctree-l1"><a class="reference internal" href="../api/keys/index.html">9. Key management reference</a></li>
1085<li class="toctree-l1"><a class="reference internal" href="../api/ops/index.html">10. Cryptographic operation reference</a></li>
1086</ul>
1087<ul class="current">
1088<li class="toctree-l1"><a class="reference internal" href="example_header.html">Example header file</a></li>
1089<li class="toctree-l1 current"><a class="current reference internal" href="#">Algorithm and key type encoding</a><ul>
1090<li class="toctree-l2"><a class="reference internal" href="#algorithm-identifier-encoding">Algorithm identifier encoding</a><ul>
1091<li class="toctree-l3"><a class="reference internal" href="#algorithm-categories">Algorithm categories</a></li>
1092<li class="toctree-l3"><a class="reference internal" href="#hash-algorithm-encoding">Hash algorithm encoding</a></li>
1093<li class="toctree-l3"><a class="reference internal" href="#mac-algorithm-encoding">MAC algorithm encoding</a></li>
1094<li class="toctree-l3"><a class="reference internal" href="#cipher-algorithm-encoding">Cipher algorithm encoding</a></li>
1095<li class="toctree-l3"><a class="reference internal" href="#aead-algorithm-encoding">AEAD algorithm encoding</a></li>
1096<li class="toctree-l3"><a class="reference internal" href="#key-derivation-algorithm-encoding">Key derivation algorithm encoding</a></li>
1097<li class="toctree-l3"><a class="reference internal" href="#asymmetric-signature-algorithm-encoding">Asymmetric signature algorithm encoding</a></li>
1098<li class="toctree-l3"><a class="reference internal" href="#asymmetric-encryption-algorithm-encoding">Asymmetric encryption algorithm encoding</a></li>
1099<li class="toctree-l3"><a class="reference internal" href="#key-agreement-algorithm-encoding">Key agreement algorithm encoding</a></li>
1100</ul>
1101</li>
1102<li class="toctree-l2"><a class="reference internal" href="#key-type-encoding">Key type encoding</a><ul>
1103<li class="toctree-l3"><a class="reference internal" href="#key-type-categories">Key type categories</a></li>
1104<li class="toctree-l3"><a class="reference internal" href="#raw-key-encoding">Raw key encoding</a></li>
1105<li class="toctree-l3"><a class="reference internal" href="#symmetric-key-encoding">Symmetric key encoding</a></li>
1106<li class="toctree-l3"><a class="reference internal" href="#asymmetric-key-encoding">Asymmetric key encoding</a></li>
1107</ul>
1108</li>
1109</ul>
1110</li>
1111<li class="toctree-l1"><a class="reference internal" href="specdef_values.html">Example macro implementations</a></li>
1112<li class="toctree-l1"><a class="reference internal" href="sra.html">Security Risk Assessment</a></li>
1113<li class="toctree-l1"><a class="reference internal" href="history.html">Changes to the API</a></li>
1114</ul>
1115<ul>
1116<li class="toctree-l1"><a class="reference internal" href="../psa_c-identifiers.html">Index of API elements</a></li>
1117</ul>
1118<div id="searchbox" style="display: none" role="search">
1119 <h3>Quick search</h3>
1120 <form class="search" action="../search.html" method="get">
1121 <div><input type="text" name="q" /></div>
1122 <div><input type="submit" value="Go" /></div>
1123 <input type="hidden" name="check_keywords" value="yes" />
1124 <input type="hidden" name="area" value="default" />
1125 </form>
1126</div>
1127<script type="text/javascript">$('#searchbox').show(0);</script>
1128 </div>
1129 </div>
1130 <div class="clearer"></div>
1131 </div>
1132 <div class="footer">
1133 &copy; 2018-2022, Arm Limited or its affiliates. All rights reserved.
1134
1135 |
1136 Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.7</a>
1137 &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.8</a>
1138
1139 </div>
1140
1141
1142
1143
1144 </body>
1145</html>