From 75736a8811641e2afdaf15ed0069e28b453bcce6 Mon Sep 17 00:00:00 2001 From: Gaurav Kashyap Date: Fri, 11 Sep 2020 15:24:01 -0700 Subject: [PATCH] vold: Generate storage key without rollback resistance Generate a storage key without rollback_resistance when device doesnt support the corresponding tag. Bug: 168527558 Change-Id: Iaf27c64dba627a31c9cbd9178458bf6785d00251 --- KeyStorage.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/KeyStorage.cpp b/KeyStorage.cpp index 951536b..533a7cb 100644 --- a/KeyStorage.cpp +++ b/KeyStorage.cpp @@ -141,9 +141,12 @@ bool generateWrappedStorageKey(KeyBuffer* key) { if (!keymaster) return false; std::string key_temp; auto paramBuilder = km::AuthorizationSetBuilder().AesEncryptionKey(AES_KEY_BYTES * 8); - paramBuilder.Authorization(km::TAG_ROLLBACK_RESISTANCE); paramBuilder.Authorization(km::TAG_STORAGE_KEY); - if (!keymaster.generateKey(paramBuilder, &key_temp)) return false; + auto paramsWithRollback = paramBuilder; + paramsWithRollback.Authorization(km::TAG_ROLLBACK_RESISTANCE); + if (!keymaster.generateKey(paramsWithRollback, &key_temp)) { + if (!keymaster.generateKey(paramBuilder, &key_temp)) return false; + } *key = KeyBuffer(key_temp.size()); memcpy(reinterpret_cast(key->data()), key_temp.c_str(), key->size()); return true;