Offer IDs no longer need to be calculated or echoed in requests.

The initiator flag in the transport protocol makes this unnecessary by
linking the two sides of a stream-mode connection, making it
impossible for an attacker to replay the responder's side of a
different connection.
This commit is contained in:
akwizgran
2011-09-12 16:21:17 +01:00
parent 7ed747b2a3
commit 64548375cc
27 changed files with 45 additions and 194 deletions

View File

@@ -8,9 +8,6 @@ public interface Offer {
/** The maximum number of message IDs per offer. */
static final int MAX_IDS_PER_OFFER = 29959;
/** Returns the offer's unique identifier. */
OfferId getId();
/** Returns the message IDs contained in the offer. */
Collection<MessageId> getMessageIds();
}

View File

@@ -1,26 +0,0 @@
package net.sf.briar.api.protocol;
import java.io.IOException;
import java.util.Arrays;
import net.sf.briar.api.serial.Writer;
/** Type-safe wrapper for a byte array that uniquely identifies an offer. */
public class OfferId extends UniqueId {
public OfferId(byte[] id) {
super(id);
}
public void writeTo(Writer w) throws IOException {
w.writeUserDefinedTag(Tags.OFFER_ID);
w.writeBytes(id);
}
@Override
public boolean equals(Object o) {
if(o instanceof OfferId)
return Arrays.equals(id, ((OfferId) o).id);
return false;
}
}

View File

@@ -5,12 +5,6 @@ import java.util.BitSet;
/** A packet requesting some or all of the messages from an offer. */
public interface Request {
/**
* Returns the unique identifier of the offer to which this request
* responds.
*/
OfferId getOfferId();
/**
* Returns a sequence of bits corresponding to the sequence of messages in
* the offer, where the i^th bit is set if the i^th message should be sent.

View File

@@ -17,7 +17,7 @@ public interface Tags {
static final int MESSAGE = 7;
static final int MESSAGE_ID = 8;
static final int OFFER = 9;
static final int OFFER_ID = 10;
// FIXME: Renumber
static final int REQUEST = 11;
static final int SUBSCRIPTION_UPDATE = 12;
static final int TRANSPORT_PROPERTIES = 13;

View File

@@ -3,7 +3,6 @@ package net.sf.briar.api.protocol.writers;
import java.io.IOException;
import net.sf.briar.api.protocol.MessageId;
import net.sf.briar.api.protocol.OfferId;
/** An interface for creating an offer packet. */
public interface OfferWriter {
@@ -14,6 +13,6 @@ public interface OfferWriter {
*/
boolean writeMessageId(MessageId m) throws IOException;
/** Finishes writing the offer and returns its unique identifier. */
OfferId finish() throws IOException;
/** Finishes writing the offer. */
void finish() throws IOException;
}

View File

@@ -3,11 +3,9 @@ package net.sf.briar.api.protocol.writers;
import java.io.IOException;
import java.util.BitSet;
import net.sf.briar.api.protocol.OfferId;
/** An interface for creating a request packet. */
public interface RequestWriter {
/** Writes the contents of the request. */
void writeRequest(OfferId offerId, BitSet b, int length) throws IOException;
void writeRequest(BitSet b, int length) throws IOException;
}