summaryrefslogtreecommitdiffstats
path: root/crypto/cryptsettings
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2012-09-05 21:24:24 +0200
committerDees_Troy <dees_troy@teamw.in>2012-09-05 21:24:31 +0200
commit51a0e82eb29a6dfc79f93479883383fbdbf8bcc2 (patch)
tree52fc18206eb0feba9f50dc3b0ede9fdc5e40f35e /crypto/cryptsettings
parentInitial stub of partitions.hpp (diff)
downloadandroid_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar.gz
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar.bz2
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar.lz
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar.xz
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar.zst
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.zip
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;
+}