summaryrefslogtreecommitdiff
path: root/doc/context/third/enigma/enigma_manual.tex
blob: d136dc1e17c0f72ea032c29e8244146881b3fca7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
\startdocchapter[title=Usage]

\startdocsection[title=Loading the Module/Package]
  \TODO{instuctions for plain, latex + ctx}
\stopdocsection

\startdocsection[title=Basic Functionality]

Encrypt the text of your document using the script interface. For
a start try out the settings as given in below listing.

\starttyping
mtxrun --script mtx-t-enigma                    \
       --setup="other_chars = ok,               \
                day_key = B I II III 01 01 01,  \
                rotor_setting = xyz,            \
                verbose=0"                      \
       --text="Gentlemen don’t read each other’s mail, Mr. Turing\!"
\stoptyping

This will result in the thoroughly scrambled string
\type{omribshpwfrfjovkntgqgiabbkhjpxmhdztapkatwrvf}.
Then, use the same settings you encrypted the text with in your
document.

\startcontexttyping
\usemodule[enigma]
\defineenigma [secretmessage]
\setupenigma  [secretmessage] [
  other_chars = ok,
  day_key = B I II III 01 01 01,
  rotor_setting = xyz,
  verbose=3,
]

\starttext

\startsecretmessage
  omribshpwfrfjovkntgqgiabbkhjpxmhdztapkatwrvf
\stopsecretmessage

\stoptext
\stopcontexttyping

If you compile this document with \CONTEXT, the plain text will
reappear.
Notice that punctuation is substituted with the letter “x” before
encryption and that spaces are omitted.

\stopdocsection

\startdocsection[title=Uses and Abuses]

In \LUATEX, \identifier{callback}s may stack. This allows filtering the
input through many enigma machines successively. For instance, in the
following listing, two instances of the same machine are generated and
applied.

\startcontexttyping
\usemodule[enigma]              %% load the module
\defineenigma [secretmessage]   %% generate and
\setupenigma  [secretmessage] [ %% configure a machine
  other_chars = ok,
  day_key = B IV V II 01 01 01 AD CN ET FL GI JV KZ PU QY WX,
  rotor_setting = foo,
  verbose=3,
]

%% now, copy the first machine’s settings
\defineenigma [othermessage] [secretmessage]

%% here we go!
\starttext

\startothermessage  %% enable machine 1
\startsecretmessage %% enable machine 2 while no 1 is active
Encryption equals decryption.
\stopothermessage
\stopsecretmessage

\stoptext \endinput
\stopcontexttyping

\useURL[kgbuch] [http://de.wikipedia.org/wiki/Kenngruppenbuch]
       []       [code book]
Now it’s certainly not wise to carry around the key to encrypted
documents as plain text within those documents. The keys will have to be
distributed via an independent channel, e.\,g. a \from[kgbuch].
Keys in general don’t have to be supplied inside the document. If there
is none specified, the module will interrupt the \TEX\ run and
\emph{ask} for user input. Suppose Alice wanted to send an encrypted
file to Bob and already generated the cipher text as follows:

\starttyping
mtxrun --script mtx-t-enigma                                    \
        --setup="day_key =B I IV V 22 07 10 AZ DG IE YJ QM CW,  \
                 rotor_setting = bar,                           \
                 verbose=0"                                     \
        --text="I have nothing to hide. From the NSA, that is."
\stoptyping

Alice would then include the result of this line in her \LATEX\ document
as follows:

\startlatextyping
\documentclass{scrartcl}
\usepackage{enigma}
\defineenigma{decryption}
%% Encryption key not given in the setup.
\setupenigma{decryption}{
  rotor_setting = bar,
  verbose       = 3,
}
\begin{document}

\startdecryption
usbatbwcaajhzgeyzkqskupzbmdhbdepccgeh
\stopdecryption

\end{document}
\stoplatextyping

She subsequently mails this file to Bob and conveys the key through a
secure channel. They only thing that will be left for Bob to do now, is
to enter the key at the prompt when compiling the document with
\LUALATEX.

\stopdocsection

\stopdocchapter

\startdocchapter[title=Acknowledgements]
The Enigma module was inspired by Arno Trautmann’s
\identifier{chickenize} package.
Without \LUATEX, encryption on node-level would not have been possible.
\stopdocchapter