Skip to content

Conversation

@bathina2
Copy link
Contributor

@bathina2 bathina2 commented Mar 13, 2024

This PR allows kopia users to pick the key derivation algorithm to use.
This is a follow up to #3725 which added the ability to switch between multiple key derivation algorithms.

image

@bathina2 bathina2 changed the title Ability to set key derivation algorithm feat(general): Ability to set key derivation algorithm Mar 13, 2024
@codecov
Copy link

codecov bot commented Mar 15, 2024

Codecov Report

Attention: Patch coverage is 92.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 77.10%. Comparing base (cb455c6) to head (27ca0f4).
Report is 73 commits behind head on master.

❗ Current head 27ca0f4 differs from pull request most recent head f9993c7. Consider uploading reports for the commit f9993c7 to get more accurate results

Files Patch % Lines
cli/command_user_add_set.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3731      +/-   ##
==========================================
+ Coverage   75.86%   77.10%   +1.23%     
==========================================
  Files         470      476       +6     
  Lines       37301    28803    -8498     
==========================================
- Hits        28299    22208    -6091     
+ Misses       7071     4671    -2400     
+ Partials     1931     1924       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@redgoat650 redgoat650 left a comment

Choose a reason for hiding this comment

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

A few suggestions for user experience, but looks good otherwise

cmd.Flag("enable-actions", "Allow snapshot actions").BoolVar(&c.connectEnableActions)
cmd.Flag("repository-format-cache-duration", "Duration of kopia.repository format blob cache").Hidden().DurationVar(&c.formatBlobCacheDuration)
cmd.Flag("disable-repository-format-cache", "Disable caching of kopia.repository format blob").Hidden().BoolVar(&c.disableFormatBlobCache)
cmd.Flag("key-derivation-algorithm", "Key Derivation Algorithm").Default(crypto.DefaultKeyDerivationAlgorithm).StringVar(&c.keyDerivationAlgorithm)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: matching capitalization of other flags

Suggested change
cmd.Flag("key-derivation-algorithm", "Key Derivation Algorithm").Default(crypto.DefaultKeyDerivationAlgorithm).StringVar(&c.keyDerivationAlgorithm)
cmd.Flag("key-derivation-algorithm", "Key derivation algorithm").Default(crypto.DefaultKeyDerivationAlgorithm).StringVar(&c.keyDerivationAlgorithm)

cmd.Flag("enable-actions", "Allow snapshot actions").BoolVar(&c.connectEnableActions)
cmd.Flag("repository-format-cache-duration", "Duration of kopia.repository format blob cache").Hidden().DurationVar(&c.formatBlobCacheDuration)
cmd.Flag("disable-repository-format-cache", "Disable caching of kopia.repository format blob").Hidden().BoolVar(&c.disableFormatBlobCache)
cmd.Flag("key-derivation-algorithm", "Key Derivation Algorithm").Default(crypto.DefaultKeyDerivationAlgorithm).StringVar(&c.keyDerivationAlgorithm)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: What if we used EnumVar instead of StringVar here? That way we can define the acceptable key derivation algo flag values in a user-friendly way? Similar to, e.g.

	cmd.Flag("compression", "Compression algorithm").EnumVar(&c.policySetCompressionAlgorithm, supportedCompressionAlgorithms()...)
Suggested change
cmd.Flag("key-derivation-algorithm", "Key Derivation Algorithm").Default(crypto.DefaultKeyDerivationAlgorithm).StringVar(&c.keyDerivationAlgorithm)
cmd.Flag("key-derivation-algorithm", "Key Derivation Algorithm").Default(crypto.DefaultKeyDerivationAlgorithm).EnumVar(&c.keyDerivationAlgorithm, crypto.AllowedKeyDerivationAlgorithms()...)

}

cmd.Flag("ask-password", "Ask for user password").BoolVar(&c.userAskPassword)
cmd.Flag("key-derivation-algorithm", "Key Derivation Algorithm").Default(crypto.DefaultKeyDerivationAlgorithm).StringVar(&c.keyDerivationAlgorithm)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same suggestion here:

Suggested change
cmd.Flag("key-derivation-algorithm", "Key Derivation Algorithm").Default(crypto.DefaultKeyDerivationAlgorithm).StringVar(&c.keyDerivationAlgorithm)
cmd.Flag("key-derivation-algorithm", "Key Derivation Algorithm").Default(crypto.DefaultKeyDerivationAlgorithm).EnumVar(&c.keyDerivationAlgorithm, crypto.AllowedKeyDerivationAlgorithms()...)

Copy link
Contributor

@redgoat650 redgoat650 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the flag improvements

@bathina2
Copy link
Contributor Author

bathina2 commented Apr 4, 2024

Closing this PR in favor of #3770 and #3779

@bathina2 bathina2 closed this Apr 4, 2024
@julio-lopez julio-lopez deleted the set-key-derivation branch June 12, 2024 17:36
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.

2 participants