Lines Matching refs:dir
199 static KeymasterOperation begin(Keymaster& keymaster, const std::string& dir, in begin() argument
204 auto kmKeyPath = dir + "/" + kFn_keymaster_key_blob; in begin()
215 LOG(DEBUG) << "Upgrading key: " << dir; in begin()
218 auto newKeyPath = dir + "/" + kFn_keymaster_key_blob_upgraded; in begin()
225 if (!android::vold::FsyncDirectory(dir)) { in begin()
226 LOG(ERROR) << "Key dir sync failed: " << dir; in begin()
230 LOG(ERROR) << "Key deletion failed during upgrade, continuing anyway: " << dir; in begin()
234 LOG(INFO) << "Key upgraded: " << dir; in begin()
238 static bool encryptWithKeymasterKey(Keymaster& keymaster, const std::string& dir, in encryptWithKeymasterKey() argument
244 auto opHandle = begin(keymaster, dir, km::KeyPurpose::ENCRYPT, keyParams, opParams, authToken, in encryptWithKeymasterKey()
266 static bool decryptWithKeymasterKey(Keymaster& keymaster, const std::string& dir, in decryptWithKeymasterKey() argument
275 auto opHandle = begin(keymaster, dir, km::KeyPurpose::DECRYPT, keyParams, opParams, authToken, in decryptWithKeymasterKey()
452 bool storeKey(const std::string& dir, const KeyAuthentication& auth, const KeyBuffer& key) { in storeKey() argument
453 if (TEMP_FAILURE_RETRY(mkdir(dir.c_str(), 0700)) == -1) { in storeKey()
454 PLOG(ERROR) << "key mkdir " << dir; in storeKey()
457 if (!writeStringToFile(kCurrentVersion, dir + "/" + kFn_version)) return false; in storeKey()
459 if (!createSecdiscardable(dir + "/" + kFn_secdiscardable, &secdiscardable_hash)) return false; in storeKey()
461 if (!writeStringToFile(stretching, dir + "/" + kFn_stretching)) return false; in storeKey()
468 if (!writeStringToFile(salt, dir + "/" + kFn_salt)) return false; in storeKey()
478 if (!writeStringToFile(kmKey, dir + "/" + kFn_keymaster_key_blob)) return false; in storeKey()
482 if (!encryptWithKeymasterKey(keymaster, dir, keyParams, authToken, key, &encryptedKey, in storeKey()
488 if (!writeStringToFile(encryptedKey, dir + "/" + kFn_encrypted_key)) return false; in storeKey()
489 if (!FsyncDirectory(dir)) return false; in storeKey()
512 bool retrieveKey(const std::string& dir, const KeyAuthentication& auth, KeyBuffer* key, in retrieveKey() argument
515 if (!readFileToString(dir + "/" + kFn_version, &version)) return false; in retrieveKey()
521 if (!readSecdiscardable(dir + "/" + kFn_secdiscardable, &secdiscardable_hash)) return false; in retrieveKey()
523 if (!readFileToString(dir + "/" + kFn_stretching, &stretching)) return false; in retrieveKey()
526 if (!readFileToString(dir + "/" + kFn_salt, &salt)) return false; in retrieveKey()
531 if (!readFileToString(dir + "/" + kFn_encrypted_key, &encryptedMessage)) return false; in retrieveKey()
538 if (!decryptWithKeymasterKey(keymaster, dir, keyParams, authToken, encryptedMessage, key, in retrieveKey()
547 static bool deleteKey(const std::string& dir) { in deleteKey() argument
549 if (!readFileToString(dir + "/" + kFn_keymaster_key_blob, &kmKey)) return false; in deleteKey()
564 static bool recursiveDeleteKey(const std::string& dir) { in recursiveDeleteKey() argument
565 if (ForkExecvp(std::vector<std::string>{kRmPath, "-rf", dir}) != 0) { in recursiveDeleteKey()
572 bool destroyKey(const std::string& dir) { in destroyKey() argument
575 bool uses_km = pathExists(dir + "/" + kFn_keymaster_key_blob); in destroyKey()
577 success &= deleteKey(dir); in destroyKey()
582 dir + "/" + kFn_encrypted_key, in destroyKey()
583 dir + "/" + kFn_secdiscardable, in destroyKey()
586 secdiscard_cmd.emplace_back(dir + "/" + kFn_keymaster_key_blob); in destroyKey()
592 success &= recursiveDeleteKey(dir); in destroyKey()