1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Synchronous Block Cipher API</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="API.html" title="Chapter&#160;5.&#160;Programming Interface"><link rel="prev" href="API-aead-request-set-assoc.html" title="aead_request_set_assoc"><link rel="next" href="API-crypto-alloc-blkcipher.html" title="crypto_alloc_blkcipher"></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">Synchronous Block Cipher API</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-aead-request-set-assoc.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;5.&#160;Programming Interface</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-crypto-alloc-blkcipher.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="idp1097766292"></a>Synchronous Block Cipher API</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="refentrytitle"><a href="API-crypto-alloc-blkcipher.html"><span class="phrase">crypto_alloc_blkcipher</span></a></span><span class="refpurpose"> &#8212; 
2  allocate synchronous block cipher handle
3 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-free-blkcipher.html"><span class="phrase">crypto_free_blkcipher</span></a></span><span class="refpurpose"> &#8212; 
4  zeroize and free the block cipher handle
5 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-has-blkcipher.html"><span class="phrase">crypto_has_blkcipher</span></a></span><span class="refpurpose"> &#8212; 
6  Search for the availability of a block cipher
7 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-blkcipher-name.html"><span class="phrase">crypto_blkcipher_name</span></a></span><span class="refpurpose"> &#8212; 
8  return the name / cra_name from the cipher handle
9 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-blkcipher-ivsize.html"><span class="phrase">crypto_blkcipher_ivsize</span></a></span><span class="refpurpose"> &#8212; 
10  obtain IV size
11 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-blkcipher-blocksize.html"><span class="phrase">crypto_blkcipher_blocksize</span></a></span><span class="refpurpose"> &#8212; 
12  obtain block size of cipher
13 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-blkcipher-setkey.html"><span class="phrase">crypto_blkcipher_setkey</span></a></span><span class="refpurpose"> &#8212; 
14  set key for cipher
15 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-blkcipher-encrypt.html"><span class="phrase">crypto_blkcipher_encrypt</span></a></span><span class="refpurpose"> &#8212; 
16  encrypt plaintext
17 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-blkcipher-encrypt-iv.html"><span class="phrase">crypto_blkcipher_encrypt_iv</span></a></span><span class="refpurpose"> &#8212; 
18  encrypt plaintext with dedicated IV
19 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-blkcipher-decrypt.html"><span class="phrase">crypto_blkcipher_decrypt</span></a></span><span class="refpurpose"> &#8212; 
20  decrypt ciphertext
21 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-blkcipher-decrypt-iv.html"><span class="phrase">crypto_blkcipher_decrypt_iv</span></a></span><span class="refpurpose"> &#8212; 
22  decrypt ciphertext with dedicated IV
23 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-blkcipher-set-iv.html"><span class="phrase">crypto_blkcipher_set_iv</span></a></span><span class="refpurpose"> &#8212; 
24  set IV for cipher
25 </span></dt><dt><span class="refentrytitle"><a href="API-crypto-blkcipher-get-iv.html"><span class="phrase">crypto_blkcipher_get_iv</span></a></span><span class="refpurpose"> &#8212; 
26  obtain IV from cipher
27 </span></dt></dl></div><p>
28   </p><p>
29   The synchronous block cipher API is used with the ciphers of type
30   CRYPTO_ALG_TYPE_BLKCIPHER (listed as type <span class="quote">&#8220;<span class="quote">blkcipher</span>&#8221;</span> in /proc/crypto)
31   </p><p>
32   Synchronous calls, have a context in the tfm. But since a single tfm can be
33   used in multiple calls and in parallel, this info should not be changeable
34   (unless a lock is used). This applies, for example, to the symmetric key.
35   However, the IV is changeable, so there is an iv field in blkcipher_tfm
36   structure for synchronous blkcipher api. So, its the only state info that can
37   be kept for synchronous calls without using a big lock across a tfm.
38   </p><p>
39   The block cipher API allows the use of a complete cipher, i.e. a cipher
40   consisting of a template (a block chaining mode) and a single block cipher
41   primitive (e.g. AES).
42   </p><p>
43   The plaintext data buffer and the ciphertext data buffer are pointed to
44   by using scatter/gather lists. The cipher operation is performed
45   on all segments of the provided scatter/gather lists.
46   </p><p>
47   The kernel crypto API supports a cipher operation <span class="quote">&#8220;<span class="quote">in-place</span>&#8221;</span> which means that
48   the caller may provide the same scatter/gather list for the plaintext and
49   cipher text. After the completion of the cipher operation, the plaintext
50   data is replaced with the ciphertext data in case of an encryption and vice
51   versa for a decryption. The caller must ensure that the scatter/gather lists
52   for the output data point to sufficiently large buffers, i.e. multiples of
53   the block size of the cipher.
54</p></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-assoc.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="API.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-crypto-alloc-blkcipher.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">aead_request_set_assoc</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">crypto_alloc_blkcipher</span></td></tr></table></div></body></html>
55