This file is indexed.

/usr/share/doc/axiom-doc/hypertex/cryptoclass4.xhtml is in axiom-hypertex-data 20120501-8.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xmlns:m="http://www.w3.org/1998/Math/MathML">
 <head>
  <meta http-equiv="Content-Type" content="text/html" charset="us-ascii"/>
  <title>Axiom Documentation</title>
  <style>

   html {
     background-color: #ECEA81;
   }

   body { 
     margin: 0px;
     padding: 0px;
   }

   div.command { 
     color:red;
   }

   div.center {
     color:blue;
   }

   div.reset {
     visibility:hidden;
   }

   div.mathml { 
     color:blue;
   }

   input.subbut {
     background-color:#ECEA81;
     border: 0;
     color:green;
     font-family: "Courier New", Courier, monospace;
   }

   input.noresult {
     background-color:#ECEA81;
     border: 0;
     color:black;
     font-family: "Courier New", Courier, monospace;
   }

   span.cmd { 
     color:green;
     font-family: "Courier New", Courier, monospace;
   }

   pre {
     font-family: "Courier New", Courier, monospace;
   }
  </style>
 </head>
 <body>
  <div align="center"><img align="middle" src="doctitle.png"/></div>
  <hr/>
<center>
 <h2>RCM3720 Cryptography, Network and Computer Security</h2>
 <h3>Laboratory Class 4: Simple Cryptosystems</h3>
</center>
<hr/>

We have experimented with the Caesar cipher and the more general
translation cipher.  We shall start looking at the Vigen&#x0E8;re cipher.
The trick is to add the correct letter of the code to the letter of
the key:
<pre>
 Index of plain text i: 1  2  3  4  5  6  7  8
             Plaintext: W  I  T  H  D  R  A  W
                   Key: C  O  D  E  C  O  D  E
        Index of key j: 1  2  3  4  1  2  3  4
</pre>

The indices of the key repeat 1, 2, 3, 4.  We can get a repetition of
length four by using a modulus of 4:
<pre>
                     i: 1  2  3  4  5  6  7  8
             i (mod 4): 1  2  3  0  1  2  3  0
</pre>

What we need to do is to subtract one before the modulus, and add one after:
<pre>
                     i: 1  2  3  4  5  6  7  8
                   i-1: 0  1  2  3  4  5  6  7
           i-1 (mod 4): 0  1  2  3  0  1  2  3
       i-1 (mod 4) + 1: 1  2  3  4  1  2  3  4
</pre>

This means that in the Vigen&#x0E8;re cipher, we add the <i>i</i>-th
character of the plaintext, and the <i>j</i>-th character of the key, where
<pre>
   j=i-1 (mod n) + 1
</pre>
with <i>n</i> being the length of the key.

<ul>

 <li> First read in the <tt>rcm3720.input</tt> file you have created:
  <ul>
   <li> <span class="cmd">)read rcm3720</span></li>
  </ul>

  You may have to include the full path here.
 </li>
 <li> Enter a plaintext
  <ul>
   <li> <span class="cmd">plaintext:="WITHDRAWONEHUNDREDDOLLARS"</span></li>
  </ul>
 </li>
 <li> and a keyword:
  <ul>
   <li> <span class="cmd">key := "CODE"</span></li>
  </ul>
 </li>
 <li> Now we can obtain the lengths of the plaintext and key with the hash
      symbol:
  <ul>
   <li> <span class="cmd">pn:=#plaintext</span></li>
   <li> <span class="cmd">kn:=#key</span></li>
  </ul>
 </li>
 <li> Turn both plaintext and key into lists of numbers:
  <ul>
   <li> <span class="cmd">pl:=str2lst(plaintext)</span></li>
   <li> <span class="cmd">kl:=str2lst(key)</span></li>
  </ul>
 </li>  
 <li> Now we can add them using the formula for <tt>j</tt> above to obtain 
      the list corresponding to the ciphertext:
  <ul>
   <li> 
    <span class="cmd">
     cl:=[(pl.i+kl.((i-1) rem kn+1))::ZMOD 26 for i in 1..pn]
    </span>
   </li>
  </ul>
 </li>
 <li> And obtain the ciphertext (we need to convert our list to a list of
      integers first):
  <ul>
   <li> <span class="cmd">ciphertext:=lst2str(cl::List INT)</span></li>
  </ul>
 </li>
 <li> Try a few other Vigen&#x0E8;re encryptions.</li>
  
 <li> To decrypt, we just <i>subtract</i> the key value from the ciphertext
  value:
  <ul>
   <li> 
    <span class="cmd">
     pl:=[(cl.i+kl.((i-1) rem kn+1))::ZMOD 26 for i in 1..pn]
    </span>
    </li>
   <li> <span class="cmd">lst2str(pl::List INT)</span></li>
  </ul>
 </li>  
 <li> Now for the Hill (matrix) cipher.  We shall use <tt>3 x 3</tt>
  matrices, so first create a plaintext whose length is a multiple of 3:
  <ul>
   <li> <span class="cmd">plaintext:="WITHDRAWONEHUNDREDDOLLARSXX"</span></li>
   <li> <span class="cmd">pl:=str2lst(plaintext)</span></li>
   <li> <span class="cmd">r:=3</span></li>
   <li> <span class="cmd">c:INT:=#pl/r</span></li>
  </ul>
 </li>
 <li> The values <tt>r</tt> and <tt>c</tt> are the row and column numbers 
      of the plaintext matrix.
 </li>  
 <li> Now put all the plaintext values into a <tt>r x c</tt> matrix:
  <ul>
   <li> 
    <span class="cmd">
     S:=matrix([[pl.(r*(i-1)+j) for i in 1..c] for j in 1..r])
    </span>
   </li>
  </ul>
 </li>
 <li> Create the key matrix:
  <ul>
   <li> 
    <span class="cmd">
     M:Matrix ZMOD 26:=matrix([[22,11,19],[15,20,24],[25,21,16]])
    </span>
   </li>
  </ul>
 </li>  
 <li> Multiply the two matrices:
  <ul>
   <li> <span class="cmd">C:=M*S</span></li>
  </ul>
 </li>
 <li> Notice how the results are automatically reduced modulo 26,
      because that is how the matrix <tt>M</tt> was defined.
 </li> 
 <li> Now we have to read off the elements of <tt>C</tt> into a single list;
  this can be done by transposing the matrix, and reading off the rows as
  lists:
  <ul>
   <li> 
    <span class="cmd">
     CL:=concat(transpose(C)::List List ZMOD 26)
    </span>
   </li>
  </ul>
 </li>
 <li> And finally turn into ciphertext:
  <ul>
   <li> <span class="cmd">lst2str(CL::List INT)</span></li>
  </ul>
 </li>
 <li> Finally, here's how we can invert our matrix <tt>M</tt> modulo 26:
  <ul>
   <li> <span class="cmd">adj:=adjoint(M).adjMat</span></li>
   <li> <span class="cmd">invdet:=recip(determinant(M))</span></li>
   <li> <span class="cmd">MI:=invdet*adj</span></li>
  </ul>
 </li>
 <li> Or alternatively, as one command:
  <ul>
   <li> 
    <span class="cmd">
     MI:=recip(determinant(M))*adjoint(M).adjMat
    </span>
   </li>
  </ul>
 </li>
 <li> Check the result:
  <ul>
   <li> <span class="cmd">M*MI</span></li>
  </ul>
 </li>
</ul>
 </body>
</html>