Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132930 views
License: OTHER
1
\documentclass{article}
2
\usepackage[pdftex,active,tightpage]{preview}
3
4
\usepackage{tikz}
5
\usetikzlibrary{calc}
6
7
\begin{document}
8
\begin{preview}
9
% thanks to http://tex.stackexchange.com/a/75838/5645
10
\tikzset{XOR/.style={fill=black!15,draw,minimum size=13pt,circle,append after command={
11
[shorten >=\pgflinewidth, shorten <=\pgflinewidth,]
12
(\tikzlastnode.north) edge (\tikzlastnode.south)
13
(\tikzlastnode.east) edge (\tikzlastnode.west)
14
}
15
}
16
}
17
18
\tikzstyle{encrypt}=[draw,fill=black!15,rectangle,minimum size=20pt,inner sep=0pt]
19
\begin{tikzpicture}
20
\newcommand{\n}{3}
21
\foreach \nr in {1, ..., \n}{
22
\node (M\nr) at (0,{(\n-\nr)*2}) {$M_\nr$};
23
\node (x\nr)[XOR] at (2,{(\n-\nr)*2}) {};
24
\node (E\nr)[encrypt] at (4,{(\n-\nr)*2}) {$E$};
25
\node (C\nr) at (6,{(\n-\nr)*2}) {$C_\nr$};
26
27
\node (K\nr) at (4,{(\n-\nr)*2+1}) {$K$};
28
29
\draw[->,very thick] (M\nr) -- (x\nr);
30
\draw[->,very thick] (x\nr) -- (E\nr);
31
\draw[->,very thick] (E\nr) -- (C\nr);
32
33
\draw[->,very thick] (K\nr) -- (E\nr);
34
}
35
36
\foreach \nr in {2, ..., \n}{
37
\pgfmathtruncatemacro{\tmp}{\nr-1}
38
\draw[->,very thick] (E\tmp) -- (4, {(\n-\tmp)*2-0.5}) -- (2, {(\n-\nr)*2+1.5}) -- (x\nr);
39
}
40
41
\node (IV) at (2,{\n*2-1}) {$IV$};
42
\draw[->, very thick] (IV) -- (x1);
43
44
\node (Mx) at (0,-1) {$\vdots$};
45
\node (xx) at (2,-1) {$\vdots$};
46
\node (Ex) at (4,-1) {$\vdots$};
47
\node (Cx) at (6,-1) {$\vdots$};
48
\end{tikzpicture}
49
\end{preview}
50
\end{document}
51
52