diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2014-02-26 20:36:08 +0100 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2014-02-26 20:37:35 +0100 |
commit | 71413f4ee9a2d345da059793e795d798924b2209 (patch) | |
tree | 37b356f793585a15dad444d5f811f2a1520f4200 /crypto | |
parent | Remove unneeded logging (diff) | |
download | android_bootable_recovery-71413f4ee9a2d345da059793e795d798924b2209.tar android_bootable_recovery-71413f4ee9a2d345da059793e795d798924b2209.tar.gz android_bootable_recovery-71413f4ee9a2d345da059793e795d798924b2209.tar.bz2 android_bootable_recovery-71413f4ee9a2d345da059793e795d798924b2209.tar.lz android_bootable_recovery-71413f4ee9a2d345da059793e795d798924b2209.tar.xz android_bootable_recovery-71413f4ee9a2d345da059793e795d798924b2209.tar.zst android_bootable_recovery-71413f4ee9a2d345da059793e795d798924b2209.zip |
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ics/cryptfs.c | 22 | ||||
-rw-r--r-- | crypto/ics/cryptfs.h | 1 | ||||
-rw-r--r-- | crypto/jb/cryptfs.c | 23 | ||||
-rw-r--r-- | crypto/jb/cryptfs.h | 1 |
4 files changed, 45 insertions, 2 deletions
diff --git a/crypto/ics/cryptfs.c b/crypto/ics/cryptfs.c index 193339ec9..4f3d5d01a 100644 --- a/crypto/ics/cryptfs.c +++ b/crypto/ics/cryptfs.c @@ -653,6 +653,28 @@ int cryptfs_crypto_complete(void) return -1; } +int cryptfs_check_footer(void) +{ + int rc = -1; + char fs_type[PROPERTY_VALUE_MAX]; + char real_blkdev[MAXPATHLEN]; + char fs_options[PROPERTY_VALUE_MAX]; + unsigned long mnt_flags; + struct crypt_mnt_ftr crypt_ftr; + /* Allocate enough space for a 256 bit key, but we may use less */ + unsigned char encrypted_master_key[256]; + unsigned char salt[SALT_LEN]; + + if (get_orig_mount_parms(DATA_MNT_POINT, fs_type, real_blkdev, &mnt_flags, fs_options)) { + printf("Error reading original mount parms for mount point %s\n", DATA_MNT_POINT); + return rc; + } + + rc = get_crypt_ftr_and_key(real_blkdev, &crypt_ftr, encrypted_master_key, salt); + + return rc; +} + int cryptfs_check_passwd(const char *passwd) { char pwbuf[256]; diff --git a/crypto/ics/cryptfs.h b/crypto/ics/cryptfs.h index eee43b3bc..8c8037659 100644 --- a/crypto/ics/cryptfs.h +++ b/crypto/ics/cryptfs.h @@ -76,6 +76,7 @@ struct crypt_mnt_ftr { #ifdef __cplusplus extern "C" { #endif + int cryptfs_check_footer(void); int cryptfs_check_passwd(const char *pw); #ifdef __cplusplus } diff --git a/crypto/jb/cryptfs.c b/crypto/jb/cryptfs.c index 4e5706b64..f9c0d7489 100644 --- a/crypto/jb/cryptfs.c +++ b/crypto/jb/cryptfs.c @@ -1354,13 +1354,32 @@ int cryptfs_crypto_complete(void) #define FSTAB_PREFIX "/fstab." +int cryptfs_check_footer(void) +{ + int rc = -1; + char fstab_filename[PROPERTY_VALUE_MAX + sizeof(FSTAB_PREFIX)]; + char propbuf[PROPERTY_VALUE_MAX]; + struct crypt_mnt_ftr crypt_ftr; + + property_get("ro.hardware", propbuf, ""); + snprintf(fstab_filename, sizeof(fstab_filename), FSTAB_PREFIX"%s", propbuf); + + fstab = fs_mgr_read_fstab(fstab_filename); + if (!fstab) { + printf("failed to open %s\n", fstab_filename); + return -1; + } + + rc = get_crypt_ftr_and_key(&crypt_ftr); + + return rc; +} + int cryptfs_check_passwd(char *passwd) { int rc = -1; char fstab_filename[PROPERTY_VALUE_MAX + sizeof(FSTAB_PREFIX)]; char propbuf[PROPERTY_VALUE_MAX]; - int i; - int flags; property_get("ro.hardware", propbuf, ""); snprintf(fstab_filename, sizeof(fstab_filename), FSTAB_PREFIX"%s", propbuf); diff --git a/crypto/jb/cryptfs.h b/crypto/jb/cryptfs.h index 162159eb0..d815814d3 100644 --- a/crypto/jb/cryptfs.h +++ b/crypto/jb/cryptfs.h @@ -139,6 +139,7 @@ extern "C" { typedef void (*kdf_func)(char *passwd, unsigned char *salt, unsigned char *ikey, void *params); int cryptfs_crypto_complete(void); + int cryptfs_check_footer(void); int cryptfs_check_passwd(char *pw); int cryptfs_verify_passwd(char *newpw); int cryptfs_restart(void); |