mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -04:00
signature: remove some unused stuff
This commit is contained in:
parent
b92e729f54
commit
556f564591
@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.data.chat.signature
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.LastSeenMessage
|
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
|
||||||
import java.time.Instant
|
|
||||||
|
|
||||||
class MessageBody(
|
|
||||||
val text: ChatComponent,
|
|
||||||
val time: Instant,
|
|
||||||
val salt: Long,
|
|
||||||
val lastSeen: Array<LastSeenMessage>,
|
|
||||||
)
|
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.data.chat.signature
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.chat.filter.Filter
|
|
||||||
import de.bixilon.minosoft.data.chat.type.MessageType
|
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
|
||||||
|
|
||||||
data class SignedMessage(
|
|
||||||
val header: MessageHeader,
|
|
||||||
val signature: ByteArray,
|
|
||||||
val body: MessageBody,
|
|
||||||
val unsigned: ChatComponent? = null,
|
|
||||||
val type: MessageType? = null,
|
|
||||||
val filter: Filter? = null,
|
|
||||||
)
|
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.data.chat.signature.verifyer
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.chat.signature.ChatSignatureProperties
|
||||||
|
import de.bixilon.minosoft.data.chat.signature.errors.MessageExpiredError
|
||||||
|
import java.time.Instant
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object MessageVerifyUtil {
|
||||||
|
|
||||||
|
fun checkExpired(sent: Instant, received: Instant): Exception? {
|
||||||
|
if (received.toEpochMilli() - sent.toEpochMilli() > ChatSignatureProperties.MESSAGE_TTL) {
|
||||||
|
return MessageExpiredError(sent, received)
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated("TODO")
|
||||||
|
fun verifyMessage(
|
||||||
|
sent: Instant,
|
||||||
|
received: Instant,
|
||||||
|
versionId: Int,
|
||||||
|
seed: Long,
|
||||||
|
content: String,
|
||||||
|
sender: UUID,
|
||||||
|
): Exception? {
|
||||||
|
checkExpired(sent, received)?.let { return it }
|
||||||
|
|
||||||
|
// TODO: Verify signature
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
@ -16,10 +16,9 @@ import de.bixilon.minosoft.data.chat.ChatUtil.getMessageSender
|
|||||||
import de.bixilon.minosoft.data.chat.filter.ChatFilter
|
import de.bixilon.minosoft.data.chat.filter.ChatFilter
|
||||||
import de.bixilon.minosoft.data.chat.filter.Filter
|
import de.bixilon.minosoft.data.chat.filter.Filter
|
||||||
import de.bixilon.minosoft.data.chat.message.SignedChatMessage
|
import de.bixilon.minosoft.data.chat.message.SignedChatMessage
|
||||||
import de.bixilon.minosoft.data.chat.signature.ChatSignatureProperties
|
|
||||||
import de.bixilon.minosoft.data.chat.signature.errors.MessageExpiredError
|
|
||||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.IndexedLastSeenMessage
|
import de.bixilon.minosoft.data.chat.signature.lastSeen.IndexedLastSeenMessage
|
||||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.LastSeenMessage
|
import de.bixilon.minosoft.data.chat.signature.lastSeen.LastSeenMessage
|
||||||
|
import de.bixilon.minosoft.data.chat.signature.verifyer.MessageVerifyUtil
|
||||||
import de.bixilon.minosoft.data.registries.chat.ChatParameter
|
import de.bixilon.minosoft.data.registries.chat.ChatParameter
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.data.text.TextComponent
|
import de.bixilon.minosoft.data.text.TextComponent
|
||||||
@ -77,7 +76,7 @@ class SignedChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
|
|
||||||
val received = Instant.now()
|
val received = Instant.now()
|
||||||
|
|
||||||
val error = verifyMessage(sent, received, versionId, salt, message, sender.uuid)
|
val error = MessageVerifyUtil.verifyMessage(sent, received, versionId, salt, message, sender.uuid)
|
||||||
|
|
||||||
|
|
||||||
return SignedChatMessage(connection, message, type, connection.getMessageSender(sender.uuid), parameters, null, error, sent, received)
|
return SignedChatMessage(connection, message, type, connection.getMessageSender(sender.uuid), parameters, null, error, sent, received)
|
||||||
@ -121,7 +120,7 @@ class SignedChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
val sender = connection.getMessageSender(senderUUID)
|
val sender = connection.getMessageSender(senderUUID)
|
||||||
val received = Instant.now()
|
val received = Instant.now()
|
||||||
|
|
||||||
val error = verifyMessage(sent, received, versionId, salt, message, senderUUID)
|
val error = MessageVerifyUtil.verifyMessage(sent, received, versionId, salt, message, senderUUID)
|
||||||
|
|
||||||
return SignedChatMessage(
|
return SignedChatMessage(
|
||||||
connection = connection,
|
connection = connection,
|
||||||
@ -136,28 +135,6 @@ class SignedChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkExpired(sent: Instant, received: Instant): Exception? {
|
|
||||||
if (received.toEpochMilli() - sent.toEpochMilli() > ChatSignatureProperties.MESSAGE_TTL) {
|
|
||||||
return MessageExpiredError(sent, received)
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun verifyMessage(
|
|
||||||
sent: Instant,
|
|
||||||
received: Instant,
|
|
||||||
versionId: Int,
|
|
||||||
seed: Long,
|
|
||||||
content: String,
|
|
||||||
sender: UUID,
|
|
||||||
): Exception? {
|
|
||||||
checkExpired(sent, received)?.let { return it }
|
|
||||||
|
|
||||||
// TODO: Verify signature
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
if (message.error != null) {
|
if (message.error != null) {
|
||||||
// failed
|
// failed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user