1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>struct cipher_alg</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="ch05s02.html" title="Block Cipher Algorithm Definitions"><link rel="prev" href="API-struct-blkcipher-alg.html" title="struct blkcipher_alg"><link rel="next" href="API-struct-rng-alg.html" title="struct rng_alg"></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">struct cipher_alg</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-struct-blkcipher-alg.html">Prev</a> </td><th width="60%" align="center">Block Cipher Algorithm Definitions</th><td width="20%" align="right"> <a accesskey="n" href="API-struct-rng-alg.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-cipher-alg"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct cipher_alg — 2 single-block symmetric ciphers definition 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting"> 4struct cipher_alg { 5 unsigned int cia_min_keysize; 6 unsigned int cia_max_keysize; 7 int (* cia_setkey) (struct crypto_tfm *tfm, const u8 *key,unsigned int keylen); 8 void (* cia_encrypt) (struct crypto_tfm *tfm, u8 *dst, const u8 *src); 9 void (* cia_decrypt) (struct crypto_tfm *tfm, u8 *dst, const u8 *src); 10}; </pre></div><div class="refsect1"><a name="idp1097470340"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">cia_min_keysize</span></dt><dd><p> 11Minimum key size supported by the transformation. This is 12the smallest key length supported by this transformation 13algorithm. This must be set to one of the pre-defined 14values as this is not hardware specific. Possible values 15for this field can be found via git grep <span class="quote">“<span class="quote">_MIN_KEY_SIZE</span>”</span> 16include/crypto/ 17 </p></dd><dt><span class="term">cia_max_keysize</span></dt><dd><p> 18Maximum key size supported by the transformation. This is 19the largest key length supported by this transformation 20algorithm. This must be set to one of the pre-defined values 21as this is not hardware specific. Possible values for this 22field can be found via git grep <span class="quote">“<span class="quote">_MAX_KEY_SIZE</span>”</span> 23include/crypto/ 24 </p></dd><dt><span class="term">cia_setkey</span></dt><dd><p> 25Set key for the transformation. This function is used to either 26program a supplied key into the hardware or store the key in the 27transformation context for programming it later. Note that this 28function does modify the transformation context. This function 29can be called multiple times during the existence of the 30transformation object, so one must make sure the key is properly 31reprogrammed into the hardware. This function is also 32responsible for checking the key length for validity. 33 </p></dd><dt><span class="term">cia_encrypt</span></dt><dd><p> 34Encrypt a single block. This function is used to encrypt a 35single block of data, which must be <em class="parameter"><code>cra_blocksize</code></em> big. This 36always operates on a full <em class="parameter"><code>cra_blocksize</code></em> and it is not possible 37to encrypt a block of smaller size. The supplied buffers must 38therefore also be at least of <em class="parameter"><code>cra_blocksize</code></em> size. Both the 39input and output buffers are always aligned to <em class="parameter"><code>cra_alignmask</code></em>. 40In case either of the input or output buffer supplied by user 41of the crypto API is not aligned to <em class="parameter"><code>cra_alignmask</code></em>, the crypto 42API will re-align the buffers. The re-alignment means that a 43new buffer will be allocated, the data will be copied into the 44new buffer, then the processing will happen on the new buffer, 45then the data will be copied back into the original buffer and 46finally the new buffer will be freed. In case a software 47fallback was put in place in the <em class="parameter"><code>cra_init</code></em> call, this function 48might need to use the fallback if the algorithm doesn't support 49all of the key sizes. In case the key was stored in 50transformation context, the key might need to be re-programmed 51into the hardware in this function. This function shall not 52modify the transformation context, as this function may be 53called in parallel with the same transformation object. 54 </p></dd><dt><span class="term">cia_decrypt</span></dt><dd><p> 55Decrypt a single block. This is a reverse counterpart to 56<em class="parameter"><code>cia_encrypt</code></em>, and the conditions are exactly the same. 57 </p></dd></dl></div></div><div class="refsect1"><a name="idp1097479076"></a><h2>Description</h2><p> 58 All fields are mandatory and must be filled. 59</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-struct-blkcipher-alg.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch05s02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-struct-rng-alg.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">struct blkcipher_alg</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">struct rng_alg</span></td></tr></table></div></body></html> 60