aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-07-17crypto: Conversion to/from C stringsJoe Richey joerichey@google.com
2017-07-17pam: Add PAM Items and FlagsJoe Richey joerichey@google.com
Code pulled from github.com/msteinert/pam
2017-07-17util: Add conversions for byte/pointer arraysJoe Richey joerichey@google.com
2017-07-17Merge pull request #20 from google/fixJoseph Richey
Refactor ReadLine functions
2017-07-17cmd/fscrypt: prompts now use command functionsJoe Richey joerichey@google.com
2017-07-17util: Move line reading into common packageJoe Richey joerichey@google.com
2017-07-17Merge pull request #19 from google/fixJoseph Richey
Separate encryption support from metadata support
2017-07-17cmd/fscrypt: Improve "fscrypt status"Joe Richey joerichey@google.com
Now that we can distinguish between lacking encryption support and lacking fscrypt metadata, "fscrypt status" can now display this additional information.
2017-07-17cmd/fscrypt: Check support before encryptingJoe Richey joerichey@google.com
Almost all actions only need to to check that the fscrypt metadata exists (this is handled by the Mount methods). Only "fscrypt encrypt" need to be sure the filesystem also supports encryption, so this check is added.
2017-07-17filesystem: Distinguish support and setup for fsJoe Richey joerichey@google.com
This commit splits two pieces of functionality. Detecting if the fscrypt metadata exists is now in CheckSetup() and checking if the filesystem supports encryption is now in CheckSupport().
2017-07-17Merge pull request #18 from google/fixJoseph Richey
Polices can now be directly unlocked with Protectors
2017-07-17actions: Add tests for policy unlockingJoe Richey joerichey@google.com
2017-07-17actions: Protectors can directly unlock PoliciesJoe Richey joerichey@google.com
In addition to using callbacks, unlocked Protectors can now directly unlock a policy. The error codes are updated to make more sense.
2017-07-14Merge pull request #16 from google/fixJoseph Richey
Use Description when placing keys in the keyring
2017-07-14actions: Policies now have Description methodJoe Richey joerichey@google.com
2017-07-14crypto: Use single description parameterJoe Richey joerichey@google.com
Instead of using the service+descriptor parameters (which are always combined in the same way), use a single description parameter.
2017-07-14Merge pull request #15 from google/fixJoseph Richey
Bug fixing for "fscrypt encrypt"
2017-07-14cmd/fscrypt: fix protector and policy cleanupJoe Richey joerichey@google.com
Protectors are only reverted if they were created, and Policies are only depovisioned on failure.
2017-07-14vendor: Fixed package list so "make all" will workJoe Richey joerichey@google.com
During an earlier commit the vendor directory was self-referencing various "fscrypt/<pkg>" packages. This no longer occurs.
2017-07-13Merge pull request #14 from google/docsJoseph Richey
Version now uses git tags and releases
2017-07-13Makefile: version and data now pulled in directlyJoe Richey joerichey@google.com
2017-07-13README: Fixed version badge to pull from Git tagsJoseph Richey
2017-07-13Merge pull request #12 from google/docsJoseph Richey
Cleanup README.md
2017-07-13README: Add badges for protect, docs, report cardJoseph Richey
2017-07-13README: fix typos and formattingJoseph Richey
Some of the documentation was misspelled or incorrectly formatted.
2017-06-28Finalize import paths and documentationv0.1.00.1.0Joe Richey joerichey@google.com
This commit changes all the internal import paths from `fscrypt/foo` to `github.com/google/fscrypt/foo` so that it can be built once we release externaly. The documentation in README.md is updated accordingly. Also, the README has a note noting that we do not make any guarantees about project stability before 1.0 (when it ships with Ubuntu). Change-Id: I6ba86e442c74057c8a06ba32a42e17f94833e280
2017-06-28Update Makefile and READMEJoe Richey joerichey@google.com
This commit updates the README and Makefile to get them ready for external release. This includes adding some common pitfalls, including example usage, and allowing for tarball creation. Change-Id: I442338c7aff613a14bae449dbf091bfcaf73ed9d
2017-06-28cmd/fscrypt: commands to add/remove protectorsJoe Richey joerichey@google.com
This commit adds in the "fscrypt metadata add-protector-to-policy" and the "fscrypt metadata remove-protector-from-policy" subcommands. These commands allow for the creating of policies protected by multiple protectors. Change-Id: Id7e6c057448d15757c838a82d487a1b9806f585d
2017-06-28cmd/fscrypt: add metadata commandJoe Richey joerichey@google.com
This command adds in the "fscrypt metadata" command. This command allows advanced users to manipulate the metadata directly instead of just creating a policy or protector as an option when encrypting a directory. As some of these methods will require certain flags, error handling for this case is also added. As the change passphrase method must indicate when a old vs new password is necessary, additional KeyFuncs are added which add this indicator. Change-Id: Ibc92872088fae078df3c0eebd4f0cfcb7252d781
2017-06-28cmd/fscrypt: add in status and purge commandsJoe Richey joerichey@google.com
This commit adds in the status command, which has 2 functions, allowing the user to query the state of the entire system or a specific filesystem. This commit also adds in the purge command to remove all policy keys corresponding to a filesystem. This (along with getting the unlock status for the status commands) uses additional keyctl functionality in the crypto and actions packages. Change-Id: Ic8e097b335c044c0b91973eff19753f363f4525d
2017-06-28cmd/fscrypt: setup, encrypt, unlock commandsJoe Richey joerichey@google.com
This commit adds in the framework for adding commands and subcommands to the fscrypt tool. This commit adds in the "setup", "encrypt", and "unlock" commands. Additional information can be found by running: fscrypt <command> --help. This commit defines how flags are parsed and errors are handled. It also creates an extensible framework for prompting the user for information. Change-Id: I159d7f44ee2b2bbc5e072f0802850e082d9a13ce
2017-06-28actions: error handling and API changedJoe Richey joerichey@google.com
This commit changes the error handling for the actions package to use the error handling library github.com/pkg/errors. This means replacing "errors" with "github.com/pkg/errors", reworking some of the error values, and wrapping some errors with additional context. This commit also changes the Protector/Policy API, moving most of the package functionality into Protector or Policy methods. These types are now "locked" when they are queried from the filesystem, and Unlock() must be used to get their corresponding keys. Note that only certain operations will require unlocking the keys. Certain unnecessary functions and methods are also removed. This CL also fixes two bugs reported by Tyler Hicks in CreateConfigFile. CPU time is used instead of wall time, and kiB is used instead of kB. Change-Id: I88f45659e9fe4938d148843e3289e7b6d5b698d8
2017-06-28Change error handling to new packageJoe Richey joerichey@google.com
This commit changes the error handing for the crypto, filesystem, metadata, pam, and util packages to use the error handling library github.com/pkg/errors. This means elimination of the FSError type, an increased use of wrapping errors (as opposed to logging), switching on the Cause() of an error (as opposed to its value), and improving our integration tests involving TEST_FILESYSTEM_ROOT. This commit also fixes a few bugs with the keyring code to ensure that our {Find|Remove|Insert}PolicyKey functions are always operating on the same keyring. The check for filesystem support has been moved from the filesystem package to the metadata package. Finally, the API for the filesystem package has been slightly modified: * filesystem.AllFilesystems() now returns all the filesystems in sorted order * certain path methods are now public O_SYNC is also removed for writing the metadata. We don't get that much from syncing the metadata, as the actual file data could also be corrupted by and IO error. The sync operation is also occasionally very slow (~3 seconds) and can be unfriendly to battery life. Change-Id: I392c2655141714b16dfdbc84ac09780072be2cf0
2017-06-26vendor: add in github.com/pkg/errorsJoe Richey joerichey@google.com
This commit adds in the github.com/pkg/errors package for handling errors. This allows us to continue to add context to our errors as they move up the call stack, but still be able to switch on their root cause. Change-Id: I6fd55f184318ea1e28c93a84444a2627bff03682
2017-06-26actions: Simplify the callback mechanismJoe Richey joerichey@google.com
This commit makes the callbacks for getting keys easier to understand. Functions which need keys now take a KeyFunc callback. This callback contains a ProtectorInfo parameter (basically a read-only version of metadata.ProtectorData) and a boolean which indicates if the call is being retried. The documentation is also updated to say which functions will retry the KeyFunc. For selecting a protector, there is now an OptionFunc callback which takes a slice of ProtectorOptions. A ProtectorOption is a ProtectorInfo along with additional information about a linked filesystem (if applicable). This commit also adds in methods for getting the protector options for a specific filesystem or policy. It also adds a function for getting the policy descriptor for a specific path. Change-Id: I41e0d94ffd44e7166b0c5cf1b5d18437960bdf90
2017-06-15vendor: update x/sys/unixJoe Richey joerichey@google.com
This commit updates the vendored x/sys/unix to the current version. This means that our vendored version of x/sys/unix no longer contains custom patches. A few changes are needed in InsertPolicyKey() as the final API differed slightly from our patches. Change-Id: Ifff31c04e708f9dc4395ab5bfcc94e42fb46dea5
2017-06-15crypto: add in additional keyring functionalityJoe Richey joerichey@google.com
This commit adds in the FindPolicyKey and RemovePolicyKey functions to complement the InsertPolicyKey function. The existing functions were also refactored slightly. Change-Id: Iabd275f2186a9e3023d5efd44c772966123e3657
2017-06-15metadata: change encryption mode namesJoe Richey joerichey@google.com
As new encryption modes are being added to the kernel that use 128 bit keys (see https://patchwork.kernel.org/patch/9741913), we will need the encryption modes to be more descriptive. This change breaks backwards compatibility for the protobuf, but that's fine because we have not released yet. Change-Id: Ifb58d3d5a42db491f1e5393c12f3d260d9a091de
2017-06-15filesystem: change support detection and bug-fixesJoe Richey joerichey@google.com
Instead of checking if the filesystem type is correct, we now detect if a filesystem supports encryption by trying to read a policy on its root directory. The error returned tells us if there is support or not. This commit also fixes a bug in the use libblkid. Throughout all of fscrypt, cannonicalizePath() is used before any path comparison or lookup. However, the canonical device path in the blkid cache may differ from our idea of a canonical path. Additional blkid functions are needed to perform the necessary translation. This is noted in the documentation of makeLink(). Finally, this commit makes a few API changes. AllSupporedFilesystems() now returns an error, and a GetProtector() method now replaces the GetLinkedProtector() and GetEitherProtector() methods. A PathSorter has also been added so Mounts can be sorted in a reliable order. Change-Id: I664f46fafd1483ebecb743c061b03d708b3233a4
2017-06-15pam: checking a user's login passphraseJoe Richey joerichey@google.com
This commit adds in the fscrypt/pam package. This package will hold all functionality related to Linux Pluggable Authentication Modules (PAM). Right now this package uses cgo to mock a PAM conversation, allowing the function to check if a provided passphrase actually belongs to a user. Due to the nature of cgo callbacks, global state of the key to check is necessary for this function. This commit also addresses some issues about building the cgo components. Now, only the minimal linking flags are included in the go files. Additional linker flags may now be necessary to build a static binary of fscrypt. This is addressed in the Makefile and README. Finally, this commit fixes a bug where the tests would not run correctly due to shared global state on the testing filesystem. Fixed, by having all the tests run sequentially. Change-Id: Ia43636801da984b505d2f43dd14127b7cfbf2c48
2017-05-31vendor: add in external packages for use with CLIJoe Richey joerichey@google.com
crypto/ssh/terminal gets us information about the terminal, such as its dimensions and state. It also allows us to manipulate the terminal. For example, we can put the terminal in raw mode when a passphrase needs to be entered. This commit also add the github.com/urfave/cli package which we will use to write the command line tool component of fscrypt. This tool allows for us to easily use commands and subcommands. Note that this is actually the upstream repository with two PRs applied: https://github.com/urfave/cli/pull/629 https://github.com/urfave/cli/pull/630 They fix bugs in the handling of custom usage errors. Change-Id: I2d3ba967b1bce8f73440e3a06df4eaba7ab96c19
2017-05-31actions: creating and unlocking policiesJoe Richey joerichey@google.com
This commit adds in the Policy structure. This structure represents an unlocked policy key and its associated data. Policies can add or remove Protectors, apply encryption policies to filesystem directories, and provision a key into the kernel keyring. Change-Id: I089710223221e0ea60188d523703469e5d67ad0e
2017-05-31actions: creating and unlocking protectorsJoe Richey joerichey@google.com
This commit adds in the Protector struct to the actions package. This struct represents an unlocked Protector. They can be created from a context or they can be unlocked using some provided data. In either case, the data is provided via a callback mechanism. Change-Id: I066e965b8e8e0feeba61d9c0e4472dd08965cafb
2017-05-31actions: generate a config file for fscryptJoe Richey joerichey@google.com
This commit adds in the actions package. This package will be the highest-level interface to the fscrypt packages. The public functions in this package will be called directly from cmd/fscrypt. The actions added in this commit pertain to creating and reading the fscrypt global config file "fscrypt.conf". The challenging part about creating this file is finding the correct hashing parameters for the desired time target. The getHashingCosts() function finds the desired costs by doubling the costs and running the passphrase hash until the target is exceeded. Then, a cost estimate is obtained using a linear interpolation between the last two costs (and their time results). Change-Id: I4a0eaf4856ec4ff49eb4360da3267f7caa9d07b2
2017-05-31filesystem: creating the directories and filesJoe Richey joerichey@google.com
This commit adds in the filesystem subpackage. The goal of this package is to provide and interface for adding to and removing from the metadata storage for a given filesystem. This is primarily done in filesystem.go. To facilitate this functionality, mountpoint.go exposes an interface for querying the system about the current mounted filesystems and their information. Note that this operation is done with a lazy loading mechanism. To refer to other filesystems, we use link files that can be parsed by libblkid. The README is also updated to account for this new dependancy. This package uses the FSError type under the hood so that error messages will include the filesystem name, but callers can still check for specific error instances. Change-Id: I74fe4e84b8e3a5b73f1337c35307ffe0bf7cdea9
2017-05-31crypto: tests, errors, and descriptor computationJoe Richey joerichey@google.com
This changes the crypto package so it now builds in light of the changes to the util and metadata package. This commit also improves the error handling, adds tests, and makes it so recovery keys now correspond to Policy keys (as they are used to recover a directory in the absence of any metadata). The only feature addition here is the ability to compute descriptors. For backwards compatibility, we keep the same descriptor algorithm used before (double SHA512). Change-Id: Ia2b53c6e85ce65c57595e6823d3c4c92219bc8dc
2017-05-31metadata: reorganize and add consistency checksJoe Richey joerichey@google.com
This commit adds in IsValid() checks for the metadata structures that let us enforce stronger invariants than those imposed by the protobuf package. The main uses of this will be to check that metadata is valid before writing it to the filesystem, and to check that the filesystem contains valid metadata before returning it to the user. These functions also will log the exact reason if the validity checks fail. To have these checks in the metadata package, all of the various constants have been moved to a single metadata/constants.go file. The uses of these constants were changed accordingly. Finally, this commit standardizes our use of errors so that they always begin with an appropriate prefix. Change-Id: I99008e2ee803ebe5f6236eb8d83fc83efcd22718
2017-05-31util: better handing of custom errorsJoe Richey joerichey@google.com
This commit changes how we handle InvalidInput and System errors. Instead of having formatting functions, the now just wrap a string and should be created with fmt.Sprintf or similar. We also move all of the error related code into a single place. Finally, the utils package gets additional functionality with MinInt64 and GetUsername, and the UnderlyingError function gets better logging. Note that this will break packages that depend on it. For instance, metadata and crypto currently do not build. This is fixed in a later commit. Change-Id: I819e4d1970604456a5b4b6a7c86426f180a6d092
2017-05-31fscrypt: Adding additional documentationJoe Richey joerichey@google.com
This commit moves most of the documentation about contributing to fscrypt into CONTRIBUTING.md and updates the legal disclaimer. It also updates the README.md to include all of fscrypt's planned functionality and dependencies. Finally, the makefile is updated to include more documentation, versioning support, and a different location for the output file. Change-Id: Ib7be98d41bc06dd12b02e42addf06e12a940235a
2017-05-02crypto: passphrase hashing with Argon2Joe Richey
This commit adds in the PassphraseHash function which hashes the provided passphrase (in key form) using Argon2id. This cost parameters for Argon2id and that salt are both fed into the function. It also includes tests and benchmarks for the passphrase hashing. Change-Id: I060db3e71213c756d45ce5603a0a59d3d7a1e609