-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to work with key rotation? #26
Comments
Hi @SimonLab! Thank you for opening this question to seek clarification on Encryption Key Rotation. Key rotation is designed to minimise the amount of data that can be decrypted in the event of a data breach.
OWASP suggests that "Keys used for encryption must be rotated at least annually" When to select/create a new key? > New keys should be created based on a pre-defined rotation frequency e.g: Yearly, Monthly, Weekly, Daily or even a new key per session in the case of "Perfect Forward Secrecy". https://www.wired.com/2016/11/what-is-perfect-forward-secrecy
For anyone reading this in the future, the relevant reading is: |
Key rotation is mentioned on the Readme on the following parts in the Readme:
https://github.com/dwyl/phoenix-ecto-encryption-example#owasp-cryptographic-rules
https://github.com/dwyl/phoenix-ecto-encryption-example#1-create-the-encryption-app
and on the
get_key
function description:https://github.com/dwyl/phoenix-ecto-encryption-example#3-define-the-6-functions
However it wasn't clear for me how to use key rotation (when to select a new key?, when to create a new key?, can we delete unused key?...). Maybe we can update the Readme to explain how rotation could be used in a project.
My first thought was to randomly get the index of the key from the list of keys and use this key each time we want to insert in the database an encrypted item. However randomising each encrypted item seems more to be the responsibility of the
Initialization Vector
(see #8).So I think it's ok to use the same key for consecutive inserted items on a "long period" of time. We need then to create a new key (every 6 months or a 1 year?) to be used to encrypt the new inserted items and the old keys are only used to decrypt the previous items.
So we want to
get_key/0
function will always get the last key of the list (ie the latest key created) to encrypt the dataget_key/1
function can take the key index parameter to retrieve the correct key used on encryption.@nelsonic is this logic correct or do you have other details or step in mind?
The text was updated successfully, but these errors were encountered: