1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>aead_request_set_crypt</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Kernel Crypto API"><link rel="up" href="ch05s06.html" title="Asynchronous AEAD Request Handle"><link rel="prev" href="API-aead-request-set-callback.html" title="aead_request_set_callback"><link rel="next" href="API-aead-request-set-assoc.html" title="aead_request_set_assoc"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">aead_request_set_crypt</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-aead-request-set-callback.html">Prev</a> </td><th width="60%" align="center">Asynchronous AEAD Request Handle</th><td width="20%" align="right"> <a accesskey="n" href="API-aead-request-set-assoc.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-aead-request-set-crypt"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>aead_request_set_crypt — 2 set data buffers 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">aead_request_set_crypt </b>(</code></td><td>struct aead_request * <var class="pdparam">req</var>, </td></tr><tr><td> </td><td>struct scatterlist * <var class="pdparam">src</var>, </td></tr><tr><td> </td><td>struct scatterlist * <var class="pdparam">dst</var>, </td></tr><tr><td> </td><td>unsigned int <var class="pdparam">cryptlen</var>, </td></tr><tr><td> </td><td>u8 * <var class="pdparam">iv</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1097747620"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>req</code></em></span></dt><dd><p> 4 request handle 5 </p></dd><dt><span class="term"><em class="parameter"><code>src</code></em></span></dt><dd><p> 6 source scatter / gather list 7 </p></dd><dt><span class="term"><em class="parameter"><code>dst</code></em></span></dt><dd><p> 8 destination scatter / gather list 9 </p></dd><dt><span class="term"><em class="parameter"><code>cryptlen</code></em></span></dt><dd><p> 10 number of bytes to process from <em class="parameter"><code>src</code></em> 11 </p></dd><dt><span class="term"><em class="parameter"><code>iv</code></em></span></dt><dd><p> 12 IV for the cipher operation which must comply with the IV size defined 13 by <code class="function">crypto_aead_ivsize</code> 14 </p></dd></dl></div></div><div class="refsect1"><a name="idp1097753828"></a><h2>Description</h2><p> 15 Setting the source data and destination data scatter / gather lists. 16 </p><p> 17 18 For encryption, the source is treated as the plaintext and the 19 destination is the ciphertext. For a decryption operation, the use is 20 reversed - the source is the ciphertext and the destination is the plaintext. 21 </p><p> 22 23 IMPORTANT NOTE AEAD requires an authentication tag (MAC). For decryption, 24 the caller must concatenate the ciphertext followed by the 25 authentication tag and provide the entire data stream to the 26 decryption operation (i.e. the data length used for the 27 initialization of the scatterlist and the data length for the 28 decryption operation is identical). For encryption, however, 29 the authentication tag is created while encrypting the data. 30 The destination buffer must hold sufficient space for the 31 ciphertext and the authentication tag while the encryption 32 invocation must only point to the plaintext data size. The 33 following code snippet illustrates the memory usage 34 buffer = kmalloc(ptbuflen + (enc ? authsize : 0)); 35 sg_init_one(<span class="structname">sg</span>, buffer, ptbuflen + (enc ? authsize : 0)); 36 aead_request_set_crypt(req, <span class="structname">sg</span>, <span class="structname">sg</span>, ptbuflen, iv); 37</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-aead-request-set-callback.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch05s06.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-aead-request-set-assoc.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">aead_request_set_callback</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">aead_request_set_assoc</span></td></tr></table></div></body></html> 38