Lines Matching refs:dir

230 static KeymasterOperation begin(Keymaster& keymaster, const std::string& dir,  in begin()  argument
235 auto kmKeyPath = dir + "/" + kFn_keymaster_key_blob; in begin()
246 LOG(DEBUG) << "Upgrading key: " << dir; in begin()
249 auto newKeyPath = dir + "/" + kFn_keymaster_key_blob_upgraded; in begin()
256 if (!android::vold::FsyncDirectory(dir)) { in begin()
257 LOG(ERROR) << "Key dir sync failed: " << dir; in begin()
261 LOG(ERROR) << "Key deletion failed during upgrade, continuing anyway: " << dir; in begin()
265 LOG(INFO) << "Key upgraded: " << dir; in begin()
269 static bool encryptWithKeymasterKey(Keymaster& keymaster, const std::string& dir, in encryptWithKeymasterKey() argument
275 auto opHandle = begin(keymaster, dir, km::KeyPurpose::ENCRYPT, keyParams, opParams, authToken, in encryptWithKeymasterKey()
297 static bool decryptWithKeymasterKey(Keymaster& keymaster, const std::string& dir, in decryptWithKeymasterKey() argument
306 auto opHandle = begin(keymaster, dir, km::KeyPurpose::DECRYPT, keyParams, opParams, authToken, in decryptWithKeymasterKey()
483 bool storeKey(const std::string& dir, const KeyAuthentication& auth, const KeyBuffer& key) { in storeKey() argument
484 if (TEMP_FAILURE_RETRY(mkdir(dir.c_str(), 0700)) == -1) { in storeKey()
485 PLOG(ERROR) << "key mkdir " << dir; in storeKey()
488 if (!writeStringToFile(kCurrentVersion, dir + "/" + kFn_version)) return false; in storeKey()
490 if (!createSecdiscardable(dir + "/" + kFn_secdiscardable, &secdiscardable_hash)) return false; in storeKey()
492 if (!writeStringToFile(stretching, dir + "/" + kFn_stretching)) return false; in storeKey()
499 if (!writeStringToFile(salt, dir + "/" + kFn_salt)) return false; in storeKey()
509 if (!writeStringToFile(kmKey, dir + "/" + kFn_keymaster_key_blob)) return false; in storeKey()
513 if (!encryptWithKeymasterKey(keymaster, dir, keyParams, authToken, key, &encryptedKey, in storeKey()
519 if (!writeStringToFile(encryptedKey, dir + "/" + kFn_encrypted_key)) return false; in storeKey()
520 if (!FsyncDirectory(dir)) return false; in storeKey()
543 bool retrieveKey(const std::string& dir, const KeyAuthentication& auth, KeyBuffer* key, in retrieveKey() argument
546 if (!readFileToString(dir + "/" + kFn_version, &version)) return false; in retrieveKey()
552 if (!readSecdiscardable(dir + "/" + kFn_secdiscardable, &secdiscardable_hash)) return false; in retrieveKey()
554 if (!readFileToString(dir + "/" + kFn_stretching, &stretching)) return false; in retrieveKey()
557 if (!readFileToString(dir + "/" + kFn_salt, &salt)) return false; in retrieveKey()
562 if (!readFileToString(dir + "/" + kFn_encrypted_key, &encryptedMessage)) return false; in retrieveKey()
569 if (!decryptWithKeymasterKey(keymaster, dir, keyParams, authToken, encryptedMessage, key, in retrieveKey()
578 static bool deleteKey(const std::string& dir) { in deleteKey() argument
580 if (!readFileToString(dir + "/" + kFn_keymaster_key_blob, &kmKey)) return false; in deleteKey()
595 static bool recursiveDeleteKey(const std::string& dir) { in recursiveDeleteKey() argument
596 if (ForkExecvp(std::vector<std::string>{kRmPath, "-rf", dir}) != 0) { in recursiveDeleteKey()
603 bool destroyKey(const std::string& dir) { in destroyKey() argument
606 bool uses_km = pathExists(dir + "/" + kFn_keymaster_key_blob); in destroyKey()
608 success &= deleteKey(dir); in destroyKey()
613 dir + "/" + kFn_encrypted_key, in destroyKey()
614 dir + "/" + kFn_secdiscardable, in destroyKey()
617 secdiscard_cmd.emplace_back(dir + "/" + kFn_keymaster_key_blob); in destroyKey()
623 success &= recursiveDeleteKey(dir); in destroyKey()