Class: EzCryptoTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/extensions/ezcrypto/ext/test/dsig_test.rb,
lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb

Constant Summary collapse

ALGORITHMS =
["aes128","bf","blowfish","des","des3","rc4","rc2"]
CLEAR_TEXT =
"Lorem ipsum dolor sit amet, suspendisse id interdum mus leo id. Sapien tempus consequat nullam, platea vitae sociis sed elementum et fermentum, vel praesent eget. Sed blandit augue, molestie mus sed habitant, semper voluptatibus neque, nullam a augue. Aptent imperdiet curabitur, quam quis laoreet. Dolor magna. Quis vestibulum amet eu arcu fringilla nibh, mi urna sunt dictumst nulla, elit quisque purus eros, sem hendrerit. Vulputate tortor rhoncus ac nonummy tortor nulla. Nunc id nunc luctus ligula."

Instance Method Summary collapse

Instance Method Details

#_test_generate_keyObject

very slow so not run by default



13
14
15
16
17
18
19
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 13

def _test_generate_key #very slow so not run by default
  signer=EzCrypto::Signer.generate
  assert signer.rsa?
  assert !signer.dsa?
  
  assert_signer(signer)
end

#assert_decrypt(clear) ⇒ Object



192
193
194
195
196
197
198
199
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 192

def assert_decrypt(clear)
  ALGORITHMS.each do |alg|
    key=EzCrypto::Key.generate :algorithm=>alg
    encrypted=key.encrypt clear
    assert_not_nil encrypted
    assert_equal clear,key.decrypt(encrypted)
  end
end

#assert_decrypt64(clear) ⇒ Object



201
202
203
204
205
206
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 201

def assert_decrypt64(clear)
  key=EzCrypto::Key.generate
  encrypted=key.encrypt64 clear
  assert_not_nil encrypted
  assert_equal clear,key.decrypt64(encrypted)
end

#assert_encoded_keys(size) ⇒ Object



178
179
180
181
182
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 178

def assert_encoded_keys(size)
  key=EzCrypto::Key.generate size
  key2=EzCrypto::Key.decode(key.encode)
  assert_equal key.raw, key2.raw    
end

#assert_encrypt(clear) ⇒ Object



184
185
186
187
188
189
190
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 184

def assert_encrypt(clear)
  ALGORITHMS.each do |alg|
    key=EzCrypto::Key.generate :algorithm=>alg
    encrypted=key.encrypt clear
    assert_not_nil encrypted    
  end
end

#assert_file_contains(filename, expected) ⇒ Object



157
158
159
160
161
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 157

def assert_file_contains(filename, expected)
  assert_file_exists(filename)
  content = File.open(filename,'r').read
  assert_equal expected, content
end

#assert_file_exists(filename) ⇒ Object



149
150
151
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 149

def assert_file_exists(filename)
  assert File.exists?(filename)
end

#assert_file_not_exists(filename) ⇒ Object



153
154
155
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 153

def assert_file_not_exists(filename)
  assert !File.exists?(filename)
end

#assert_file_permissions(filename, mode, msg = '') ⇒ Object



144
145
146
147
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 144

def assert_file_permissions(filename, mode, msg='')
  fmode = File.stat(filename).mode
  assert_equal fmode, mode, msg 
end

#assert_generate_alg_key(algorithm, size) ⇒ Object



167
168
169
170
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 167

def assert_generate_alg_key(algorithm,size)
  key=EzCrypto::Key.generate :algorithm=>algorithm
  assert_key_size size,key 
end

#assert_key_size(size, key) ⇒ Object



163
164
165
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 163

def assert_key_size(size,key)
  assert_equal size,key.raw.size      
end

#assert_signer(signer) ⇒ Object

Disabling these until pkyp is back up

def test_public_key_load_from_pkyp
  verifier=EzCrypto::Verifier.from_pkyp "e93e18114cbefaaa89fda908b09df63d3662879a"
  agree2=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/agree2.com.cert"
  assert_equal agree2.cert.to_s,verifier.cert.to_s
  assert verifier
end

def test_register_public_key_at_pkyp
  pub=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/agree2.com.cert"
  assert_equal pub.digest,pub.register_with_pkyp
end

def test_create_register_and_fetch_public_key
  signer=EzCrypto::Signer.generate
  assert_equal signer.verifier.digest,signer.verifier.register_with_pkyp
  verifier=EzCrypto::Verifier.from_pkyp signer.verifier.digest
  sig=signer.sign "hello"
  assert sig
  assert verifier.verify( sig,"hello")    
end


278
279
280
281
282
283
284
285
286
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 278

def assert_signer(signer)
  assert signer
  assert signer.public_key
  
  sig=signer.sign "hello"
  assert sig
  assert signer.verifier
  assert signer.verifier.verify( sig,"hello")
end

#assert_with_password(password, salt, algorithm, size) ⇒ Object



172
173
174
175
176
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 172

def assert_with_password(password,salt,algorithm,size)
  key=EzCrypto::Key.with_password password,salt,:algorithm=>algorithm
  assert_key_size size,key
  assert_equal key.raw,EzCrypto::Key.with_password( password,salt,:algorithm=>algorithm).raw
end

#setupObject



10
11
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 10

def setup
end

#test_certificate_readerObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 69

def test_certificate_reader
  signer=EzCrypto::Signer.from_file File.dirname(__FILE__) + "/testsigner.pem"
  cert=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/testsigner.cert"
  assert cert
  assert cert.cert?
  assert_instance_of EzCrypto::Certificate, cert
  assert_equal signer.public_key.to_s, cert.public_key.to_s
  
  sig=signer.sign "hello"
  assert sig
  assert cert.verify( sig,"hello")
  
  assert_equal "/C=DK/ST=Denmark/L=Copenhagen/O=EzCrypto Test Certificate/OU=testing/CN=EzCrypto Testing/[email protected]",cert.subject.to_s
  assert_equal "/C=DK/ST=Denmark/L=Copenhagen/O=EzCrypto Test Certificate/OU=testing/CN=EzCrypto Testing/[email protected]",cert.issuer.to_s
  
  assert_kind_of EzCrypto::Name,cert.issuer
  assert_kind_of EzCrypto::Name,cert.subject
  assert cert.serial
  assert cert.not_after
  assert cert.not_before
  assert cert.valid?
  
  
  assert_equal cert.subject[:emailAddress],"[email protected]"
  assert_equal cert.subject[:C],"DK"
  assert_equal cert.subject[:ST],"Denmark"
  assert_equal cert.subject[:L],"Copenhagen"
  assert_equal cert.subject[:OU],"testing"
  assert_equal cert.subject[:O],"EzCrypto Test Certificate"
  assert_equal cert.subject[:CN],"EzCrypto Testing"

  assert_equal cert.subject.emailAddress,"[email protected]"
  assert_equal cert.subject.C,"DK"
  assert_equal cert.subject.ST,"Denmark"
  assert_equal cert.subject.L,"Copenhagen"
  assert_equal cert.subject.OU,"testing"
  assert_equal cert.subject.O,"EzCrypto Test Certificate"
  assert_equal cert.subject.CN,"EzCrypto Testing"

  assert_equal cert.subject.email,"[email protected]"
  assert_equal cert.subject.c,"DK"
  assert_equal cert.subject.st,"Denmark"
  assert_equal cert.subject.l,"Copenhagen"
  assert_equal cert.subject.ou,"testing"
  assert_equal cert.subject.o,"EzCrypto Test Certificate"
  assert_equal cert.subject.cn,"EzCrypto Testing"

  assert_equal cert.subject.country,"DK"
  assert_equal cert.subject.state,"Denmark"
  assert_equal cert.subject.locality,"Copenhagen"
  assert_equal cert.subject.organisational_unit,"testing"
  assert_equal cert.subject.organisation,"EzCrypto Test Certificate"
  assert_equal cert.subject.organizational_unit,"testing"
  assert_equal cert.subject.organization,"EzCrypto Test Certificate"
  assert_equal cert.subject.name,"EzCrypto Testing"
  assert_equal cert.subject.common_name,"EzCrypto Testing"

  assert_equal cert.emailAddress,"[email protected]"
  assert_equal cert.C,"DK"
  assert_equal cert.ST,"Denmark"
  assert_equal cert.L,"Copenhagen"
  assert_equal cert.OU,"testing"
  assert_equal cert.O,"EzCrypto Test Certificate"
  assert_equal cert.CN,"EzCrypto Testing"
                   
  assert_equal cert.email,"[email protected]"
  assert_equal cert.c,"DK"
  assert_equal cert.st,"Denmark"
  assert_equal cert.l,"Copenhagen"
  assert_equal cert.ou,"testing"
  assert_equal cert.o,"EzCrypto Test Certificate"
  assert_equal cert.cn,"EzCrypto Testing"
                   
  assert_equal cert.country,"DK"
  assert_equal cert.state,"Denmark"
  assert_equal cert.locality,"Copenhagen"
  assert_equal cert.organisational_unit,"testing"
  assert_equal cert.organisation,"EzCrypto Test Certificate"
  assert_equal cert.organizational_unit,"testing"
  assert_equal cert.organization,"EzCrypto Test Certificate"
  assert_equal cert.name,"EzCrypto Testing"
  assert_equal cert.common_name,"EzCrypto Testing"

  assert_equal cert.issuer[:emailAddress],"[email protected]"
  assert_equal cert.issuer[:C],"DK"
  assert_equal cert.issuer[:ST],"Denmark"
  assert_equal cert.issuer[:L],"Copenhagen"
  assert_equal cert.issuer[:OU],"testing"
  assert_equal cert.issuer[:O],"EzCrypto Test Certificate"
  assert_equal cert.issuer[:CN],"EzCrypto Testing"

  assert_equal cert.issuer.emailAddress,"[email protected]"
  assert_equal cert.issuer.C,"DK"
  assert_equal cert.issuer.ST,"Denmark"
  assert_equal cert.issuer.L,"Copenhagen"
  assert_equal cert.issuer.OU,"testing"
  assert_equal cert.issuer.O,"EzCrypto Test Certificate"
  assert_equal cert.issuer.CN,"EzCrypto Testing"

  assert_equal cert.issuer.email,"[email protected]"
  assert_equal cert.issuer.c,"DK"
  assert_equal cert.issuer.st,"Denmark"
  assert_equal cert.issuer.l,"Copenhagen"
  assert_equal cert.issuer.ou,"testing"
  assert_equal cert.issuer.o,"EzCrypto Test Certificate"
  assert_equal cert.issuer.cn,"EzCrypto Testing"
  assert_equal cert.issuer.country,"DK"
  assert_equal cert.issuer.state,"Denmark"
  assert_equal cert.issuer.locality,"Copenhagen"
  assert_equal cert.issuer.organisational_unit,"testing"
  assert_equal cert.issuer.organisation,"EzCrypto Test Certificate"
  assert_equal cert.issuer.organizational_unit,"testing"
  assert_equal cert.issuer.organization,"EzCrypto Test Certificate"
  assert_equal cert.issuer.name,"EzCrypto Testing"
  assert_equal cert.issuer.common_name,"EzCrypto Testing"
  
  ## Extensions
  
  assert cert.extensions
  
end

#test_decryptObject



54
55
56
57
58
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 54

def test_decrypt    
  0.upto(CLEAR_TEXT.size) do |size|
    assert_decrypt CLEAR_TEXT[0..size]
  end  
end

#test_decrypt64Object



60
61
62
63
64
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 60

def test_decrypt64
  0.upto(CLEAR_TEXT.size) do |size|
    assert_decrypt64 CLEAR_TEXT[0..size]
  end  
end

#test_disk_storeObject



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 214

def test_disk_store
  trust=EzCrypto::TrustStore.new File.dirname(__FILE__) + "/store"
  sf_root=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/sf-class2-root.crt"
  trust.add(sf_root)
  assert trust.verify(sf_root)
  starfield=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/sf_intermediate.crt"
  assert trust.verify(starfield)
  trust.add(starfield)
  agree2=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/agree2.com.cert"
  assert trust.verify(agree2)
  
  cert=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/testsigner.cert"
  assert !trust.verify(cert)
  trust.add cert
  assert trust.verify(cert)
end

#test_dsa_from_fileObject



28
29
30
31
32
33
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 28

def test_dsa_from_file
  signer=EzCrypto::Signer.from_file File.dirname(__FILE__) + "/dsakey.pem"
  assert signer.dsa?
  assert !signer.rsa?
  assert_signer(signer)
end

#test_dsa_public_key_readObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 54

def test_dsa_public_key_read
  signer=EzCrypto::Signer.from_file File.dirname(__FILE__) + "/dsakey.pem"
  verifier=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/dsapubkey.pem"
  
  assert verifier
  sig=signer.sign "test this dsa"
  assert sig
  assert verifier.verify( sig,"test this dsa")

  assert !verifier.cert?
  
  # This fails as it seems like it returns an incorrect public key
#    assert_equal signer.public_key.to_s, verifier.public_key.to_s
end

#test_encodedObject



42
43
44
45
46
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 42

def test_encoded
  0.upto 32 do |size|
    assert_encoded_keys size
  end
end

#test_encryptObject



48
49
50
51
52
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 48

def test_encrypt    
  0.upto(CLEAR_TEXT.size-1) do |size|
    assert_encrypt CLEAR_TEXT[0..size]
  end  
end

#test_filestuff_with_defaultsObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 84

def test_filestuff_with_defaults      

  clearfile = 'lorem_ipsum.txt'
  keyfile = 'lorem_ipsum.key'
  algo, size = "aes-256-cbc", 32
  
  File.open(clearfile, 'w') { |f| f.write(CLEAR_TEXT) }
  assert_file_contains clearfile, CLEAR_TEXT    

  key = EzCrypto::Key.generate :algorithm => algo    

  # default behaviour: remove clearfile, append '.ez' suffix  
  cryptfile = key.encrypt_file(clearfile)    
  assert_equal cryptfile, clearfile + ".ez"
  assert_file_not_exists clearfile
  assert_file_exists cryptfile 
  assert_file_contains cryptfile, key.encrypt(CLEAR_TEXT)    

  # default behaviour: unlink cryptfile and remove suffix from filename
  clearfile = key.decrypt_file cryptfile
  assert_file_exists clearfile
  assert_file_not_exists cryptfile
  assert_file_contains clearfile, CLEAR_TEXT    
  FileUtils.rm [keyfile, clearfile, cryptfile], :force => true
end

#test_filestuff_with_optionsObject



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 110

def test_filestuff_with_options

  clearfile = 'lorem_ipsum.txt'
  keyfile = 'lorem_ipsum.key'
  algo, size = "aes-256-cbc", 32    

  File.open(clearfile, 'w') { |f| f.write(CLEAR_TEXT) }
  assert_file_contains clearfile, CLEAR_TEXT
  
  key = EzCrypto::Key.generate :algorithm => algo      
  
  # with options: keep the original file, auto-create a 
  # new filename with a user-defined suffix        
  cryptfile = key.encrypt_file(clearfile, nil, :autoclean => false, :suffix => '.Encrypted')
  assert_equal cryptfile, clearfile + ".Encrypted", 'suffix was added'
  assert_file_exists clearfile
  assert_file_exists cryptfile    
  assert_file_permissions cryptfile, 0100600
  
  assert_raises(Errno::EEXIST, "the original file would not be overwritten") { 
    key.decrypt_file(cryptfile, nil, :autoclean => false, :suffix => '.Encrypted')
  } 
  FileUtils.rm [clearfile], :force => true    

  clearfile = key.decrypt_file(cryptfile, nil, :autoclean => false, :suffix => '.Encrypted')
  assert_equal cryptfile, clearfile + ".Encrypted", 'suffix was removed'    
  assert_file_exists clearfile
  assert_file_exists cryptfile
  assert_file_permissions cryptfile, 0100600    
  assert_file_contains clearfile, CLEAR_TEXT    

  FileUtils.rm [keyfile, clearfile, cryptfile], :force => true        
end

#test_from_fileObject



21
22
23
24
25
26
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 21

def test_from_file
  signer=EzCrypto::Signer.from_file File.dirname(__FILE__) + "/testsigner.pem"
  assert signer.rsa?
  assert !signer.dsa?
  assert_signer(signer)
end

#test_from_password_protected_fileObject



35
36
37
38
39
40
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 35

def test_from_password_protected_file
  signer=EzCrypto::Signer.from_file File.dirname(__FILE__) + "/protectedsigner.pem","secret"
  assert signer.rsa?
  assert !signer.dsa?
  assert_signer(signer)
end

#test_generate_alg_keyObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 13

def test_generate_alg_key
  assert_generate_alg_key "aes-128-cbc",16
  assert_generate_alg_key "aes-192-cbc",24
  assert_generate_alg_key "aes-256-cbc",32    
  assert_generate_alg_key "rc2-40-cbc",5 
  assert_generate_alg_key "rc2-64-cbc",8
  assert_generate_alg_key "rc4-64" ,8
  assert_generate_alg_key "blowfish" ,16
  assert_generate_alg_key "des" ,8
end

#test_in_memory_storeObject



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 191

def test_in_memory_store
  trust=EzCrypto::TrustStore.new
  cert=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/testsigner.cert"
  assert !trust.verify(cert)
  trust.add cert
  assert trust.verify(cert)
  
  sf_root=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/sf-class2-root.crt"
  assert !trust.verify(sf_root)
  starfield=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/sf_intermediate.crt"
  assert !trust.verify(starfield)
  agree2=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/agree2.com.cert"
  assert !trust.verify(agree2)
  
  trust.add sf_root
  assert trust.verify(sf_root)
  assert trust.verify(starfield)
  assert !trust.verify(agree2)
  
  trust.add starfield
  assert trust.verify(agree2)
end

#test_keyfile_store_loadObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 66

def test_keyfile_store_load

  algo, size = "aes-256-cbc", 32   
  keyfile = 'ezcrypto-test.key'
  
  FileUtils.rm [keyfile], :force => true
  key = EzCrypto::Key.generate :algorithm => algo    
  assert_file_not_exists keyfile    
  key.store keyfile    
  assert_file_exists keyfile    
  assert_file_permissions keyfile, 0100400    
  
  key2 = EzCrypto::Key.load(keyfile)    
  assert_equal key.raw, key2.raw
  
  FileUtils.rm [keyfile], :force => true    
end

#test_load_combinedObject



231
232
233
234
235
236
237
238
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 231

def test_load_combined
  certs=EzCrypto::Verifier.load_all_from_file File.dirname(__FILE__) + "/../lib/trusted.pem"
  assert certs.is_a?( Array)
  assert certs.size>1
  certs.each do |cert|
    assert_instance_of EzCrypto::Certificate, cert
  end
end

#test_load_trusted_truststoreObject



240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 240

def test_load_trusted_truststore
  trust=EzCrypto::TrustStore.default_trusted
  sf_root=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/sf-class2-root.crt"
  assert trust.verify(sf_root)
  starfield=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/sf_intermediate.crt"
  assert trust.verify(starfield)
  agree2=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/agree2.com.cert"
  assert trust.verify(agree2)
  
  cert=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/testsigner.cert"
  assert !trust.verify(cert)
  trust.add cert
  assert trust.verify(cert)  
end

#test_public_key_readObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/extensions/ezcrypto/ext/test/dsig_test.rb', line 42

def test_public_key_read
  signer=EzCrypto::Signer.from_file File.dirname(__FILE__) + "/testsigner.pem"
  verifier=EzCrypto::Verifier.from_file File.dirname(__FILE__) + "/testpub.pem"
  assert verifier
  sig=signer.sign "test this rsa"
  assert sig
  assert verifier.verify( sig,"test this rsa")

  assert !verifier.cert?
  assert_equal signer.public_key.to_s, verifier.public_key.to_s
end

#test_with_passwordObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb', line 24

def test_with_password
    assert_with_password "","secret","aes-128-cbc",16
    assert_with_password "test","secret","aes-128-cbc",16
    assert_with_password "password","secret","aes-128-cbc",16
    assert_with_password "a�sldfad8q5�34j2�l4j24l6j2456","secret","aes-128-cbc",16
    
    assert_with_password "","secret","aes-192-cbc",24
    assert_with_password "test","secret","aes-192-cbc",24
    assert_with_password "password","secret","aes-192-cbc",24
    assert_with_password "a�sldfad8q5�34j2�l4j24l6j2456","secret","aes-192-cbc",24

    assert_with_password "","secret","aes-256-cbc",32
    assert_with_password "test","secret","aes-256-cbc",32
    assert_with_password "password","secret","aes-256-cbc",32
    assert_with_password "a�sldfad8q5�34j2�l4j24l6j2456","secret","aes-256-cbc",32

end