1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Single-Block Symmetric Ciphers [CIPHER]</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="Development.html" title="Chapter 3. Developing Cipher Algorithms"><link rel="prev" href="Development.html" title="Chapter 3. Developing Cipher Algorithms"><link rel="next" href="ch03s03.html" title="Multi-Block Ciphers [BLKCIPHER] [ABLKCIPHER]"></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">Single-Block Symmetric Ciphers [CIPHER]</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="Development.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Developing Cipher Algorithms</th><td width="20%" align="right"> <a accesskey="n" href="ch03s03.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="idp1094346428"></a>Single-Block Symmetric Ciphers [CIPHER]</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="ch03s02.html#idp1094347492">Registration specifics</a></span></dt><dt><span class="sect2"><a href="ch03s02.html#idp1094348476">Cipher Definition With struct cipher_alg</a></span></dt></dl></div><p> 2 Example of transformations: aes, arc4, ... 3 </p><p> 4 This section describes the simplest of all transformation 5 implementations, that being the CIPHER type used for symmetric 6 ciphers. The CIPHER type is used for transformations which 7 operate on exactly one block at a time and there are no 8 dependencies between blocks at all. 9 </p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="idp1094347492"></a>Registration specifics</h3></div></div></div><p> 10 The registration of [CIPHER] algorithm is specific in that 11 struct crypto_alg field .cra_type is empty. The .cra_u.cipher 12 has to be filled in with proper callbacks to implement this 13 transformation. 14 </p><p> 15 See struct cipher_alg below. 16 </p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="idp1094348476"></a>Cipher Definition With struct cipher_alg</h3></div></div></div><p> 17 Struct cipher_alg defines a single block cipher. 18 </p><p> 19 Here are schematics of how these functions are called when 20 operated from other part of the kernel. Note that the 21 .cia_setkey() call might happen before or after any of these 22 schematics happen, but must not happen during any of these 23 are in-flight. 24 </p><p> 25 </p><pre class="programlisting"> 26 KEY ---. PLAINTEXT ---. 27 v v 28 .cia_setkey() -> .cia_encrypt() 29 | 30 '-----> CIPHERTEXT 31 </pre><p> 32 </p><p> 33 Please note that a pattern where .cia_setkey() is called 34 multiple times is also valid: 35 </p><p> 36 </p><pre class="programlisting"> 37 38 KEY1 --. PLAINTEXT1 --. KEY2 --. PLAINTEXT2 --. 39 v v v v 40 .cia_setkey() -> .cia_encrypt() -> .cia_setkey() -> .cia_encrypt() 41 | | 42 '---> CIPHERTEXT1 '---> CIPHERTEXT2 43 </pre><p> 44 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="Development.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="Development.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 3. Developing Cipher Algorithms </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Multi-Block Ciphers [BLKCIPHER] [ABLKCIPHER]</td></tr></table></div></body></html> 45