From 83ec2af13a970695390b5a582692910d71ebf0b5 Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Wed, 20 Dec 2017 19:12:59 +0200 Subject: cryptfs_hw: Add compatibility for pre-O hw crypto * Restore compatibility for pre-O way of hw crypto interaction with qsee as the new way is not compatible with old blobs. * Old blobs and current OSS keymaster still use the old property to check if qseecomd is loaded. * This conditionally reverts: cryptfs_hw: Add new APIs for key management 84ac4882d6feeceb24e983a4eaba1d148c2ba3e6 cryptfs_hw: Use HW keymaster for FDE keys a5d3a02eb13362490222ac2a7eefde6543546e31 cryptfs_hw: Update listener status flag eec7d0b6d8e690ebe268965e89593812d607b3a8 Change-Id: I9a5db406c16c3610237a1b85fbfab5c0d63e4960 --- Android.bp | 8 ++++ cryptfs_hw.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 118 insertions(+), 14 deletions(-) diff --git a/Android.bp b/Android.bp index 8aea8b6..12e2aa6 100644 --- a/Android.bp +++ b/Android.bp @@ -16,6 +16,14 @@ cc_library_shared { srcs: sourceFiles, shared_libs: commonSharedLibraries, + product_variables: { + lineage: { + supports_legacy_hw_fde: { + cflags: ["-DLEGACY_HW_DISK_ENCRYPTION"], + }, + }, + }, + owner: "qti", } diff --git a/cryptfs_hw.c b/cryptfs_hw.c index a5d76ef..36d5d48 100644 --- a/cryptfs_hw.c +++ b/cryptfs_hw.c @@ -45,6 +45,10 @@ #include "cutils/android_reboot.h" #include "cryptfs_hw.h" +#ifdef LEGACY_HW_DISK_ENCRYPTION +#define QSEECOM_LIBRARY_NAME "libQSEEComAPI.so" +#endif + /* * When device comes up or when user tries to change the password, user can * try wrong password upto a certain number of times. If user enters wrong @@ -59,6 +63,13 @@ #define SET_HW_DISK_ENC_KEY 1 #define UPDATE_HW_DISK_ENC_KEY 2 +#ifdef LEGACY_HW_DISK_ENCRYPTION +static int loaded_library = 0; +static int (*qseecom_create_key)(int, void*); +static int (*qseecom_update_key)(int, void*, void*); +static int (*qseecom_wipe_key)(int); +#endif + #define CRYPTFS_HW_KMS_CLEAR_KEY 0 #define CRYPTFS_HW_KMS_WIPE_KEY 1 #define CRYPTFS_HW_UP_CHECK_COUNT 10 @@ -85,6 +96,89 @@ static inline void* secure_memset(void* v, int c , size_t n) return v; } +#ifdef LEGACY_HW_DISK_ENCRYPTION +static int is_qseecom_up() +{ + int i = 0; + char value[PROPERTY_VALUE_MAX] = {0}; + + for (; imodule_api_version; } +#endif int should_use_keymaster() { +#ifdef LEGACY_HW_DISK_ENCRYPTION + /* + * HW FDE key should be tied to keymaster only if + * new Keymaster is available + */ + int rc = 0; + if (get_keymaster_version() != KEYMASTER_MODULE_API_VERSION_1_0) { + SLOGI("Keymaster version is not 1.0"); + return rc; + } +#else /* * HW FDE key should be tied to keymaster */ +#endif + return 1; } -- cgit v1.2.3