[PM-26420] FlightRecorder vault unlock method (#6084)

This commit is contained in:
André Bispo 2025-10-27 17:55:51 +00:00 committed by GitHub
parent 064a98f86b
commit c0f8307361
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 10 deletions

View File

@ -226,14 +226,15 @@ class VaultLockManagerImpl(
userId = userId,
)
if (it is VaultUnlockResult.Success) {
Timber.d(
"[Auth] Vault unlocked, method: %s",
initUserCryptoMethod.logTag,
)
clearInvalidUnlockCount(userId = userId)
trustedDeviceManager
.trustThisDeviceIfNecessary(userId = userId)
updateKdfIfNeeded(initUserCryptoMethod)
migratePinProtectedUserKeyIfNeeded(
userId = userId,
initUserCryptoMethod = initUserCryptoMethod,
)
migratePinProtectedUserKeyIfNeeded(userId = userId)
setVaultToUnlocked(userId = userId)
} else {
incrementInvalidUnlockCount(userId = userId)
@ -315,19 +316,15 @@ class VaultLockManagerImpl(
* Optionally marks the envelope as in-memory only if the PIN-protected user key is not present.
*
* @param userId The ID of the user for whom to migrate the PIN-protected user key.
* @param initUserCryptoMethod The method used to initialize the user's crypto.
*/
private suspend fun migratePinProtectedUserKeyIfNeeded(
userId: String,
initUserCryptoMethod: InitUserCryptoMethod,
) {
val encryptedPin = authDiskSource.getEncryptedPin(userId) ?: return
if (authDiskSource.getPinProtectedUserKeyEnvelope(userId) != null) return
val inMemoryOnly = authDiskSource.getPinProtectedUserKey(userId) == null
Timber.d("[Auth] Vault unlocked, method: ${initUserCryptoMethod.logTag}")
vaultSdkSource.enrollPinWithEncryptedPin(userId, encryptedPin)
.onSuccess { enrollPinResponse ->
authDiskSource.storeEncryptedPin(

View File

@ -546,6 +546,7 @@ class VaultRepositoryImpl(
userId: String,
initUserCryptoMethod: InitUserCryptoMethod,
) {
Timber.d("[Auth] Vault unlocked, method: ${initUserCryptoMethod.logTag}")
val encryptedPin = authDiskSource.getEncryptedPin(userId = userId) ?: return
val existingPinProtectedUserKeyEnvelope = authDiskSource
.getPinProtectedUserKeyEnvelope(
@ -553,8 +554,6 @@ class VaultRepositoryImpl(
)
if (existingPinProtectedUserKeyEnvelope != null) return
Timber.d("[Auth] Vault unlocked, method: ${initUserCryptoMethod.logTag}")
vaultSdkSource
.enrollPinWithEncryptedPin(
userId = userId,