aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-06-28 09:24:31 +0800
committerGitHub <noreply@github.com>2016-06-28 09:24:31 +0800
commit7369178357a339b5af87ac04aa1256712ff2fdaa (patch)
tree67b005a5f950d13b3e21bb2aacb759318d8ac46d /activesupport/test
parentcf8605ad28192af81af08296d4f170076362d281 (diff)
parent8ee269cf51c58b0600a3fa536219637f240e888d (diff)
downloadrails-7369178357a339b5af87ac04aa1256712ff2fdaa.tar.gz
rails-7369178357a339b5af87ac04aa1256712ff2fdaa.tar.bz2
rails-7369178357a339b5af87ac04aa1256712ff2fdaa.zip
Merge pull request #25192 from vipulnsward/25185-default-key-length
Fix default key length on cipher
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/key_generator_test.rb2
-rw-r--r--activesupport/test/message_encryptor_test.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/activesupport/test/key_generator_test.rb b/activesupport/test/key_generator_test.rb
index f7e8e9a795..6cf72f1fec 100644
--- a/activesupport/test/key_generator_test.rb
+++ b/activesupport/test/key_generator_test.rb
@@ -19,7 +19,7 @@ class KeyGeneratorTest < ActiveSupport::TestCase
test "Generating a key of the default length" do
derived_key = @generator.generate_key("some_salt")
assert_kind_of String, derived_key
- assert_equal OpenSSL::Digest::SHA1.new.block_length, derived_key.length, "Should have generated a key of the default size"
+ assert_equal OpenSSL::Cipher.new('aes-256-cbc').key_len, derived_key.length, "Should have generated a key of the default size"
end
test "Generating a key of an alternative length" do
diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb
index eb71369397..a1ff4c1d3e 100644
--- a/activesupport/test/message_encryptor_test.rb
+++ b/activesupport/test/message_encryptor_test.rb
@@ -15,7 +15,7 @@ class MessageEncryptorTest < ActiveSupport::TestCase
end
def setup
- @secret = SecureRandom.hex(64)
+ @secret = SecureRandom.random_bytes(32)
@verifier = ActiveSupport::MessageVerifier.new(@secret, :serializer => ActiveSupport::MessageEncryptor::NullSerializer)
@encryptor = ActiveSupport::MessageEncryptor.new(@secret)
@data = { :some => "data", :now => Time.local(2010) }
@@ -51,7 +51,7 @@ class MessageEncryptorTest < ActiveSupport::TestCase
def test_alternative_serialization_method
prev = ActiveSupport.use_standard_json_time_format
ActiveSupport.use_standard_json_time_format = true
- encryptor = ActiveSupport::MessageEncryptor.new(SecureRandom.hex(64), SecureRandom.hex(64), :serializer => JSONSerializer.new)
+ encryptor = ActiveSupport::MessageEncryptor.new(SecureRandom.random_bytes(32), SecureRandom.random_bytes(128), :serializer => JSONSerializer.new)
message = encryptor.encrypt_and_sign({ :foo => 123, 'bar' => Time.utc(2010) })
exp = { "foo" => 123, "bar" => "2010-01-01T00:00:00.000Z" }
assert_equal exp, encryptor.decrypt_and_verify(message)