Add method to forget private partition keys.
Report both the disk and the partition GUID for private volumes to
userspace, and offer to forget the encryption key for a given
partition GUID.
Bug: 21782268
Change-Id: Ie77a3a58e47bf3563cdb3e4b0edfab1de4d0e6b4
diff --git a/Utils.cpp b/Utils.cpp
index e06111a..2ccd45f 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -52,6 +52,7 @@
security_context_t sFsckUntrustedContext = nullptr;
static const char* kBlkidPath = "/system/bin/blkid";
+static const char* kKeyPath = "/data/misc/vold";
static const char* kProcFilesystems = "/proc/filesystems";
@@ -391,6 +392,14 @@
return OK;
}
+status_t NormalizeHex(const std::string& in, std::string& out) {
+ std::string tmp;
+ if (HexToStr(in, tmp)) {
+ return -EINVAL;
+ }
+ return StrToHex(tmp, out);
+}
+
uint64_t GetFreeBytes(const std::string& path) {
struct statvfs sb;
if (statvfs(path.c_str(), &sb) == 0) {
@@ -509,5 +518,9 @@
return res;
}
+std::string BuildKeyPath(const std::string& partGuid) {
+ return StringPrintf("%s/expand_%s.key", kKeyPath, partGuid.c_str());
+}
+
} // namespace vold
} // namespace android