123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=9"/>
- <meta name="generator" content="Doxygen 1.8.13"/>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <title>José: JWE</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript" src="dynsections.js"></script>
- <link href="search/search.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="search/searchdata.js"></script>
- <script type="text/javascript" src="search/search.js"></script>
- <link href="doxygen.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
- <div id="titlearea">
- <table cellspacing="0" cellpadding="0">
- <tbody>
- <tr style="height: 56px;">
- <td id="projectalign" style="padding-left: 0.5em;">
- <div id="projectname">José
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <!-- Generated by Doxygen 1.8.13 -->
- <script type="text/javascript">
- var searchBox = new SearchBox("searchBox", "search",false,'Search');
- </script>
- <script type="text/javascript" src="menudata.js"></script>
- <script type="text/javascript" src="menu.js"></script>
- <script type="text/javascript">
- $(function() {
- initMenu('',true,false,'search.php','Search');
- $(document).ready(function() { init_search(); });
- });
- </script>
- <div id="main-nav"></div>
- </div><!-- top -->
- <!-- window showing the filter options -->
- <div id="MSearchSelectWindow"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- onkeydown="return searchBox.OnSearchSelectKey(event)">
- </div>
- <!-- iframe showing the search results (closed by default) -->
- <div id="MSearchResultsWindow">
- <iframe src="javascript:void(0)" frameborder="0"
- name="MSearchResults" id="MSearchResults">
- </iframe>
- </div>
- <div class="header">
- <div class="summary">
- <a href="#func-members">Functions</a> </div>
- <div class="headertitle">
- <div class="title">JWE</div> </div>
- </div><!--header-->
- <div class="contents">
- <p>JSON Web Encryption (RFC 7516)
- <a href="#details">More...</a></p>
- <table class="memberdecls">
- <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
- Functions</h2></td></tr>
- <tr class="memitem:ga5920b450d6f4b0aa1729a7230a48fb32"><td class="memItemLeft" align="right" valign="top">json_t * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#ga5920b450d6f4b0aa1729a7230a48fb32">jose_jwe_hdr</a> (const json_t *jwe, const json_t *rcp)</td></tr>
- <tr class="memdesc:ga5920b450d6f4b0aa1729a7230a48fb32"><td class="mdescLeft"> </td><td class="mdescRight">Merges the JOSE headers of a JWE object and a JWE recpient object. <a href="#ga5920b450d6f4b0aa1729a7230a48fb32">More...</a><br /></td></tr>
- <tr class="separator:ga5920b450d6f4b0aa1729a7230a48fb32"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:ga67fd2b695bfff58a3b7adaf6bce9a773"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#ga67fd2b695bfff58a3b7adaf6bce9a773">jose_jwe_enc</a> (jose_cfg_t *cfg, json_t *jwe, json_t *rcp, const json_t *jwk, const void *pt, size_t ptl)</td></tr>
- <tr class="memdesc:ga67fd2b695bfff58a3b7adaf6bce9a773"><td class="mdescLeft"> </td><td class="mdescRight">Wraps and encrypts plaintext. <a href="#ga67fd2b695bfff58a3b7adaf6bce9a773">More...</a><br /></td></tr>
- <tr class="separator:ga67fd2b695bfff58a3b7adaf6bce9a773"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:ga27e44e2144dc81b778158163661b7f9f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structjose__io__t.html">jose_io_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#ga27e44e2144dc81b778158163661b7f9f">jose_jwe_enc_io</a> (jose_cfg_t *cfg, json_t *jwe, json_t *rcp, const json_t *jwk, <a class="el" href="structjose__io__t.html">jose_io_t</a> *next)</td></tr>
- <tr class="memdesc:ga27e44e2144dc81b778158163661b7f9f"><td class="mdescLeft"> </td><td class="mdescRight">Wraps and encrypts plaintext using streaming. <a href="#ga27e44e2144dc81b778158163661b7f9f">More...</a><br /></td></tr>
- <tr class="separator:ga27e44e2144dc81b778158163661b7f9f"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:ga6cebc627dea8bb944d35acb776abe769"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#ga6cebc627dea8bb944d35acb776abe769">jose_jwe_enc_jwk</a> (jose_cfg_t *cfg, json_t *jwe, json_t *rcp, const json_t *jwk, json_t *cek)</td></tr>
- <tr class="memdesc:ga6cebc627dea8bb944d35acb776abe769"><td class="mdescLeft"> </td><td class="mdescRight">Wraps a CEK with a JWK. <a href="#ga6cebc627dea8bb944d35acb776abe769">More...</a><br /></td></tr>
- <tr class="separator:ga6cebc627dea8bb944d35acb776abe769"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:ga885caaa8a0f24bcbdf283478b26b614d"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#ga885caaa8a0f24bcbdf283478b26b614d">jose_jwe_enc_cek</a> (jose_cfg_t *cfg, json_t *jwe, const json_t *cek, const void *pt, size_t ptl)</td></tr>
- <tr class="memdesc:ga885caaa8a0f24bcbdf283478b26b614d"><td class="mdescLeft"> </td><td class="mdescRight">Encrypts plaintext with the CEK. <a href="#ga885caaa8a0f24bcbdf283478b26b614d">More...</a><br /></td></tr>
- <tr class="separator:ga885caaa8a0f24bcbdf283478b26b614d"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:gae484a56237a35f5c18038a1b24952f0a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structjose__io__t.html">jose_io_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#gae484a56237a35f5c18038a1b24952f0a">jose_jwe_enc_cek_io</a> (jose_cfg_t *cfg, json_t *jwe, const json_t *cek, <a class="el" href="structjose__io__t.html">jose_io_t</a> *next)</td></tr>
- <tr class="memdesc:gae484a56237a35f5c18038a1b24952f0a"><td class="mdescLeft"> </td><td class="mdescRight">Encrypts plaintext with the CEK using streaming. <a href="#gae484a56237a35f5c18038a1b24952f0a">More...</a><br /></td></tr>
- <tr class="separator:gae484a56237a35f5c18038a1b24952f0a"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:gac873b95e6fad75e2d517970a94346c5d"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#gac873b95e6fad75e2d517970a94346c5d">jose_jwe_dec</a> (jose_cfg_t *cfg, const json_t *jwe, const json_t *rcp, const json_t *jwk, size_t *ptl)</td></tr>
- <tr class="memdesc:gac873b95e6fad75e2d517970a94346c5d"><td class="mdescLeft"> </td><td class="mdescRight">Unwraps and decrypts ciphertext. <a href="#gac873b95e6fad75e2d517970a94346c5d">More...</a><br /></td></tr>
- <tr class="separator:gac873b95e6fad75e2d517970a94346c5d"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:gacd3c7703b57c524bc2683f2c0d0db4b8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structjose__io__t.html">jose_io_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#gacd3c7703b57c524bc2683f2c0d0db4b8">jose_jwe_dec_io</a> (jose_cfg_t *cfg, const json_t *jwe, const json_t *rcp, const json_t *jwk, <a class="el" href="structjose__io__t.html">jose_io_t</a> *next)</td></tr>
- <tr class="memdesc:gacd3c7703b57c524bc2683f2c0d0db4b8"><td class="mdescLeft"> </td><td class="mdescRight">Unwraps and decrypts ciphertext using streaming. <a href="#gacd3c7703b57c524bc2683f2c0d0db4b8">More...</a><br /></td></tr>
- <tr class="separator:gacd3c7703b57c524bc2683f2c0d0db4b8"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:gab9608cf23da17fadce6078aa2d862608"><td class="memItemLeft" align="right" valign="top">json_t * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#gab9608cf23da17fadce6078aa2d862608">jose_jwe_dec_jwk</a> (jose_cfg_t *cfg, const json_t *jwe, const json_t *rcp, const json_t *jwk)</td></tr>
- <tr class="memdesc:gab9608cf23da17fadce6078aa2d862608"><td class="mdescLeft"> </td><td class="mdescRight">Unwraps a CEK with a JWK. <a href="#gab9608cf23da17fadce6078aa2d862608">More...</a><br /></td></tr>
- <tr class="separator:gab9608cf23da17fadce6078aa2d862608"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:ga64b1b6074f8643aa301007fc125aed59"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#ga64b1b6074f8643aa301007fc125aed59">jose_jwe_dec_cek</a> (jose_cfg_t *cfg, const json_t *jwe, const json_t *cek, size_t *ptl)</td></tr>
- <tr class="memdesc:ga64b1b6074f8643aa301007fc125aed59"><td class="mdescLeft"> </td><td class="mdescRight">Decrypts ciphertext with the CEK. <a href="#ga64b1b6074f8643aa301007fc125aed59">More...</a><br /></td></tr>
- <tr class="separator:ga64b1b6074f8643aa301007fc125aed59"><td class="memSeparator" colspan="2"> </td></tr>
- <tr class="memitem:gaf22bbcd02627f938be28fa4b1778e29c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structjose__io__t.html">jose_io_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__jose__jwe.html#gaf22bbcd02627f938be28fa4b1778e29c">jose_jwe_dec_cek_io</a> (jose_cfg_t *cfg, const json_t *jwe, const json_t *cek, <a class="el" href="structjose__io__t.html">jose_io_t</a> *next)</td></tr>
- <tr class="memdesc:gaf22bbcd02627f938be28fa4b1778e29c"><td class="mdescLeft"> </td><td class="mdescRight">Decrypts ciphertext with the CEK using streaming. <a href="#gaf22bbcd02627f938be28fa4b1778e29c">More...</a><br /></td></tr>
- <tr class="separator:gaf22bbcd02627f938be28fa4b1778e29c"><td class="memSeparator" colspan="2"> </td></tr>
- </table>
- <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
- <p>JSON Web Encryption (RFC 7516) </p>
- <p>A JSON Web Encryption (JWE) object contains (usually) two levels of encryption. First, the plaintext is encrypted with a random symmetric key. In José, we call this key the Content Encryption Key (CEK). Next, the CEK is wrapped (encrypted) with one or more keys. These keys are standard JSON Web Keys (JWK) and may be symmetric or asymmetric.</p>
- <p>Thus there is (usually) one CEK and one or more JWKs. However, there are some exceptions to this rule. Two such examples are the algorithms: "dir" and "ECDH-ES". In the first case, the JWK is a symmetric key and is used directly as the CEK. In the second case, an ECDH key exchange is performed and the result is used directly as the CEK. But in general, the maxim holds.</p>
- <p>This means that you can encrypt the data using one CEK and then encrypt the CEK to multiple recipients. With this schema, multiple recipients can each decrypt the data using their own key without having to send separate ciphertext to each recipient.</p>
- <p>For maximum flexibility, José structures its API to take advantage of this schema. For example, when encrypting to two recipients, the code could look like this (error handling omitted): </p><pre class="fragment">json_t *enc(void *plaintext, size_t len, json_t *jwk0, json_t *jwk1) {
- json_auto_t *jwe = json_object();
- json_auto_t *cek = json_object();
- // Wrap to the first recipient (CEK generated implicitly)
- jose_jwe_enc_jwk(NULL, jwe, NULL, jwk0, cek);
- // Wrap to the second recipient
- jose_jwe_enc_jwk(NULL, jwe, NULL, jwk1, cek);
- // Encrypt plaintext using the generated CEK
- jose_jwe_enc_cek(NULL, jwe, cek, plaintext, len);
- return json_incref(jwe);
- }
- </pre><p>However, because José intends to be easy to use, we also provide shortcuts. For example, you could use a JWKSet which contains multiple JWKs: </p><pre class="fragment">json_t *enc(void *plaintext, size_t len, json_t *jwkset) {
- json_auto_t *jwe = json_object();
- // Perform wrapping and encryption to all recipients
- jose_jwe_enc(NULL, jwe, NULL, jwkset, plaintext, len);
- return json_incref(jwe);
- }
- </pre><p>Here are two tips to remember. First, let José generate your CEK implicitly. Second, always perform wrapping before encryption. Both of these tips are important because some wrapping algorithms may impose constraints on the generation of the CEK.</p>
- <p>To decrypt a JWE, we just reverse the process. First, we use a JWK to unwrap the CEK. Then we use the CEK to decrypt the ciphertext. Here is how that might look in code (again, error handling omitted): </p><pre class="fragment">void *dec(json_t *jwe, json_t *jwk, size_t *len) {
- json_auto_t *cek = NULL;
- // Unwrap the CEK using our JWK
- cek = jose_jwe_dec_jwk(NULL, jwe, NULL, jwk);
- // Decrypt ciphertext using the CEK
- return jose_jwe_dec_cek(NULL, jwe, cek, len);
- }
- </pre><p>Or, again, in simplified form: </p><pre class="fragment">void *dec(json_t *jwe, json_t *jwk, size_t *len) {
- return jose_jwe_dec(NULL, jwe, NULL, jwk, len);
- }
- </pre><p>If you need to forward a JWE to a new recipient, you can do this without performing re-encryption. Just unwrap the CEK and then wrap the CEK again using a new JWK. For example: </p><pre class="fragment">void fwd(json_t *jwe, json_t *oldjwk, json_t *newjwk) {
- json_auto_t *cek = NULL;
- // Unwrap the CEK using the old JWK
- cek = jose_jwe_dec_jwk(NULL, jwe, NULL, oldjwk);
- // Wrap the CEK to the new JWK
- jose_jwe_enc_jwk(NULL, jwe, NULL, newjwk, cek);
- }
- </pre><p>In all the above examples, parameters like which encryption algorithms to use were inferred from our keys. Where such an inference cannot be made, sensible and secure defaults were chosen automatically. If you would like more control over the process, simply set parameters in the appropriate objects (more on this in the function documentation). For example, to enable plaintext compression, you can specify the <code>zip</code> property in the JWE Protected Header: </p><pre class="fragment">json_t *enc(void *plaintext, size_t len, json_t *jwkset) {
- json_auto_t *jwe = json_pack("{s:{s:s}}", "protected", "zip", "DEF");
- // Perform compressed wrapping and encryption to all recipients
- jose_jwe_enc(NULL, jwe, NULL, jwkset, plaintext, len);
- return json_incref(jwe);
- }
- </pre><p>José currently supports the "alg", "enc" and "zip" header parameters, as well as any algorithm-specific header parameters used by the specific algorithms we implement. Other header parameters may be specified, but do not effect the behavior of José's JWE implementation.</p>
- <dl class="section see"><dt>See also</dt><dd><a href="https://tools.ietf.org/html/rfc7516">https://tools.ietf.org/html/rfc7516</a> </dd></dl>
- <h2 class="groupheader">Function Documentation</h2>
- <a id="ga5920b450d6f4b0aa1729a7230a48fb32"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#ga5920b450d6f4b0aa1729a7230a48fb32">◆ </a></span>jose_jwe_hdr()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname">json_t* jose_jwe_hdr </td>
- <td>(</td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>rcp</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Merges the JOSE headers of a JWE object and a JWE recpient object. </p>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">jwe</td><td>A JWE object. </td></tr>
- <tr><td class="paramname">rcp</td><td>A JWE recipient object. </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>The newly allocated JOSE header. </dd></dl>
- </div>
- </div>
- <a id="ga67fd2b695bfff58a3b7adaf6bce9a773"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#ga67fd2b695bfff58a3b7adaf6bce9a773">◆ </a></span>jose_jwe_enc()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname">bool jose_jwe_enc </td>
- <td>(</td>
- <td class="paramtype">jose_cfg_t * </td>
- <td class="paramname"><em>cfg</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">json_t * </td>
- <td class="paramname"><em>rcp</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwk</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const void * </td>
- <td class="paramname"><em>pt</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">size_t </td>
- <td class="paramname"><em>ptl</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Wraps and encrypts plaintext. </p>
- <p>This function is a thin wrapper around the <a class="el" href="group__jose__jwe.html#ga27e44e2144dc81b778158163661b7f9f" title="Wraps and encrypts plaintext using streaming. ">jose_jwe_enc_io()</a> function allowing the user to specify the plaintext in a single call. The ciphertext output will be appended to the JWE as the "ciphertext" property.</p>
- <dl class="section see"><dt>See also</dt><dd><a class="el" href="group__jose__jwe.html#gae484a56237a35f5c18038a1b24952f0a" title="Encrypts plaintext with the CEK using streaming. ">jose_jwe_enc_cek_io()</a> </dd></dl>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
- <tr><td class="paramname">jwe</td><td>The JWE object. </td></tr>
- <tr><td class="paramname">rcp</td><td>The JWE recipient object(s) or NULL. </td></tr>
- <tr><td class="paramname">jwk</td><td>The JWK(s) or JWKSet used for wrapping. </td></tr>
- <tr><td class="paramname">pt</td><td>The plaintext. </td></tr>
- <tr><td class="paramname">ptl</td><td>The length of the plaintext. </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>On success, true. Otherwise, false. </dd></dl>
- </div>
- </div>
- <a id="ga27e44e2144dc81b778158163661b7f9f"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#ga27e44e2144dc81b778158163661b7f9f">◆ </a></span>jose_jwe_enc_io()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname"><a class="el" href="structjose__io__t.html">jose_io_t</a>* jose_jwe_enc_io </td>
- <td>(</td>
- <td class="paramtype">jose_cfg_t * </td>
- <td class="paramname"><em>cfg</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">json_t * </td>
- <td class="paramname"><em>rcp</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwk</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype"><a class="el" href="structjose__io__t.html">jose_io_t</a> * </td>
- <td class="paramname"><em>next</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Wraps and encrypts plaintext using streaming. </p>
- <p>This function is a thin wrapper around the <a class="el" href="group__jose__jwe.html#ga6cebc627dea8bb944d35acb776abe769" title="Wraps a CEK with a JWK. ">jose_jwe_enc_jwk()</a> and <a class="el" href="group__jose__jwe.html#gae484a56237a35f5c18038a1b24952f0a" title="Encrypts plaintext with the CEK using streaming. ">jose_jwe_enc_cek_io()</a> functions, removing the complexity of managing the CEK.</p>
- <dl class="section see"><dt>See also</dt><dd><a class="el" href="group__jose__jwe.html#ga6cebc627dea8bb944d35acb776abe769" title="Wraps a CEK with a JWK. ">jose_jwe_enc_jwk()</a> </dd>
- <dd>
- <a class="el" href="group__jose__jwe.html#gae484a56237a35f5c18038a1b24952f0a" title="Encrypts plaintext with the CEK using streaming. ">jose_jwe_enc_cek_io()</a> </dd></dl>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
- <tr><td class="paramname">jwe</td><td>The JWE object. </td></tr>
- <tr><td class="paramname">rcp</td><td>The JWE recipient object(s) or NULL. </td></tr>
- <tr><td class="paramname">jwk</td><td>The JWK(s) or JWKSet used for wrapping. </td></tr>
- <tr><td class="paramname">next</td><td>The next IO object in the chain. </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>The new IO object or NULL on error. </dd></dl>
- </div>
- </div>
- <a id="ga6cebc627dea8bb944d35acb776abe769"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#ga6cebc627dea8bb944d35acb776abe769">◆ </a></span>jose_jwe_enc_jwk()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname">bool jose_jwe_enc_jwk </td>
- <td>(</td>
- <td class="paramtype">jose_cfg_t * </td>
- <td class="paramname"><em>cfg</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">json_t * </td>
- <td class="paramname"><em>rcp</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwk</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">json_t * </td>
- <td class="paramname"><em>cek</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Wraps a CEK with a JWK. </p>
- <p>The purpose of this function is to wrap (encrypt) or, in some cases, produce the CEK (<code>cek</code>) from the provided JWK(s) (<code>jwk</code>). This function can be used in two modes: single-JWK and multi-JWK.</p>
- <p>In single-JWK mode, the <code>jwk</code> parameter contains a JWK object and the <code>rcp</code> parameter must contain either a JWE recipient object or NULL, in which case a default empty JWE recipient object is created internally.</p>
- <p>Multi-JWK mode works exactly the same as single-JWK mode except that it performs multiple wrappings in a single call. This mode is enabled by passing either an array of JWK objects or a JWKSet as the <code>jwk</code> parameter. In this mode, the <code>rcp</code> parameter contains one of the following values:</p>
- <ol type="1">
- <li>A JWE recipient object that will be used for all wrappings. In this case, a copy will be made for each wrapping and <code>rcp</code> will not be modified in any way.</li>
- <li>An array of JWE recipient objects. Each object will be used with its corresponding JWK from <code>jwk</code>. If the arrays in <code>sig</code> and <code>jwk</code> are a different size, an error will occur.</li>
- <li>NULL. This has the same effect as passing NULL for each separate JWK.</li>
- </ol>
- <p>In either mode, if the resulting JWE (<code>jwe</code>) would contain only a single recipient, the JWE will be represented in Flattened JWE JSON Serialization Syntax. Otherwise, it will be represented in General JWE JSON Serialization Syntax.</p>
- <p>If the "alg" parameter is not specified in the JOSE Header, it will be inferred from the JWK and the chosen algorithm will be added to the JWE Per-Recipient Unprotected Header. Likewise, any missing, required, algorithm-specific parameters will be either inferred or sensible, secure defaults will be chosen and the results will be added to the JWE Per-Recipient Unprotected Header.</p>
- <p>If the provided CEK (<code>cek</code>) does not contain key material, it will be implicitly generated during the first call to <a class="el" href="group__jose__jwe.html#ga6cebc627dea8bb944d35acb776abe769" title="Wraps a CEK with a JWK. ">jose_jwe_enc_jwk()</a>. This important feature enables the use of the "dir" and "ECDH-ES" algorithms. In the case of the "dir" algorithm, the JWK is the CEK and thus the key material is copied from <code>jwk</code> to <code>cek</code>. A similar situation arises with the algorithm "ECDH-ES" where the result of a key exchange is used as the CEK; thus, the CEK is produced during the wrapping process. This feature implies that if multiple wrappings are created, only one of them may have the algorithm "ECDH-ES" and it must be the first wrapping. Attempting to use "ECDH-ES" with an existing CEK will result in an error.</p>
- <p>It is additionally possible to pass a password JSON string as key input to the PBES2 family of algorithms anywhere a JWK can be used. Likewise, if the "alg" JOSE Header parameter is not specified and a JSON string is used in place of a JWK, the PBES2 family of algorithms will be inferred.</p>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
- <tr><td class="paramname">jwe</td><td>The JWE object. </td></tr>
- <tr><td class="paramname">rcp</td><td>The JWE recipient object(s) or NULL. </td></tr>
- <tr><td class="paramname">jwk</td><td>The JWK(s) or JWKSet used for wrapping. </td></tr>
- <tr><td class="paramname">cek</td><td>The CEK to wrap (if empty, generated). </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>On success, true. Otherwise, false. </dd></dl>
- </div>
- </div>
- <a id="ga885caaa8a0f24bcbdf283478b26b614d"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#ga885caaa8a0f24bcbdf283478b26b614d">◆ </a></span>jose_jwe_enc_cek()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname">bool jose_jwe_enc_cek </td>
- <td>(</td>
- <td class="paramtype">jose_cfg_t * </td>
- <td class="paramname"><em>cfg</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>cek</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const void * </td>
- <td class="paramname"><em>pt</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">size_t </td>
- <td class="paramname"><em>ptl</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Encrypts plaintext with the CEK. </p>
- <p>This function is a thin wrapper around the <a class="el" href="group__jose__jwe.html#gae484a56237a35f5c18038a1b24952f0a" title="Encrypts plaintext with the CEK using streaming. ">jose_jwe_enc_cek_io()</a> function allowing the user to specify the plaintext in a single call. The ciphertext output will be appended to the JWE as the "ciphertext" property.</p>
- <dl class="section see"><dt>See also</dt><dd><a class="el" href="group__jose__jwe.html#gae484a56237a35f5c18038a1b24952f0a" title="Encrypts plaintext with the CEK using streaming. ">jose_jwe_enc_cek_io()</a> </dd></dl>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
- <tr><td class="paramname">jwe</td><td>The JWE object. </td></tr>
- <tr><td class="paramname">cek</td><td>The CEK object. </td></tr>
- <tr><td class="paramname">pt</td><td>The plaintext. </td></tr>
- <tr><td class="paramname">ptl</td><td>The length of the plaintext. </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>On success, true. Otherwise, false. </dd></dl>
- </div>
- </div>
- <a id="gae484a56237a35f5c18038a1b24952f0a"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#gae484a56237a35f5c18038a1b24952f0a">◆ </a></span>jose_jwe_enc_cek_io()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname"><a class="el" href="structjose__io__t.html">jose_io_t</a>* jose_jwe_enc_cek_io </td>
- <td>(</td>
- <td class="paramtype">jose_cfg_t * </td>
- <td class="paramname"><em>cfg</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>cek</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype"><a class="el" href="structjose__io__t.html">jose_io_t</a> * </td>
- <td class="paramname"><em>next</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Encrypts plaintext with the CEK using streaming. </p>
- <p>The plaintext is provided through the returned IO object. The plaintext will be encrypted and written to the <code>next</code> IO object. This IO object works on binary data, so you may need to use a URL-safe Base64 decoder on input and a URL-safe Base64 encoder on output, depending on your situation.</p>
- <p>Compressed plaintext can be implicitly enabled by specifying the "zip" parameter the JWE Protected Header.</p>
- <p>If the JWE Protected Header is a JSON object rather than an encoded string, this function will encode the JWE Protected Header to its URL-safe Base64 encoding as defined in RFC 7516. However, this function will never modify a JWE Protected Header that is already encoded.</p>
- <p>If the "enc" parameter is not specified in the JWE Protected Header or the JWE Shared Unprotected Header, it will be inferred from the CEK and stored in either the JWE Protected Header or the JWE Shared Unprotected Header (preferring the JWE Protected header if it can be modified).</p>
- <p>Please note that the "tag" property will only be added to the JWE when <a class="el" href="structjose__io__t.html#a76d1eac0d05d3604c16686b08bd80aa0">jose_io_t::done()</a> returns.</p>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
- <tr><td class="paramname">jwe</td><td>The JWE object. </td></tr>
- <tr><td class="paramname">cek</td><td>The CEK object. </td></tr>
- <tr><td class="paramname">next</td><td>The next IO object in the chain. </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>The new IO object or NULL on error. </dd></dl>
- </div>
- </div>
- <a id="gac873b95e6fad75e2d517970a94346c5d"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#gac873b95e6fad75e2d517970a94346c5d">◆ </a></span>jose_jwe_dec()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname">void* jose_jwe_dec </td>
- <td>(</td>
- <td class="paramtype">jose_cfg_t * </td>
- <td class="paramname"><em>cfg</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>rcp</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwk</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">size_t * </td>
- <td class="paramname"><em>ptl</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Unwraps and decrypts ciphertext. </p>
- <p>This function is a thin wrapper around the <a class="el" href="group__jose__jwe.html#gacd3c7703b57c524bc2683f2c0d0db4b8" title="Unwraps and decrypts ciphertext using streaming. ">jose_jwe_dec_io()</a> function allowing the user to obtain the plaintext in a single call. The ciphertext input will be obtained from the JWE "ciphertext" property.</p>
- <dl class="section see"><dt>See also</dt><dd><a class="el" href="group__jose__jwe.html#gacd3c7703b57c524bc2683f2c0d0db4b8" title="Unwraps and decrypts ciphertext using streaming. ">jose_jwe_dec_io()</a> </dd></dl>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
- <tr><td class="paramname">jwe</td><td>The JWE object. </td></tr>
- <tr><td class="paramname">rcp</td><td>The JWE recipient object(s) or NULL. </td></tr>
- <tr><td class="paramname">jwk</td><td>The JWK(s) or JWKSet used for wrapping. </td></tr>
- <tr><td class="paramname">ptl</td><td>The length of the plaintext (output). </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>The newly-allocated plaintext. </dd></dl>
- </div>
- </div>
- <a id="gacd3c7703b57c524bc2683f2c0d0db4b8"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#gacd3c7703b57c524bc2683f2c0d0db4b8">◆ </a></span>jose_jwe_dec_io()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname"><a class="el" href="structjose__io__t.html">jose_io_t</a>* jose_jwe_dec_io </td>
- <td>(</td>
- <td class="paramtype">jose_cfg_t * </td>
- <td class="paramname"><em>cfg</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>rcp</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwk</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype"><a class="el" href="structjose__io__t.html">jose_io_t</a> * </td>
- <td class="paramname"><em>next</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Unwraps and decrypts ciphertext using streaming. </p>
- <p>This function is a thin wrapper around the <a class="el" href="group__jose__jwe.html#gab9608cf23da17fadce6078aa2d862608" title="Unwraps a CEK with a JWK. ">jose_jwe_dec_jwk()</a> and <a class="el" href="group__jose__jwe.html#gaf22bbcd02627f938be28fa4b1778e29c" title="Decrypts ciphertext with the CEK using streaming. ">jose_jwe_dec_cek_io()</a> functions, removing the complexity of managing the CEK.</p>
- <dl class="section see"><dt>See also</dt><dd><a class="el" href="group__jose__jwe.html#gab9608cf23da17fadce6078aa2d862608" title="Unwraps a CEK with a JWK. ">jose_jwe_dec_jwk()</a> </dd>
- <dd>
- <a class="el" href="group__jose__jwe.html#gaf22bbcd02627f938be28fa4b1778e29c" title="Decrypts ciphertext with the CEK using streaming. ">jose_jwe_dec_cek_io()</a> </dd></dl>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
- <tr><td class="paramname">jwe</td><td>The JWE object. </td></tr>
- <tr><td class="paramname">rcp</td><td>The JWE recipient object(s) or NULL. </td></tr>
- <tr><td class="paramname">jwk</td><td>The JWK(s) or JWKSet used for unwrapping. </td></tr>
- <tr><td class="paramname">next</td><td>The next IO object in the chain. </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>The new IO object or NULL on error. </dd></dl>
- </div>
- </div>
- <a id="gab9608cf23da17fadce6078aa2d862608"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#gab9608cf23da17fadce6078aa2d862608">◆ </a></span>jose_jwe_dec_jwk()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname">json_t* jose_jwe_dec_jwk </td>
- <td>(</td>
- <td class="paramtype">jose_cfg_t * </td>
- <td class="paramname"><em>cfg</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>rcp</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwk</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Unwraps a CEK with a JWK. </p>
- <p>The purpose of this function is to unwrap (decrypt) or, in some cases, produce the CEK (<code>cek</code>) from the provided JWK(s) (<code>jwk</code>). This function can be used in two modes: single-JWK and multi-JWK.</p>
- <p>In single-JWK mode, the <code>jwk</code> parameter contains a JWK object and the <code>rcp</code> parameter must contain either a JWE recipient object you wish to unwrap or NULL, in which case all JWE recipients will be tried.</p>
- <p>Multi-JWK mode works exactly the same as single-JWK mode except that it attempts to unwrap with multiple JWKs in a single call. This mode is enabled by passing either an array of JWK objects or a JWKSet as the <code>jwk</code> parameter. In this mode, the <code>rcp</code> parameter contains one of the following values:</p>
- <ol type="1">
- <li>A JWE recipient object that will be used for all attempted unwrappings.</li>
- <li>An array of JWE recipient objects. Each object will be used with its corresponding JWK from <code>jwk</code>. If the arrays in <code>sig</code> and <code>jwk</code> are a different size, an error will occur.</li>
- <li>NULL. This has the same effect as passing NULL for each separate JWK.</li>
- </ol>
- <p>In either mode, a CEK is returned for the first JWK that successfully unwraps a CEK. Two exceptions to this rule are if the "dir" or "ECDH-ES" algorithms are used. In this case, a CEK may be returned which will fail during decryption since there is no way to completely validate the JWK with these algorithms. Thus, we suggest placing the keys for these algorithms last when unwrapping with multiple JWKs.</p>
- <p>If the "alg" parameter is not specified in the JOSE Header, it will be inferred from the JWK. This includes using a JSON string in place of a JWK for the PBES2 family of algorithms.</p>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
- <tr><td class="paramname">jwe</td><td>The JWE object. </td></tr>
- <tr><td class="paramname">rcp</td><td>The JWE recipient object(s) or NULL. </td></tr>
- <tr><td class="paramname">jwk</td><td>The JWK(s) or JWKSet used for wrapping. </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>On success, a newly-allocated CEK object. Otherwise, NULL. </dd></dl>
- </div>
- </div>
- <a id="ga64b1b6074f8643aa301007fc125aed59"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#ga64b1b6074f8643aa301007fc125aed59">◆ </a></span>jose_jwe_dec_cek()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname">void* jose_jwe_dec_cek </td>
- <td>(</td>
- <td class="paramtype">jose_cfg_t * </td>
- <td class="paramname"><em>cfg</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>cek</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">size_t * </td>
- <td class="paramname"><em>ptl</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Decrypts ciphertext with the CEK. </p>
- <p>This function is a thin wrapper around the <a class="el" href="group__jose__jwe.html#gaf22bbcd02627f938be28fa4b1778e29c" title="Decrypts ciphertext with the CEK using streaming. ">jose_jwe_dec_cek_io()</a> function allowing the user to obtain the plaintext in a single call. The ciphertext input will be obtained from the JWE "ciphertext" property.</p>
- <dl class="section see"><dt>See also</dt><dd><a class="el" href="group__jose__jwe.html#gaf22bbcd02627f938be28fa4b1778e29c" title="Decrypts ciphertext with the CEK using streaming. ">jose_jwe_dec_cek_io()</a> </dd></dl>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
- <tr><td class="paramname">jwe</td><td>The JWE object. </td></tr>
- <tr><td class="paramname">cek</td><td>The CEK object. </td></tr>
- <tr><td class="paramname">ptl</td><td>The length of the plaintext (output). </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>The newly-allocated plaintext. </dd></dl>
- </div>
- </div>
- <a id="gaf22bbcd02627f938be28fa4b1778e29c"></a>
- <h2 class="memtitle"><span class="permalink"><a href="#gaf22bbcd02627f938be28fa4b1778e29c">◆ </a></span>jose_jwe_dec_cek_io()</h2>
- <div class="memitem">
- <div class="memproto">
- <table class="memname">
- <tr>
- <td class="memname"><a class="el" href="structjose__io__t.html">jose_io_t</a>* jose_jwe_dec_cek_io </td>
- <td>(</td>
- <td class="paramtype">jose_cfg_t * </td>
- <td class="paramname"><em>cfg</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>jwe</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype">const json_t * </td>
- <td class="paramname"><em>cek</em>, </td>
- </tr>
- <tr>
- <td class="paramkey"></td>
- <td></td>
- <td class="paramtype"><a class="el" href="structjose__io__t.html">jose_io_t</a> * </td>
- <td class="paramname"><em>next</em> </td>
- </tr>
- <tr>
- <td></td>
- <td>)</td>
- <td></td><td></td>
- </tr>
- </table>
- </div><div class="memdoc">
- <p>Decrypts ciphertext with the CEK using streaming. </p>
- <p>The ciphertext is provided through the returned IO object. The ciphertext will be decrypted and written to the <code>next</code> IO object. This IO object works on binary data, so you may need to use a URL-safe Base64 decoder on input and a URL-safe Base64 encoder on output, depending on your situation.</p>
- <p>Please note that validation of the ciphertext integrity protection is delayed until <a class="el" href="structjose__io__t.html#a76d1eac0d05d3604c16686b08bd80aa0">jose_io_t::done()</a> returns. This means it is incredibly important to check this return value and it is also important to be careful with the plaintext emitted until this check is performed.</p>
- <p>Compressed plaintext will be internally decompressed if the "zip" property is appropriately defined.</p>
- <p>If the "enc" parameter is not specified in the JWE Protected Header or the JWE Shared Unprotected Header, it will be inferred from the CEK.</p>
- <p>Please note that the "tag" property on the JWE will only be accessed when <a class="el" href="structjose__io__t.html#a76d1eac0d05d3604c16686b08bd80aa0">jose_io_t::done()</a> is called. So you may define it at any time on the JWE object before calling <a class="el" href="structjose__io__t.html#a76d1eac0d05d3604c16686b08bd80aa0">jose_io_t::done()</a>.</p>
- <dl class="params"><dt>Parameters</dt><dd>
- <table class="params">
- <tr><td class="paramname">cfg</td><td>The configuration context (optional). </td></tr>
- <tr><td class="paramname">jwe</td><td>The JWE object. </td></tr>
- <tr><td class="paramname">cek</td><td>The CEK object. </td></tr>
- <tr><td class="paramname">next</td><td>The next IO object in the chain. </td></tr>
- </table>
- </dd>
- </dl>
- <dl class="section return"><dt>Returns</dt><dd>The new IO object or NULL on error. </dd></dl>
- </div>
- </div>
- </div><!-- contents -->
- <!-- start footer part -->
- <hr class="footer"/><address class="footer"><small>
- Generated by  <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/>
- </a> 1.8.13
- </small></address>
- </body>
- </html>
|