1<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><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="re38.html" title="include/crypto/aead.h"></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="re38.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><a class="link" href="API-struct-aead-request.html" title="struct aead_request">struct aead_request</a> * <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="id-1.7.8.9.5"></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"><a class="link" href="API-crypto-aead-ivsize.html" title="crypto_aead_ivsize">crypto_aead_ivsize</a></code> 14 </p></dd></dl></div></div><div class="refsect1"><a name="id-1.7.8.9.6"></a><h2>Description</h2><p> 15 Setting the source data and destination data scatter / gather lists which 16 hold the associated data concatenated with the plaintext or ciphertext. See 17 below for the authentication tag. 18 </p><p> 19 20 For encryption, the source is treated as the plaintext and the 21 destination is the ciphertext. For a decryption operation, the use is 22 reversed - the source is the ciphertext and the destination is the plaintext. 23 </p><p> 24 25 For both src/dst the layout is associated data, plain/cipher text, 26 authentication tag. 27 </p><p> 28 29 The content of the AD in the destination buffer after processing 30 will either be untouched, or it will contain a copy of the AD 31 from the source buffer. In order to ensure that it always has 32 a copy of the AD, the user must copy the AD over either before 33 or after processing. Of course this is not relevant if the user 34 is doing in-place processing where src == dst. 35 </p><p> 36 37 IMPORTANT NOTE AEAD requires an authentication tag (MAC). For decryption, 38 the caller must concatenate the ciphertext followed by the 39 authentication tag and provide the entire data stream to the 40 decryption operation (i.e. the data length used for the 41 initialization of the scatterlist and the data length for the 42 decryption operation is identical). For encryption, however, 43 the authentication tag is created while encrypting the data. 44 The destination buffer must hold sufficient space for the 45 ciphertext and the authentication tag while the encryption 46 invocation must only point to the plaintext data size. The 47 following code snippet illustrates the memory usage 48 buffer = kmalloc(ptbuflen + (enc ? authsize : 0)); 49 sg_init_one(<span class="structname">sg</span>, buffer, ptbuflen + (enc ? authsize : 0)); 50 aead_request_set_crypt(req, <span class="structname">sg</span>, <span class="structname">sg</span>, ptbuflen, iv); 51</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="re38.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"> 52 include/crypto/aead.h 53 </td></tr></table></div></body></html> 54