This commit is contained in:
Valere 2022-06-15 15:35:42 +02:00
parent 8e829c6aad
commit ddd82441bd
15 changed files with 19 additions and 56 deletions

View File

@ -193,7 +193,7 @@ interface CryptoService {
fun prepareToEncrypt(roomId: String, callback: MatrixCallback<Unit>)
/**
* Share all inbound sessions of the last chunk messages to the provided userId devices
* Share all inbound sessions of the last chunk messages to the provided userId devices.
*/
suspend fun sendSharedHistoryKeys(roomId: String, userId: String, sessionInfoSet: Set<SessionInfo>?)
}

View File

@ -72,8 +72,7 @@ data class ForwardedRoomKeyContent(
val senderClaimedEd25519Key: String? = null,
/**
* MSC3061
* Identifies keys that were sent when the room's visibility setting was set to world_readable or shared
* MSC3061 Identifies keys that were sent when the room's visibility setting was set to world_readable or shared.
*/
@Json(name = "org.matrix.msc3061.shared_history")
val sharedHistory: Boolean? = false,

View File

@ -41,8 +41,7 @@ data class RoomKeyContent(
val chainIndex: Any? = null,
/**
* MSC3061
* Identifies keys that were sent when the room's visibility setting was set to world_readable or shared
* MSC3061 Identifies keys that were sent when the room's visibility setting was set to world_readable or shared.
*/
@Json(name = "org.matrix.msc3061.shared_history")
val sharedHistory: Boolean? = false

View File

@ -50,7 +50,7 @@ enum class RoomHistoryVisibility {
}
/**
* Room history should be shared only if room visibility is world_readable or shared
* Room history should be shared only if room visibility is world_readable or shared.
*/
internal fun RoomHistoryVisibility.shouldShareHistory() =
this == RoomHistoryVisibility.WORLD_READABLE || this == RoomHistoryVisibility.SHARED

View File

@ -601,6 +601,7 @@ internal class MXOlmDevice @Inject constructor(
* @param forwardingCurve25519KeyChain Devices involved in forwarding this session to us.
* @param keysClaimed Other keys the sender claims.
* @param exportFormat true if the megolm keys are in export format
* @param sharedHistory MSC3061, this key is sharable on invite
* @return true if the operation succeeds.
*/
fun addInboundGroupSession(sessionId: String,

View File

@ -73,7 +73,7 @@ internal data class MegolmSessionData(
/**
* Flag that indicates whether or not the current inboundSession will be shared to
* invited users to decrypt past messages
* invited users to decrypt past messages.
*/
// When this feature lands in spec name = shared_history should be used
@Json(name = "org.matrix.msc3061.shared_history")

View File

@ -300,7 +300,7 @@ internal class MXMegolmDecryption(
}
/**
* Returns boolean shared key flag, if enabled with respect to matrix configuration
* Returns boolean shared key flag, if enabled with respect to matrix configuration.
*/
private fun RoomKeyContent.getSharedKey(): Boolean {
if (!cryptoStore.isShareKeysOnInviteEnabled()) return false
@ -308,7 +308,7 @@ internal class MXMegolmDecryption(
}
/**
* Check if the some messages can be decrypted with a new session
* Check if the some messages can be decrypted with a new session.
*
* @param roomId the room id where the new Megolm session has been created for, may be null when importing from external sessions
* @param senderKey the session sender key

View File

@ -1469,7 +1469,7 @@ internal class DefaultKeysBackupService @Inject constructor(
}
/**
* Returns boolean shared key flag, if enabled with respect to matrix configuration
* Returns boolean shared key flag, if enabled with respect to matrix configuration.
*/
private fun MXInboundMegolmSessionWrapper.getSharedKey(): Boolean {
if (!cryptoStore.isShareKeysOnInviteEnabled()) return false

View File

@ -54,7 +54,7 @@ internal data class KeyBackupData(
/**
* Flag that indicates whether or not the current inboundSession will be shared to
* invited users to decrypt past messages
* invited users to decrypt past messages.
*/
@Json(name = "org.matrix.msc3061.shared_history")
val sharedHistory: Boolean = false

View File

@ -43,9 +43,9 @@ data class InboundGroupSessionData(
/**
* Flag that indicates whether or not the current inboundSession will be shared to
*invited users to decrypt past messages
* invited users to decrypt past messages.
*/
@Json(name = "shared_history")
val sharedHistory: Boolean = false,
)
)

View File

@ -34,7 +34,7 @@ data class MXInboundMegolmSessionWrapper(
val safeSessionId = tryOrNull("Fail to get megolm session Id") { session.sessionIdentifier() }
/**
* Export the inbound group session keys
* Export the inbound group session keys.
* @param index the index to export. If null, the first known index will be used
* @return the inbound group session as MegolmSessionData if the operation succeeds
*/

View File

@ -107,8 +107,8 @@ internal class OlmInboundGroupSessionWrapper2 : Serializable {
/**
* Export the inbound group session keys.
* @param index the index to export. If null, the first known index will be used
* @param sharedHistory the flag that indicates whether or not the session can be shared
* @param index the index to export. If null, the first known index will be used
* @return the inbound group session as MegolmSessionData if the operation succeeds
*/
fun exportKeys(sharedHistory: Boolean = false, index: Long? = null): MegolmSessionData? {

View File

@ -22,7 +22,7 @@ internal data class OutboundGroupSessionWrapper(
val outboundGroupSession: OlmOutboundGroupSession,
val creationTime: Long,
/**
* As per MSC 3061, declares if this key could be shared when inviting a new user to the room
* As per MSC 3061, declares if this key could be shared when inviting a new user to the room.
*/
val sharedHistory: Boolean = false
)

View File

@ -67,7 +67,7 @@ internal interface IMXCryptoStore {
fun getInboundGroupSessions(): List<MXInboundMegolmSessionWrapper>
/**
* Retrieve the known inbound group sessions for the specified room
* Retrieve the known inbound group sessions for the specified room.
*
* @param roomId The roomId that the sessions will be returned
* @return the list of all known group sessions, for the provided roomId
@ -276,7 +276,7 @@ internal interface IMXCryptoStore {
/**
* Sets a boolean flag that will determine whether or not room history (existing inbound sessions)
* will be shared to new user invites
* will be shared to new user invites.
*
* @param roomId the room id
* @param shouldShareHistory The boolean flag
@ -345,7 +345,7 @@ internal interface IMXCryptoStore {
fun getInboundGroupSession(sessionId: String, senderKey: String, sharedHistory: Boolean): MXInboundMegolmSessionWrapper?
/**
* Get the current outbound group session for this encrypted room
* Get the current outbound group session for this encrypted room.
*/
fun getCurrentOutboundGroupSessionForRoom(roomId: String): OutboundGroupSessionWrapper?
@ -355,7 +355,7 @@ internal interface IMXCryptoStore {
fun storeCurrentOutboundGroupSessionForRoom(roomId: String, outboundGroupSession: OlmOutboundGroupSession?)
/**
* Remove an inbound group session
* Remove an inbound group session.
*
* @param sessionId the session identifier.
* @param senderKey the base64-encoded curve25519 key of the sender.

View File

@ -1,36 +0,0 @@
/*
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.android.sdk.internal.crypto.store.db.migration
import io.realm.DynamicRealm
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoMetadataEntityFields
import org.matrix.android.sdk.internal.util.database.RealmMigrator
/**
* Support for MSC3061 (share room keys for past messages as a flag)
*/
internal class MigrateCryptoTo018(realm: DynamicRealm) : RealmMigrator(realm, 18) {
override fun doMigrate(realm: DynamicRealm) {
realm.schema.get("CryptoMetadataEntity")
?.addField(CryptoMetadataEntityFields.ENABLE_KEY_FORWARDING_ON_INVITE, Boolean::class.java)
?.transform { obj ->
// default to false
obj.setBoolean(CryptoMetadataEntityFields.ENABLE_KEY_FORWARDING_ON_INVITE, false)
}
}
}