1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>struct crypto_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="ch05s02.html" title="Block Cipher Algorithm Definitions"><link rel="next" href="API-struct-ablkcipher-alg.html" title="struct ablkcipher_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 crypto_alg</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch05s02.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-ablkcipher-alg.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-crypto-alg"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct crypto_alg — 2 definition of a cryptograpic cipher algorithm 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting"> 4struct crypto_alg { 5 struct list_head cra_list; 6 struct list_head cra_users; 7 u32 cra_flags; 8 unsigned int cra_blocksize; 9 unsigned int cra_ctxsize; 10 unsigned int cra_alignmask; 11 int cra_priority; 12 atomic_t cra_refcnt; 13 char cra_name[CRYPTO_MAX_ALG_NAME]; 14 char cra_driver_name[CRYPTO_MAX_ALG_NAME]; 15 const struct crypto_type * cra_type; 16 union cra_u; 17 int (* cra_init) (struct crypto_tfm *tfm); 18 void (* cra_exit) (struct crypto_tfm *tfm); 19 void (* cra_destroy) (struct crypto_alg *alg); 20 struct module * cra_module; 21}; </pre></div><div class="refsect1"><a name="idp1097407420"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">cra_list</span></dt><dd><p> 22internally used 23 </p></dd><dt><span class="term">cra_users</span></dt><dd><p> 24internally used 25 </p></dd><dt><span class="term">cra_flags</span></dt><dd><p> 26Flags describing this transformation. See include/linux/crypto.h 27CRYPTO_ALG_* flags for the flags which go in here. Those are 28used for fine-tuning the description of the transformation 29algorithm. 30 </p></dd><dt><span class="term">cra_blocksize</span></dt><dd><p> 31Minimum block size of this transformation. The size in bytes 32of the smallest possible unit which can be transformed with 33this algorithm. The users must respect this value. 34In case of HASH transformation, it is possible for a smaller 35block than <em class="parameter"><code>cra_blocksize</code></em> to be passed to the crypto API for 36transformation, in case of any other transformation type, an 37error will be returned upon any attempt to transform smaller 38than <em class="parameter"><code>cra_blocksize</code></em> chunks. 39 </p></dd><dt><span class="term">cra_ctxsize</span></dt><dd><p> 40Size of the operational context of the transformation. This 41value informs the kernel crypto API about the memory size 42needed to be allocated for the transformation context. 43 </p></dd><dt><span class="term">cra_alignmask</span></dt><dd><p> 44Alignment mask for the input and output data buffer. The data 45buffer containing the input data for the algorithm must be 46aligned to this alignment mask. The data buffer for the 47output data must be aligned to this alignment mask. Note that 48the Crypto API will do the re-alignment in software, but 49only under special conditions and there is a performance hit. 50The re-alignment happens at these occasions for different 51 </p></dd><dt><span class="term">cra_priority</span></dt><dd><p> 52Priority of this transformation implementation. In case 53multiple transformations with same <em class="parameter"><code>cra_name</code></em> are available to 54the Crypto API, the kernel will use the one with highest 55<em class="parameter"><code>cra_priority</code></em>. 56 </p></dd><dt><span class="term">cra_refcnt</span></dt><dd><p> 57internally used 58 </p></dd><dt><span class="term">cra_name[CRYPTO_MAX_ALG_NAME]</span></dt><dd><p> 59Generic name (usable by multiple implementations) of the 60transformation algorithm. This is the name of the transformation 61itself. This field is used by the kernel when looking up the 62providers of particular transformation. 63 </p></dd><dt><span class="term">cra_driver_name[CRYPTO_MAX_ALG_NAME]</span></dt><dd><p> 64Unique name of the transformation provider. This is the 65name of the provider of the transformation. This can be any 66arbitrary value, but in the usual case, this contains the 67name of the chip or provider and the name of the 68transformation algorithm. 69 </p></dd><dt><span class="term">cra_type</span></dt><dd><p> 70Type of the cryptographic transformation. This is a pointer to 71struct crypto_type, which implements callbacks common for all 72trasnformation types. There are multiple options: 73<span class="structname">crypto_blkcipher_type</span>, <span class="structname">crypto_ablkcipher_type</span>, 74<span class="structname">crypto_ahash_type</span>, <span class="structname">crypto_aead_type</span>, <span class="structname">crypto_rng_type</span>. 75This field might be empty. In that case, there are no common 76callbacks. This is the case for: cipher, compress, shash. 77 </p></dd><dt><span class="term">cra_u</span></dt><dd><p> 78Callbacks implementing the transformation. This is a union of 79multiple structures. Depending on the type of transformation selected 80by <em class="parameter"><code>cra_type</code></em> and <em class="parameter"><code>cra_flags</code></em> above, the associated structure must be 81filled with callbacks. This field might be empty. This is the case 82for ahash, shash. 83 </p></dd><dt><span class="term">cra_init</span></dt><dd><p> 84Initialize the cryptographic transformation object. This function 85is used to initialize the cryptographic transformation object. 86This function is called only once at the instantiation time, right 87after the transformation context was allocated. In case the 88cryptographic hardware has some special requirements which need to 89be handled by software, this function shall check for the precise 90requirement of the transformation and put any software fallbacks 91in place. 92 </p></dd><dt><span class="term">cra_exit</span></dt><dd><p> 93Deinitialize the cryptographic transformation object. This is a 94counterpart to <em class="parameter"><code>cra_init</code></em>, used to remove various changes set in 95<em class="parameter"><code>cra_init</code></em>. 96 </p></dd><dt><span class="term">cra_destroy</span></dt><dd><p> 97internally used 98 </p></dd><dt><span class="term">cra_module</span></dt><dd><p> 99Owner of this transformation implementation. Set to THIS_MODULE 100 </p></dd></dl></div></div><div class="refsect1"><a name="idp1097425028"></a><h2>Description</h2><p> 101 The struct crypto_alg describes a generic Crypto API algorithm and is common 102 for all of the transformations. Any variable not documented here shall not 103 be used by a cipher implementation as it is internal to the Crypto API. 104</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch05s02.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-ablkcipher-alg.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Block Cipher Algorithm Definitions </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 ablkcipher_alg</span></td></tr></table></div></body></html> 105