@@ -33,7 +33,7 @@ import org.matrix.android.sdk.api.session.crypto.GlobalCryptoConfig
3333import org.matrix.android.sdk.api.session.crypto.NewSessionListener
3434import org.matrix.android.sdk.api.session.crypto.OutgoingKeyRequest
3535import org.matrix.android.sdk.api.session.crypto.OutgoingRoomKeyRequestState
36- import org.matrix.android.sdk.api.session.crypto.crosssigning.CryptoCrossSigningKey
36+ import org.matrix.android.sdk.api.session.crypto.crosssigning.CryptoCrossSigningKeys
3737import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
3838import org.matrix.android.sdk.api.session.crypto.crosssigning.PrivateKeysInfo
3939import org.matrix.android.sdk.api.session.crypto.keysbackup.SavedKeyBackupKeyInfo
@@ -332,25 +332,21 @@ internal class RealmCryptoStore @Inject constructor(
332332
333333 override fun storeUserCrossSigningKeys (
334334 userId : String ,
335- masterKey : CryptoCrossSigningKey ? ,
336- selfSigningKey : CryptoCrossSigningKey ? ,
337- userSigningKey : CryptoCrossSigningKey ?
335+ cryptoCrossSigningKeys : CryptoCrossSigningKeys ,
338336 ) {
339337 doRealmTransaction(" storeUserCrossSigningKeys" , realmConfiguration) { realm ->
340- storeUserCrossSigningKeys(realm, userId, masterKey, selfSigningKey, userSigningKey )
338+ storeUserCrossSigningKeys(realm, userId, cryptoCrossSigningKeys )
341339 }
342340 }
343341
344342 private fun storeUserCrossSigningKeys (
345343 realm : Realm ,
346344 userId : String ,
347- masterKey : CryptoCrossSigningKey ? ,
348- selfSigningKey : CryptoCrossSigningKey ? ,
349- userSigningKey : CryptoCrossSigningKey ?
345+ keys : CryptoCrossSigningKeys ,
350346 ) {
351347 UserEntity .getOrCreate(realm, userId)
352348 .let { userEntity ->
353- if (masterKey == null || selfSigningKey == null ) {
349+ if (keys. masterKey == null || keys. selfSigningKey == null ) {
354350 // The user has disabled cross signing?
355351 userEntity.crossSigningInfoEntity?.deleteOnCascade()
356352 userEntity.crossSigningInfoEntity = null
@@ -359,11 +355,11 @@ internal class RealmCryptoStore @Inject constructor(
359355 CrossSigningInfoEntity .getOrCreate(realm, userId).let { signingInfo ->
360356 // What should we do if we detect a change of the keys?
361357 val existingMaster = signingInfo.getMasterKey()
362- if (existingMaster != null && existingMaster.publicKeyBase64 == masterKey.unpaddedBase64PublicKey) {
363- crossSigningKeysMapper.update(existingMaster, masterKey)
358+ if (existingMaster != null && existingMaster.publicKeyBase64 == keys. masterKey.unpaddedBase64PublicKey) {
359+ crossSigningKeysMapper.update(existingMaster, keys. masterKey)
364360 } else {
365361 Timber .d(" ## CrossSigning MSK change for $userId " )
366- val keyEntity = crossSigningKeysMapper.map(masterKey)
362+ val keyEntity = crossSigningKeysMapper.map(keys. masterKey)
367363 signingInfo.setMasterKey(keyEntity)
368364 if (userId == this .userId) {
369365 shouldResetMyDevicesLocalTrust = true
@@ -378,11 +374,11 @@ internal class RealmCryptoStore @Inject constructor(
378374 }
379375
380376 val existingSelfSigned = signingInfo.getSelfSignedKey()
381- if (existingSelfSigned != null && existingSelfSigned.publicKeyBase64 == selfSigningKey.unpaddedBase64PublicKey) {
382- crossSigningKeysMapper.update(existingSelfSigned, selfSigningKey)
377+ if (existingSelfSigned != null && existingSelfSigned.publicKeyBase64 == keys. selfSigningKey.unpaddedBase64PublicKey) {
378+ crossSigningKeysMapper.update(existingSelfSigned, keys. selfSigningKey)
383379 } else {
384380 Timber .d(" ## CrossSigning SSK change for $userId " )
385- val keyEntity = crossSigningKeysMapper.map(selfSigningKey)
381+ val keyEntity = crossSigningKeysMapper.map(keys. selfSigningKey)
386382 signingInfo.setSelfSignedKey(keyEntity)
387383 if (userId == this .userId) {
388384 shouldResetMyDevicesLocalTrust = true
@@ -394,13 +390,13 @@ internal class RealmCryptoStore @Inject constructor(
394390 }
395391
396392 // Only for me
397- if (userSigningKey != null ) {
393+ if (keys. userSigningKey != null ) {
398394 val existingUSK = signingInfo.getUserSigningKey()
399- if (existingUSK != null && existingUSK.publicKeyBase64 == userSigningKey.unpaddedBase64PublicKey) {
400- crossSigningKeysMapper.update(existingUSK, userSigningKey)
395+ if (existingUSK != null && existingUSK.publicKeyBase64 == keys. userSigningKey.unpaddedBase64PublicKey) {
396+ crossSigningKeysMapper.update(existingUSK, keys. userSigningKey)
401397 } else {
402398 Timber .d(" ## CrossSigning USK change for $userId " )
403- val keyEntity = crossSigningKeysMapper.map(userSigningKey)
399+ val keyEntity = crossSigningKeysMapper.map(keys. userSigningKey)
404400 signingInfo.setUserSignedKey(keyEntity)
405401 if (userId == this .userId) {
406402 shouldResetMyDevicesLocalTrust = true
@@ -1862,7 +1858,7 @@ internal class RealmCryptoStore @Inject constructor(
18621858 storeUserDevices(realm, it.key, it.value)
18631859 }
18641860 userDataToStore.userCrossSigningKeys.forEach {
1865- storeUserCrossSigningKeys(realm, it.key, it.value.first, it.value.second, it.value.third )
1861+ storeUserCrossSigningKeys(realm, it.key, it.value)
18661862 }
18671863 }
18681864 }
0 commit comments