Lines Matching refs:dir
223 static bool CommitUpgradedKey(Keymaster& keymaster, const std::string& dir) { in CommitUpgradedKey() argument
224 auto blob_file = dir + "/" + kFn_keymaster_key_blob; in CommitUpgradedKey()
225 auto upgraded_blob_file = dir + "/" + kFn_keymaster_key_blob_upgraded; in CommitUpgradedKey()
235 if (!FsyncDirectory(dir)) return false; in CommitUpgradedKey()
254 for (auto& dir : key_dirs_to_commit) { in DeferredCommitKeys() local
255 LOG(INFO) << "Committing upgraded key " << dir; in DeferredCommitKeys()
256 CommitUpgradedKey(keymaster, dir); in DeferredCommitKeys()
263 static bool IsKeyCommitPending(const std::string& dir) { in IsKeyCommitPending() argument
265 if (IsSameFile(dir, dir_to_commit)) return true; in IsKeyCommitPending()
272 static void ScheduleKeyCommit(const std::string& dir) { in ScheduleKeyCommit() argument
274 key_dirs_to_commit.push_back(dir); in ScheduleKeyCommit()
277 static void CancelPendingKeyCommit(const std::string& dir) { in CancelPendingKeyCommit() argument
280 if (IsSameFile(*it, dir)) { in CancelPendingKeyCommit()
281 LOG(DEBUG) << "Cancelling pending commit of upgraded key " << dir in CancelPendingKeyCommit()
329 static KeymasterOperation BeginKeymasterOp(Keymaster& keymaster, const std::string& dir, in BeginKeymasterOp() argument
336 auto blob_file = dir + "/" + kFn_keymaster_key_blob; in BeginKeymasterOp()
337 auto upgraded_blob_file = dir + "/" + kFn_keymaster_key_blob_upgraded; in BeginKeymasterOp()
342 bool already_upgraded = IsKeyCommitPending(dir); in BeginKeymasterOp()
370 ScheduleKeyCommit(dir); in BeginKeymasterOp()
372 if (!CommitUpgradedKey(keymaster, dir)) return KeymasterOperation(); in BeginKeymasterOp()
378 static bool encryptWithKeymasterKey(Keymaster& keymaster, const std::string& dir, in encryptWithKeymasterKey() argument
386 auto opHandle = BeginKeymasterOp(keymaster, dir, keyParams, opParams, &outParams); in encryptWithKeymasterKey()
406 static bool decryptWithKeymasterKey(Keymaster& keymaster, const std::string& dir, in decryptWithKeymasterKey() argument
415 auto opHandle = BeginKeymasterOp(keymaster, dir, keyParams, opParams, nullptr); in decryptWithKeymasterKey()
575 bool storeKey(const std::string& dir, const KeyAuthentication& auth, const KeyBuffer& key) { in storeKey() argument
576 if (TEMP_FAILURE_RETRY(mkdir(dir.c_str(), 0700)) == -1) { in storeKey()
577 PLOG(ERROR) << "key mkdir " << dir; in storeKey()
580 if (!writeStringToFile(kCurrentVersion, dir + "/" + kFn_version)) return false; in storeKey()
582 if (!createSecdiscardable(dir + "/" + kFn_secdiscardable, &secdiscardable_hash)) return false; in storeKey()
584 if (!writeStringToFile(stretching, dir + "/" + kFn_stretching)) return false; in storeKey()
593 if (!writeStringToFile(kmKey, dir + "/" + kFn_keymaster_key_blob)) return false; in storeKey()
595 if (!encryptWithKeymasterKey(keymaster, dir, keyParams, key, &encryptedKey)) return false; in storeKey()
599 if (!writeStringToFile(encryptedKey, dir + "/" + kFn_encrypted_key)) return false; in storeKey()
600 if (!FsyncDirectory(dir)) return false; in storeKey()
625 bool retrieveKey(const std::string& dir, const KeyAuthentication& auth, KeyBuffer* key) { in retrieveKey() argument
627 if (!readFileToString(dir + "/" + kFn_version, &version)) return false; in retrieveKey()
633 if (!readSecdiscardable(dir + "/" + kFn_secdiscardable, &secdiscardable_hash)) return false; in retrieveKey()
635 if (!readFileToString(dir + "/" + kFn_stretching, &stretching)) return false; in retrieveKey()
639 if (!readFileToString(dir + "/" + kFn_encrypted_key, &encryptedMessage)) return false; in retrieveKey()
644 if (!decryptWithKeymasterKey(keymaster, dir, keyParams, encryptedMessage, key)) in retrieveKey()
670 static bool recursiveDeleteKey(const std::string& dir) { in recursiveDeleteKey() argument
671 if (ForkExecvp(std::vector<std::string>{kRmPath, "-rf", dir}) != 0) { in recursiveDeleteKey()
678 bool destroyKey(const std::string& dir) { in destroyKey() argument
681 CancelPendingKeyCommit(dir); in destroyKey()
686 dir + "/" + kFn_encrypted_key, in destroyKey()
687 dir + "/" + kFn_secdiscardable, in destroyKey()
692 auto blob_file = dir + "/" + fn; in destroyKey()
702 success &= recursiveDeleteKey(dir); in destroyKey()