@@ -33,9 +33,9 @@ import org.matrix.android.sdk.api.session.crypto.GlobalCryptoConfig
33
33
import org.matrix.android.sdk.api.session.crypto.NewSessionListener
34
34
import org.matrix.android.sdk.api.session.crypto.OutgoingKeyRequest
35
35
import org.matrix.android.sdk.api.session.crypto.OutgoingRoomKeyRequestState
36
- import org.matrix.android.sdk.api.session.crypto.crosssigning.CryptoCrossSigningKeys
37
36
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
38
37
import org.matrix.android.sdk.api.session.crypto.crosssigning.PrivateKeysInfo
38
+ import org.matrix.android.sdk.api.session.crypto.crosssigning.UserIdentity
39
39
import org.matrix.android.sdk.api.session.crypto.keysbackup.SavedKeyBackupKeyInfo
40
40
import org.matrix.android.sdk.api.session.crypto.model.AuditTrail
41
41
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
@@ -330,23 +330,23 @@ internal class RealmCryptoStore @Inject constructor(
330
330
}
331
331
}
332
332
333
- override fun storeUserCrossSigningKeys (
333
+ override fun storeUserIdentity (
334
334
userId : String ,
335
- cryptoCrossSigningKeys : CryptoCrossSigningKeys ,
335
+ userIdentity : UserIdentity ,
336
336
) {
337
- doRealmTransaction(" storeUserCrossSigningKeys " , realmConfiguration) { realm ->
338
- storeUserCrossSigningKeys (realm, userId, cryptoCrossSigningKeys )
337
+ doRealmTransaction(" storeUserIdentity " , realmConfiguration) { realm ->
338
+ storeUserIdentity (realm, userId, userIdentity )
339
339
}
340
340
}
341
341
342
- private fun storeUserCrossSigningKeys (
342
+ private fun storeUserIdentity (
343
343
realm : Realm ,
344
344
userId : String ,
345
- keys : CryptoCrossSigningKeys ,
345
+ userIdentity : UserIdentity ,
346
346
) {
347
347
UserEntity .getOrCreate(realm, userId)
348
348
.let { userEntity ->
349
- if (keys .masterKey == null || keys .selfSigningKey == null ) {
349
+ if (userIdentity .masterKey == null || userIdentity .selfSigningKey == null ) {
350
350
// The user has disabled cross signing?
351
351
userEntity.crossSigningInfoEntity?.deleteOnCascade()
352
352
userEntity.crossSigningInfoEntity = null
@@ -355,11 +355,11 @@ internal class RealmCryptoStore @Inject constructor(
355
355
CrossSigningInfoEntity .getOrCreate(realm, userId).let { signingInfo ->
356
356
// What should we do if we detect a change of the keys?
357
357
val existingMaster = signingInfo.getMasterKey()
358
- if (existingMaster != null && existingMaster.publicKeyBase64 == keys .masterKey.unpaddedBase64PublicKey) {
359
- crossSigningKeysMapper.update(existingMaster, keys .masterKey)
358
+ if (existingMaster != null && existingMaster.publicKeyBase64 == userIdentity .masterKey.unpaddedBase64PublicKey) {
359
+ crossSigningKeysMapper.update(existingMaster, userIdentity .masterKey)
360
360
} else {
361
361
Timber .d(" ## CrossSigning MSK change for $userId " )
362
- val keyEntity = crossSigningKeysMapper.map(keys .masterKey)
362
+ val keyEntity = crossSigningKeysMapper.map(userIdentity .masterKey)
363
363
signingInfo.setMasterKey(keyEntity)
364
364
if (userId == this .userId) {
365
365
shouldResetMyDevicesLocalTrust = true
@@ -374,11 +374,11 @@ internal class RealmCryptoStore @Inject constructor(
374
374
}
375
375
376
376
val existingSelfSigned = signingInfo.getSelfSignedKey()
377
- if (existingSelfSigned != null && existingSelfSigned.publicKeyBase64 == keys .selfSigningKey.unpaddedBase64PublicKey) {
378
- crossSigningKeysMapper.update(existingSelfSigned, keys .selfSigningKey)
377
+ if (existingSelfSigned != null && existingSelfSigned.publicKeyBase64 == userIdentity .selfSigningKey.unpaddedBase64PublicKey) {
378
+ crossSigningKeysMapper.update(existingSelfSigned, userIdentity .selfSigningKey)
379
379
} else {
380
380
Timber .d(" ## CrossSigning SSK change for $userId " )
381
- val keyEntity = crossSigningKeysMapper.map(keys .selfSigningKey)
381
+ val keyEntity = crossSigningKeysMapper.map(userIdentity .selfSigningKey)
382
382
signingInfo.setSelfSignedKey(keyEntity)
383
383
if (userId == this .userId) {
384
384
shouldResetMyDevicesLocalTrust = true
@@ -390,13 +390,13 @@ internal class RealmCryptoStore @Inject constructor(
390
390
}
391
391
392
392
// Only for me
393
- if (keys .userSigningKey != null ) {
393
+ if (userIdentity .userSigningKey != null ) {
394
394
val existingUSK = signingInfo.getUserSigningKey()
395
- if (existingUSK != null && existingUSK.publicKeyBase64 == keys .userSigningKey.unpaddedBase64PublicKey) {
396
- crossSigningKeysMapper.update(existingUSK, keys .userSigningKey)
395
+ if (existingUSK != null && existingUSK.publicKeyBase64 == userIdentity .userSigningKey.unpaddedBase64PublicKey) {
396
+ crossSigningKeysMapper.update(existingUSK, userIdentity .userSigningKey)
397
397
} else {
398
398
Timber .d(" ## CrossSigning USK change for $userId " )
399
- val keyEntity = crossSigningKeysMapper.map(keys .userSigningKey)
399
+ val keyEntity = crossSigningKeysMapper.map(userIdentity .userSigningKey)
400
400
signingInfo.setUserSignedKey(keyEntity)
401
401
if (userId == this .userId) {
402
402
shouldResetMyDevicesLocalTrust = true
@@ -1857,8 +1857,8 @@ internal class RealmCryptoStore @Inject constructor(
1857
1857
userDataToStore.userDevices.forEach {
1858
1858
storeUserDevices(realm, it.key, it.value)
1859
1859
}
1860
- userDataToStore.userCrossSigningKeys .forEach {
1861
- storeUserCrossSigningKeys (realm, it.key, it.value)
1860
+ userDataToStore.userIdentities .forEach {
1861
+ storeUserIdentity (realm, it.key, it.value)
1862
1862
}
1863
1863
}
1864
1864
}
0 commit comments