-
Notifications
You must be signed in to change notification settings - Fork 421
Description
ruby '2.7.6'
rails (6.1.7.6)
activerecord (= 6.1.7.6)
attr_encrypted (4.2.0)
encryptor (~> 3.0.0)
I am getting 'must specify an iv' when using defaults ('aes-256-gcm', :per_attribute_iv)
For example:
attr_encrypted :account_number, key: Rails.application.config.encryption.bank_account_number_key
Bank_account_number_key is set from ENV variable as 64 character hex string
Both encrypted_account_number & encrpted_account_number_iv exist in database as strings
I have tried:
attr_encrypted :account_number, key: Rails.application.config.encryption.bank_account_number_key, iv: SecureRandom.random_bytes(12)
attr_encrypted :account_number, key: Rails.application.config.encryption.bank_account_number_key, iv: -> { SecureRandom.random_bytes(12) }
attr_encrypted :account_number, key: Rails.application.config.encryption.bank_account_number_key, iv: ->(record) { SecureRandom.random_bytes(12) }
but I get error saying iv needs to be atleast 12 bytes long.
so i am a bit confused. is this a documentation issue that iv needs to be specified?
why is it not generated automagically?
looking through source code, it appears that it should
what am i missing?
everything works fine for me when using algorithm: 'aes-256-cbc', mode: :single_iv_and_salt, insecure_mode: true on old columns but now having trouble when making new columns using defaults
trying to migrate to more secure options (the defaults)