ruby-aes-normal 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,265 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: AesShared</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">AesShared</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/ruby-aes/aes_shared_rb.html">
59
+ lib/ruby-aes/aes_shared.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+
76
+
77
+ </div>
78
+
79
+ <div id="method-list">
80
+ <h3 class="section-bar">Methods</h3>
81
+
82
+ <div class="name-list">
83
+ <a href="#M000002">decrypt_blocks</a>&nbsp;&nbsp;
84
+ <a href="#M000004">decrypt_buffer</a>&nbsp;&nbsp;
85
+ <a href="#M000001">encrypt_blocks</a>&nbsp;&nbsp;
86
+ <a href="#M000003">encrypt_buffer</a>&nbsp;&nbsp;
87
+ </div>
88
+ </div>
89
+
90
+ </div>
91
+
92
+
93
+ <!-- if includes -->
94
+
95
+ <div id="section">
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+ <!-- if method_list -->
105
+ <div id="methods">
106
+ <h3 class="section-bar">Public Instance methods</h3>
107
+
108
+ <div id="method-M000002" class="method-detail">
109
+ <a name="M000002"></a>
110
+
111
+ <div class="method-heading">
112
+ <a href="#M000002" class="method-signature">
113
+ <span class="method-name">decrypt_blocks</span><span class="method-args">(buffer)</span>
114
+ </a>
115
+ </div>
116
+
117
+ <div class="method-description">
118
+ <p><a class="source-toggle" href="#"
119
+ onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
120
+ <div class="method-source-code" id="M000002-source">
121
+ <pre>
122
+ <span class="ruby-comment cmt"># File lib/ruby-aes/aes_shared.rb, line 23</span>
123
+ 23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">decrypt_blocks</span>(<span class="ruby-identifier">buffer</span>)
124
+ 24: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad block length&quot;</span> <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">%</span> <span class="ruby-value">16</span>).<span class="ruby-identifier">zero?</span>
125
+ 25: <span class="ruby-identifier">pt</span> = <span class="ruby-value str">&quot;&quot;</span>
126
+ 26: <span class="ruby-identifier">block</span> = <span class="ruby-value str">&quot;&quot;</span>
127
+ 27: <span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">each_byte</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">char</span><span class="ruby-operator">|</span>
128
+ 28: <span class="ruby-identifier">block</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">char</span>
129
+ 29: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">16</span>
130
+ 30: <span class="ruby-identifier">pt</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">decrypt_block</span>(<span class="ruby-identifier">block</span>)
131
+ 31: <span class="ruby-identifier">block</span> = <span class="ruby-value str">&quot;&quot;</span>
132
+ 32: <span class="ruby-keyword kw">end</span>
133
+ 33: <span class="ruby-keyword kw">end</span>
134
+ 34: <span class="ruby-identifier">pt</span>
135
+ 35: <span class="ruby-keyword kw">end</span>
136
+ </pre>
137
+ </div>
138
+ </div>
139
+ </div>
140
+
141
+ <div id="method-M000004" class="method-detail">
142
+ <a name="M000004"></a>
143
+
144
+ <div class="method-heading">
145
+ <a href="#M000004" class="method-signature">
146
+ <span class="method-name">decrypt_buffer</span><span class="method-args">(buffer)</span>
147
+ </a>
148
+ </div>
149
+
150
+ <div class="method-description">
151
+ <p><a class="source-toggle" href="#"
152
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
153
+ <div class="method-source-code" id="M000004-source">
154
+ <pre>
155
+ <span class="ruby-comment cmt"># File lib/ruby-aes/aes_shared.rb, line 55</span>
156
+ 55: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">decrypt_buffer</span>(<span class="ruby-identifier">buffer</span>)
157
+ 56: <span class="ruby-identifier">pt</span> = <span class="ruby-value str">&quot;&quot;</span>
158
+ 57: <span class="ruby-identifier">block</span> = <span class="ruby-value str">&quot;&quot;</span>
159
+ 58: <span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">each_byte</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">char</span><span class="ruby-operator">|</span>
160
+ 59: <span class="ruby-identifier">block</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">char</span>
161
+ 60: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">16</span>
162
+ 61: <span class="ruby-identifier">pt</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">decrypt_block</span>(<span class="ruby-identifier">block</span>)
163
+ 62: <span class="ruby-identifier">block</span> = <span class="ruby-value str">&quot;&quot;</span>
164
+ 63: <span class="ruby-keyword kw">end</span>
165
+ 64: <span class="ruby-keyword kw">end</span>
166
+ 65: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">!=</span> <span class="ruby-value">1</span>
167
+ 66: <span class="ruby-identifier">raise</span> <span class="ruby-value str">'Bad Block Padding'</span>
168
+ 67: <span class="ruby-keyword kw">elsif</span> (<span class="ruby-identifier">c</span> = <span class="ruby-identifier">block</span>[<span class="ruby-value">-1</span>]).<span class="ruby-identifier">zero?</span>
169
+ 68: <span class="ruby-identifier">pt</span>
170
+ 69: <span class="ruby-keyword kw">else</span>
171
+ 70: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">pt</span>[<span class="ruby-operator">-</span><span class="ruby-identifier">c</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
172
+ 71: <span class="ruby-identifier">pt</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-operator">-</span><span class="ruby-identifier">c</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>]
173
+ 72: <span class="ruby-keyword kw">else</span>
174
+ 73: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad Block Padding&quot;</span>
175
+ 74: <span class="ruby-keyword kw">end</span>
176
+ 75: <span class="ruby-keyword kw">end</span>
177
+ 76: <span class="ruby-keyword kw">end</span>
178
+ </pre>
179
+ </div>
180
+ </div>
181
+ </div>
182
+
183
+ <div id="method-M000001" class="method-detail">
184
+ <a name="M000001"></a>
185
+
186
+ <div class="method-heading">
187
+ <a href="#M000001" class="method-signature">
188
+ <span class="method-name">encrypt_blocks</span><span class="method-args">(buffer)</span>
189
+ </a>
190
+ </div>
191
+
192
+ <div class="method-description">
193
+ <p><a class="source-toggle" href="#"
194
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
195
+ <div class="method-source-code" id="M000001-source">
196
+ <pre>
197
+ <span class="ruby-comment cmt"># File lib/ruby-aes/aes_shared.rb, line 9</span>
198
+ 9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">encrypt_blocks</span>(<span class="ruby-identifier">buffer</span>)
199
+ 10: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad block length&quot;</span> <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">%</span> <span class="ruby-value">16</span>).<span class="ruby-identifier">zero?</span>
200
+ 11: <span class="ruby-identifier">ct</span> = <span class="ruby-value str">&quot;&quot;</span>
201
+ 12: <span class="ruby-identifier">block</span> = <span class="ruby-value str">&quot;&quot;</span>
202
+ 13: <span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">each_byte</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">char</span><span class="ruby-operator">|</span>
203
+ 14: <span class="ruby-identifier">block</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">char</span>
204
+ 15: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">16</span>
205
+ 16: <span class="ruby-identifier">ct</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">encrypt_block</span>(<span class="ruby-identifier">block</span>)
206
+ 17: <span class="ruby-identifier">block</span> = <span class="ruby-value str">&quot;&quot;</span>
207
+ 18: <span class="ruby-keyword kw">end</span>
208
+ 19: <span class="ruby-keyword kw">end</span>
209
+ 20: <span class="ruby-identifier">ct</span>
210
+ 21: <span class="ruby-keyword kw">end</span>
211
+ </pre>
212
+ </div>
213
+ </div>
214
+ </div>
215
+
216
+ <div id="method-M000003" class="method-detail">
217
+ <a name="M000003"></a>
218
+
219
+ <div class="method-heading">
220
+ <a href="#M000003" class="method-signature">
221
+ <span class="method-name">encrypt_buffer</span><span class="method-args">(buffer)</span>
222
+ </a>
223
+ </div>
224
+
225
+ <div class="method-description">
226
+ <p><a class="source-toggle" href="#"
227
+ onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
228
+ <div class="method-source-code" id="M000003-source">
229
+ <pre>
230
+ <span class="ruby-comment cmt"># File lib/ruby-aes/aes_shared.rb, line 37</span>
231
+ 37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">encrypt_buffer</span>(<span class="ruby-identifier">buffer</span>)
232
+ 38: <span class="ruby-identifier">ct</span> = <span class="ruby-value str">&quot;&quot;</span>
233
+ 39: <span class="ruby-identifier">block</span> = <span class="ruby-value str">&quot;&quot;</span>
234
+ 40: <span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">each_byte</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">char</span><span class="ruby-operator">|</span>
235
+ 41: <span class="ruby-identifier">block</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">char</span>
236
+ 42: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">16</span>
237
+ 43: <span class="ruby-identifier">ct</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">encrypt_block</span>(<span class="ruby-identifier">block</span>)
238
+ 44: <span class="ruby-identifier">block</span> = <span class="ruby-value str">&quot;&quot;</span>
239
+ 45: <span class="ruby-keyword kw">end</span>
240
+ 46: <span class="ruby-keyword kw">end</span>
241
+ 47: <span class="ruby-identifier">c</span> = <span class="ruby-value str">&quot;\000&quot;</span>
242
+ 48: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">m</span> = <span class="ruby-value">16</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">%</span> <span class="ruby-value">16</span>) <span class="ruby-operator">!=</span> <span class="ruby-value">16</span>
243
+ 49: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">chr</span>
244
+ 50: <span class="ruby-identifier">ct</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">encrypt_block</span>(<span class="ruby-identifier">block</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">m</span>)
245
+ 51: <span class="ruby-keyword kw">end</span>
246
+ 52: <span class="ruby-identifier">ct</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">c</span>
247
+ 53: <span class="ruby-keyword kw">end</span>
248
+ </pre>
249
+ </div>
250
+ </div>
251
+ </div>
252
+
253
+
254
+ </div>
255
+
256
+
257
+ </div>
258
+
259
+
260
+ <div id="validator-badges">
261
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
262
+ </div>
263
+
264
+ </body>
265
+ </html>
@@ -1 +1 @@
1
- Wed Aug 01 17:32:37 CEST 2007
1
+ Sat, 05 Jan 2008 02:15:01 +0100
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Jul 29 21:54:22 CEST 2007</td>
59
+ <td>Sat Jan 05 00:53:21 +0100 2008</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -69,7 +69,17 @@
69
69
  <div id="contextContent">
70
70
 
71
71
  <div id="description">
72
- <h1>0.1</h1>
72
+ <h1>1.1</h1>
73
+ <h3>2008-01-05</h3>
74
+ <ul>
75
+ <li>Fixed padding problem (bug 15885)
76
+
77
+ </li>
78
+ <li>Fixed encrypt/decrypt stream
79
+
80
+ </li>
81
+ </ul>
82
+ <h1>1.0</h1>
73
83
  <h3>2007-07-30</h3>
74
84
  <ul>
75
85
  <li>Initial release: RAA project import
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Jul 29 18:32:22 CEST 2007</td>
59
+ <td>Sun Jul 29 18:32:22 +0200 2007</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -70,7 +70,7 @@
70
70
 
71
71
  <div id="description">
72
72
  <p>
73
- Copyright &#169; 2007 Alex Boussinet
73
+ Copyright (c) 2007 Alex Boussinet
74
74
  </p>
75
75
  <p>
76
76
  Permission is hereby granted, free of charge, to any person obtaining a
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Jul 29 18:32:22 CEST 2007</td>
59
+ <td>Sun Jul 29 18:32:22 +0200 2007</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -84,7 +84,7 @@ href="mailto:alex.boussinet@gmail.com">alex.boussinet@gmail.com</a>&gt;
84
84
  </p>
85
85
  <p>
86
86
  This release is mainly an import from the Ruby Application Archive (RAA).
87
- I&#8217;ve added all the versions I was working on (algorithm variations)
87
+ I&#8216;ve added all the versions I was working on (algorithm variations)
88
88
  and a new C extension for improved performance. 6 variations are available:
89
89
  </p>
90
90
  <ul>
@@ -113,7 +113,7 @@ for speed. The SubBytes and ShiftRows methods have been combined.
113
113
  <p>
114
114
  Pure Ruby implementation based on the C code from the Rijndael website. The
115
115
  arrays of constants are bigger because all the operations are already
116
- computed so it&#8217;s mainly based on table look ups.
116
+ computed so it&#8216;s mainly based on table look ups.
117
117
  </p>
118
118
  <ul>
119
119
  <li>&quot;Table Optimized 2&quot;:
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: aes_shared.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>aes_shared.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/ruby-aes/aes_shared.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Fri Jan 04 17:08:17 +0100 2008</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+
73
+ </div>
74
+
75
+
76
+ </div>
77
+
78
+
79
+ <!-- if includes -->
80
+
81
+ <div id="section">
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <!-- if method_list -->
91
+
92
+
93
+ </div>
94
+
95
+
96
+ <div id="validator-badges">
97
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
98
+ </div>
99
+
100
+ </body>
101
+ </html>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Jul 29 18:32:22 CEST 2007</td>
59
+ <td>Fri Jan 04 17:09:17 +0100 2008</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>