From 777b6713bb473d2e09c8340ab9a96373fdbaae50 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 22 Nov 2018 15:35:49 +0100 Subject: Ensure that db encryption keys have proper bytesize --- config/settings.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'config') diff --git a/config/settings.rb b/config/settings.rb index 3f3481bb65d..1b94df785a7 100644 --- a/config/settings.rb +++ b/config/settings.rb @@ -95,6 +95,14 @@ class Settings < Settingslogic Gitlab::Application.secrets.db_key_base[0..31] end + def attr_encrypted_db_key_base_32 + Gitlab::Utils.ensure_utf8_size(attr_encrypted_db_key_base, bytes: 32.bytes) + end + + def attr_encrypted_db_key_base_12 + Gitlab::Utils.ensure_utf8_size(attr_encrypted_db_key_base, bytes: 12.bytes) + end + # This should be used for :per_attribute_salt_and_iv mode. There is no # need to truncate the key because the encryptor will use the salt to # generate a hash of the password: -- cgit v1.2.3