mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
depending on the value of the first byte, so that an object's initial tag is included in the data seen by the ObjectReader. Digests and signatures can therefore be calculated over objects by their readers without any risk of ambiguity.
21 lines
597 B
Java
21 lines
597 B
Java
package net.sf.briar.protocol;
|
|
|
|
import java.io.IOException;
|
|
|
|
import net.sf.briar.api.protocol.BatchId;
|
|
import net.sf.briar.api.protocol.Tags;
|
|
import net.sf.briar.api.protocol.UniqueId;
|
|
import net.sf.briar.api.serial.FormatException;
|
|
import net.sf.briar.api.serial.ObjectReader;
|
|
import net.sf.briar.api.serial.Reader;
|
|
|
|
public class BatchIdReader implements ObjectReader<BatchId> {
|
|
|
|
public BatchId readObject(Reader r) throws IOException {
|
|
r.readUserDefinedTag(Tags.BATCH_ID);
|
|
byte[] b = r.readRaw();
|
|
if(b.length != UniqueId.LENGTH) throw new FormatException();
|
|
return new BatchId(b);
|
|
}
|
|
}
|