mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
signature: rename some last seen properties
This commit is contained in:
parent
ee3a27faa2
commit
43970d1258
@ -17,7 +17,7 @@ import de.bixilon.kutil.base64.Base64Util.fromBase64
|
||||
import de.bixilon.minosoft.data.accounts.types.test.TestAccount
|
||||
import de.bixilon.minosoft.data.chat.signature.LastSeenMessageList
|
||||
import de.bixilon.minosoft.data.chat.signature.SignatureTestUtil
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.LastSeenMessage
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.MessageSignatureData
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.protocol.versions.Version
|
||||
import de.bixilon.minosoft.protocol.versions.Versions
|
||||
@ -66,7 +66,7 @@ class MessageSigner2Test {
|
||||
val time = Instant.ofEpochMilli(1673103854_8402)
|
||||
val signer = create()
|
||||
|
||||
val lastSeen = LastSeenMessageList(arrayOf(LastSeenMessage(UUID(0L, 0L), "/OmblHW9CwdAawdE7WtVurRs7umsa/my8EeTT/NY36lqg3HmtAsqyRQ4fXHelw6pOA4o8UroAlmx+inwiEFHXkDICEIVM69vHKapQvoAaeEVrQ4pn9vURTY3GcUVOgr12V3d00odEpwviXaF6kchG1b/pZsLsfpacMiiVHkxZoqolvUNifHQKXVS48Gu1AKkwRw6bkcOKYZpcZgffe6U273rEQQefwzIdT/8F1P04WhiH7SREexVOolkuoKo6gYxXELf5M0BUf0ssG3SS1k8Wr3ys9nzB6hSoEd/ftKqGVxoqeq7pd1GgKfaRWpka8ZNyDpdm8JqvrmlN/phpS5X4Q==".fromBase64()))) // uuid does not matter, bytes are random
|
||||
val lastSeen = LastSeenMessageList(arrayOf(MessageSignatureData(UUID(0L, 0L), "/OmblHW9CwdAawdE7WtVurRs7umsa/my8EeTT/NY36lqg3HmtAsqyRQ4fXHelw6pOA4o8UroAlmx+inwiEFHXkDICEIVM69vHKapQvoAaeEVrQ4pn9vURTY3GcUVOgr12V3d00odEpwviXaF6kchG1b/pZsLsfpacMiiVHkxZoqolvUNifHQKXVS48Gu1AKkwRw6bkcOKYZpcZgffe6U273rEQQefwzIdT/8F1P04WhiH7SREexVOolkuoKo6gYxXELf5M0BUf0ssG3SS1k8Wr3ys9nzB6hSoEd/ftKqGVxoqeq7pd1GgKfaRWpka8ZNyDpdm8JqvrmlN/phpS5X4Q==".fromBase64()))) // uuid does not matter, bytes are random
|
||||
val signature = signer.signMessage(SignatureTestUtil.key.pair.private, message, null, 6392082609L, TestAccount.uuid, time, lastSeen)
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.kutil.uuid.UUIDUtil.toUUID
|
||||
import de.bixilon.minosoft.data.accounts.types.test.TestAccount
|
||||
import de.bixilon.minosoft.data.chat.signature.LastSeenMessageList
|
||||
import de.bixilon.minosoft.data.chat.signature.SignatureTestUtil
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.LastSeenMessage
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.MessageSignatureData
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.protocol.versions.Version
|
||||
import de.bixilon.minosoft.protocol.versions.Versions
|
||||
@ -67,7 +67,7 @@ class MessageSigner3Test {
|
||||
val time = Instant.ofEpochMilli(1673103854_8402)
|
||||
val signer = create("5c31705b-963c-4832-b8a5-1ee617a4b362".toUUID())
|
||||
|
||||
val lastSeen = LastSeenMessageList(arrayOf(LastSeenMessage(UUID(0L, 0L), "/OmblHW9CwdAawdE7WtVurRs7umsa/my8EeTT/NY36lqg3HmtAsqyRQ4fXHelw6pOA4o8UroAlmx+inwiEFHXkDICEIVM69vHKapQvoAaeEVrQ4pn9vURTY3GcUVOgr12V3d00odEpwviXaF6kchG1b/pZsLsfpacMiiVHkxZoqolvUNifHQKXVS48Gu1AKkwRw6bkcOKYZpcZgffe6U273rEQQefwzIdT/8F1P04WhiH7SREexVOolkuoKo6gYxXELf5M0BUf0ssG3SS1k8Wr3ys9nzB6hSoEd/ftKqGVxoqeq7pd1GgKfaRWpka8ZNyDpdm8JqvrmlN/phpS5X4Q==".fromBase64()))) // uuid does not matter, bytes are random
|
||||
val lastSeen = LastSeenMessageList(arrayOf(MessageSignatureData(UUID(0L, 0L), "/OmblHW9CwdAawdE7WtVurRs7umsa/my8EeTT/NY36lqg3HmtAsqyRQ4fXHelw6pOA4o8UroAlmx+inwiEFHXkDICEIVM69vHKapQvoAaeEVrQ4pn9vURTY3GcUVOgr12V3d00odEpwviXaF6kchG1b/pZsLsfpacMiiVHkxZoqolvUNifHQKXVS48Gu1AKkwRw6bkcOKYZpcZgffe6U273rEQQefwzIdT/8F1P04WhiH7SREexVOolkuoKo6gYxXELf5M0BUf0ssG3SS1k8Wr3ys9nzB6hSoEd/ftKqGVxoqeq7pd1GgKfaRWpka8ZNyDpdm8JqvrmlN/phpS5X4Q==".fromBase64()))) // uuid does not matter, bytes are random
|
||||
val signature = signer.signMessage(SignatureTestUtil.key.pair.private, message, 6392082609L, TestAccount.uuid, time, lastSeen)
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger and contributors
|
||||
* 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.
|
||||
*
|
||||
@ -13,13 +13,13 @@
|
||||
|
||||
package de.bixilon.minosoft.data.chat.signature
|
||||
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.LastSeenMessage
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.MessageSignatureData
|
||||
import java.util.*
|
||||
|
||||
class Acknowledgement(
|
||||
val offset: Int,
|
||||
val lastSeen: LastSeenMessageList,
|
||||
val lastReceived: LastSeenMessage? = null,
|
||||
val lastReceived: MessageSignatureData? = null,
|
||||
val acknowledged: BitSet,
|
||||
) {
|
||||
companion object {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger and contributors
|
||||
* 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.
|
||||
*
|
||||
@ -13,8 +13,8 @@
|
||||
|
||||
package de.bixilon.minosoft.data.chat.signature
|
||||
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.LastSeenMessage
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.MessageSignatureData
|
||||
|
||||
class LastSeenMessageList(
|
||||
val messages: Array<LastSeenMessage>,
|
||||
val entries: Array<MessageSignatureData>,
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.data.chat.signature.lastSeen
|
||||
|
||||
class IndexedLastSeenMessage(
|
||||
val id: Int,
|
||||
class IndexedMessageSignatureData(
|
||||
val index: Int,
|
||||
val signature: ByteArray?,
|
||||
)
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.chat.signature.lastSeen
|
||||
|
||||
import java.util.*
|
||||
|
||||
class LastSeenMessage(
|
||||
val profile: UUID,
|
||||
class MessageSignatureData(
|
||||
val sender: UUID,
|
||||
val signature: ByteArray,
|
||||
)
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.chat.signature.signer
|
||||
|
||||
import com.google.common.primitives.Longs
|
||||
import de.bixilon.minosoft.data.chat.signature.LastSeenMessageList
|
||||
import de.bixilon.minosoft.data.chat.signature.signer.MessageSigningUtil.getSignatureBytes
|
||||
import de.bixilon.minosoft.data.chat.signature.signer.MessageSigningUtil.getJsonSignatureBytes
|
||||
import de.bixilon.minosoft.data.chat.signature.signer.MessageSigningUtil.update
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.protocol.encryption.CryptManager
|
||||
@ -40,7 +40,7 @@ class MessageSigner1(
|
||||
signature.update(Longs.toByteArray(salt))
|
||||
signature.update(sender)
|
||||
signature.update(Longs.toByteArray(time.epochSecond))
|
||||
signature.update(message.getSignatureBytes())
|
||||
signature.update(message.getJsonSignatureBytes())
|
||||
|
||||
return signature.sign()
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.chat.signature.signer
|
||||
|
||||
import com.google.common.hash.Hashing
|
||||
import de.bixilon.minosoft.data.chat.signature.LastSeenMessageList
|
||||
import de.bixilon.minosoft.data.chat.signature.signer.MessageSigningUtil.getSignatureBytes
|
||||
import de.bixilon.minosoft.data.chat.signature.signer.MessageSigningUtil.getJsonSignatureBytes
|
||||
import de.bixilon.minosoft.data.chat.signature.signer.MessageSigningUtil.update
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.protocol.OutByteBuffer
|
||||
@ -43,16 +43,16 @@ class MessageSigner2(
|
||||
if (version.versionId >= ProtocolVersions.V_1_19_2) { // ToDo: This changed somewhere after 1.19.1-pre5
|
||||
buffer.writeBareString(message)
|
||||
} else {
|
||||
buffer.writeBareByteArray(message.getSignatureBytes())
|
||||
buffer.writeBareByteArray(message.getJsonSignatureBytes())
|
||||
}
|
||||
|
||||
if (version.versionId >= ProtocolVersions.V_1_19_1_PRE5) {
|
||||
buffer.writeByte(0x46)
|
||||
// ToDo: send preview text (optional)
|
||||
|
||||
for (entry in lastSeen.messages) {
|
||||
for (entry in lastSeen.entries) {
|
||||
buffer.writeByte(0x46)
|
||||
buffer.writeUUID(entry.profile)
|
||||
buffer.writeUUID(entry.sender)
|
||||
buffer.writeBareByteArray(entry.signature)
|
||||
}
|
||||
}
|
||||
|
@ -56,9 +56,9 @@ class MessageSigner3(
|
||||
signature.update(Ints.toByteArray(encoded.size))
|
||||
signature.update(encoded)
|
||||
|
||||
signature.update(Ints.toByteArray(lastSeen.messages.size))
|
||||
signature.update(Ints.toByteArray(lastSeen.entries.size))
|
||||
|
||||
for (lastSeenMessage in lastSeen.messages) {
|
||||
for (lastSeenMessage in lastSeen.entries) {
|
||||
signature.update(lastSeenMessage.signature)
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ import java.util.*
|
||||
|
||||
object MessageSigningUtil {
|
||||
|
||||
fun String.getSignatureBytes(): ByteArray {
|
||||
fun String.getJsonSignatureBytes(): ByteArray {
|
||||
return """{"text":"${String(JsonStringEncoder.getInstance().quoteAsString(this))}"}""".encodeNetwork()
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,8 @@ import de.bixilon.minosoft.data.chat.ChatUtil.getMessageSender
|
||||
import de.bixilon.minosoft.data.chat.filter.ChatFilter
|
||||
import de.bixilon.minosoft.data.chat.filter.Filter
|
||||
import de.bixilon.minosoft.data.chat.message.SignedChatMessage
|
||||
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.IndexedMessageSignatureData
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.MessageSignatureData
|
||||
import de.bixilon.minosoft.data.chat.signature.verifyer.MessageVerifyUtil
|
||||
import de.bixilon.minosoft.data.registries.chat.ChatParameter
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
@ -45,17 +45,17 @@ class SignedChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
}
|
||||
|
||||
|
||||
fun PlayInByteBuffer.readLastSeenMessage(): LastSeenMessage {
|
||||
return LastSeenMessage(readUUID(), readByteArray())
|
||||
fun PlayInByteBuffer.readLastSeenMessage(): MessageSignatureData {
|
||||
return MessageSignatureData(readUUID(), readByteArray())
|
||||
}
|
||||
|
||||
fun PlayInByteBuffer.readIndexedLastSeenMessage(): IndexedLastSeenMessage {
|
||||
fun PlayInByteBuffer.readIndexedLastSeenMessage(): IndexedMessageSignatureData {
|
||||
val id = readVarInt() - 1
|
||||
var signature: ByteArray? = null
|
||||
if (id == -1) {
|
||||
signature = readSignatureData()
|
||||
}
|
||||
return IndexedLastSeenMessage(id, signature)
|
||||
return IndexedMessageSignatureData(id, signature)
|
||||
}
|
||||
|
||||
private fun PlayInByteBuffer.readLegacySignedMessage(): SignedChatMessage {
|
||||
|
@ -16,7 +16,7 @@ import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.minosoft.data.chat.signature.Acknowledgement
|
||||
import de.bixilon.minosoft.data.chat.signature.ChatSignatureProperties
|
||||
import de.bixilon.minosoft.data.chat.signature.LastSeenMessageList
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.LastSeenMessage
|
||||
import de.bixilon.minosoft.data.chat.signature.lastSeen.MessageSignatureData
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.protocol.PlayerPublicKey
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
@ -107,13 +107,13 @@ class PlayOutByteBuffer(val connection: PlayConnection) : OutByteBuffer() {
|
||||
}
|
||||
}
|
||||
|
||||
fun writeLastSeenMessage(lastSeenMessage: LastSeenMessage) {
|
||||
writeUUID(lastSeenMessage.profile)
|
||||
writeByteArray(lastSeenMessage.signature)
|
||||
fun writeLastSeenMessage(signatureData: MessageSignatureData) {
|
||||
writeUUID(signatureData.sender)
|
||||
writeByteArray(signatureData.signature)
|
||||
}
|
||||
|
||||
fun writeLastSeenMessageList(list: LastSeenMessageList) {
|
||||
writeArray(list.messages) { writeLastSeenMessage(it) }
|
||||
writeArray(list.entries) { writeLastSeenMessage(it) }
|
||||
}
|
||||
|
||||
fun writeAcknowledgement(acknowledgement: Acknowledgement) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user