Lines Matching refs:dir

163 static KeymasterOperation begin(Keymaster& keymaster, const std::string& dir,  in begin()  argument
168 auto kmKeyPath = dir + "/" + kFn_keymaster_key_blob; in begin()
179 LOG(DEBUG) << "Upgrading key: " << dir; in begin()
182 auto newKeyPath = dir + "/" + kFn_keymaster_key_blob_upgraded; in begin()
189 LOG(ERROR) << "Key deletion failed during upgrade, continuing anyway: " << dir; in begin()
192 LOG(INFO) << "Key upgraded: " << dir; in begin()
196 static bool encryptWithKeymasterKey(Keymaster& keymaster, const std::string& dir, in encryptWithKeymasterKey() argument
201 auto opHandle = begin(keymaster, dir, KeyPurpose::ENCRYPT, keyParams, opParams, &outParams); in encryptWithKeymasterKey()
221 static bool decryptWithKeymasterKey(Keymaster& keymaster, const std::string& dir, in decryptWithKeymasterKey() argument
228 auto opHandle = begin(keymaster, dir, KeyPurpose::DECRYPT, keyParams, opParams, nullptr); in decryptWithKeymasterKey()
403 bool storeKey(const std::string& dir, const KeyAuthentication& auth, const std::string& key) { in storeKey() argument
404 if (TEMP_FAILURE_RETRY(mkdir(dir.c_str(), 0700)) == -1) { in storeKey()
405 PLOG(ERROR) << "key mkdir " << dir; in storeKey()
408 if (!writeStringToFile(kCurrentVersion, dir + "/" + kFn_version)) return false; in storeKey()
411 if (!writeStringToFile(secdiscardable, dir + "/" + kFn_secdiscardable)) return false; in storeKey()
413 if (!writeStringToFile(stretching, dir + "/" + kFn_stretching)) return false; in storeKey()
420 if (!writeStringToFile(salt, dir + "/" + kFn_salt)) return false; in storeKey()
430 if (!writeStringToFile(kmKey, dir + "/" + kFn_keymaster_key_blob)) return false; in storeKey()
432 if (!encryptWithKeymasterKey(keymaster, dir, keyParams, key, &encryptedKey)) return false; in storeKey()
436 if (!writeStringToFile(encryptedKey, dir + "/" + kFn_encrypted_key)) return false; in storeKey()
440 bool retrieveKey(const std::string& dir, const KeyAuthentication& auth, std::string* key) { in retrieveKey() argument
442 if (!readFileToString(dir + "/" + kFn_version, &version)) return false; in retrieveKey()
448 if (!readFileToString(dir + "/" + kFn_secdiscardable, &secdiscardable)) return false; in retrieveKey()
450 if (!readFileToString(dir + "/" + kFn_stretching, &stretching)) return false; in retrieveKey()
453 if (!readFileToString(dir + "/" + kFn_salt, &salt)) return false; in retrieveKey()
458 if (!readFileToString(dir + "/" + kFn_encrypted_key, &encryptedMessage)) return false; in retrieveKey()
463 … if (!decryptWithKeymasterKey(keymaster, dir, keyParams, encryptedMessage, key)) return false; in retrieveKey()
470 static bool deleteKey(const std::string& dir) { in deleteKey() argument
472 if (!readFileToString(dir + "/" + kFn_keymaster_key_blob, &kmKey)) return false; in deleteKey()
479 static bool runSecdiscard(const std::string& dir) { in runSecdiscard() argument
482 dir + "/" + kFn_encrypted_key, in runSecdiscard()
483 dir + "/" + kFn_keymaster_key_blob, in runSecdiscard()
484 dir + "/" + kFn_secdiscardable, in runSecdiscard()
502 static bool recursiveDeleteKey(const std::string& dir) { in recursiveDeleteKey() argument
503 if (ForkExecvp(std::vector<std::string>{kRmPath, "-rf", dir}) != 0) { in recursiveDeleteKey()
510 bool destroyKey(const std::string& dir) { in destroyKey() argument
513 success &= deleteKey(dir); in destroyKey()
514 success &= runSecdiscard(dir); in destroyKey()
515 success &= recursiveDeleteKey(dir); in destroyKey()