ruby-aes-normal 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/COPYING +20 -0
- data/README +77 -0
- data/Rakefile +154 -0
- data/doc/rdoc/classes/Aes.html +494 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/CHANGELOG.html +117 -0
- data/doc/rdoc/files/COPYING.html +129 -0
- data/doc/rdoc/files/README.html +235 -0
- data/doc/rdoc/files/lib/ruby-aes_rb.html +108 -0
- data/doc/rdoc/fr_class_index.html +27 -0
- data/doc/rdoc/fr_file_index.html +30 -0
- data/doc/rdoc/fr_method_index.html +39 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/examples/encrypt_block.rb +22 -0
- data/examples/encrypt_buffer.rb +24 -0
- data/examples/encrypt_stream.rb +39 -0
- data/examples/example_helper.rb +27 -0
- data/lib/ruby-aes.rb +162 -0
- data/lib/ruby-aes/aes_alg.rb +277 -0
- data/lib/ruby-aes/aes_cons.rb +216 -0
- data/test/KAT_MCT/aes_kat_mct.rb +386 -0
- data/test/KAT_MCT/rijndael-vals.zip +0 -0
- data/test/KAT_MCT/table.128 +128 -0
- data/test/KAT_MCT/table.192 +128 -0
- data/test/KAT_MCT/table.256 +128 -0
- data/test/test_helper.rb +14 -0
- data/test/test_ruby-aes.rb +113 -0
- metadata +93 -0
@@ -0,0 +1 @@
|
|
1
|
+
Wed Aug 01 17:32:37 CEST 2007
|
@@ -0,0 +1,117 @@
|
|
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: CHANGELOG</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>CHANGELOG</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>CHANGELOG
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Sun Jul 29 21:54:22 CEST 2007</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<h1>0.1</h1>
|
73
|
+
<h3>2007-07-30</h3>
|
74
|
+
<ul>
|
75
|
+
<li>Initial release: RAA project import
|
76
|
+
|
77
|
+
</li>
|
78
|
+
<li>Added a C extension for speed along the 6 other versions (see README)
|
79
|
+
|
80
|
+
</li>
|
81
|
+
<li>Minor changes in the API
|
82
|
+
|
83
|
+
</li>
|
84
|
+
</ul>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
|
92
|
+
</div>
|
93
|
+
|
94
|
+
|
95
|
+
<!-- if includes -->
|
96
|
+
|
97
|
+
<div id="section">
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
<!-- if method_list -->
|
107
|
+
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
|
112
|
+
<div id="validator-badges">
|
113
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
</body>
|
117
|
+
</html>
|
@@ -0,0 +1,129 @@
|
|
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: COPYING</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>COPYING</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>COPYING
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Sun Jul 29 18:32:22 CEST 2007</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
Copyright © 2007 Alex Boussinet
|
74
|
+
</p>
|
75
|
+
<p>
|
76
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
77
|
+
copy of this software and associated documentation files (the
|
78
|
+
"Software"), to deal in the Software without restriction,
|
79
|
+
including without limitation the rights to use, copy, modify, merge,
|
80
|
+
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
81
|
+
permit persons to whom the Software is furnished to do so, subject to the
|
82
|
+
following conditions:
|
83
|
+
</p>
|
84
|
+
<p>
|
85
|
+
The above copyright notice and this permission notice shall be included in
|
86
|
+
all copies or substantial portions of the Software.
|
87
|
+
</p>
|
88
|
+
<p>
|
89
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
90
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
91
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
92
|
+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
93
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
94
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
95
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
96
|
+
</p>
|
97
|
+
|
98
|
+
</div>
|
99
|
+
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
|
107
|
+
<!-- if includes -->
|
108
|
+
|
109
|
+
<div id="section">
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
<!-- if method_list -->
|
119
|
+
|
120
|
+
|
121
|
+
</div>
|
122
|
+
|
123
|
+
|
124
|
+
<div id="validator-badges">
|
125
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
126
|
+
</div>
|
127
|
+
|
128
|
+
</body>
|
129
|
+
</html>
|
@@ -0,0 +1,235 @@
|
|
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: README</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>README</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>README
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Sun Jul 29 18:32:22 CEST 2007</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
README for ruby-aes
|
74
|
+
</p>
|
75
|
+
<h6>=============</h6>
|
76
|
+
<p>
|
77
|
+
Ruby AES <<a
|
78
|
+
href="http://rubyforge.org/projects/ruby-aes">rubyforge.org/projects/ruby-aes</a>>
|
79
|
+
is an implementation of the Rijndael algorithm.
|
80
|
+
</p>
|
81
|
+
<p>
|
82
|
+
Written by Alex Boussinet <<a
|
83
|
+
href="mailto:alex.boussinet@gmail.com">alex.boussinet@gmail.com</a>>
|
84
|
+
</p>
|
85
|
+
<p>
|
86
|
+
This release is mainly an import from the Ruby Application Archive (RAA).
|
87
|
+
I’ve added all the versions I was working on (algorithm variations)
|
88
|
+
and a new C extension for improved performance. 6 variations are available:
|
89
|
+
</p>
|
90
|
+
<ul>
|
91
|
+
<li>"Normal":
|
92
|
+
|
93
|
+
</li>
|
94
|
+
</ul>
|
95
|
+
<p>
|
96
|
+
Pure Ruby implementation of the Rijndael algorithm specifications. Useful
|
97
|
+
for understanding the algorithm.
|
98
|
+
</p>
|
99
|
+
<ul>
|
100
|
+
<li>"Optimized":
|
101
|
+
|
102
|
+
</li>
|
103
|
+
</ul>
|
104
|
+
<p>
|
105
|
+
Pure Ruby implementation based on the "Normal" code but optimized
|
106
|
+
for speed. The SubBytes and ShiftRows methods have been combined.
|
107
|
+
</p>
|
108
|
+
<ul>
|
109
|
+
<li>"Table Optimized 1":
|
110
|
+
|
111
|
+
</li>
|
112
|
+
</ul>
|
113
|
+
<p>
|
114
|
+
Pure Ruby implementation based on the C code from the Rijndael website. The
|
115
|
+
arrays of constants are bigger because all the operations are already
|
116
|
+
computed so it’s mainly based on table look ups.
|
117
|
+
</p>
|
118
|
+
<ul>
|
119
|
+
<li>"Table Optimized 2":
|
120
|
+
|
121
|
+
</li>
|
122
|
+
</ul>
|
123
|
+
<p>
|
124
|
+
Pure Ruby implementation based on the "Table Optimized 1" code.
|
125
|
+
The arrays of constants are bigger because all the operations are already
|
126
|
+
computed and table look ups are also combined.
|
127
|
+
</p>
|
128
|
+
<ul>
|
129
|
+
<li>"Table Unroll Optimized 1":
|
130
|
+
|
131
|
+
</li>
|
132
|
+
</ul>
|
133
|
+
<p>
|
134
|
+
Pure Ruby implementation based on the "Table Optimized 1" code.
|
135
|
+
The change here is that the loops are unrolled.
|
136
|
+
</p>
|
137
|
+
<ul>
|
138
|
+
<li>"Table Unroll Optimized 2":
|
139
|
+
|
140
|
+
</li>
|
141
|
+
</ul>
|
142
|
+
<p>
|
143
|
+
Pure Ruby implementation based on the "Table Optimized 2" code.
|
144
|
+
The change here is that the loops are unrolled.
|
145
|
+
</p>
|
146
|
+
<ul>
|
147
|
+
<li>"EXT Table Unroll Optimized 2":
|
148
|
+
|
149
|
+
</li>
|
150
|
+
</ul>
|
151
|
+
<p>
|
152
|
+
C extension based on the "Table Unroll Optimized 2" code. This
|
153
|
+
extension is provided for major speed improvement.
|
154
|
+
</p>
|
155
|
+
<p>
|
156
|
+
All those variations share the same API:
|
157
|
+
</p>
|
158
|
+
<pre>
|
159
|
+
Default key_length: 128
|
160
|
+
Default mode: 'ECB'
|
161
|
+
Default IV: 16 null chars ("00" * 16 in hex format)
|
162
|
+
Default key: 16 null chars ("00" * 16 in hex format)
|
163
|
+
Default input text: "PLAINTEXT"
|
164
|
+
|
165
|
+
Aes.check_key(key_string, key_length)
|
166
|
+
Aes.check_iv(iv_string)
|
167
|
+
Aes.check_kl(key_length)
|
168
|
+
Aes.check_mode(mode)
|
169
|
+
Aes.init(key_length, mode, key, iv)
|
170
|
+
Aes.encrypt_block(key_length, mode, key, iv, block) # no padding
|
171
|
+
Aes.decrypt_block(key_length, mode, key, iv, block) # no padding
|
172
|
+
Aes.encrypt_buffer(key_length, mode, key, iv, block) # padding
|
173
|
+
Aes.decrypt_buffer(key_length, mode, key, iv, block) # padding
|
174
|
+
Aes.encrypt_stream(key_length, mode, key, iv, sin, sout)
|
175
|
+
Aes.decrypt_stream(key_length, mode, key, iv, sin, sout)
|
176
|
+
Aes.bs() # block size for read operations (stream)
|
177
|
+
Aes.bs=(bs)
|
178
|
+
</pre>
|
179
|
+
<p>
|
180
|
+
Valid modes are:
|
181
|
+
</p>
|
182
|
+
<pre>
|
183
|
+
* ECB (Electronic Code Book)
|
184
|
+
* CBC (Cipher Block Chaining)
|
185
|
+
* OFB (Output Feedback)
|
186
|
+
* CFB (Cipher Feedback)
|
187
|
+
</pre>
|
188
|
+
<p>
|
189
|
+
Valid key length:
|
190
|
+
</p>
|
191
|
+
<pre>
|
192
|
+
* 128 bits
|
193
|
+
* 192 bits
|
194
|
+
* 256 bits
|
195
|
+
</pre>
|
196
|
+
<p>
|
197
|
+
For a really good encryption, 256 bits CBC is recommanded.
|
198
|
+
</p>
|
199
|
+
<p>
|
200
|
+
For more information on AES-Rijndael, see: <<a
|
201
|
+
href="http://csrc.nist.gov/encryption/aes/rijndael">csrc.nist.gov/encryption/aes/rijndael</a>/>
|
202
|
+
</p>
|
203
|
+
|
204
|
+
</div>
|
205
|
+
|
206
|
+
|
207
|
+
</div>
|
208
|
+
|
209
|
+
|
210
|
+
</div>
|
211
|
+
|
212
|
+
|
213
|
+
<!-- if includes -->
|
214
|
+
|
215
|
+
<div id="section">
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
<!-- if method_list -->
|
225
|
+
|
226
|
+
|
227
|
+
</div>
|
228
|
+
|
229
|
+
|
230
|
+
<div id="validator-badges">
|
231
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
</body>
|
235
|
+
</html>
|