aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-07-01 02:06:12 +0930
committerGitHub <noreply@github.com>2016-07-01 02:06:12 +0930
commit0c95a918fe9bfb24d46748bdb5f05af7f2fd785b (patch)
tree5b2bed6b9bce6cad96e1ad74d6c63cbac37e2f80 /activesupport/lib
parent11841527fc34a91feb113ffaf9065bd4993b6066 (diff)
parentea7fee03f78dfeac44b3a80f6fd61bf314b5a369 (diff)
downloadrails-0c95a918fe9bfb24d46748bdb5f05af7f2fd785b.tar.gz
rails-0c95a918fe9bfb24d46748bdb5f05af7f2fd785b.tar.bz2
rails-0c95a918fe9bfb24d46748bdb5f05af7f2fd785b.zip
Merge pull request #25602 from matthewd/restore-key-generator
Partially revert #25192
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/key_generator.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/key_generator.rb b/activesupport/lib/active_support/key_generator.rb
index 7eafbb571f..0f0e931c06 100644
--- a/activesupport/lib/active_support/key_generator.rb
+++ b/activesupport/lib/active_support/key_generator.rb
@@ -15,8 +15,9 @@ module ActiveSupport
end
# Returns a derived key suitable for use. The default key_size is chosen
- # to be compatible with the acceptable key length of aes-256-cbc, the default cipher.
- def generate_key(salt, key_size=32)
+ # to be compatible with the default settings of ActiveSupport::MessageVerifier.
+ # i.e. OpenSSL::Digest::SHA1#block_length
+ def generate_key(salt, key_size=64)
OpenSSL::PKCS5.pbkdf2_hmac_sha1(@secret, salt, @iterations, key_size)
end
end
@@ -30,10 +31,9 @@ module ActiveSupport
@cache_keys = Concurrent::Map.new
end
- # Returns a derived key suitable for use. The default key_size is chosen
- # to be compatible with the acceptable key length of aes-256-cbc, the default cipher.
- def generate_key(salt, key_size=32)
- @cache_keys["#{salt}#{key_size}"] ||= @key_generator.generate_key(salt, key_size)
+ # Returns a derived key suitable for use.
+ def generate_key(*args)
+ @cache_keys[args.join] ||= @key_generator.generate_key(*args)
end
end