Skip to content
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

Encrypt work factor #477

Merged
merged 6 commits into from
Jun 8, 2023
Merged

Encrypt work factor #477

merged 6 commits into from
Jun 8, 2023

Conversation

semenov-vladyslav
Copy link

Description of change

The changes introduce public access to the default snapshot encryption work factor. This is a workaround to make tests run faster at the cost of resetting work factor to zero during testing. In production this feature must not be used, and the default work factor must not be modified as it will lead to security compromise and potential leaks of secrets, including seed.

Links to any relevant issues

Be sure to reference any related issues by adding fixes issue #.

Type of change

Choose a type of change, and delete any options that are not relevant.

  • Bug fix (a non-breaking change which fixes an issue)
  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Fix

How the change has been tested

Describe the tests that you ran to verify your changes.

Make sure to provide instructions for the maintainer as well as any relevant configurations.

Change checklist

Add an x to the boxes that are relevant to your changes, and delete any items that are not.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@@ -194,6 +194,7 @@ fn test_stronghold_purge_client() {

#[test]
fn purge_client() {
engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use 1 for these or is there no point?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use 1. 0 will also work.

@@ -85,7 +105,8 @@ pub enum WriteError {
/// It is safe to use with strong keys, although computing resources may be wasted.
/// In this case it is recommended to use `encrypt_content_with_work_factor` with small/zero work factor.
pub fn encrypt_content<O: Write>(plain: &[u8], output: &mut O, key: &Key) -> Result<(), WriteError> {
let work_factor = age::RECOMMENDED_MINIMUM_ENCRYPT_WORK_FACTOR;
let work_factor = get_encrypt_work_factor();
// let work_factor = age::RECOMMENDED_MINIMUM_ENCRYPT_WORK_FACTOR;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@thibault-martinez thibault-martinez merged commit 988a9d1 into 2.0 Jun 8, 2023
@thibault-martinez thibault-martinez deleted the feat/encrypt_work_factor branch June 8, 2023 15:37
@semenov-vladyslav semenov-vladyslav mentioned this pull request Jun 9, 2023
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants