1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>struct ahash_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="ch05s10.html" title="Message Digest Algorithm Definitions"><link rel="prev" href="API-struct-hash-alg-common.html" title="struct hash_alg_common"><link rel="next" href="API-struct-shash-alg.html" title="struct shash_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 ahash_alg</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-struct-hash-alg-common.html">Prev</a> </td><th width="60%" align="center">Message Digest Algorithm Definitions</th><td width="20%" align="right"> <a accesskey="n" href="API-struct-shash-alg.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-ahash-alg"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct ahash_alg — 2 asynchronous message digest definition 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting"> 4struct ahash_alg { 5 int (* init) (struct ahash_request *req); 6 int (* update) (struct ahash_request *req); 7 int (* final) (struct ahash_request *req); 8 int (* finup) (struct ahash_request *req); 9 int (* digest) (struct ahash_request *req); 10 int (* export) (struct ahash_request *req, void *out); 11 int (* import) (struct ahash_request *req, const void *in); 12 int (* setkey) (struct crypto_ahash *tfm, const u8 *key,unsigned int keylen); 13 struct hash_alg_common halg; 14}; </pre></div><div class="refsect1"><a name="idp1098064228"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">init</span></dt><dd><p> 15Initialize the transformation context. Intended only to initialize the 16state of the HASH transformation at the begining. This shall fill in 17the internal structures used during the entire duration of the whole 18transformation. No data processing happens at this point. 19 </p></dd><dt><span class="term">update</span></dt><dd><p> 20Push a chunk of data into the driver for transformation. This 21function actually pushes blocks of data from upper layers into the 22driver, which then passes those to the hardware as seen fit. This 23function must not finalize the HASH transformation by calculating the 24final message digest as this only adds more data into the 25transformation. This function shall not modify the transformation 26context, as this function may be called in parallel with the same 27transformation object. Data processing can happen synchronously 28[SHASH] or asynchronously [AHASH] at this point. 29 </p></dd><dt><span class="term">final</span></dt><dd><p> 30Retrieve result from the driver. This function finalizes the 31transformation and retrieves the resulting hash from the driver and 32pushes it back to upper layers. No data processing happens at this 33point. 34 </p></dd><dt><span class="term">finup</span></dt><dd><p> 35Combination of <em class="parameter"><code>update</code></em> and <em class="parameter"><code>final</code></em>. This function is effectively a 36combination of <em class="parameter"><code>update</code></em> and <em class="parameter"><code>final</code></em> calls issued in sequence. As some 37hardware cannot do <em class="parameter"><code>update</code></em> and <em class="parameter"><code>final</code></em> separately, this callback was 38added to allow such hardware to be used at least by IPsec. Data 39processing can happen synchronously [SHASH] or asynchronously [AHASH] 40at this point. 41 </p></dd><dt><span class="term">digest</span></dt><dd><p> 42Combination of <em class="parameter"><code>init</code></em> and <em class="parameter"><code>update</code></em> and <em class="parameter"><code>final</code></em>. This function 43effectively behaves as the entire chain of operations, <em class="parameter"><code>init</code></em>, 44<em class="parameter"><code>update</code></em> and <em class="parameter"><code>final</code></em> issued in sequence. Just like <em class="parameter"><code>finup</code></em>, this was 45added for hardware which cannot do even the <em class="parameter"><code>finup</code></em>, but can only do 46the whole transformation in one run. Data processing can happen 47synchronously [SHASH] or asynchronously [AHASH] at this point. 48 </p></dd><dt><span class="term">export</span></dt><dd><p> 49Export partial state of the transformation. This function dumps the 50entire state of the ongoing transformation into a provided block of 51data so it can be <em class="parameter"><code>import</code></em> 'ed back later on. This is useful in case 52you want to save partial result of the transformation after 53processing certain amount of data and reload this partial result 54multiple times later on for multiple re-use. No data processing 55happens at this point. 56 </p></dd><dt><span class="term">import</span></dt><dd><p> 57Import partial state of the transformation. This function loads the 58entire state of the ongoing transformation from a provided block of 59data so the transformation can continue from this point onward. No 60data processing happens at this point. 61 </p></dd><dt><span class="term">setkey</span></dt><dd><p> 62Set optional key used by the hashing algorithm. Intended to push 63optional key used by the hashing algorithm from upper layers into 64the driver. This function can store the key in the transformation 65context or can outright program it into the hardware. In the former 66case, one must be careful to program the key into the hardware at 67appropriate time and one must be careful that .<code class="function">setkey</code> can be 68called multiple times during the existence of the transformation 69object. Not all hashing algorithms do implement this function as it 70is only needed for keyed message digests. SHAx/MDx/CRCx do NOT 71implement this function. HMAC(MDx)/HMAC(SHAx)/CMAC(AES) do implement 72this function. This function must be called before any other of the 73<em class="parameter"><code>init</code></em>, <em class="parameter"><code>update</code></em>, <em class="parameter"><code>final</code></em>, <em class="parameter"><code>finup</code></em>, <em class="parameter"><code>digest</code></em> is called. No data 74processing happens at this point. 75 </p></dd><dt><span class="term">halg</span></dt><dd><p> 76see struct hash_alg_common 77 </p></dd></dl></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-struct-hash-alg-common.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch05s10.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-struct-shash-alg.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">struct hash_alg_common</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 shash_alg</span></td></tr></table></div></body></html> 78