diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-06-28 09:24:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-28 09:24:31 +0800 |
commit | 7369178357a339b5af87ac04aa1256712ff2fdaa (patch) | |
tree | 67b005a5f950d13b3e21bb2aacb759318d8ac46d /activesupport/lib/active_support/key_generator.rb | |
parent | cf8605ad28192af81af08296d4f170076362d281 (diff) | |
parent | 8ee269cf51c58b0600a3fa536219637f240e888d (diff) | |
download | rails-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/lib/active_support/key_generator.rb')
-rw-r--r-- | activesupport/lib/active_support/key_generator.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/key_generator.rb b/activesupport/lib/active_support/key_generator.rb index 7f73f9ddfc..7eafbb571f 100644 --- a/activesupport/lib/active_support/key_generator.rb +++ b/activesupport/lib/active_support/key_generator.rb @@ -15,9 +15,8 @@ module ActiveSupport end # Returns a derived key suitable for use. The default key_size is chosen - # to be compatible with the default settings of ActiveSupport::MessageVerifier. - # i.e. OpenSSL::Digest::SHA1#block_length - def generate_key(salt, key_size=64) + # to be compatible with the acceptable key length of aes-256-cbc, the default cipher. + def generate_key(salt, key_size=32) OpenSSL::PKCS5.pbkdf2_hmac_sha1(@secret, salt, @iterations, key_size) end end @@ -32,9 +31,8 @@ module ActiveSupport end # Returns a derived key suitable for use. The default key_size is chosen - # to be compatible with the default settings of ActiveSupport::MessageVerifier. - # i.e. OpenSSL::Digest::SHA1#block_length - def generate_key(salt, key_size=64) + # 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) end end |