summaryrefslogtreecommitdiffstats
path: root/crypto/cryptsettings
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/cryptsettings')
-rw-r--r--crypto/cryptsettings/Android.mk13
-rw-r--r--crypto/cryptsettings/cryptsettings.c51
2 files changed, 64 insertions, 0 deletions
diff --git a/crypto/cryptsettings/Android.mk b/crypto/cryptsettings/Android.mk
new file mode 100644
index 000000000..9e7aa5f38
--- /dev/null
+++ b/crypto/cryptsettings/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ cryptsettings.c
+LOCAL_CFLAGS:= -g -c -W
+LOCAL_MODULE:=cryptsettings
+LOCAL_MODULE_TAGS:= eng
+LOCAL_SHARED_LIBRARIES += libc libcutils
+LOCAL_STATIC_LIBRARIES += libfs_mgrtwrp
+LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
+include $(BUILD_EXECUTABLE)
diff --git a/crypto/cryptsettings/cryptsettings.c b/crypto/cryptsettings/cryptsettings.c
new file mode 100644
index 000000000..79fad7198
--- /dev/null
+++ b/crypto/cryptsettings/cryptsettings.c
@@ -0,0 +1,51 @@
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "../crypto/fs_mgr/include/fs_mgr.h"
+
+#include "cutils/properties.h"
+
+#ifndef PROPERTY_VALUE_MAX
+#define PROPERTY_VALUE_MAX 255
+#endif
+#ifndef FSTAB_PREFIX
+#define FSTAB_PREFIX "/fstab."
+#endif
+
+int main(void)
+{
+ char prop[PROPERTY_VALUE_MAX];
+ char key_loc[PROPERTY_VALUE_MAX];
+ char blk_dev[PROPERTY_VALUE_MAX];
+ char fstab_filename[PROPERTY_VALUE_MAX + sizeof(FSTAB_PREFIX)];
+
+ printf("This tool will gather the build flags needed for decryption support for TWRP.\n");
+ printf("This tool comes with no warranties whatsoever.\n");
+ printf("http://teamw.in\n\n");
+ property_get("ro.crypto.state", prop, "encrypted");
+ if (strcmp(prop, "encrypted") != 0)
+ printf("Your device is not encrypted, continuing anyway.\n\nTW_INCLUDE_CRYPTO := true\n");
+ property_get("ro.crypto.fs_type", prop, "ERROR");
+ printf("TW_CRYPTO_FS_TYPE := \"%s\"\n", prop);
+ property_get("ro.crypto.fs_real_blkdev", prop, "ERROR");
+ printf("TW_CRYPTO_REAL_BLKDEV := \"%s\"\n", prop);
+ property_get("ro.crypto.fs_mnt_point", prop, "ERROR");
+ printf("TW_CRYPTO_MNT_POINT := \"%s\"\n", prop);
+ property_get("ro.crypto.fs_options", prop, "ERROR");
+ printf("TW_CRYPTO_FS_OPTIONS := \"%s\"\n", prop);
+ property_get("ro.crypto.fs_flags", prop, "ERROR");
+ printf("TW_CRYPTO_FS_FLAGS := \"%s\"\n", prop);
+ property_get("ro.crypto.keyfile.userdata", prop, "footer");
+ printf("TW_CRYPTO_KEY_LOC := \"%s\"\n", prop);
+ printf("\n*** NEW FOR JELLY BEAN:\n");
+ strcpy(fstab_filename, FSTAB_PREFIX);
+ property_get("ro.hardware", fstab_filename + sizeof(FSTAB_PREFIX) - 1, "");
+ fs_mgr_get_crypt_info(fstab_filename, key_loc, blk_dev, sizeof(key_loc));
+ printf("fstab file location: '%s'\n\nTW_INCLUDE_JB_CRYPTO := true\n", fstab_filename);
+
+ return 0;
+}