Skip to content

Commit 631e269

Browse files
authored
Add additional backup and restore logging
1 parent 775af25 commit 631e269

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

Signal/Registration/RegistrationCoordinatorImpl.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,7 @@ public class RegistrationCoordinatorImpl: RegistrationCoordinator {
15261526
accountIdentity: AccountIdentity,
15271527
) async throws -> BackupServiceAuth {
15281528
let backupKey = try MessageRootBackupKey(accountEntropyPool: accountEntropyPool, aci: accountIdentity.aci)
1529+
Logger.info("Fetching backup auth [\(accountEntropyPool.getLoggingKey())]")
15291530

15301531
func fetchBackupServiceAuth() async throws -> BackupServiceAuth {
15311532
return try await self.deps.backupRequestManager.fetchBackupServiceAuthForRegistration(

SignalServiceKit/Backups/BackupExportJob/BackupExportJob.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ class BackupExportJobImpl: BackupExportJob {
128128
private func _exportAndUploadBackup(
129129
mode: BackupExportJobMode,
130130
) async throws {
131-
let logger = logger.suffixed(with: "[\(mode)]")
132-
logger.info("Starting...")
133-
134131
await db.awaitableWrite {
135132
self.backupSettingsStore.setIsBackupUploadQueueSuspended(false, tx: $0)
136133
}
@@ -140,9 +137,11 @@ class BackupExportJobImpl: BackupExportJob {
140137
backupKey,
141138
shouldAllowBackupUploadsOnCellular,
142139
currentBackupPlan,
140+
logger,
143141
) = try db.read { tx throws in
144142
guard
145143
tsAccountManager.registrationState(tx: tx).isRegisteredPrimaryDevice,
144+
let aep = accountKeyStore.getAccountEntropyPool(tx: tx),
146145
let localIdentifiers = tsAccountManager.localIdentifiers(tx: tx)
147146
else {
148147
throw NotRegisteredError()
@@ -152,11 +151,15 @@ class BackupExportJobImpl: BackupExportJob {
152151
throw OWSAssertionError("Missing or invalid message root backup key.")
153152
}
154153

154+
let logger = self.logger.suffixed(with: "[\(mode)][\(aep.getLoggingKey())]")
155+
logger.info("Starting...")
156+
155157
return (
156158
localIdentifiers,
157159
backupKey,
158160
backupSettingsStore.shouldAllowBackupUploadsOnCellular(tx: tx),
159161
backupSettingsStore.backupPlan(tx: tx),
162+
logger,
160163
)
161164
}
162165

SignalServiceKit/SecureValueRecovery/AccountEntropyPool/AccountEntropyPool.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,8 @@ public struct AccountEntropyPool: Codable, Equatable {
5151
public func getBackupKey() -> BackupKey {
5252
return try! LibSignalClient.AccountEntropyPool.deriveBackupKey(rawString)
5353
}
54+
55+
public func getLoggingKey() -> String {
56+
return String(getMasterKey().data(for: .loggingKey).canonicalStringRepresentation.suffix(4))
57+
}
5458
}

SignalServiceKit/SecureValueRecovery/MasterKey.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public struct MasterKey: Codable {
3838
}
3939

4040
switch key {
41+
case .loggingKey:
42+
return SVR.DerivedKeyData(keyType: .loggingKey, dataToDeriveFrom: masterKey)
4143
case .registrationLock:
4244
return SVR.DerivedKeyData(keyType: .registrationLock, dataToDeriveFrom: masterKey)
4345
case .registrationRecoveryPassword:
@@ -94,6 +96,8 @@ private extension SVR.DerivedKeyData {
9496
private extension SVR.DerivedKey {
9597
private var infoString: String {
9698
switch self {
99+
case .loggingKey:
100+
return "Logging Key"
97101
case .registrationLock:
98102
return "Registration Lock"
99103
case .registrationRecoveryPassword:
@@ -111,6 +115,7 @@ private extension SVR.DerivedKey {
111115
let infoData = Data(infoString.utf8)
112116
switch self {
113117
case
118+
.loggingKey,
114119
.registrationLock,
115120
.registrationRecoveryPassword,
116121
.storageService,

SignalServiceKit/SecureValueRecovery/SecureValueRecovery.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public enum SVR {
5050
/// used to locate and decrypt Storage Service records.
5151
case storageServiceManifest(version: UInt64)
5252

53+
/// A key used to hash values used for logging.
54+
case loggingKey
55+
5356
/// Today, Storage Service records are encrypted using a key stored in
5457
/// the manifest. However, in the past they were encrypted using an
5558
/// SVR-derived key. This case represents the key formerly used to
@@ -101,7 +104,7 @@ public enum SVR {
101104
switch type {
102105
case .storageService, .storageServiceManifest, .legacy_storageServiceRecord, .registrationRecoveryPassword:
103106
return rawData.base64EncodedString()
104-
case .registrationLock:
107+
case .registrationLock, .loggingKey:
105108
return rawData.hexadecimalString
106109
}
107110
}

0 commit comments

Comments
 (0)