ruby-aes-table1 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,494 @@
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: Aes</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">Aes</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/ruby-aes_rb.html">
59
+ lib/ruby-aes.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="#M000014">bs</a>&nbsp;&nbsp;
84
+ <a href="#M000015">bs=</a>&nbsp;&nbsp;
85
+ <a href="#M000017">check_iv</a>&nbsp;&nbsp;
86
+ <a href="#M000016">check_key</a>&nbsp;&nbsp;
87
+ <a href="#M000019">check_kl</a>&nbsp;&nbsp;
88
+ <a href="#M000018">check_mode</a>&nbsp;&nbsp;
89
+ <a href="#M000022">decrypt_block</a>&nbsp;&nbsp;
90
+ <a href="#M000024">decrypt_buffer</a>&nbsp;&nbsp;
91
+ <a href="#M000026">decrypt_stream</a>&nbsp;&nbsp;
92
+ <a href="#M000021">encrypt_block</a>&nbsp;&nbsp;
93
+ <a href="#M000023">encrypt_buffer</a>&nbsp;&nbsp;
94
+ <a href="#M000025">encrypt_stream</a>&nbsp;&nbsp;
95
+ <a href="#M000020">init</a>&nbsp;&nbsp;
96
+ </div>
97
+ </div>
98
+
99
+ </div>
100
+
101
+
102
+ <!-- if includes -->
103
+
104
+ <div id="section">
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+ <!-- if method_list -->
114
+ <div id="methods">
115
+ <h3 class="section-bar">Public Class methods</h3>
116
+
117
+ <div id="method-M000014" class="method-detail">
118
+ <a name="M000014"></a>
119
+
120
+ <div class="method-heading">
121
+ <a href="#M000014" class="method-signature">
122
+ <span class="method-name">bs</span><span class="method-args">()</span>
123
+ </a>
124
+ </div>
125
+
126
+ <div class="method-description">
127
+ <p><a class="source-toggle" href="#"
128
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
129
+ <div class="method-source-code" id="M000014-source">
130
+ <pre>
131
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 45</span>
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>
133
+ </pre>
134
+ </div>
135
+ </div>
136
+ </div>
137
+
138
+ <div id="method-M000015" class="method-detail">
139
+ <a name="M000015"></a>
140
+
141
+ <div class="method-heading">
142
+ <a href="#M000015" class="method-signature">
143
+ <span class="method-name">bs=</span><span class="method-args">(bs)</span>
144
+ </a>
145
+ </div>
146
+
147
+ <div class="method-description">
148
+ <p><a class="source-toggle" href="#"
149
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
150
+ <div class="method-source-code" id="M000015-source">
151
+ <pre>
152
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 46</span>
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>
154
+ </pre>
155
+ </div>
156
+ </div>
157
+ </div>
158
+
159
+ <div id="method-M000017" class="method-detail">
160
+ <a name="M000017"></a>
161
+
162
+ <div class="method-heading">
163
+ <a href="#M000017" class="method-signature">
164
+ <span class="method-name">check_iv</span><span class="method-args">(iv_string)</span>
165
+ </a>
166
+ </div>
167
+
168
+ <div class="method-description">
169
+ <p><a class="source-toggle" href="#"
170
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
171
+ <div class="method-source-code" id="M000017-source">
172
+ <pre>
173
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 61</span>
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>)
175
+ 62: <span class="ruby-identifier">k</span> = <span class="ruby-identifier">iv_string</span>.<span class="ruby-identifier">length</span>
176
+ 63: <span class="ruby-identifier">hex</span> = (<span class="ruby-identifier">iv_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>
177
+ 64: <span class="ruby-identifier">bin</span> = <span class="ruby-operator">!</span> <span class="ruby-identifier">hex</span>
178
+ 65: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">k</span> <span class="ruby-operator">==</span> <span class="ruby-value">32</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">hex</span>
179
+ 66: <span class="ruby-keyword kw">return</span> [<span class="ruby-identifier">iv_string</span>].<span class="ruby-identifier">pack</span>(<span class="ruby-value str">&quot;H*&quot;</span>)
180
+ 67: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">k</span> <span class="ruby-operator">==</span> <span class="ruby-value">16</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">bin</span>
181
+ 68: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">iv_string</span>
182
+ 69: <span class="ruby-keyword kw">else</span>
183
+ 70: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad IV string&quot;</span>
184
+ 71: <span class="ruby-keyword kw">end</span>
185
+ 72: <span class="ruby-keyword kw">end</span>
186
+ </pre>
187
+ </div>
188
+ </div>
189
+ </div>
190
+
191
+ <div id="method-M000016" class="method-detail">
192
+ <a name="M000016"></a>
193
+
194
+ <div class="method-heading">
195
+ <a href="#M000016" class="method-signature">
196
+ <span class="method-name">check_key</span><span class="method-args">(key_string, kl = 128)</span>
197
+ </a>
198
+ </div>
199
+
200
+ <div class="method-description">
201
+ <p><a class="source-toggle" href="#"
202
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
203
+ <div class="method-source-code" id="M000016-source">
204
+ <pre>
205
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 48</span>
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
+ 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>
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
+ 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
+ 53: <span class="ruby-identifier">bin</span> = <span class="ruby-operator">!</span> <span class="ruby-identifier">hex</span>
212
+ 54: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span> (([<span class="ruby-value">32</span>, <span class="ruby-value">48</span>, <span class="ruby-value">64</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">hex</span>) <span class="ruby-operator">||</span>
213
+ 55: ([<span class="ruby-value">16</span>, <span class="ruby-value">24</span>, <span class="ruby-value">32</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">bin</span>))
214
+ 56: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad key string&quot;</span>
215
+ 57: <span class="ruby-keyword kw">end</span>
216
+ 58: <span class="ruby-identifier">hex</span> <span class="ruby-value">? </span>[<span class="ruby-identifier">key_string</span>].<span class="ruby-identifier">pack</span>(<span class="ruby-value str">&quot;H*&quot;</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">key_string</span>
217
+ 59: <span class="ruby-keyword kw">end</span>
218
+ </pre>
219
+ </div>
220
+ </div>
221
+ </div>
222
+
223
+ <div id="method-M000019" class="method-detail">
224
+ <a name="M000019"></a>
225
+
226
+ <div class="method-heading">
227
+ <a href="#M000019" class="method-signature">
228
+ <span class="method-name">check_kl</span><span class="method-args">(key_length)</span>
229
+ </a>
230
+ </div>
231
+
232
+ <div class="method-description">
233
+ <p><a class="source-toggle" href="#"
234
+ onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
235
+ <div class="method-source-code" id="M000019-source">
236
+ <pre>
237
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 82</span>
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>)
239
+ 83: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">key_length</span>
240
+ 84: <span class="ruby-keyword kw">when</span> <span class="ruby-value">128</span>, <span class="ruby-value">192</span>, <span class="ruby-value">256</span>
241
+ 85: <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad key length&quot;</span>
242
+ 86: <span class="ruby-keyword kw">end</span>
243
+ 87: <span class="ruby-identifier">key_length</span>
244
+ 88: <span class="ruby-keyword kw">end</span>
245
+ </pre>
246
+ </div>
247
+ </div>
248
+ </div>
249
+
250
+ <div id="method-M000018" class="method-detail">
251
+ <a name="M000018"></a>
252
+
253
+ <div class="method-heading">
254
+ <a href="#M000018" class="method-signature">
255
+ <span class="method-name">check_mode</span><span class="method-args">(mode)</span>
256
+ </a>
257
+ </div>
258
+
259
+ <div class="method-description">
260
+ <p><a class="source-toggle" href="#"
261
+ onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
262
+ <div class="method-source-code" id="M000018-source">
263
+ <pre>
264
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 74</span>
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>)
266
+ 75: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">mode</span>
267
+ 76: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'ECB'</span>, <span class="ruby-value str">'CBC'</span>, <span class="ruby-value str">'OFB'</span>, <span class="ruby-value str">'CFB'</span>
268
+ 77: <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad cipher mode&quot;</span>
269
+ 78: <span class="ruby-keyword kw">end</span>
270
+ 79: <span class="ruby-identifier">mode</span>
271
+ 80: <span class="ruby-keyword kw">end</span>
272
+ </pre>
273
+ </div>
274
+ </div>
275
+ </div>
276
+
277
+ <div id="method-M000022" class="method-detail">
278
+ <a name="M000022"></a>
279
+
280
+ <div class="method-heading">
281
+ <a href="#M000022" class="method-signature">
282
+ <span class="method-name">decrypt_block</span><span class="method-args">(keyl, mode, key, iv, block = &quot;DEFAULT PLAINTXT&quot;)</span>
283
+ </a>
284
+ </div>
285
+
286
+ <div class="method-description">
287
+ <p><a class="source-toggle" href="#"
288
+ onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
289
+ <div class="method-source-code" id="M000022-source">
290
+ <pre>
291
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 106</span>
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>)
293
+ 107: <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>)
294
+ 108: <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">decrypt_block</span>(<span class="ruby-identifier">block</span>)
295
+ 109: <span class="ruby-keyword kw">end</span>
296
+ </pre>
297
+ </div>
298
+ </div>
299
+ </div>
300
+
301
+ <div id="method-M000024" class="method-detail">
302
+ <a name="M000024"></a>
303
+
304
+ <div class="method-heading">
305
+ <a href="#M000024" class="method-signature">
306
+ <span class="method-name">decrypt_buffer</span><span class="method-args">(keyl, mode, key, iv, buffer = &quot;DEFAULT PLAINTXT&quot;)</span>
307
+ </a>
308
+ </div>
309
+
310
+ <div class="method-description">
311
+ <p><a class="source-toggle" href="#"
312
+ onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
313
+ <div class="method-source-code" id="M000024-source">
314
+ <pre>
315
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 116</span>
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>)
317
+ 117: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad Block size&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">16</span>
318
+ 118: <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>)
319
+ 119: <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">decrypt_buffer</span>(<span class="ruby-identifier">buffer</span>)
320
+ 120: <span class="ruby-keyword kw">end</span>
321
+ </pre>
322
+ </div>
323
+ </div>
324
+ </div>
325
+
326
+ <div id="method-M000026" class="method-detail">
327
+ <a name="M000026"></a>
328
+
329
+ <div class="method-heading">
330
+ <a href="#M000026" class="method-signature">
331
+ <span class="method-name">decrypt_stream</span><span class="method-args">(keyl, mode, key, iv, sin = STDIN, sout = STDOUT)</span>
332
+ </a>
333
+ </div>
334
+
335
+ <div class="method-description">
336
+ <p><a class="source-toggle" href="#"
337
+ onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
338
+ <div class="method-source-code" id="M000026-source">
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>
360
+ </pre>
361
+ </div>
362
+ </div>
363
+ </div>
364
+
365
+ <div id="method-M000021" class="method-detail">
366
+ <a name="M000021"></a>
367
+
368
+ <div class="method-heading">
369
+ <a href="#M000021" class="method-signature">
370
+ <span class="method-name">encrypt_block</span><span class="method-args">(keyl, mode, key, iv, block = &quot;DEFAULT PLAINTXT&quot;)</span>
371
+ </a>
372
+ </div>
373
+
374
+ <div class="method-description">
375
+ <p><a class="source-toggle" href="#"
376
+ onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
377
+ <div class="method-source-code" id="M000021-source">
378
+ <pre>
379
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 100</span>
380
+ 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>)
381
+ 101: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad Block size&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&lt;</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">&gt;</span> <span class="ruby-value">16</span>
382
+ 102: <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>)
383
+ 103: <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">encrypt_block</span>(<span class="ruby-identifier">block</span>)
384
+ 104: <span class="ruby-keyword kw">end</span>
385
+ </pre>
386
+ </div>
387
+ </div>
388
+ </div>
389
+
390
+ <div id="method-M000023" class="method-detail">
391
+ <a name="M000023"></a>
392
+
393
+ <div class="method-heading">
394
+ <a href="#M000023" class="method-signature">
395
+ <span class="method-name">encrypt_buffer</span><span class="method-args">(keyl, mode, key, iv, buffer = &quot;PLAINTEXT&quot;)</span>
396
+ </a>
397
+ </div>
398
+
399
+ <div class="method-description">
400
+ <p><a class="source-toggle" href="#"
401
+ onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
402
+ <div class="method-source-code" id="M000023-source">
403
+ <pre>
404
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 111</span>
405
+ 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>)
406
+ 112: <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>)
407
+ 113: <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">encrypt_buffer</span>(<span class="ruby-identifier">buffer</span>)
408
+ 114: <span class="ruby-keyword kw">end</span>
409
+ </pre>
410
+ </div>
411
+ </div>
412
+ </div>
413
+
414
+ <div id="method-M000025" class="method-detail">
415
+ <a name="M000025"></a>
416
+
417
+ <div class="method-heading">
418
+ <a href="#M000025" class="method-signature">
419
+ <span class="method-name">encrypt_stream</span><span class="method-args">(keyl, mode, key, iv, sin = STDIN, sout = STDOUT)</span>
420
+ </a>
421
+ </div>
422
+
423
+ <div class="method-description">
424
+ <p><a class="source-toggle" href="#"
425
+ onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
426
+ <div class="method-source-code" id="M000025-source">
427
+ <pre>
428
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 122</span>
429
+ 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>)
430
+ 123: <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>)
431
+ 124: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">sout</span>
432
+ 125: <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>
433
+ 126: <span class="ruby-keyword kw">else</span>
434
+ 127: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Bad output stream (String, Array, IO)&quot;</span>
435
+ 128: <span class="ruby-keyword kw">end</span>
436
+ 129: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">sin</span>
437
+ 130: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span>
438
+ 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
+ 132: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">IO</span>
440
+ 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>
448
+ </pre>
449
+ </div>
450
+ </div>
451
+ </div>
452
+
453
+ <div id="method-M000020" class="method-detail">
454
+ <a name="M000020"></a>
455
+
456
+ <div class="method-heading">
457
+ <a href="#M000020" class="method-signature">
458
+ <span class="method-name">init</span><span class="method-args">(keyl, mode, key, iv)</span>
459
+ </a>
460
+ </div>
461
+
462
+ <div class="method-description">
463
+ <p><a class="source-toggle" href="#"
464
+ onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
465
+ <div class="method-source-code" id="M000020-source">
466
+ <pre>
467
+ <span class="ruby-comment cmt"># File lib/ruby-aes.rb, line 90</span>
468
+ 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>)
469
+ 91: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@@aes</span>
470
+ 92: <span class="ruby-ivar">@@aes</span> = <span class="ruby-constant">AesAlg</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_kl</span>(<span class="ruby-identifier">keyl</span>), <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_mode</span>(<span class="ruby-identifier">mode</span>),
471
+ 93: <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_key</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">keyl</span>), <span class="ruby-identifier">iv</span> <span class="ruby-value">? </span><span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_iv</span>(<span class="ruby-identifier">iv</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>)
472
+ 94: <span class="ruby-keyword kw">else</span>
473
+ 95: <span class="ruby-ivar">@@aes</span>.<span class="ruby-identifier">init</span>(<span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_kl</span>(<span class="ruby-identifier">keyl</span>), <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_mode</span>(<span class="ruby-identifier">mode</span>),
474
+ 96: <span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_key</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">keyl</span>), <span class="ruby-identifier">iv</span> <span class="ruby-value">? </span><span class="ruby-constant">Aes</span>.<span class="ruby-identifier">check_iv</span>(<span class="ruby-identifier">iv</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>)
475
+ 97: <span class="ruby-keyword kw">end</span>
476
+ 98: <span class="ruby-keyword kw">end</span>
477
+ </pre>
478
+ </div>
479
+ </div>
480
+ </div>
481
+
482
+
483
+ </div>
484
+
485
+
486
+ </div>
487
+
488
+
489
+ <div id="validator-badges">
490
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
491
+ </div>
492
+
493
+ </body>
494
+ </html>