-
Notifications
You must be signed in to change notification settings - Fork 757
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
Configuration backup with AES-256-GCM #5665
Conversation
100 000 rounds is quite low number of rounds in year 2022. Approximate one second duration (but at least 100 000 rounds in every case) could be calculated with: <?php
$timer = hrtime(true);
$temp = hash_pbkdf2('sha512', 'password', random_bytes(16), 100_000, 44, true);
$timer = (hrtime(true) - $timer) / 10 ** 9;
$iterations = max(100_000, ceil(100_000 / $timer));
var_dump($iterations);I think at least one second should be spent here since it is quite rare occurrence unlike login which should be relatively fast. What do you think? |
|
It would be great if someone with older |
|
@oittaa you could always try on our forum if someone would like to test your code. |
|
Made a post to https://forum.opnsense.org/index.php?topic=27768.0 |
|
I actually installed OPNsense version 21.1, took an encrypted backup, and restored it on a recent OPNsense with this patch. It worked as expected. Encrypted config: and so on... |
|
Here's an example why integrity checks matter and what can happen when a single bit flips. $ echo -n 'ATTACK AT DAWN' | openssl enc -aes-256-cbc -a -md sha512 -salt -pbkdf2 -iter 100000 -pass pass:'password'
U2FsdGVkX19+WSFvvM2d+S2Y2JBWIhKzdnyHlGX7eAs=
$ echo 'U2FsdGVkX19+WSFvvM2d+S2Y2JBWIhKzdnyHlGX7eAr=' | openssl enc -aes-256-cbc -d -a -md sha512 -salt -pbkdf2 -iter 100000 -pass pass:'password'
�#*{;�}KyRC�
Only the last |
|
|
closing, not enough traction. |
As discussed a little bit in #5661
AES-256-GCM mode provides proper integrity checking. Additional authentication data can be added easily if something needs to be authenticated, but made available prior to decryption some time in the future.
This pull request also removes
opensslshell commands and implements the needed legacy key derivation function in pure PHP.Example below: I wrapped the three new methods (
keyAndIV,opensslDecrypt,opensslEncrypt) in a test class if people want to test easily on their own machines without modifying the whole OPNsense installation.