Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132928 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
TODO
21
\newcommand{\n}{3}
22
\foreach \nr in {1, ..., \n}{
23
\node (C\nr) at (0,{(\n-\nr)*3}) {$C_\nr$};
24
\node (x\nr)[XOR] at (2,{(\n-\nr)*3}) {};
25
\node (D\nr)[encrypt] at (2,{(\n-\nr)*3+1}) {$E$};
26
\node (K\nr) at (2,{(\n-\nr)*3+2}) {$K$};
27
\node (M\nr) at (4,{(\n-\nr)*3}) {$M_\nr$};
28
29
\draw[->,very thick] (C\nr) -- (x\nr);
30
\draw[->,very thick] (x\nr) -- (M\nr);
31
\draw[->,very thick] (K\nr) -- (D\nr);
32
\draw[->,very thick] (D\nr) -- (x\nr);
33
}
34
35
\foreach \nr in {2, ..., \n}{
36
\pgfmathtruncatemacro{\tmp}{\nr-1}
37
\draw[->,very thick] (1, {(\n-\tmp)*3}) -- (1, {(\n-\nr)*3+1}) -- (D\nr);
38
}
39
40
\node (IV) at (0.5,{\n*3-2}) {$IV$};
41
\draw[->, very thick] (IV) -- (D1);
42
43
\node (Mx) at (0,-1) {$\vdots$};
44
\node (xx) at (2,-1) {$\vdots$};
45
\node (Ex) at (4,-1) {$\vdots$};
46
\end{tikzpicture}
47
\end{preview}
48
\end{document}
49
50