SLOGE("Error getting crypt footer and key\n");
return -1;
}
+
+ if (crypt_ftr.flags & CRYPT_ENCRYPTION_IN_PROGRESS) {
+ SLOGE("Encryption process didn't finish successfully\n");
+ return -2; /* -2 is the clue to the UI that there is no usable data on the disk,
+ * and give the user an option to wipe the disk */
+ }
+
SLOGD("crypt_ftr->fs_size = %lld\n", crypt_ftr.fs_size);
orig_failed_decrypt_count = crypt_ftr.failed_decrypt_count;
/* Initialize a crypt_mnt_ftr for the partition */
cryptfs_init_crypt_mnt_ftr(&crypt_ftr);
crypt_ftr.fs_size = nr_sec - (CRYPT_FOOTER_OFFSET / 512);
+ crypt_ftr.flags |= CRYPT_ENCRYPTION_IN_PROGRESS;
strcpy((char *)crypt_ftr.crypto_type_name, "aes-cbc-essiv:sha256");
/* Make an encrypted master key */
if (! rc) {
/* Success */
+ /* Clear the encryption in progres flag in the footer */
+ crypt_ftr.flags &= ~CRYPT_ENCRYPTION_IN_PROGRESS;
+ put_crypt_ftr_and_key(real_blkdev, &crypt_ftr, 0, 0);
+
sleep(2); /* Give the UI a change to show 100% progress */
sync();
reboot(LINUX_REBOOT_CMD_RESTART);
/* definitions of flags in the structure below */
#define CRYPT_MNT_KEY_UNENCRYPTED 0x1 /* The key for the partition is not encrypted. */
+#define CRYPT_ENCRYPTION_IN_PROGRESS 0x2 /* Set when starting encryption,
+ * clear when done before rebooting */
#define CRYPT_MNT_MAGIC 0xD0B5B1C4