summaryrefslogtreecommitdiffstats
path: root/cryptfs_hw.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cryptfs_hw.cpp')
-rw-r--r--cryptfs_hw.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/cryptfs_hw.cpp b/cryptfs_hw.cpp
index 6cd634d..c1d42c9 100644
--- a/cryptfs_hw.cpp
+++ b/cryptfs_hw.cpp
@@ -26,6 +26,8 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#define LOG_TAG "Cryptfs_hw"
+
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
@@ -34,8 +36,10 @@
#include <errno.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"
+#include <vendor/qti/hardware/cryptfshw/1.0/ICryptfsHw.h>
using android::sp;
using vendor::qti::hardware::cryptfshw::V1_0::ICryptfsHw;
@@ -124,3 +128,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;
+}