summaryrefslogtreecommitdiffstats
path: root/cryptfs_hw.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cryptfs_hw.cpp')
-rw-r--r--cryptfs_hw.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/cryptfs_hw.cpp b/cryptfs_hw.cpp
index 2d9af7a..8f94493 100644
--- a/cryptfs_hw.cpp
+++ b/cryptfs_hw.cpp
@@ -35,6 +35,8 @@
#include <linux/qseecom.h>
#include "cutils/log.h"
#include "cutils/properties.h"
+#include <hardware/hardware.h>
+#include <hardware/keymaster_common.h>
#include "cryptfs_hw.h"
#include "CryptfsHw.h"
@@ -132,3 +134,29 @@ int clear_hw_device_encryption_key()
return rc;
}
+static int get_keymaster_version()
+{
+ int rc = -1;
+ const hw_module_t* mod;
+ rc = hw_get_module_by_class(KEYSTORE_HARDWARE_MODULE_ID, NULL, &mod);
+ if (rc) {
+ ALOGE("could not find any keystore module");
+ return rc;
+ }
+ return mod->module_api_version;
+}
+
+int should_use_keymaster()
+{
+ /*
+ * HW FDE key should be tied to keymaster
+ * if version is above 0.3. this is to
+ * support msm8909 go target.
+ */
+ int rc = 1;
+ if (get_keymaster_version() == KEYMASTER_MODULE_API_VERSION_0_3) {
+ ALOGI("Keymaster version is 0.3");
+ rc = 0;
+ }
+ return rc;
+}