blob: 4fa2b935433346571061389ca11c773208abe47d [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001#include <sys/types.h>
2#include <unistd.h>
3#include <stdio.h>
4#include <string.h>
5#include <stdlib.h>
6#include <sys/stat.h>
7#include <fcntl.h>
OliverG9606b91e72013-12-06 00:10:56 +00008#ifdef TW_INCLUDE_JB_CRYPTO
Dees_Troy51a0e822012-09-05 15:24:24 -04009#include "../crypto/fs_mgr/include/fs_mgr.h"
OliverG9606b91e72013-12-06 00:10:56 +000010#endif
Dees_Troy51a0e822012-09-05 15:24:24 -040011
12#include "cutils/properties.h"
13
14#ifndef PROPERTY_VALUE_MAX
15#define PROPERTY_VALUE_MAX 255
16#endif
17#ifndef FSTAB_PREFIX
18#define FSTAB_PREFIX "/fstab."
19#endif
20
21int main(void)
22{
23 char prop[PROPERTY_VALUE_MAX];
24 char key_loc[PROPERTY_VALUE_MAX];
25 char blk_dev[PROPERTY_VALUE_MAX];
26 char fstab_filename[PROPERTY_VALUE_MAX + sizeof(FSTAB_PREFIX)];
27
28 printf("This tool will gather the build flags needed for decryption support for TWRP.\n");
29 printf("This tool comes with no warranties whatsoever.\n");
30 printf("http://teamw.in\n\n");
31 property_get("ro.crypto.state", prop, "encrypted");
32 if (strcmp(prop, "encrypted") != 0)
33 printf("Your device is not encrypted, continuing anyway.\n\nTW_INCLUDE_CRYPTO := true\n");
34 property_get("ro.crypto.fs_type", prop, "ERROR");
35 printf("TW_CRYPTO_FS_TYPE := \"%s\"\n", prop);
36 property_get("ro.crypto.fs_real_blkdev", prop, "ERROR");
37 printf("TW_CRYPTO_REAL_BLKDEV := \"%s\"\n", prop);
38 property_get("ro.crypto.fs_mnt_point", prop, "ERROR");
39 printf("TW_CRYPTO_MNT_POINT := \"%s\"\n", prop);
40 property_get("ro.crypto.fs_options", prop, "ERROR");
41 printf("TW_CRYPTO_FS_OPTIONS := \"%s\"\n", prop);
42 property_get("ro.crypto.fs_flags", prop, "ERROR");
43 printf("TW_CRYPTO_FS_FLAGS := \"%s\"\n", prop);
44 property_get("ro.crypto.keyfile.userdata", prop, "footer");
45 printf("TW_CRYPTO_KEY_LOC := \"%s\"\n", prop);
OliverG9606b91e72013-12-06 00:10:56 +000046#ifdef TW_INCLUDE_JB_CRYPTO
Dees_Troy51a0e822012-09-05 15:24:24 -040047 printf("\n*** NEW FOR JELLY BEAN:\n");
48 strcpy(fstab_filename, FSTAB_PREFIX);
49 property_get("ro.hardware", fstab_filename + sizeof(FSTAB_PREFIX) - 1, "");
50 fs_mgr_get_crypt_info(fstab_filename, key_loc, blk_dev, sizeof(key_loc));
51 printf("fstab file location: '%s'\n\nTW_INCLUDE_JB_CRYPTO := true\n", fstab_filename);
OliverG9606b91e72013-12-06 00:10:56 +000052#endif
Dees_Troy51a0e822012-09-05 15:24:24 -040053
54 return 0;
55}