mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Use block label for root hash of single-block messages.
This commit is contained in:
@@ -19,10 +19,10 @@ public class MessageId extends UniqueId {
|
||||
public static final String ID_LABEL = "org.briarproject.bramble/MESSAGE_ID";
|
||||
|
||||
/**
|
||||
* Label for hashing the root blocks of messages.
|
||||
* Label for hashing blocks of messages.
|
||||
*/
|
||||
public static final String ROOT_LABEL =
|
||||
"org.briarproject.bramble/MESSAGE_ROOT";
|
||||
public static final String BLOCK_LABEL =
|
||||
"org.briarproject.bramble/MESSAGE_BLOCK";
|
||||
|
||||
public MessageId(byte[] id) {
|
||||
super(id);
|
||||
|
||||
@@ -13,8 +13,8 @@ import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.bramble.api.sync.Message.FORMAT_VERSION;
|
||||
import static org.briarproject.bramble.api.sync.MessageId.BLOCK_LABEL;
|
||||
import static org.briarproject.bramble.api.sync.MessageId.ID_LABEL;
|
||||
import static org.briarproject.bramble.api.sync.MessageId.ROOT_LABEL;
|
||||
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||
import static org.briarproject.bramble.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
||||
import static org.briarproject.bramble.util.ByteUtils.INT_64_BYTES;
|
||||
@@ -36,7 +36,7 @@ class MessageFactoryImpl implements MessageFactory {
|
||||
throw new IllegalArgumentException();
|
||||
byte[] versionBytes = new byte[] {FORMAT_VERSION};
|
||||
// There's only one block, so the root hash is the hash of the block
|
||||
byte[] rootHash = crypto.hash(ROOT_LABEL, versionBytes, body);
|
||||
byte[] rootHash = crypto.hash(BLOCK_LABEL, versionBytes, body);
|
||||
byte[] timeBytes = new byte[INT_64_BYTES];
|
||||
ByteUtils.writeUint64(timestamp, timeBytes, 0);
|
||||
byte[] idHash = crypto.hash(ID_LABEL, versionBytes, g.getBytes(),
|
||||
|
||||
Reference in New Issue
Block a user