This file is indexed.

/usr/share/doc/axiom-doc/hypertex/cryptoclass8.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?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 8: Modes of Encryption</h3>
</center>
<hr/>

We will investigate the different modes of encryption using the Hill
(matrix) cryptosystem.  Start off by entering some matrices:
  <ul>
   <li> 
    <span class="cmd">
     M:=matrix([[15,9,21],[2,10,7],[16,11,12]])::Matrix ZMOD 26
    </span>
   </li>
   <li> 
    <span class="cmd">
     MI:=matrix([[7,17,19],[24,0,23],[12,25,10]])::Matrix ZMOD 26
    </span>
   </li>
  </ul>

Check that you've entered everything correctly with
  <ul>
   <li> <span class="cmd">M*MI</span></li>
  </ul>

Note that because the matrices were defined in terms of numbers mod 26,
their product is automatically reduced mod 26.

Now enter the following column vector:
  <ul>
   <li> 
    <span class="cmd">
     zero31:=matrix([[0],[0],[0]])::Matrix ZMOD 26
    </span>
   </li>
  </ul>
 
For this lab, rather than fiddling about with translations between 
letters and numbers, all our work will be done with numbers alone 
(in the range 0..25).

<br/><br/>
<b>ECB</b>
<br/><br/>
For electronic codebook mode, encryption is performed by multiplying each
plaintext block by the matrix, and decryption by multiplying each ciphertext
block by the inverse matrix:
<pre>
                  -1
    C =M.P ,  P =M  C
     i    i    i     i
</pre>
where all arithmetic is performed mod 26.

<ul>
 <li> Start by entering a plaintext, which will be a list of column vectors:
  <ul>
   <li> 
    <span class="cmd">
     P:=[matrix([[3*i],[3*i+1],[3*i+2]]) for i in 0..7]
    </span>
   </li>
  </ul>
 </li>
 <li> and a list which will receive the ciphertext:
  <ul>
   <li> <span class="cmd">C:=[zero31 for i in 1..8]</span></li>
  </ul>
 </li>
 <li> and encrypt it: 
  <ul>
   <li> <span class="cmd">for i in 1..8 repeat C.i:=M*P.i</span></li>
  </ul>
 </li>
 <li> Now decrypt (first make an empty list <tt>D</tt>):
  <ul>
   <li> <span class="cmd">D:=[zero31 for i in 1..8]</span></li>
   <li> <span class="cmd">for i in 1..8 repeat D.i:=MI*C.i</span></li>
  </ul>
 </li>
 <li> If all has worked out, the list <tt>D</tt> should be the same 
      plaintext you obtained earlier.
 </li>
 <li> Now change one value in the plaintext:
  <ul>
   <li> <span class="cmd">Q:=P</span></li>
   <li> <span class="cmd">Q.3:=matrix([[6],[19],[8]])</span></li>
  </ul>
 </li>
 <li> Now encrypt the new plaintext <tt>Q</tt> to a ciphertext <tt>E</tt>. How
  does this ciphertext differ from the ciphertext <tt>C</tt> obtained from
  <tt>P</tt>?
 </li>
 <li> Check that you can decrypt <tt>E</tt> to obtain <tt>Q</tt>.</li>
</ul>
<br/><br/>
<b>CBC</b>
<br/><br/>
For cipherblock chaining mode, the encryption formula for the Hill
cryptosystem is
<pre>
   C =M(P +C   )
    i    i  i-1
</pre>
and decryption is
<pre>
       -1
   P =M  C -C
    i     i  i-1
</pre>

<ul>
 <li> To enable us to use these formulas, we shall first add an extra column
  to the front of <tt>P</tt> and <tt>C</tt>:
  <ul>
   <li> <span class="cmd">P:=append([zero31],P)</span></li>
   <li> <span class="cmd">C:=append([zero31],C)</span></li>
  </ul>
 </li>
 <li> And we need to create a initialization vector:
  <ul>
   <li> <span class="cmd">IV:=matrix([[random(26)] for i in 1..3])</span></li>
  </ul>
 </li>
 <li> Now for encryption:
  <ul>
   <li> <span class="cmd">C.1:=IV</span></li>
   <li> 
    <span class="cmd">
     for i in 2..9 repeat C.i:=M*(P.i+C.(i-1))
    </span>
   </li>
  </ul>
 </li>
 <li> Let's try to decrypt the ciphertext, using the CBC formula:
  <ul>
   <li> <span class="cmd">D:=[zero31 for i in 1..9]</span></li>
   <li>
    <span class="cmd">
     for i in 2..9 repeat D.i:=MI*(C.i)-C.(i-1)
    </span>
   </li>
  </ul>
 </li>
 <li> Did it work out?</li>
  
 <li> As before, change one value in the plaintext:
  <ul>
   <li> <span class="cmd">Q:=P</span></li>
   <li> <span class="cmd">Q.4:=matrix([[6],[19],[8]])</span></li>
  </ul>
 </li>
 <li> Now encrypt <tt>Q</tt> to <tt>E</tt> following the procedure outlined
      above.  Compare <tt>E</tt> with <tt>C</tt>---
      how much difference is there?
      How does this difference compare with the differences of ciphertexts
      obtained with ECB?
 </li>
 <li> Just to make sure you can do it, decrypt <tt>E</tt> and make sure you
  end up with a list equal to <tt>Q</tt>.
 </li>
</ul>
<br/><br/>
<b>OFB</b>
<br/><br/>
Output feedback mode works by creating a <i>key stream</i>, and then adding 
it to the plaintext to obtain the ciphertext.  With the Hill system, and an
initialization vector <tt>IV</tt>:
<pre>
   k =IV,   k =Mk
    1        i   i-1
</pre>
and then
<pre>
   c =p +k
    i  i  i
</pre>

<ul>
 <li> First, the key stream:
  <ul>
   <li> <span class="cmd">K:=[zero31 for i in 1..9]</span></li>
   <li> <span class="cmd">K.1:=IV</span></li>
   <li> <span class="cmd">for i in 2..9 repeat K.i:=M*K.(i-1)</span></li>
  </ul>
 </li>
 <li> and next the encryption:
  <ul>
   <li> <span class="cmd">for i in 2..9 repeat C.i:=K.i+P.i</span></li>
  </ul>
 </li>
 <li> What is the formula for decryption?  
      Apply it to your ciphertext <tt>C</tt>.
 </li>
</ul>
 </body>
</html>