lib/symmetric_encryption/keystore.rb in symmetric-encryption-4.0.0 vs lib/symmetric_encryption/keystore.rb in symmetric-encryption-4.0.1
- old
+ new
@@ -1,12 +1,13 @@
module SymmetricEncryption
+ # Encryption keys are secured in Keystores
module Keystore
- #@formatter:off
+ # @formatter:off
autoload :Environment, 'symmetric_encryption/keystore/environment'
autoload :File, 'symmetric_encryption/keystore/file'
autoload :Memory, 'symmetric_encryption/keystore/memory'
- #@formatter:on
+ # @formatter:on
# Returns [Hash] a new configuration file after performing key rotation.
#
# Perform key rotation for each of the environments in the configuration file, by
# * generating a new key, and iv with an incremented version number.
@@ -42,16 +43,16 @@
# Only generate new keys for keystore's that have a key encrypting key
next unless config[:key_encrypting_key] || config[:private_rsa_key]
cipher_name = config[:cipher_name] || 'aes-256-cbc'
new_key_config =
- if config.has_key?(:key_filename)
+ if config.key?(:key_filename)
key_path = ::File.dirname(config[:key_filename])
Keystore::File.new_key_config(key_path: key_path, cipher_name: cipher_name, app_name: app_name, version: version, environment: environment)
- elsif config.has_key?(:key_env_var)
+ elsif config.key?(:key_env_var)
Keystore::Environment.new_key_config(cipher_name: cipher_name, app_name: app_name, version: version, environment: environment)
- elsif config.has_key?(:encrypted_key)
+ elsif config.key?(:encrypted_key)
Keystore::Memory.new_key_config(cipher_name: cipher_name, app_name: app_name, version: version, environment: environment)
end
# Add as second key so that key can be published now and only used in a later deploy.
if rolling_deploy
@@ -86,16 +87,16 @@
# The current data encrypting key without any of the key encrypting keys.
key = Key.from_config(config)
cipher_name = key.cipher_name
new_key_config =
- if config.has_key?(:key_filename)
+ if config.key?(:key_filename)
key_path = ::File.dirname(config[:key_filename])
Keystore::File.new_key_config(key_path: key_path, cipher_name: cipher_name, app_name: app_name, version: version, environment: environment, dek: key)
- elsif config.has_key?(:key_env_var)
+ elsif config.key?(:key_env_var)
Keystore::Environment.new_key_config(cipher_name: cipher_name, app_name: app_name, version: version, environment: environment, dek: key)
- elsif config.has_key?(:encrypted_key)
+ elsif config.key?(:encrypted_key)
Keystore::Memory.new_key_config(cipher_name: cipher_name, app_name: app_name, version: version, environment: environment, dek: key)
end
new_key_config[:always_add_header] = always_add_header
new_key_config[:encoding] = encoding
@@ -119,8 +120,7 @@
version: 1
}
]
}
end
-
end
end