ruby-aes-cext 1.1-i486-linux

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,12 @@
1
+ = 1.1
2
+
3
+ === 2008-01-05
4
+ * Fixed padding problem (bug #15885)
5
+ * Fixed encrypt/decrypt stream
6
+
7
+ = 1.0
8
+
9
+ === 2007-07-30
10
+ * Initial release: RAA project import
11
+ * Added a C extension for speed along the 6 other versions (see README)
12
+ * Minor changes in the API
data/COPYING ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 Alex Boussinet
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,77 @@
1
+ README for ruby-aes
2
+ ===================
3
+
4
+ Ruby AES <http://rubyforge.org/projects/ruby-aes> is an implementation of the Rijndael algorithm.
5
+
6
+ Written by Alex Boussinet <mailto:alex.boussinet@gmail.com>
7
+
8
+ This release is mainly an import from the Ruby Application Archive (RAA).
9
+ I've added all the versions I was working on (algorithm variations) and a new
10
+ C extension for improved performance.
11
+ 6 variations are available:
12
+
13
+ * "Normal":
14
+ Pure Ruby implementation of the Rijndael algorithm specifications.
15
+ Useful for understanding the algorithm.
16
+
17
+ * "Optimized":
18
+ Pure Ruby implementation based on the "Normal" code but optimized for speed.
19
+ The SubBytes and ShiftRows methods have been combined.
20
+
21
+ * "Table Optimized 1":
22
+ Pure Ruby implementation based on the C code from the Rijndael website.
23
+ The arrays of constants are bigger because all the operations are
24
+ already computed so it's mainly based on table look ups.
25
+
26
+ * "Table Optimized 2":
27
+ Pure Ruby implementation based on the "Table Optimized 1" code.
28
+ The arrays of constants are bigger because all the operations are
29
+ already computed and table look ups are also combined.
30
+
31
+ * "Table Unroll Optimized 1":
32
+ Pure Ruby implementation based on the "Table Optimized 1" code.
33
+ The change here is that the loops are unrolled.
34
+
35
+ * "Table Unroll Optimized 2":
36
+ Pure Ruby implementation based on the "Table Optimized 2" code.
37
+ The change here is that the loops are unrolled.
38
+
39
+ * "EXT Table Unroll Optimized 2":
40
+ C extension based on the "Table Unroll Optimized 2" code.
41
+ This extension is provided for major speed improvement.
42
+
43
+ All those variations share the same API:
44
+ Default key_length: 128
45
+ Default mode: 'ECB'
46
+ Default IV: 16 null chars ("00" * 16 in hex format)
47
+ Default key: 16 null chars ("00" * 16 in hex format)
48
+ Default input text: "PLAINTEXT"
49
+
50
+ Aes.check_key(key_string, key_length)
51
+ Aes.check_iv(iv_string)
52
+ Aes.check_kl(key_length)
53
+ Aes.check_mode(mode)
54
+ Aes.init(key_length, mode, key, iv)
55
+ Aes.encrypt_block(key_length, mode, key, iv, block) # no padding
56
+ Aes.decrypt_block(key_length, mode, key, iv, block) # no padding
57
+ Aes.encrypt_buffer(key_length, mode, key, iv, block) # padding
58
+ Aes.decrypt_buffer(key_length, mode, key, iv, block) # padding
59
+ Aes.encrypt_stream(key_length, mode, key, iv, sin, sout)
60
+ Aes.decrypt_stream(key_length, mode, key, iv, sin, sout)
61
+ Aes.bs() # block size for read operations (stream)
62
+ Aes.bs=(bs)
63
+
64
+ Valid modes are:
65
+ * ECB (Electronic Code Book)
66
+ * CBC (Cipher Block Chaining)
67
+ * OFB (Output Feedback)
68
+ * CFB (Cipher Feedback)
69
+
70
+ Valid key length:
71
+ * 128 bits
72
+ * 192 bits
73
+ * 256 bits
74
+
75
+ For a really good encryption, 256 bits CBC is recommanded.
76
+
77
+ For more information on AES-Rijndael, see: <http://csrc.nist.gov/encryption/aes/rijndael/>
data/Rakefile ADDED
@@ -0,0 +1,154 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'rake/gempackagetask'
5
+ require 'rake/rdoctask'
6
+ require 'fileutils'
7
+
8
+ include FileUtils
9
+
10
+ @name = 'ruby-aes'
11
+ @version = '1.1'
12
+ @native = false
13
+
14
+ @lib = "lib/#{@name}"
15
+ @ext = "ext/#{@name}"
16
+ @ext_o = 'aes_alg.o'
17
+ @ext_so = "aes_alg.#{Config::CONFIG['DLEXT']}"
18
+
19
+ RDOC_OPTS = ['--quiet',
20
+ '--title', 'ruby-aes reference',
21
+ '--opname', 'index.html',
22
+ '--exclude', 'ext',
23
+ '--line-numbers',
24
+ '--main', 'README',
25
+ '--inline-source']
26
+
27
+ CLEAN.include [
28
+ '**/.*.sw?', '*.gem', '.config', '**/.DS_Store',
29
+ "#{@ext}/#{@ext_so}", "#{@ext}/#{@ext_o}",
30
+ "#{@ext}/Makefile", "#{@ext}/aes_cons.h", "#{@ext}/mkmf.log",
31
+ "#{@lib}/aes_alg.rb", "#{@lib}/aes_cons.rb", "#{@lib}/aes_gencons.rb"
32
+ ]
33
+
34
+ SPEC = Gem::Specification.new do |s|
35
+ s.name = @name
36
+ s.version = @version
37
+ s.platform = Gem::Platform::RUBY
38
+ s.has_rdoc = true
39
+ s.rdoc_options += RDOC_OPTS
40
+ s.extra_rdoc_files = ['README', 'CHANGELOG', 'COPYING']
41
+ s.summary = 'ruby-aes is an implementation of the Rijndael algorithm (AES)'
42
+ s.description = s.summary
43
+ s.author = 'Alex Boussinet'
44
+ s.email = 'alex.boussinet@gmail.com'
45
+ s.homepage = "http://#{@name}.rubyforge.org"
46
+ s.rubyforge_project = @name
47
+ s.test_files = FileList['test/test_*.rb']
48
+ s.require_paths = ['lib']
49
+ # s.bindir = 'bin'
50
+ s.files = %w(CHANGELOG COPYING README Rakefile) +
51
+ Dir.glob('{doc,examples,lib,test}/**/*')
52
+ end
53
+
54
+ def task_gem
55
+ desc 'Build the gem'
56
+ Rake::GemPackageTask.new(SPEC) do |p|
57
+ p.need_tar = true
58
+ p.gem_spec = SPEC
59
+ end
60
+ end
61
+
62
+ Dir.glob('extras/*').each do |project|
63
+ desc "Specify the project to use"
64
+ task File.basename(project).to_sym do |t|
65
+ @type = t.name
66
+
67
+ @gem_name = "#{@name}-#{@type}"
68
+ SPEC.name = @gem_name
69
+ SPEC.files += [ "#{@lib}/aes_alg.rb", "#{@lib}/aes_cons.rb" ]
70
+ task_gem
71
+ end
72
+ end
73
+
74
+ desc "Specify the project to use"
75
+ task :cext do |t|
76
+ @type = t.name
77
+
78
+ @gem_name = "#{@name}-#{@type}"
79
+ SPEC.name = @gem_name
80
+ SPEC.require_paths += ['ext']
81
+ if @native
82
+ SPEC.files += ["#{@ext}/#{@ext_so}"]
83
+ SPEC.platform = Gem::Platform::CURRENT
84
+ else
85
+ SPEC.files += [ "#{@ext}/aes_alg.c", "#{@ext}/extconf.rb", "#{@ext}/aes_cons.h" ]
86
+ SPEC.extensions = "#{@ext}/extconf.rb"
87
+ end
88
+ task_gem
89
+ end
90
+ desc "Use the native version of cext"
91
+ task :native do
92
+ @native = true
93
+ Rake::Task[:cext].invoke
94
+ end
95
+
96
+ task :prepare do
97
+ if @type == 'cext'
98
+ Dir.chdir(@ext) do
99
+ ruby 'aes_gencons.rb'
100
+ if @native
101
+ ruby 'extconf.rb'
102
+ sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
103
+ end
104
+ end
105
+ else
106
+ cp "extras/#{@type}/aes_alg.rb", "#{@lib}/"
107
+ cp "extras/#{@type}/aes_gencons.rb", "#{@lib}/"
108
+ Dir.chdir(@lib) do
109
+ ruby 'aes_gencons.rb'
110
+ rm_f 'aes_gencons.rb'
111
+ end
112
+ end
113
+ end
114
+
115
+ task :package => [:clean, :prepare, :rerdoc]
116
+
117
+ task :default do
118
+ STDERR.puts <<-EOM
119
+ You must call rake with one of this task as first param:
120
+ normal
121
+ optimized
122
+ table1
123
+ table2
124
+ unroll1
125
+ unroll2
126
+ cext
127
+ native (imply cext)
128
+ EOM
129
+ end
130
+
131
+ desc 'Run all the tests'
132
+ Rake::TestTask.new do |t|
133
+ t.libs << "test"
134
+ t.test_files = FileList['test/test_*.rb']
135
+ t.verbose = true
136
+ end
137
+
138
+ desc 'Build the documentation'
139
+ Rake::RDocTask.new do |rdoc|
140
+ rdoc.rdoc_dir = 'doc/rdoc'
141
+ rdoc.options += RDOC_OPTS
142
+ rdoc.main = 'README'
143
+ rdoc.rdoc_files.add ['README', 'CHANGELOG', 'COPYING', 'lib/**/*.rb']
144
+ end
145
+
146
+ desc 'Install the package'
147
+ task :install do |t|
148
+ sh %{sudo gem install pkg/#{@gem_name}}
149
+ end
150
+
151
+ desc 'Uninstall the package'
152
+ task :uninstall do
153
+ sh %{sudo gem uninstall #{@gem_name}}
154
+ end