mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 20:29:52 +01:00
Renamed raw data type.
This commit is contained in:
@@ -45,7 +45,7 @@ class AuthorFactoryImpl implements AuthorFactory {
|
||||
try {
|
||||
w.writeListStart();
|
||||
w.writeString(name);
|
||||
w.writeBytes(publicKey);
|
||||
w.writeRaw(publicKey);
|
||||
w.writeListEnd();
|
||||
} catch(IOException e) {
|
||||
// Shouldn't happen with ByteArrayOutputStream
|
||||
|
||||
@@ -29,7 +29,7 @@ class AuthorReader implements ObjectReader<Author> {
|
||||
r.readListStart();
|
||||
String name = r.readString(MAX_AUTHOR_NAME_LENGTH);
|
||||
if(name.length() == 0) throw new FormatException();
|
||||
byte[] publicKey = r.readBytes(MAX_PUBLIC_KEY_LENGTH);
|
||||
byte[] publicKey = r.readRaw(MAX_PUBLIC_KEY_LENGTH);
|
||||
r.readListEnd();
|
||||
// Reset the reader
|
||||
r.removeConsumer(digesting);
|
||||
|
||||
@@ -38,7 +38,7 @@ class GroupFactoryImpl implements GroupFactory {
|
||||
try {
|
||||
w.writeListStart();
|
||||
w.writeString(name);
|
||||
w.writeBytes(salt);
|
||||
w.writeRaw(salt);
|
||||
w.writeListEnd();
|
||||
} catch(IOException e) {
|
||||
// Shouldn't happen with ByteArrayOutputStream
|
||||
|
||||
@@ -28,7 +28,7 @@ class GroupReader implements ObjectReader<Group> {
|
||||
r.readListStart();
|
||||
String name = r.readString(MAX_GROUP_NAME_LENGTH);
|
||||
if(name.length() == 0) throw new FormatException();
|
||||
byte[] salt = r.readBytes(GROUP_SALT_LENGTH);
|
||||
byte[] salt = r.readRaw(GROUP_SALT_LENGTH);
|
||||
if(salt.length != GROUP_SALT_LENGTH) throw new FormatException();
|
||||
r.readListEnd();
|
||||
r.removeConsumer(digesting);
|
||||
|
||||
@@ -84,7 +84,7 @@ class MessageFactoryImpl implements MessageFactory {
|
||||
// Write the message
|
||||
w.writeListStart();
|
||||
if(parent == null) w.writeNull();
|
||||
else w.writeBytes(parent.getBytes());
|
||||
else w.writeRaw(parent.getBytes());
|
||||
writeGroup(w, group);
|
||||
if(author == null) w.writeNull();
|
||||
else writeAuthor(w, author);
|
||||
@@ -92,8 +92,8 @@ class MessageFactoryImpl implements MessageFactory {
|
||||
w.writeInteger(timestamp);
|
||||
byte[] salt = new byte[MESSAGE_SALT_LENGTH];
|
||||
random.nextBytes(salt);
|
||||
w.writeBytes(salt);
|
||||
w.writeBytes(body);
|
||||
w.writeRaw(salt);
|
||||
w.writeRaw(body);
|
||||
int bodyStart = (int) counting.getCount() - body.length;
|
||||
// Sign the message with the author's private key, if there is one
|
||||
if(privateKey == null) {
|
||||
@@ -103,7 +103,7 @@ class MessageFactoryImpl implements MessageFactory {
|
||||
byte[] sig = signature.sign();
|
||||
if(sig.length > MAX_SIGNATURE_LENGTH)
|
||||
throw new IllegalArgumentException();
|
||||
w.writeBytes(sig);
|
||||
w.writeRaw(sig);
|
||||
}
|
||||
w.writeListEnd();
|
||||
// Hash the message, including the signature, to get the message ID
|
||||
@@ -116,14 +116,14 @@ class MessageFactoryImpl implements MessageFactory {
|
||||
private void writeGroup(Writer w, Group g) throws IOException {
|
||||
w.writeListStart();
|
||||
w.writeString(g.getName());
|
||||
w.writeBytes(g.getSalt());
|
||||
w.writeRaw(g.getSalt());
|
||||
w.writeListEnd();
|
||||
}
|
||||
|
||||
private void writeAuthor(Writer w, Author a) throws IOException {
|
||||
w.writeListStart();
|
||||
w.writeString(a.getName());
|
||||
w.writeBytes(a.getPublicKey());
|
||||
w.writeRaw(a.getPublicKey());
|
||||
w.writeListEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class MessageReader implements ObjectReader<UnverifiedMessage> {
|
||||
if(r.hasNull()) {
|
||||
r.readNull();
|
||||
} else {
|
||||
byte[] b = r.readBytes(UniqueId.LENGTH);
|
||||
byte[] b = r.readRaw(UniqueId.LENGTH);
|
||||
if(b.length < UniqueId.LENGTH) throw new FormatException();
|
||||
parent = new MessageId(b);
|
||||
}
|
||||
@@ -56,10 +56,10 @@ class MessageReader implements ObjectReader<UnverifiedMessage> {
|
||||
long timestamp = r.readInteger();
|
||||
if(timestamp < 0) throw new FormatException();
|
||||
// Read the salt
|
||||
byte[] salt = r.readBytes(MESSAGE_SALT_LENGTH);
|
||||
byte[] salt = r.readRaw(MESSAGE_SALT_LENGTH);
|
||||
if(salt.length < MESSAGE_SALT_LENGTH) throw new FormatException();
|
||||
// Read the message body
|
||||
byte[] body = r.readBytes(MAX_BODY_LENGTH);
|
||||
byte[] body = r.readRaw(MAX_BODY_LENGTH);
|
||||
// Record the offset of the body within the message
|
||||
int bodyStart = (int) counting.getCount() - body.length;
|
||||
// Record the length of the data covered by the author's signature
|
||||
@@ -67,7 +67,7 @@ class MessageReader implements ObjectReader<UnverifiedMessage> {
|
||||
// Read the author's signature, if there is one
|
||||
byte[] signature = null;
|
||||
if(author == null) r.readNull();
|
||||
else signature = r.readBytes(MAX_SIGNATURE_LENGTH);
|
||||
else signature = r.readRaw(MAX_SIGNATURE_LENGTH);
|
||||
// Read the end of the message
|
||||
r.readListEnd();
|
||||
// Reset the reader
|
||||
|
||||
@@ -122,7 +122,7 @@ class PacketReaderImpl implements PacketReader {
|
||||
List<MessageId> acked = new ArrayList<MessageId>();
|
||||
r.readListStart();
|
||||
while(!r.hasListEnd()) {
|
||||
byte[] b = r.readBytes(UniqueId.LENGTH);
|
||||
byte[] b = r.readRaw(UniqueId.LENGTH);
|
||||
if(b.length != UniqueId.LENGTH)
|
||||
throw new FormatException();
|
||||
acked.add(new MessageId(b));
|
||||
@@ -168,7 +168,7 @@ class PacketReaderImpl implements PacketReader {
|
||||
List<MessageId> offered = new ArrayList<MessageId>();
|
||||
r.readListStart();
|
||||
while(!r.hasListEnd()) {
|
||||
byte[] b = r.readBytes(UniqueId.LENGTH);
|
||||
byte[] b = r.readRaw(UniqueId.LENGTH);
|
||||
if(b.length != UniqueId.LENGTH)
|
||||
throw new FormatException();
|
||||
offered.add(new MessageId(b));
|
||||
@@ -198,7 +198,7 @@ class PacketReaderImpl implements PacketReader {
|
||||
r.readListStart();
|
||||
List<MessageId> requested = new ArrayList<MessageId>();
|
||||
while(!r.hasListEnd()) {
|
||||
byte[] b = r.readBytes(UniqueId.LENGTH);
|
||||
byte[] b = r.readRaw(UniqueId.LENGTH);
|
||||
if(b.length != UniqueId.LENGTH)
|
||||
throw new FormatException();
|
||||
requested.add(new MessageId(b));
|
||||
|
||||
@@ -85,7 +85,7 @@ class PacketWriterImpl implements PacketWriter {
|
||||
Writer w = writerFactory.createWriter(payload);
|
||||
w.writeListStart();
|
||||
w.writeListStart();
|
||||
for(MessageId m : a.getMessageIds()) w.writeBytes(m.getBytes());
|
||||
for(MessageId m : a.getMessageIds()) w.writeRaw(m.getBytes());
|
||||
w.writeListEnd();
|
||||
w.writeListEnd();
|
||||
writePacket(ACK);
|
||||
@@ -103,7 +103,7 @@ class PacketWriterImpl implements PacketWriter {
|
||||
Writer w = writerFactory.createWriter(payload);
|
||||
w.writeListStart();
|
||||
w.writeListStart();
|
||||
for(MessageId m : o.getMessageIds()) w.writeBytes(m.getBytes());
|
||||
for(MessageId m : o.getMessageIds()) w.writeRaw(m.getBytes());
|
||||
w.writeListEnd();
|
||||
w.writeListEnd();
|
||||
writePacket(OFFER);
|
||||
@@ -114,7 +114,7 @@ class PacketWriterImpl implements PacketWriter {
|
||||
Writer w = writerFactory.createWriter(payload);
|
||||
w.writeListStart();
|
||||
w.writeListStart();
|
||||
for(MessageId m : r.getMessageIds()) w.writeBytes(m.getBytes());
|
||||
for(MessageId m : r.getMessageIds()) w.writeRaw(m.getBytes());
|
||||
w.writeListEnd();
|
||||
w.writeListEnd();
|
||||
writePacket(REQUEST);
|
||||
@@ -157,7 +157,7 @@ class PacketWriterImpl implements PacketWriter {
|
||||
for(Group g : u.getGroups()) {
|
||||
w.writeListStart();
|
||||
w.writeString(g.getName());
|
||||
w.writeBytes(g.getSalt());
|
||||
w.writeRaw(g.getSalt());
|
||||
w.writeListEnd();
|
||||
}
|
||||
w.writeListEnd();
|
||||
|
||||
Reference in New Issue
Block a user