kingpong-ruby-mcrypt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest +14 -0
- data/README.rdoc +85 -0
- data/Rakefile +16 -0
- data/ext/extconf.rb +33 -0
- data/ext/mcrypt_wrapper.c +581 -0
- data/lib/mcrypt.rb +472 -0
- data/ruby-mcrypt.gemspec +32 -0
- data/test/generate/Makefile +11 -0
- data/test/generate/generate_testcases.c +389 -0
- data/test/helper.rb +13 -0
- data/test/test_all.rb +5 -0
- data/test/test_basics.rb +216 -0
- data/test/test_brute.rb +3386 -0
- data/test/test_reciprocity.rb +50 -0
- metadata +76 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__),"helper.rb")
|
4
|
+
|
5
|
+
class McryptReciprocityTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def generate(len)
|
8
|
+
"0" * len
|
9
|
+
end
|
10
|
+
|
11
|
+
def make_mcrypt(algo,mode,padding)
|
12
|
+
mc = Mcrypt.new(algo,mode)
|
13
|
+
mc.key = generate(mc.key_size)
|
14
|
+
mc.iv = generate(mc.iv_size) if mc.has_iv?
|
15
|
+
mc.padding = padding
|
16
|
+
mc
|
17
|
+
end
|
18
|
+
|
19
|
+
# test a few algorithms
|
20
|
+
# with both stream and block modes,
|
21
|
+
# with different padding implementations
|
22
|
+
# with different input sizes
|
23
|
+
# with on-boundary and off-boundary
|
24
|
+
|
25
|
+
[:tripledes,:twofish,:rijndael_256].each do |algorithm|
|
26
|
+
[:cbc, :cfb, :ecb].each do |mode|
|
27
|
+
[:zeros,:pkcs,:none].each do |padding_type|
|
28
|
+
[1,2,3].each do |blocks|
|
29
|
+
|
30
|
+
define_method("test_#{algorithm}_#{mode}_#{padding_type}_#{blocks}_on_boundary") do
|
31
|
+
mc = make_mcrypt(algorithm,mode,padding_type)
|
32
|
+
plaintext = generate(mc.block_size * blocks)
|
33
|
+
assert_equal plaintext, mc.decrypt(mc.encrypt(plaintext))
|
34
|
+
end
|
35
|
+
|
36
|
+
# off-boundary only works without padding for stream modes
|
37
|
+
if padding_type != :none || Mcrypt.stream_mode?(mode)
|
38
|
+
define_method("test_#{algorithm}_#{mode}_#{padding_type}_#{blocks}_off_boundary") do
|
39
|
+
mc = make_mcrypt(algorithm,mode,padding_type)
|
40
|
+
plaintext = generate((mc.block_size * blocks) - 1)
|
41
|
+
assert_equal plaintext, mc.decrypt(mc.encrypt(plaintext))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kingpong-ruby-mcrypt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Philip Garrett
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-09 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Ruby bindings for libmcrypt
|
17
|
+
email: philip@pastemagazine.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
- ext/extconf.rb
|
25
|
+
- ext/mcrypt_wrapper.c
|
26
|
+
- lib/mcrypt.rb
|
27
|
+
files:
|
28
|
+
- Manifest
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- ext/extconf.rb
|
32
|
+
- ext/mcrypt_wrapper.c
|
33
|
+
- lib/mcrypt.rb
|
34
|
+
- ruby-mcrypt.gemspec
|
35
|
+
- test/generate/Makefile
|
36
|
+
- test/generate/generate_testcases.c
|
37
|
+
- test/helper.rb
|
38
|
+
- test/test_all.rb
|
39
|
+
- test/test_basics.rb
|
40
|
+
- test/test_brute.rb
|
41
|
+
- test/test_reciprocity.rb
|
42
|
+
has_rdoc: false
|
43
|
+
homepage: http://github.com/kingpong/ruby-mcrypt
|
44
|
+
licenses:
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --line-numbers
|
48
|
+
- --inline-source
|
49
|
+
- --title
|
50
|
+
- Ruby-mcrypt
|
51
|
+
- --main
|
52
|
+
- README.rdoc
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
- ext
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "1.2"
|
67
|
+
version:
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project: ruby-mcrypt
|
71
|
+
rubygems_version: 1.3.5
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: ruby-mcrypt 0.0.1
|
75
|
+
test_files:
|
76
|
+
- test/test_all.rb
|