Debian Codegraph @

doc/doxygen/html/group__jose__jwk.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
6 <meta name="generator" content="Doxygen 1.8.13"/>
7 <meta name="viewport" content="width=device-width, initial-scale=1"/>
8 <title>José: JWK</title>
9 <link href="tabs.css" rel="stylesheet" type="text/css"/>
10 <script type="text/javascript" src="jquery.js"></script>
11 <script type="text/javascript" src="dynsections.js"></script>
12 <link href="search/search.css" rel="stylesheet" type="text/css"/>
13 <script type="text/javascript" src="search/searchdata.js"></script>
14 <script type="text/javascript" src="search/search.js"></script>
15 <link href="doxygen.css" rel="stylesheet" type="text/css" />
16 </head>
17 <body>
18 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
19 <div id="titlearea">
20 <table cellspacing="0" cellpadding="0">
21 <tbody>
22 <tr style="height: 56px;">
23 <td id="projectalign" style="padding-left: 0.5em;">
24 <div id="projectname">José
25 </div>
26 </td>
27 </tr>
28 </tbody>
29 </table>
30 </div>
31 <!-- end header part -->
32 <!-- Generated by Doxygen 1.8.13 -->
33 <script type="text/javascript">
34 var searchBox = new SearchBox("searchBox", "search",false,'Search');
35 </script>
36 <script type="text/javascript" src="menudata.js"></script>
37 <script type="text/javascript" src="menu.js"></script>
38 <script type="text/javascript">
39 $(function() {
40 initMenu('',true,false,'search.php','Search');
41 $(document).ready(function() { init_search(); });
42 });
43 </script>
44 <div id="main-nav"></div>
45 </div><!-- top -->
46 <!-- window showing the filter options -->
47 <div id="MSearchSelectWindow"
48 onmouseover="return searchBox.OnSearchSelectShow()"
49 onmouseout="return searchBox.OnSearchSelectHide()"
50 onkeydown="return searchBox.OnSearchSelectKey(event)">
51 </div>
52
53 <!-- iframe showing the search results (closed by default) -->
54 <div id="MSearchResultsWindow">
55 <iframe src="javascript:void(0)" frameborder="0"
56 name="MSearchResults" id="MSearchResults">
57 </iframe>
58 </div>
59
60 <div class="header">
61 <div class="summary">
62 <a href="#func-members">Functions</a> </div>
63 <div class="headertitle">
64 <div class="title">JWK</div> </div>
65 </div><!--header-->
66 <div class="contents">
67
68 <p>JSON Web Keys (RFC 7517)
69 <a href="#details">More...</a></p>
70 <table class="memberdecls">
71 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
72 Functions</h2></td></tr>
73 <tr class="memitem:gac4daef7aeb077caaa459f07af353e9a8"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwk.html#gac4daef7aeb077caaa459f07af353e9a8">jose_jwk_gen</a> (jose_cfg_t *cfg, json_t *jwk)</td></tr>
74 <tr class="memdesc:gac4daef7aeb077caaa459f07af353e9a8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generates a new JWK. <a href="#gac4daef7aeb077caaa459f07af353e9a8">More...</a><br /></td></tr>
75 <tr class="separator:gac4daef7aeb077caaa459f07af353e9a8"><td class="memSeparator" colspan="2">&#160;</td></tr>
76 <tr class="memitem:ga3ebb220fa6f93ad00c6589400c1a441c"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwk.html#ga3ebb220fa6f93ad00c6589400c1a441c">jose_jwk_pub</a> (jose_cfg_t *cfg, json_t *jwk)</td></tr>
77 <tr class="memdesc:ga3ebb220fa6f93ad00c6589400c1a441c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Removes all private key material from a JWK. <a href="#ga3ebb220fa6f93ad00c6589400c1a441c">More...</a><br /></td></tr>
78 <tr class="separator:ga3ebb220fa6f93ad00c6589400c1a441c"><td class="memSeparator" colspan="2">&#160;</td></tr>
79 <tr class="memitem:gaa2023d0376c2e5ca14c2177f80f8ecd5"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwk.html#gaa2023d0376c2e5ca14c2177f80f8ecd5">jose_jwk_prm</a> (jose_cfg_t *cfg, const json_t *jwk, bool req, const char *op)</td></tr>
80 <tr class="memdesc:gaa2023d0376c2e5ca14c2177f80f8ecd5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Determines if an operation is permitted for a JWK. <a href="#gaa2023d0376c2e5ca14c2177f80f8ecd5">More...</a><br /></td></tr>
81 <tr class="separator:gaa2023d0376c2e5ca14c2177f80f8ecd5"><td class="memSeparator" colspan="2">&#160;</td></tr>
82 <tr class="memitem:ga4f5d2e9dc5f9e24646808b502b87b764"><td class="memItemLeft" align="right" valign="top">json_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwk.html#ga4f5d2e9dc5f9e24646808b502b87b764">jose_jwk_thp</a> (jose_cfg_t *cfg, const json_t *jwk, const char *alg)</td></tr>
83 <tr class="memdesc:ga4f5d2e9dc5f9e24646808b502b87b764"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculates the thumbprint of a JWK as a URL-safe Base64 encoded JSON string. <a href="#ga4f5d2e9dc5f9e24646808b502b87b764">More...</a><br /></td></tr>
84 <tr class="separator:ga4f5d2e9dc5f9e24646808b502b87b764"><td class="memSeparator" colspan="2">&#160;</td></tr>
85 <tr class="memitem:ga03f820f8de4e63ffe2feb3490236040e"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwk.html#ga03f820f8de4e63ffe2feb3490236040e">jose_jwk_thp_buf</a> (jose_cfg_t *cfg, const json_t *jwk, const char *alg, uint8_t *thp, size_t len)</td></tr>
86 <tr class="memdesc:ga03f820f8de4e63ffe2feb3490236040e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculates the thumbprint of a JWK. <a href="#ga03f820f8de4e63ffe2feb3490236040e">More...</a><br /></td></tr>
87 <tr class="separator:ga03f820f8de4e63ffe2feb3490236040e"><td class="memSeparator" colspan="2">&#160;</td></tr>
88 <tr class="memitem:ga9977a603c39b1b7c545f3f0c3dd0a7ef"><td class="memItemLeft" align="right" valign="top">json_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwk.html#ga9977a603c39b1b7c545f3f0c3dd0a7ef">jose_jwk_exc</a> (jose_cfg_t *cfg, const json_t *prv, const json_t *pub)</td></tr>
89 <tr class="memdesc:ga9977a603c39b1b7c545f3f0c3dd0a7ef"><td class="mdescLeft">&#160;</td><td class="mdescRight">Perform a key exchange. <a href="#ga9977a603c39b1b7c545f3f0c3dd0a7ef">More...</a><br /></td></tr>
90 <tr class="separator:ga9977a603c39b1b7c545f3f0c3dd0a7ef"><td class="memSeparator" colspan="2">&#160;</td></tr>
91 </table>
92 <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
93 <p>JSON Web Keys (RFC 7517) </p>
94 <p>A JSON Web Key (JWS) is a standard data format for expresing cryptographic keys in JSON.</p>
95 <dl class="section see"><dt>See also</dt><dd><a href="https://tools.ietf.org/html/rfc7517">https://tools.ietf.org/html/rfc7517</a> </dd>
96 <dd>
97 <a href="https://tools.ietf.org/html/rfc7638">https://tools.ietf.org/html/rfc7638</a> </dd></dl>
98 <h2 class="groupheader">Function Documentation</h2>
99 <a id="gac4daef7aeb077caaa459f07af353e9a8"></a>
100 <h2 class="memtitle"><span class="permalink"><a href="#gac4daef7aeb077caaa459f07af353e9a8">&#9670;&nbsp;</a></span>jose_jwk_gen()</h2>
101
102 <div class="memitem">
103 <div class="memproto">
104 <table class="memname">
105 <tr>
106 <td class="memname">bool jose_jwk_gen </td>
107 <td>(</td>
108 <td class="paramtype">jose_cfg_t *&#160;</td>
109 <td class="paramname"><em>cfg</em>, </td>
110 </tr>
111 <tr>
112 <td class="paramkey"></td>
113 <td></td>
114 <td class="paramtype">json_t *&#160;</td>
115 <td class="paramname"><em>jwk</em>&#160;</td>
116 </tr>
117 <tr>
118 <td></td>
119 <td>)</td>
120 <td></td><td></td>
121 </tr>
122 </table>
123 </div><div class="memdoc">
124
125 <p>Generates a new JWK. </p>
126 <p>The JWK is generated using hints from the input in exactly the same format as you would find in the output. For example, the most common way to generate a key is to specify the algorithm you'd like to use the key with. For example (error handling omitted): </p><pre class="fragment">json_t *gen(void) {
127 json_auto_t *jwk = json_pack("{s:s}", "alg", "ES256");
128 jose_jwk_gen(NULL, jwk);
129 return json_incref(jwk);
130 }
131 </pre><p>This method is preferred because other metadata can be inferred from the algorithm name, such as the key usage. Additionally, the algorithm metadata can be used to automatically generate correct headers when creating signatures (JWS) or encryptions (JWE). Thus, you should always default to creating keys by their algorithm usage.</p>
132 <p>However, should your requirements differ, you can also generate a key using raw parameters (again, error handling omitted): </p><pre class="fragment">json_t *gen(void) {
133 json_auto_t *jwk = json_pack("{s:s,s:s}", "kty", "EC", "crv", "P-256");
134 jose_jwk_gen(NULL, jwk);
135 return json_incref(jwk);
136 }
137
138 json_t *gen(void) {
139 json_auto_t *jwk = json_pack("{s:s,s:i}", "kty", "RSA", "bits", 2048);
140 jose_jwk_gen(NULL, jwk);
141 return json_incref(jwk);
142 }
143
144 json_t *gen(void) {
145 json_auto_t *jwk = json_pack("{s:s,s:i}", "kty", "oct", "bytes", 32);
146 jose_jwk_gen(NULL, jwk);
147 return json_incref(jwk);
148 }
149 </pre><p>In this case, "bits" and "bytes" will be removed from the final output.</p>
150 <dl class="section see"><dt>See also</dt><dd><a href="https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-algorithms">https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-algorithms</a> </dd></dl>
151 <dl class="params"><dt>Parameters</dt><dd>
152 <table class="params">
153 <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
154 <tr><td class="paramname">jwk</td><td>The JWK to generate. </td></tr>
155 </table>
156 </dd>
157 </dl>
158 <dl class="section return"><dt>Returns</dt><dd>On success, true. Otherwise, false. </dd></dl>
159
160 </div>
161 </div>
162 <a id="ga3ebb220fa6f93ad00c6589400c1a441c"></a>
163 <h2 class="memtitle"><span class="permalink"><a href="#ga3ebb220fa6f93ad00c6589400c1a441c">&#9670;&nbsp;</a></span>jose_jwk_pub()</h2>
164
165 <div class="memitem">
166 <div class="memproto">
167 <table class="memname">
168 <tr>
169 <td class="memname">bool jose_jwk_pub </td>
170 <td>(</td>
171 <td class="paramtype">jose_cfg_t *&#160;</td>
172 <td class="paramname"><em>cfg</em>, </td>
173 </tr>
174 <tr>
175 <td class="paramkey"></td>
176 <td></td>
177 <td class="paramtype">json_t *&#160;</td>
178 <td class="paramname"><em>jwk</em>&#160;</td>
179 </tr>
180 <tr>
181 <td></td>
182 <td>)</td>
183 <td></td><td></td>
184 </tr>
185 </table>
186 </div><div class="memdoc">
187
188 <p>Removes all private key material from a JWK. </p>
189 <p>In addition, this function will remove any key operations from the <code>key_ops</code> JWK property (if present) that apply only to the private key.</p>
190 <p>This function should be used before exporting keys to third parties.</p>
191 <dl class="params"><dt>Parameters</dt><dd>
192 <table class="params">
193 <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
194 <tr><td class="paramname">jwk</td><td>The JWK to remove private keys from. </td></tr>
195 </table>
196 </dd>
197 </dl>
198 <dl class="section return"><dt>Returns</dt><dd>On success, true. Otherwise, false. </dd></dl>
199
200 </div>
201 </div>
202 <a id="gaa2023d0376c2e5ca14c2177f80f8ecd5"></a>
203 <h2 class="memtitle"><span class="permalink"><a href="#gaa2023d0376c2e5ca14c2177f80f8ecd5">&#9670;&nbsp;</a></span>jose_jwk_prm()</h2>
204
205 <div class="memitem">
206 <div class="memproto">
207 <table class="memname">
208 <tr>
209 <td class="memname">bool jose_jwk_prm </td>
210 <td>(</td>
211 <td class="paramtype">jose_cfg_t *&#160;</td>
212 <td class="paramname"><em>cfg</em>, </td>
213 </tr>
214 <tr>
215 <td class="paramkey"></td>
216 <td></td>
217 <td class="paramtype">const json_t *&#160;</td>
218 <td class="paramname"><em>jwk</em>, </td>
219 </tr>
220 <tr>
221 <td class="paramkey"></td>
222 <td></td>
223 <td class="paramtype">bool&#160;</td>
224 <td class="paramname"><em>req</em>, </td>
225 </tr>
226 <tr>
227 <td class="paramkey"></td>
228 <td></td>
229 <td class="paramtype">const char *&#160;</td>
230 <td class="paramname"><em>op</em>&#160;</td>
231 </tr>
232 <tr>
233 <td></td>
234 <td>)</td>
235 <td></td><td></td>
236 </tr>
237 </table>
238 </div><div class="memdoc">
239
240 <p>Determines if an operation is permitted for a JWK. </p>
241 <p>The operation to be confirmed (<code>op</code>) is always specified according to the syntax of the "key_ops" JWK property, even when the "use" property is defined on the JWK.</p>
242 <p>This function has two modes of operation. If <code>req</code> is false, then JWKs which do not have any key use metadata will be approved for this operation. However, if <code>req</code> is true then this metadata will be required for approval.</p>
243 <dl class="params"><dt>Parameters</dt><dd>
244 <table class="params">
245 <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
246 <tr><td class="paramname">jwk</td><td>The JWK from which to remove private keys. </td></tr>
247 <tr><td class="paramname">req</td><td>Whether JWK key use metadata is required or not. </td></tr>
248 <tr><td class="paramname">op</td><td>The opperation to seek approval for. </td></tr>
249 </table>
250 </dd>
251 </dl>
252 <dl class="section return"><dt>Returns</dt><dd>When the JWK is approved, true. Otherwise, false. </dd></dl>
253
254 </div>
255 </div>
256 <a id="ga4f5d2e9dc5f9e24646808b502b87b764"></a>
257 <h2 class="memtitle"><span class="permalink"><a href="#ga4f5d2e9dc5f9e24646808b502b87b764">&#9670;&nbsp;</a></span>jose_jwk_thp()</h2>
258
259 <div class="memitem">
260 <div class="memproto">
261 <table class="memname">
262 <tr>
263 <td class="memname">json_t* jose_jwk_thp </td>
264 <td>(</td>
265 <td class="paramtype">jose_cfg_t *&#160;</td>
266 <td class="paramname"><em>cfg</em>, </td>
267 </tr>
268 <tr>
269 <td class="paramkey"></td>
270 <td></td>
271 <td class="paramtype">const json_t *&#160;</td>
272 <td class="paramname"><em>jwk</em>, </td>
273 </tr>
274 <tr>
275 <td class="paramkey"></td>
276 <td></td>
277 <td class="paramtype">const char *&#160;</td>
278 <td class="paramname"><em>alg</em>&#160;</td>
279 </tr>
280 <tr>
281 <td></td>
282 <td>)</td>
283 <td></td><td></td>
284 </tr>
285 </table>
286 </div><div class="memdoc">
287
288 <p>Calculates the thumbprint of a JWK as a URL-safe Base64 encoded JSON string. </p>
289 <p>This function is a thin wrapper around <a class="el" href="group__jose__jwk.html#ga03f820f8de4e63ffe2feb3490236040e" title="Calculates the thumbprint of a JWK. ">jose_jwk_thp_buf()</a>.</p>
290 <dl class="section see"><dt>See also</dt><dd><a class="el" href="group__jose__jwk.html#ga03f820f8de4e63ffe2feb3490236040e" title="Calculates the thumbprint of a JWK. ">jose_jwk_thp_buf()</a> </dd></dl>
291 <dl class="params"><dt>Parameters</dt><dd>
292 <table class="params">
293 <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
294 <tr><td class="paramname">jwk</td><td>The JWK to calculate the thumbprint for. </td></tr>
295 <tr><td class="paramname">alg</td><td>The hash algorithm to use. </td></tr>
296 </table>
297 </dd>
298 </dl>
299 <dl class="section return"><dt>Returns</dt><dd>On success, a newly-allocated JSON string. Otherwise, NULL. </dd></dl>
300
301 </div>
302 </div>
303 <a id="ga03f820f8de4e63ffe2feb3490236040e"></a>
304 <h2 class="memtitle"><span class="permalink"><a href="#ga03f820f8de4e63ffe2feb3490236040e">&#9670;&nbsp;</a></span>jose_jwk_thp_buf()</h2>
305
306 <div class="memitem">
307 <div class="memproto">
308 <table class="memname">
309 <tr>
310 <td class="memname">size_t jose_jwk_thp_buf </td>
311 <td>(</td>
312 <td class="paramtype">jose_cfg_t *&#160;</td>
313 <td class="paramname"><em>cfg</em>, </td>
314 </tr>
315 <tr>
316 <td class="paramkey"></td>
317 <td></td>
318 <td class="paramtype">const json_t *&#160;</td>
319 <td class="paramname"><em>jwk</em>, </td>
320 </tr>
321 <tr>
322 <td class="paramkey"></td>
323 <td></td>
324 <td class="paramtype">const char *&#160;</td>
325 <td class="paramname"><em>alg</em>, </td>
326 </tr>
327 <tr>
328 <td class="paramkey"></td>
329 <td></td>
330 <td class="paramtype">uint8_t *&#160;</td>
331 <td class="paramname"><em>thp</em>, </td>
332 </tr>
333 <tr>
334 <td class="paramkey"></td>
335 <td></td>
336 <td class="paramtype">size_t&#160;</td>
337 <td class="paramname"><em>len</em>&#160;</td>
338 </tr>
339 <tr>
340 <td></td>
341 <td>)</td>
342 <td></td><td></td>
343 </tr>
344 </table>
345 </div><div class="memdoc">
346
347 <p>Calculates the thumbprint of a JWK. </p>
348 <p>This function calculates the thumbprint of a JWK according to the method defined by RFC 7638.</p>
349 <p>If <code>thp</code> is NULL, this function returns the size of the buffer required for the thumbprint output.</p>
350 <dl class="section see"><dt>See also</dt><dd><a href="https://tools.ietf.org/html/rfc7638">https://tools.ietf.org/html/rfc7638</a> </dd></dl>
351 <dl class="params"><dt>Parameters</dt><dd>
352 <table class="params">
353 <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
354 <tr><td class="paramname">jwk</td><td>The JWK to calculate the thumbprint for. </td></tr>
355 <tr><td class="paramname">alg</td><td>The hash algorithm to use. </td></tr>
356 <tr><td class="paramname">thp</td><td>The output hash buffer. </td></tr>
357 <tr><td class="paramname">len</td><td>The size of the output hash buffer. </td></tr>
358 </table>
359 </dd>
360 </dl>
361 <dl class="section return"><dt>Returns</dt><dd>On success, the number of bytes written. Otherwise, SIZE_MAX. </dd></dl>
362
363 </div>
364 </div>
365 <a id="ga9977a603c39b1b7c545f3f0c3dd0a7ef"></a>
366 <h2 class="memtitle"><span class="permalink"><a href="#ga9977a603c39b1b7c545f3f0c3dd0a7ef">&#9670;&nbsp;</a></span>jose_jwk_exc()</h2>
367
368 <div class="memitem">
369 <div class="memproto">
370 <table class="memname">
371 <tr>
372 <td class="memname">json_t* jose_jwk_exc </td>
373 <td>(</td>
374 <td class="paramtype">jose_cfg_t *&#160;</td>
375 <td class="paramname"><em>cfg</em>, </td>
376 </tr>
377 <tr>
378 <td class="paramkey"></td>
379 <td></td>
380 <td class="paramtype">const json_t *&#160;</td>
381 <td class="paramname"><em>prv</em>, </td>
382 </tr>
383 <tr>
384 <td class="paramkey"></td>
385 <td></td>
386 <td class="paramtype">const json_t *&#160;</td>
387 <td class="paramname"><em>pub</em>&#160;</td>
388 </tr>
389 <tr>
390 <td></td>
391 <td>)</td>
392 <td></td><td></td>
393 </tr>
394 </table>
395 </div><div class="memdoc">
396
397 <p>Perform a key exchange. </p>
398 <p>The only currently implemented algorithm is ECDH.</p>
399 <dl class="params"><dt>Parameters</dt><dd>
400 <table class="params">
401 <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
402 <tr><td class="paramname">prv</td><td>The private JWK. </td></tr>
403 <tr><td class="paramname">pub</td><td>The public JWK. </td></tr>
404 </table>
405 </dd>
406 </dl>
407 <dl class="section return"><dt>Returns</dt><dd>On success, the JWK result of the key exchange. Otherwise, NULL. </dd></dl>
408
409 </div>
410 </div>
411 </div><!-- contents -->
412 <!-- start footer part -->
413 <hr class="footer"/><address class="footer"><small>
414 Generated by &#160;<a href="http://www.doxygen.org/index.html">
415 <img class="footer" src="doxygen.png" alt="doxygen"/>
416 </a> 1.8.13
417 </small></address>
418 </body>
419 </html>