vold: hw_fde: fix OTA issues from L to M
L release passes user password from java layers to vold in hex encoding.
This has been changed in M release where password is coming in ascii
encoding. HW FDE used password which came from java layers directly.
This is causing OTA to fail on encrypted devices. Introduced a new flag
in M which would keep track whether password used for HW FDE is ascii
or not. All M based targets would have this flag set by default. On
OTA targets, first ascii based password would be tried but if that fails,
it would converted to hex based password and verified. If verification
fails, it would return error otherwise password would be updated with
ascii password and flag in crypto footer would be updated.
Change-Id: Ib9953658c597515a624de106b8e0dc35b3dd0531
diff --git a/cryptfs.h b/cryptfs.h
index d3e07f0..ebd202e 100644
--- a/cryptfs.h
+++ b/cryptfs.h
@@ -52,6 +52,14 @@
correctly marked partial encryption */
#define CRYPT_DATA_CORRUPT 0x8 /* Set when encryption is fine, but the
underlying volume is corrupt */
+#ifdef CONFIG_HW_DISK_ENCRYPTION
+/* This flag is used to transition from L->M upgrade. L release passed
+ * a byte for every nible of user password while M release is passing
+ * ascii value of user password.
+ * Random flag value is chosen so that it does not conflict with other use cases
+ */
+#define CRYPT_ASCII_PASSWORD_UPDATED 0x1000
+#endif
/* Allowed values for type in the structure below */
#define CRYPT_TYPE_PASSWORD 0 /* master_key is encrypted with a password