Commit Graph

16 Commits

Author SHA1 Message Date
Jarek Kowalski
ac446a2d16 chore(ci): upgraded linter to 1.60.3 (#4086)
* silenced several 'gosec' findings
2024-09-03 21:29:56 -07:00
Julio López
1f9f9a1846 chore(general): use non-formatting log variants when there is no formatting (#3931)
Use non-formatting logging functions for message without formatting.
For example, `log.Info("message")` instead of `log.Infof("message")`

Configure linter for printf-like functions
2024-06-18 23:13:17 -07:00
Jarek Kowalski
fcb8197f3f chore(ci): upgraded linter to 1.59.0 (#3883) 2024-05-29 20:31:57 -07:00
Sirish Bathina
05fedcff60 fix(general): change pbkdf2 min salt length to 16 bytes (#3864)
Changing the minimum salt length of Pbkdf2 key derivation
algorithm to the NIST recommended minimum of 16 bytes.

This matches the minimum salt for scrypt-based key derivation.
2024-05-13 15:10:37 -07:00
Mark Severson
3fcdb9b185 refactor(general): avoid using empty master keys (#3835)
Previously, empty master keys were passed to the underlying
cryptographic primitives (HKDF, AEAD, etc.).

While this worked because the authentication mechanisms returned an
error, it's best to avoid passing empty master keys to these primitives
in the first place. This refactor avoids passing empty master keys and
enforces this via an assertion in the key derivation function.
2024-05-01 14:50:01 -07:00
Julio López
065e0adbfd refactor(general): make key derivers available in tests (#3826)
- Re-introduces the **insecure**, lightweight key deriver for
  testing **only**.
- Makes `scrypt` and `pbkdf2` derivers available in tests as well.
2024-04-30 17:21:11 -07:00
Julio López
ca1962f6e4 refactor(general): user password hashing and key derivation helpers (#3821)
Code movement and simplification, no functional changes.

Objectives:
- Allow callers specifying the needed key (or hash) size, instead of
hard-coding it in the registered PBK derivers. Conceptually, the caller
needs to specify the key size, since that is a requirement of the
(encryption) algorithm being used in the caller. Now, the code changes
here do not result in any functional changes since the key size is
always 32 bytes.
- Remove a global definition for the default PB key deriver to use.
Instead, each of the 3 use case sets the default value.

Changes:
- `crypto.DeriveKeyFromPassword` now takes a key size.
- Adds new constants for the key sizes at the callers.
- Removes the global `crypto.MasterKeySize` const.
- Removes the global `crypto.DefaultKeyDerivationAlgorithm` const.
- Adds const for the default derivation algorithms for each use case.
- Adds a const for the salt length in the `internal/user` package, to ensure
  the same salt length is used in both hash versions.
- Unexports various functions, variables and constants in the `internal/crypto`
  & `internal/user` packages.
- Renames various constants for consistency.
- Removes unused functions and symbols.
- Renames files to be consistent and better reflect the structure of the code.
- Adds a couple of tests to ensure the const values are in sync and supported.
- Fixes a couple of typos

Followups to:
- #3725
- #3770
- #3779
- #3799
- #3816

The individual commits show the code transformations to simplify the
review of the changes.
2024-04-26 23:30:56 -07:00
Sirish Bathina
1e98511c2e feat(general): key derivation algorithm for cache encryption (#3799)
Add an option to select the password-based key derivation algorithm
for the local cache encryption key when connecting to a kopia
repository server.
2024-04-25 17:45:12 -07:00
Sirish Bathina
02463ab118 feat(general): user profile hashing version to algorithm translation (#3816)
Reverts to using the `PasswordHashVersion` in the user profile.
Adds a simple mechanism for translating between password hash
version and the corresponding password hashing algorithm (key
derivation algorithm).
2024-04-24 17:50:26 -07:00
Julio López
17c3a8d4de refactor(general): include parameters in pbkdf2 instantiation (#3811)
Use `pbkdf2-sha256-600000` as the name to be consistent with the scrypt
instantiation.

The format is `pbkdf2-<hash_type>-<number_of_iterations>`
2024-04-19 15:50:45 -07:00
Julio López
ff9f6a8325 refactor(general): change default number of iterations for PBKDF2 (#3810)
Use the value recommended by NIST
2024-04-19 15:27:38 -07:00
Sirish Bathina
5fa39fe5eb feat(general): User_profile_add_set cli changes (#3770)
* User profile add set cli changes

* Add additional test

* get salt length from key deriver

* Fixes for failing tests

* after shikhars review

* lint fixes
2024-04-10 17:56:13 -07:00
Jarek Kowalski
7278f570e2 chore(ci): upgraded linter to 1.57.1 (#3753) 2024-03-25 22:20:38 -07:00
Sirish Bathina
4ea6cf98d1 update min salt size to 16 (#3732) 2024-03-13 15:02:33 -07:00
Sirish Bathina
ddcdfdb55a changes for switching key derivation (#3725) 2024-03-13 00:34:46 +00:00
PhracturedBlue
e653ec0a02 refactor(repository): Move encryption into a common package in preparation to handle secrets (#3351) 2023-09-24 17:44:50 -07:00