Fix encrypt-and-wipe

encrypt-and-wipe was broken when checks were added that encryption succeeded
which assumed a 'normal' full encrypt traversing the device.

encrypt-and-wipe doesn't traverse, it just lays down a file system over
the encrypted device, so in this mode do not check the amount encrypted -
it will always be 0.

Bug: 18511900
Change-Id: Icb1d7e0cdb67abd2eac0ab3cbfc1a88912768f9d
This commit is contained in:
Paul Lawrence 2014-11-25 14:57:32 -08:00
parent bb7d9afea9
commit b1eb7a06ee

View file

@ -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, "")) {