Don't export storeKey(), and update comments
storeKey() is no longer used outside KeyStorage.cpp, so make it a static function. Also fix the documentation for storeKey() (e.g. it's no longer safe to directly move/rename directories created by storeKey() -- one must use RenameKeyDir() instead). No functional changes. [ebiggers@ - cleaned up slightly from satyat@'s original change] Bug: 190398249 Change-Id: I85918359e77bef414dfddfe5ded30fcde6514013
This commit is contained in:
parent
0f890a93e1
commit
351a4af716
2 changed files with 6 additions and 7 deletions
|
@ -575,7 +575,12 @@ static bool decryptWithoutKeymaster(const std::string& preKey, const std::string
|
|||
return true;
|
||||
}
|
||||
|
||||
bool storeKey(const std::string& dir, const KeyAuthentication& auth, const KeyBuffer& key) {
|
||||
// Creates a directory at the given path |dir| and stores |key| in it, in such a
|
||||
// way that it can only be retrieved via Keymaster (if no secret is given in
|
||||
// |auth|) or with the given secret (if a secret is given in |auth|), and can be
|
||||
// securely deleted. If a storage binding seed has been set, then the storage
|
||||
// binding seed will be required to retrieve the key as well.
|
||||
static bool storeKey(const std::string& dir, const KeyAuthentication& auth, const KeyBuffer& key) {
|
||||
if (TEMP_FAILURE_RETRY(mkdir(dir.c_str(), 0700)) == -1) {
|
||||
PLOG(ERROR) << "key mkdir " << dir;
|
||||
return false;
|
||||
|
|
|
@ -45,12 +45,6 @@ bool readSecdiscardable(const std::string& path, std::string* hash);
|
|||
// This method should be used whenever a key directory needs to be moved/renamed.
|
||||
bool RenameKeyDir(const std::string& old_name, const std::string& new_name);
|
||||
|
||||
// Create a directory at the named path, and store "key" in it,
|
||||
// in such a way that it can only be retrieved via Keymaster and
|
||||
// can be securely deleted.
|
||||
// It's safe to move/rename the directory after creation.
|
||||
bool storeKey(const std::string& dir, const KeyAuthentication& auth, const KeyBuffer& key);
|
||||
|
||||
// Create a directory at the named path, and store "key" in it as storeKey
|
||||
// This version creates the key in "tmp_path" then atomically renames "tmp_path"
|
||||
// to "key_path" thereby ensuring that the key is either stored entirely or
|
||||
|
|
Loading…
Reference in a new issue