ruby-aes-normal 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,10 @@
1
- = 0.1
1
+ = 1.1
2
+
3
+ === 2008-01-05
4
+ * Fixed padding problem (bug #15885)
5
+ * Fixed encrypt/decrypt stream
6
+
7
+ = 1.0
2
8
 
3
9
  === 2007-07-30
4
10
  * Initial release: RAA project import
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ require 'fileutils'
8
8
  include FileUtils
9
9
 
10
10
  @name = 'ruby-aes'
11
- @version = '1.0'
11
+ @version = '1.1'
12
12
  @native = false
13
13
 
14
14
  @lib = "lib/#{@name}"
@@ -82,8 +82,8 @@ task :cext do |t|
82
82
  SPEC.files += ["#{@ext}/#{@ext_so}"]
83
83
  SPEC.platform = Gem::Platform::CURRENT
84
84
  else
85
- SPEC.files += Dir.glob("#{@ext}/*")
86
- SPEC.extensions = FileList["#{@ext}/extconf.rb"].to_a
85
+ SPEC.files += [ "#{@ext}/aes_alg.c", "#{@ext}/extconf.rb", "#{@ext}/aes_cons.h" ]
86
+ SPEC.extensions = "#{@ext}/extconf.rb"
87
87
  end
88
88
  task_gem
89
89
  end
@@ -80,19 +80,19 @@
80
80
  <h3 class="section-bar">Methods</h3>
81
81
 
82
82
  <div class="name-list">
83
- <a href="#M000001">bs</a>&nbsp;&nbsp;
84
- <a href="#M000002">bs=</a>&nbsp;&nbsp;
85
- <a href="#M000004">check_iv</a>&nbsp;&nbsp;
86
- <a href="#M000003">check_key</a>&nbsp;&nbsp;
87
- <a href="#M000006">check_kl</a>&nbsp;&nbsp;
88
- <a href="#M000005">check_mode</a>&nbsp;&nbsp;
89
- <a href="#M000009">decrypt_block</a>&nbsp;&nbsp;
90
- <a href="#M000011">decrypt_buffer</a>&nbsp;&nbsp;
91
- <a href="#M000013">decrypt_stream</a>&nbsp;&nbsp;
92
- <a href="#M000008">encrypt_block</a>&nbsp;&nbsp;
93
- <a href="#M000010">encrypt_buffer</a>&nbsp;&nbsp;
94
- <a href="#M000012">encrypt_stream</a>&nbsp;&nbsp;
95
- <a href="#M000007">init</a>&nbsp;&nbsp;
83
+ <a href="#M000005">bs</a>&nbsp;&nbsp;
84
+ <a href="#M000006">bs=</a>&nbsp;&nbsp;
85
+ <a href="#M000008">check_iv</a>&nbsp;&nbsp;
86
+ <a href="#M000007">check_key</a>&nbsp;&nbsp;
87
+ <a href="#M000010">check_kl</a>&nbsp;&nbsp;
88
+ <a href="#M000009">check_mode</a>&nbsp;&nbsp;
89
+ <a href="#M000013">decrypt_block</a>&nbsp;&nbsp;
90
+ <a href="#M000015">decrypt_buffer</a>&nbsp;&nbsp;
91
+ <a href="#M000017">decrypt_stream</a>&nbsp;&nbsp;
92
+ <a href="#M000012">encrypt_block</a>&nbsp;&nbsp;
93
+ <a href="#M000014">encrypt_buffer</a>&nbsp;&nbsp;
94
+ <a href="#M000016">encrypt_stream</a>&nbsp;&nbsp;
95
+ <a href="#M000011">init</a>&nbsp;&nbsp;
96
96
  </div>
97
97
  </div>
98
98
 
@@ -114,19 +114,19 @@
114
114
  <div id="methods">
115
115
  <h3 class="section-bar">Public Class methods</h3>
116
116
 
117
- <div id="method-M000001" class="method-detail">
118
- <a name="M000001"></a>
117
+ <div id="method-M000005" class="method-detail">
118
+ <a name="M000005"></a>
119
119
 
120
120
  <div class="method-heading">
121
- <a href="#M000001" class="method-signature">
121
+ <a href="#M000005" class="method-signature">
122
122
  <span class="method-name">bs</span><span class="method-args">()</span>
123
123
  </a>
124
124
  </div>
125
125
 
126
126
  <div class="method-description">
127
127
  <p><a class="source-toggle" href="#"
128
- onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
129
- <div class="method-source-code" id="M000001-source">
128
+ onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
129
+ <div class="method-source-code" id="M000005-source">
130
130
  <pre>
131
131
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 45</span>
132
132
  45: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">bs</span>(); <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@@bs</span> <span class="ruby-keyword kw">end</span>
@@ -135,19 +135,19 @@
135
135
  </div>
136
136
  </div>
137
137
 
138
- <div id="method-M000002" class="method-detail">
139
- <a name="M000002"></a>
138
+ <div id="method-M000006" class="method-detail">
139
+ <a name="M000006"></a>
140
140
 
141
141
  <div class="method-heading">
142
- <a href="#M000002" class="method-signature">
142
+ <a href="#M000006" class="method-signature">
143
143
  <span class="method-name">bs=</span><span class="method-args">(bs)</span>
144
144
  </a>
145
145
  </div>
146
146
 
147
147
  <div class="method-description">
148
148
  <p><a class="source-toggle" href="#"
149
- onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
150
- <div class="method-source-code" id="M000002-source">
149
+ onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
150
+ <div class="method-source-code" id="M000006-source">
151
151
  <pre>
152
152
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 46</span>
153
153
  46: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">bs=</span>(<span class="ruby-identifier">bs</span>); <span class="ruby-ivar">@@bs</span> = <span class="ruby-identifier">bs</span>.<span class="ruby-identifier">to_i</span>; <span class="ruby-ivar">@@bs</span><span class="ruby-operator">==</span><span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-value">4096</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@@bs</span> = <span class="ruby-ivar">@@bs</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@@bs</span><span class="ruby-operator">%</span><span class="ruby-value">16</span> <span class="ruby-keyword kw">end</span>
@@ -156,19 +156,19 @@
156
156
  </div>
157
157
  </div>
158
158
 
159
- <div id="method-M000004" class="method-detail">
160
- <a name="M000004"></a>
159
+ <div id="method-M000008" class="method-detail">
160
+ <a name="M000008"></a>
161
161
 
162
162
  <div class="method-heading">
163
- <a href="#M000004" class="method-signature">
163
+ <a href="#M000008" class="method-signature">
164
164
  <span class="method-name">check_iv</span><span class="method-args">(iv_string)</span>
165
165
  </a>
166
166
  </div>
167
167
 
168
168
  <div class="method-description">
169
169
  <p><a class="source-toggle" href="#"
170
- onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
171
- <div class="method-source-code" id="M000004-source">
170
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
171
+ <div class="method-source-code" id="M000008-source">
172
172
  <pre>
173
173
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 61</span>
174
174
  61: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_iv</span>(<span class="ruby-identifier">iv_string</span>)
@@ -188,24 +188,24 @@
188
188
  </div>
189
189
  </div>
190
190
 
191
- <div id="method-M000003" class="method-detail">
192
- <a name="M000003"></a>
191
+ <div id="method-M000007" class="method-detail">
192
+ <a name="M000007"></a>
193
193
 
194
194
  <div class="method-heading">
195
- <a href="#M000003" class="method-signature">
195
+ <a href="#M000007" class="method-signature">
196
196
  <span class="method-name">check_key</span><span class="method-args">(key_string, kl = 128)</span>
197
197
  </a>
198
198
  </div>
199
199
 
200
200
  <div class="method-description">
201
201
  <p><a class="source-toggle" href="#"
202
- onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
203
- <div class="method-source-code" id="M000003-source">
202
+ onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
203
+ <div class="method-source-code" id="M000007-source">
204
204
  <pre>
205
205
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 48</span>
206
206
  48: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_key</span>(<span class="ruby-identifier">key_string</span>, <span class="ruby-identifier">kl</span> = <span class="ruby-value">128</span>)
207
207
  49: <span class="ruby-identifier">kl</span> = <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_kl</span>(<span class="ruby-identifier">kl</span>)
208
- 50: <span class="ruby-identifier">k</span> = <span class="ruby-identifier">key_string</span>.<span class="ruby-identifier">length</span>
208
+ 50: <span class="ruby-identifier">k</span> = <span class="ruby-identifier">key_string</span> <span class="ruby-value">? </span><span class="ruby-identifier">key_string</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
209
209
  51: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad key string or bad key length&quot;</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">k</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">kl</span><span class="ruby-operator">/</span><span class="ruby-value">8</span>) <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">k</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">kl</span><span class="ruby-operator">/</span><span class="ruby-value">4</span>)
210
210
  52: <span class="ruby-identifier">hex</span> = (<span class="ruby-identifier">key_string</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/[a-f0-9A-F]{#{k}}/</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">k</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">kl</span><span class="ruby-operator">/</span><span class="ruby-value">4</span>)
211
211
  53: <span class="ruby-identifier">bin</span> = <span class="ruby-operator">!</span> <span class="ruby-identifier">hex</span>
@@ -220,19 +220,19 @@
220
220
  </div>
221
221
  </div>
222
222
 
223
- <div id="method-M000006" class="method-detail">
224
- <a name="M000006"></a>
223
+ <div id="method-M000010" class="method-detail">
224
+ <a name="M000010"></a>
225
225
 
226
226
  <div class="method-heading">
227
- <a href="#M000006" class="method-signature">
227
+ <a href="#M000010" class="method-signature">
228
228
  <span class="method-name">check_kl</span><span class="method-args">(key_length)</span>
229
229
  </a>
230
230
  </div>
231
231
 
232
232
  <div class="method-description">
233
233
  <p><a class="source-toggle" href="#"
234
- onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
235
- <div class="method-source-code" id="M000006-source">
234
+ onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
235
+ <div class="method-source-code" id="M000010-source">
236
236
  <pre>
237
237
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 82</span>
238
238
  82: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_kl</span>(<span class="ruby-identifier">key_length</span>)
@@ -247,19 +247,19 @@
247
247
  </div>
248
248
  </div>
249
249
 
250
- <div id="method-M000005" class="method-detail">
251
- <a name="M000005"></a>
250
+ <div id="method-M000009" class="method-detail">
251
+ <a name="M000009"></a>
252
252
 
253
253
  <div class="method-heading">
254
- <a href="#M000005" class="method-signature">
254
+ <a href="#M000009" class="method-signature">
255
255
  <span class="method-name">check_mode</span><span class="method-args">(mode)</span>
256
256
  </a>
257
257
  </div>
258
258
 
259
259
  <div class="method-description">
260
260
  <p><a class="source-toggle" href="#"
261
- onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
262
- <div class="method-source-code" id="M000005-source">
261
+ onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
262
+ <div class="method-source-code" id="M000009-source">
263
263
  <pre>
264
264
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 74</span>
265
265
  74: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_mode</span> (<span class="ruby-identifier">mode</span>)
@@ -274,19 +274,19 @@
274
274
  </div>
275
275
  </div>
276
276
 
277
- <div id="method-M000009" class="method-detail">
278
- <a name="M000009"></a>
277
+ <div id="method-M000013" class="method-detail">
278
+ <a name="M000013"></a>
279
279
 
280
280
  <div class="method-heading">
281
- <a href="#M000009" class="method-signature">
281
+ <a href="#M000013" class="method-signature">
282
282
  <span class="method-name">decrypt_block</span><span class="method-args">(keyl, mode, key, iv, block = &quot;DEFAULT PLAINTXT&quot;)</span>
283
283
  </a>
284
284
  </div>
285
285
 
286
286
  <div class="method-description">
287
287
  <p><a class="source-toggle" href="#"
288
- onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
289
- <div class="method-source-code" id="M000009-source">
288
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
289
+ <div class="method-source-code" id="M000013-source">
290
290
  <pre>
291
291
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 106</span>
292
292
  106: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">decrypt_block</span>(<span class="ruby-identifier">keyl</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">iv</span>, <span class="ruby-identifier">block</span> = <span class="ruby-value str">&quot;DEFAULT PLAINTXT&quot;</span>)
@@ -298,19 +298,19 @@
298
298
  </div>
299
299
  </div>
300
300
 
301
- <div id="method-M000011" class="method-detail">
302
- <a name="M000011"></a>
301
+ <div id="method-M000015" class="method-detail">
302
+ <a name="M000015"></a>
303
303
 
304
304
  <div class="method-heading">
305
- <a href="#M000011" class="method-signature">
305
+ <a href="#M000015" class="method-signature">
306
306
  <span class="method-name">decrypt_buffer</span><span class="method-args">(keyl, mode, key, iv, buffer = &quot;DEFAULT PLAINTXT&quot;)</span>
307
307
  </a>
308
308
  </div>
309
309
 
310
310
  <div class="method-description">
311
311
  <p><a class="source-toggle" href="#"
312
- onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
313
- <div class="method-source-code" id="M000011-source">
312
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
313
+ <div class="method-source-code" id="M000015-source">
314
314
  <pre>
315
315
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 116</span>
316
316
  116: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">decrypt_buffer</span>(<span class="ruby-identifier">keyl</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">iv</span>, <span class="ruby-identifier">buffer</span> = <span class="ruby-value str">&quot;DEFAULT PLAINTXT&quot;</span>)
@@ -323,58 +323,61 @@
323
323
  </div>
324
324
  </div>
325
325
 
326
- <div id="method-M000013" class="method-detail">
327
- <a name="M000013"></a>
326
+ <div id="method-M000017" class="method-detail">
327
+ <a name="M000017"></a>
328
328
 
329
329
  <div class="method-heading">
330
- <a href="#M000013" class="method-signature">
330
+ <a href="#M000017" class="method-signature">
331
331
  <span class="method-name">decrypt_stream</span><span class="method-args">(keyl, mode, key, iv, sin = STDIN, sout = STDOUT)</span>
332
332
  </a>
333
333
  </div>
334
334
 
335
335
  <div class="method-description">
336
336
  <p><a class="source-toggle" href="#"
337
- onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
338
- <div class="method-source-code" id="M000013-source">
337
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
338
+ <div class="method-source-code" id="M000017-source">
339
339
  <pre>
340
- <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 142</span>
341
- 142: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">decrypt_stream</span>(<span class="ruby-identifier">keyl</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">iv</span>, <span class="ruby-identifier">sin</span> = <span class="ruby-constant">STDIN</span>, <span class="ruby-identifier">sout</span> = <span class="ruby-constant">STDOUT</span>)
342
- 143: <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">init</span>(<span class="ruby-identifier">keyl</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">iv</span>)
343
- 144: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">sout</span>
344
- 145: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span>, <span class="ruby-constant">Array</span>, <span class="ruby-constant">IO</span>
345
- 146: <span class="ruby-keyword kw">else</span>
346
- 147: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad output stream (String, Array, IO)&quot;</span>
347
- 148: <span class="ruby-keyword kw">end</span>
348
- 149: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">sin</span>
349
- 150: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span>
350
- 151: <span class="ruby-identifier">sout</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">decrypt_buffer</span>(<span class="ruby-identifier">sin</span>)
351
- 152: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">IO</span>
352
- 153: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">buf</span> = <span class="ruby-identifier">sin</span>.<span class="ruby-identifier">read</span>(<span class="ruby-ivar">@@bs</span>)
353
- 154: <span class="ruby-identifier">sout</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">sin</span>.<span class="ruby-identifier">eof?</span> <span class="ruby-value">? </span><span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">decrypt_buffer</span>(<span class="ruby-identifier">buf</span>) <span class="ruby-operator">:</span>
354
- 155: <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">decrypt_blocks</span>(<span class="ruby-identifier">buf</span>))
355
- 156: <span class="ruby-keyword kw">end</span>
356
- 157: <span class="ruby-keyword kw">else</span>
357
- 158: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad input stream (String, IO)&quot;</span>
358
- 159: <span class="ruby-keyword kw">end</span>
359
- 160: <span class="ruby-keyword kw">end</span>
340
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 145</span>
341
+ 145: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">decrypt_stream</span>(<span class="ruby-identifier">keyl</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">iv</span>, <span class="ruby-identifier">sin</span> = <span class="ruby-constant">STDIN</span>, <span class="ruby-identifier">sout</span> = <span class="ruby-constant">STDOUT</span>)
342
+ 146: <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">init</span>(<span class="ruby-identifier">keyl</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">iv</span>)
343
+ 147: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">sout</span>
344
+ 148: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span>, <span class="ruby-constant">Array</span>, <span class="ruby-constant">IO</span>
345
+ 149: <span class="ruby-keyword kw">else</span>
346
+ 150: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad output stream (String, Array, IO)&quot;</span>
347
+ 151: <span class="ruby-keyword kw">end</span>
348
+ 152: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">sin</span>
349
+ 153: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span>
350
+ 154: <span class="ruby-identifier">sout</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">decrypt_buffer</span>(<span class="ruby-identifier">sin</span>)
351
+ 155: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">IO</span>
352
+ 156: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">buf</span> = <span class="ruby-identifier">sin</span>.<span class="ruby-identifier">read</span>(<span class="ruby-ivar">@@bs</span>)<span class="ruby-comment cmt">#+1)</span>
353
+ 157: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">buf</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@@bs</span>
354
+ 158: <span class="ruby-identifier">sout</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">decrypt_blocks</span>(<span class="ruby-identifier">buf</span>)
355
+ 159: <span class="ruby-keyword kw">else</span>
356
+ 160: <span class="ruby-identifier">sout</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">decrypt_buffer</span>(<span class="ruby-identifier">buf</span>)
357
+ 161: <span class="ruby-keyword kw">end</span>
358
+ 162: <span class="ruby-keyword kw">end</span>
359
+ 163: <span class="ruby-keyword kw">else</span>
360
+ 164: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad input stream (String, IO)&quot;</span>
361
+ 165: <span class="ruby-keyword kw">end</span>
362
+ 166: <span class="ruby-keyword kw">end</span>
360
363
  </pre>
361
364
  </div>
362
365
  </div>
363
366
  </div>
364
367
 
365
- <div id="method-M000008" class="method-detail">
366
- <a name="M000008"></a>
368
+ <div id="method-M000012" class="method-detail">
369
+ <a name="M000012"></a>
367
370
 
368
371
  <div class="method-heading">
369
- <a href="#M000008" class="method-signature">
372
+ <a href="#M000012" class="method-signature">
370
373
  <span class="method-name">encrypt_block</span><span class="method-args">(keyl, mode, key, iv, block = &quot;DEFAULT PLAINTXT&quot;)</span>
371
374
  </a>
372
375
  </div>
373
376
 
374
377
  <div class="method-description">
375
378
  <p><a class="source-toggle" href="#"
376
- onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
377
- <div class="method-source-code" id="M000008-source">
379
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
380
+ <div class="method-source-code" id="M000012-source">
378
381
  <pre>
379
382
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 100</span>
380
383
  100: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">encrypt_block</span>(<span class="ruby-identifier">keyl</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">iv</span>, <span class="ruby-identifier">block</span> = <span class="ruby-value str">&quot;DEFAULT PLAINTXT&quot;</span>)
@@ -387,19 +390,19 @@
387
390
  </div>
388
391
  </div>
389
392
 
390
- <div id="method-M000010" class="method-detail">
391
- <a name="M000010"></a>
393
+ <div id="method-M000014" class="method-detail">
394
+ <a name="M000014"></a>
392
395
 
393
396
  <div class="method-heading">
394
- <a href="#M000010" class="method-signature">
397
+ <a href="#M000014" class="method-signature">
395
398
  <span class="method-name">encrypt_buffer</span><span class="method-args">(keyl, mode, key, iv, buffer = &quot;PLAINTEXT&quot;)</span>
396
399
  </a>
397
400
  </div>
398
401
 
399
402
  <div class="method-description">
400
403
  <p><a class="source-toggle" href="#"
401
- onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
402
- <div class="method-source-code" id="M000010-source">
404
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
405
+ <div class="method-source-code" id="M000014-source">
403
406
  <pre>
404
407
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 111</span>
405
408
  111: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">encrypt_buffer</span>(<span class="ruby-identifier">keyl</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">iv</span>, <span class="ruby-identifier">buffer</span> = <span class="ruby-value str">&quot;PLAINTEXT&quot;</span>)
@@ -411,19 +414,19 @@
411
414
  </div>
412
415
  </div>
413
416
 
414
- <div id="method-M000012" class="method-detail">
415
- <a name="M000012"></a>
417
+ <div id="method-M000016" class="method-detail">
418
+ <a name="M000016"></a>
416
419
 
417
420
  <div class="method-heading">
418
- <a href="#M000012" class="method-signature">
421
+ <a href="#M000016" class="method-signature">
419
422
  <span class="method-name">encrypt_stream</span><span class="method-args">(keyl, mode, key, iv, sin = STDIN, sout = STDOUT)</span>
420
423
  </a>
421
424
  </div>
422
425
 
423
426
  <div class="method-description">
424
427
  <p><a class="source-toggle" href="#"
425
- onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
426
- <div class="method-source-code" id="M000012-source">
428
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
429
+ <div class="method-source-code" id="M000016-source">
427
430
  <pre>
428
431
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 122</span>
429
432
  122: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">encrypt_stream</span>(<span class="ruby-identifier">keyl</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">iv</span>, <span class="ruby-identifier">sin</span> = <span class="ruby-constant">STDIN</span>, <span class="ruby-identifier">sout</span> = <span class="ruby-constant">STDOUT</span>)
@@ -438,31 +441,34 @@
438
441
  131: <span class="ruby-identifier">sout</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">encrypt_buffer</span>(<span class="ruby-identifier">sin</span>)
439
442
  132: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">IO</span>
440
443
  133: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">buf</span> = <span class="ruby-identifier">sin</span>.<span class="ruby-identifier">read</span>(<span class="ruby-ivar">@@bs</span>)
441
- 134: <span class="ruby-identifier">sout</span> <span class="ruby-operator">&lt;&lt;</span> ((<span class="ruby-identifier">buf</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">%</span> <span class="ruby-value">16</span>).<span class="ruby-identifier">zero?</span> <span class="ruby-value">? </span><span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">encrypt_blocks</span>(<span class="ruby-identifier">buf</span>) <span class="ruby-operator">:</span>
442
- 135: <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">encrypt_buffer</span>(<span class="ruby-identifier">buf</span>))
443
- 136: <span class="ruby-keyword kw">end</span>
444
- 137: <span class="ruby-keyword kw">else</span>
445
- 138: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad input stream (String, IO)&quot;</span>
446
- 139: <span class="ruby-keyword kw">end</span>
447
- 140: <span class="ruby-keyword kw">end</span>
444
+ 134: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">buf</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@@bs</span>
445
+ 135: <span class="ruby-identifier">sout</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">encrypt_blocks</span>(<span class="ruby-identifier">buf</span>)
446
+ 136: <span class="ruby-keyword kw">else</span>
447
+ 137: <span class="ruby-identifier">sout</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">encrypt_buffer</span>(<span class="ruby-identifier">buf</span>)
448
+ 138: <span class="ruby-keyword kw">end</span>
449
+ 139: <span class="ruby-keyword kw">end</span>
450
+ 140: <span class="ruby-keyword kw">else</span>
451
+ 141: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad input stream (String, IO)&quot;</span>
452
+ 142: <span class="ruby-keyword kw">end</span>
453
+ 143: <span class="ruby-keyword kw">end</span>
448
454
  </pre>
449
455
  </div>
450
456
  </div>
451
457
  </div>
452
458
 
453
- <div id="method-M000007" class="method-detail">
454
- <a name="M000007"></a>
459
+ <div id="method-M000011" class="method-detail">
460
+ <a name="M000011"></a>
455
461
 
456
462
  <div class="method-heading">
457
- <a href="#M000007" class="method-signature">
463
+ <a href="#M000011" class="method-signature">
458
464
  <span class="method-name">init</span><span class="method-args">(keyl, mode, key, iv)</span>
459
465
  </a>
460
466
  </div>
461
467
 
462
468
  <div class="method-description">
463
469
  <p><a class="source-toggle" href="#"
464
- onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
465
- <div class="method-source-code" id="M000007-source">
470
+ onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
471
+ <div class="method-source-code" id="M000011-source">
466
472
  <pre>
467
473
  <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 90</span>
468
474
  90: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">init</span>(<span class="ruby-identifier">keyl</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">iv</span>)