[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, userId = userId,
) )
if (it is VaultUnlockResult.Success) { if (it is VaultUnlockResult.Success) {
Timber.d(
"[Auth] Vault unlocked, method: %s",
initUserCryptoMethod.logTag,
)
clearInvalidUnlockCount(userId = userId) clearInvalidUnlockCount(userId = userId)
trustedDeviceManager trustedDeviceManager
.trustThisDeviceIfNecessary(userId = userId) .trustThisDeviceIfNecessary(userId = userId)
updateKdfIfNeeded(initUserCryptoMethod) updateKdfIfNeeded(initUserCryptoMethod)
migratePinProtectedUserKeyIfNeeded( migratePinProtectedUserKeyIfNeeded(userId = userId)
userId = userId,
initUserCryptoMethod = initUserCryptoMethod,
)
setVaultToUnlocked(userId = userId) setVaultToUnlocked(userId = userId)
} else { } else {
incrementInvalidUnlockCount(userId = userId) 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. * 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 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( private suspend fun migratePinProtectedUserKeyIfNeeded(
userId: String, userId: String,
initUserCryptoMethod: InitUserCryptoMethod,
) { ) {
val encryptedPin = authDiskSource.getEncryptedPin(userId) ?: return val encryptedPin = authDiskSource.getEncryptedPin(userId) ?: return
if (authDiskSource.getPinProtectedUserKeyEnvelope(userId) != null) return if (authDiskSource.getPinProtectedUserKeyEnvelope(userId) != null) return
val inMemoryOnly = authDiskSource.getPinProtectedUserKey(userId) == null val inMemoryOnly = authDiskSource.getPinProtectedUserKey(userId) == null
Timber.d("[Auth] Vault unlocked, method: ${initUserCryptoMethod.logTag}")
vaultSdkSource.enrollPinWithEncryptedPin(userId, encryptedPin) vaultSdkSource.enrollPinWithEncryptedPin(userId, encryptedPin)
.onSuccess { enrollPinResponse -> .onSuccess { enrollPinResponse ->
authDiskSource.storeEncryptedPin( authDiskSource.storeEncryptedPin(

View File

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