diff --git a/cryptfs.c b/cryptfs.c index e9d6afb..7976e11 100644 --- a/cryptfs.c +++ b/cryptfs.c @@ -3186,7 +3186,8 @@ int cryptfs_enable_internal(char *howarg, int crypt_type, char *passwd, } /* Calculate checksum if we are not finished */ - if (!rc && crypt_ftr.encrypted_upto != crypt_ftr.fs_size) { + if (!rc && how == CRYPTO_ENABLE_INPLACE + && crypt_ftr.encrypted_upto != crypt_ftr.fs_size) { rc = cryptfs_SHA256_fileblock(crypto_blkdev, crypt_ftr.hash_first_block); if (rc) { @@ -3204,7 +3205,8 @@ int cryptfs_enable_internal(char *howarg, int crypt_type, char *passwd, /* Success */ crypt_ftr.flags &= ~CRYPT_INCONSISTENT_STATE; - if (crypt_ftr.encrypted_upto != crypt_ftr.fs_size) { + if (how == CRYPTO_ENABLE_INPLACE + && crypt_ftr.encrypted_upto != crypt_ftr.fs_size) { SLOGD("Encrypted up to sector %lld - will continue after reboot", crypt_ftr.encrypted_upto); crypt_ftr.flags |= CRYPT_ENCRYPTION_IN_PROGRESS; @@ -3212,7 +3214,8 @@ int cryptfs_enable_internal(char *howarg, int crypt_type, char *passwd, put_crypt_ftr_and_key(&crypt_ftr); - if (crypt_ftr.encrypted_upto == crypt_ftr.fs_size) { + if (how == CRYPTO_ENABLE_WIPE + || crypt_ftr.encrypted_upto == crypt_ftr.fs_size) { char value[PROPERTY_VALUE_MAX]; property_get("ro.crypto.state", value, ""); if (!strcmp(value, "")) {