crypto: Update crypto fde
* Some missed in https://github.com/TeamWin/android_bootable_recovery/commit/191a6948d9f1f627cc53c38d72d4bce2e7897753
* Crypto msg from https://source.codeaurora.org/quic/la/platform/system/vold/commit/cryptfs.cpp?h=LA.UM.8.1.r1-13500-sm8150.0&id=e1a7e772699216121dd8fa774381ffeedb076139
* As devices required to update 'Upgraded key' through keymaster in v4.0.
Change-Id: Ia66be6917c4690f0d70ba89ea33ebfa2fcb6974a
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
diff --git a/crypto/fde/cryptfs.cpp b/crypto/fde/cryptfs.cpp
index 5b8757c..9ba4f0b 100644
--- a/crypto/fde/cryptfs.cpp
+++ b/crypto/fde/cryptfs.cpp
@@ -528,7 +528,9 @@
ftr->keymaster_blob, KEYMASTER_BLOB_SIZE, &ftr->keymaster_blob_size);
#endif //TW_KEYMASTER_MAX_API == 3
#if TW_KEYMASTER_MAX_API >= 4
- //for (;;) {
+ for (int c = 1;c <= 20;c++) { // 20 tries are enough for signing keymaster
+ if (c > 2)
+ usleep(5000); // if failed in two tries lets rest
auto result = keymaster_sign_object_for_cryptfs_scrypt(
ftr->keymaster_blob, ftr->keymaster_blob_size, KEYMASTER_CRYPTFS_RATE_LIMIT, to_sign,
to_sign_size, signature, signature_size);
@@ -552,8 +554,7 @@
SLOGE("Failed to write upgraded key to disk\n");
}*/
SLOGD("Key upgraded successfully\n");
- return 0;
- //}
+ }
#endif
return -1;
}
@@ -912,7 +913,10 @@
tgt->length = crypt_ftr->fs_size;
crypt_params = buffer + sizeof(struct dm_ioctl) + sizeof(struct dm_target_spec);
buff_offset = crypt_params - buffer;
- SLOGI("Extra parameters for dm_crypt: %s\n", extra_params);
+ SLOGI(
+ "Creating crypto dev \"%s\"; cipher=%s, keysize=%u, real_dev=%s, len=%llu, params=\"%s\"\n",
+ name, crypt_ftr->crypto_type_name, crypt_ftr->keysize, real_blk_name, tgt->length * 512,
+ extra_params);
#ifdef CONFIG_HW_DISK_ENCRYPTION
if(is_hw_disk_encryption((char*)crypt_ftr->crypto_type_name)) {