OFB-Mode-Decryption.tex 1.5 KB

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