mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 14:38:45 +03:00
crypto: Remove more unused methods
This commit is contained in:
parent
6bc825b0bc
commit
4eeb47dc56
1 changed files with 0 additions and 89 deletions
|
@ -680,95 +680,6 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
eventDecryptor.decryptEventAsync(event, timeline, callback)
|
eventDecryptor.decryptEventAsync(event, timeline, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle a key event.
|
|
||||||
*
|
|
||||||
* @param event the key event.
|
|
||||||
*/
|
|
||||||
private fun onRoomKeyEvent(event: Event) {
|
|
||||||
val roomKeyContent = event.getClearContent().toModel<RoomKeyContent>() ?: return
|
|
||||||
Timber.i("## CRYPTO | onRoomKeyEvent() from: ${event.senderId} type<${event.getClearType()}> , sessionId<${roomKeyContent.sessionId}>")
|
|
||||||
if (roomKeyContent.roomId.isNullOrEmpty() || roomKeyContent.algorithm.isNullOrEmpty()) {
|
|
||||||
Timber.e("## CRYPTO | onRoomKeyEvent() : missing fields")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val alg = roomDecryptorProvider.getOrCreateRoomDecryptor(roomKeyContent.roomId, roomKeyContent.algorithm)
|
|
||||||
if (alg == null) {
|
|
||||||
Timber.e("## CRYPTO | GOSSIP onRoomKeyEvent() : Unable to handle keys for ${roomKeyContent.algorithm}")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
alg.onRoomKeyEvent(event, keysBackupService)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onKeyWithHeldReceived(event: Event) {
|
|
||||||
val withHeldContent = event.getClearContent().toModel<RoomKeyWithHeldContent>() ?: return Unit.also {
|
|
||||||
Timber.i("## CRYPTO | Malformed onKeyWithHeldReceived() : missing fields")
|
|
||||||
}
|
|
||||||
Timber.i("## CRYPTO | onKeyWithHeldReceived() received from:${event.senderId}, content <$withHeldContent>")
|
|
||||||
val alg = roomDecryptorProvider.getOrCreateRoomDecryptor(withHeldContent.roomId, withHeldContent.algorithm)
|
|
||||||
if (alg is IMXWithHeldExtension) {
|
|
||||||
alg.onRoomKeyWithHeldEvent(withHeldContent)
|
|
||||||
} else {
|
|
||||||
Timber.e("## CRYPTO | onKeyWithHeldReceived() from:${event.senderId}: Unable to handle WithHeldContent for ${withHeldContent.algorithm}")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onSecretSendReceived(event: Event) {
|
|
||||||
Timber.i("## CRYPTO | GOSSIP onSecretSend() from ${event.senderId} : onSecretSendReceived ${event.content?.get("sender_key")}")
|
|
||||||
if (!event.isEncrypted()) {
|
|
||||||
// secret send messages must be encrypted
|
|
||||||
Timber.e("## CRYPTO | GOSSIP onSecretSend() :Received unencrypted secret send event")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Was that sent by us?
|
|
||||||
if (event.senderId != userId) {
|
|
||||||
Timber.e("## CRYPTO | GOSSIP onSecretSend() : Ignore secret from other user ${event.senderId}")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val secretContent = event.getClearContent().toModel<SecretSendEventContent>() ?: return
|
|
||||||
|
|
||||||
val existingRequest = cryptoStore
|
|
||||||
.getOutgoingSecretKeyRequests().firstOrNull { it.requestId == secretContent.requestId }
|
|
||||||
|
|
||||||
if (existingRequest == null) {
|
|
||||||
Timber.i("## CRYPTO | GOSSIP onSecretSend() : Ignore secret that was not requested: ${secretContent.requestId}")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!handleSDKLevelGossip(existingRequest.secretName, secretContent.secretValue)) {
|
|
||||||
// TODO Ask to application layer?
|
|
||||||
Timber.v("## CRYPTO | onSecretSend() : secret not handled by SDK")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if handled by SDK, otherwise should be sent to application layer
|
|
||||||
*/
|
|
||||||
private fun handleSDKLevelGossip(secretName: String?, secretValue: String): Boolean {
|
|
||||||
return when (secretName) {
|
|
||||||
MASTER_KEY_SSSS_NAME -> {
|
|
||||||
crossSigningService.onSecretMSKGossip(secretValue)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
SELF_SIGNING_KEY_SSSS_NAME -> {
|
|
||||||
crossSigningService.onSecretSSKGossip(secretValue)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
USER_SIGNING_KEY_SSSS_NAME -> {
|
|
||||||
crossSigningService.onSecretUSKGossip(secretValue)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
KEYBACKUP_SECRET_SSSS_NAME -> {
|
|
||||||
keysBackupService.onSecretKeyGossip(secretValue)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an m.room.encryption event.
|
* Handle an m.room.encryption event.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue