diff --git a/tikz/CBC-Mode-Encryption/CBC-Mode-Encryption.png b/tikz/CBC-Mode-Encryption/CBC-Mode-Encryption.png new file mode 100644 index 0000000..5f8a827 Binary files /dev/null and b/tikz/CBC-Mode-Encryption/CBC-Mode-Encryption.png differ diff --git a/tikz/CBC-Mode-Encryption/CBC-Mode-Encryption.tex b/tikz/CBC-Mode-Encryption/CBC-Mode-Encryption.tex new file mode 100644 index 0000000..1aed374 --- /dev/null +++ b/tikz/CBC-Mode-Encryption/CBC-Mode-Encryption.tex @@ -0,0 +1,47 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} + +\usepackage{tikz} +\usetikzlibrary{calc} + +\begin{document} +\begin{preview} +% thanks to http://tex.stackexchange.com/a/75838/5645 +\tikzset{XOR/.style={fill=black!15,draw,minimum size=13pt,circle,append after command={ + [shorten >=\pgflinewidth, shorten <=\pgflinewidth,] + (\tikzlastnode.north) edge (\tikzlastnode.south) + (\tikzlastnode.east) edge (\tikzlastnode.west) + } + } +} + +\tikzstyle{encrypt}=[draw,fill=black!15,rectangle,minimum size=20pt,inner sep=0pt] +\begin{tikzpicture} + \newcommand{\n}{3} + \foreach \nr in {1, ..., \n}{ + \node (M\nr) at (0,{(\n-\nr)*2}) {$M_\nr$}; + \node (x\nr)[XOR] at (2,{(\n-\nr)*2}) {}; + \node (E\nr)[encrypt] at (4,{(\n-\nr)*2}) {$E$}; + \node (C\nr) at (6,{(\n-\nr)*2}) {$C_\nr$}; + + \node (K\nr) at (4,{(\n-\nr)*2+1}) {$K$}; + + \draw[->,very thick] (M\nr) -- (x\nr); + \draw[->,very thick] (x\nr) -- (E\nr); + \draw[->,very thick] (E\nr) -- (C\nr); + + \draw[->,very thick] (K\nr) -- (E\nr); + } + + \foreach \nr in {2, ..., \n}{ + \pgfmathtruncatemacro{\tmp}{\nr-1} + \draw[->,very thick] (E\tmp) -- (4, {(\n-\tmp)*2-0.5}) -- (2, {(\n-\nr)*2+1.5}) -- (x\nr); + } + + \node (Mx) at (0,-1) {$\vdots$}; + \node (xx) at (2,-1) {$\vdots$}; + \node (Ex) at (4,-1) {$\vdots$}; + \node (Cx) at (6,-1) {$\vdots$}; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/CBC-Mode-Encryption/Makefile b/tikz/CBC-Mode-Encryption/Makefile new file mode 100644 index 0000000..44ed561 --- /dev/null +++ b/tikz/CBC-Mode-Encryption/Makefile @@ -0,0 +1,35 @@ +SOURCE = CBC-Mode-Encryption +DELAY = 80 +DENSITY = 300 +WIDTH = 512 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + make + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg + rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg + inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg + rm $(SOURCE)2.svg diff --git a/tikz/CBC-Mode-Encryption/Readme.md b/tikz/CBC-Mode-Encryption/Readme.md new file mode 100644 index 0000000..5293ac3 --- /dev/null +++ b/tikz/CBC-Mode-Encryption/Readme.md @@ -0,0 +1,3 @@ +Compiled example +---------------- +![Example](CBC-Mode-Encryption.png)