mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Encode transport properties more compactly in QR codes.
This commit is contained in:
@@ -4,7 +4,7 @@ package org.briarproject.api.keyagreement;
|
||||
public interface KeyAgreementConstants {
|
||||
|
||||
/** The current version of the BQP protocol. */
|
||||
byte PROTOCOL_VERSION = 1;
|
||||
byte PROTOCOL_VERSION = 2;
|
||||
|
||||
/** The length of the record header in bytes. */
|
||||
int RECORD_HEADER_LENGTH = 4;
|
||||
@@ -16,4 +16,10 @@ public interface KeyAgreementConstants {
|
||||
int COMMIT_LENGTH = 16;
|
||||
|
||||
long CONNECTION_TIMEOUT = 20 * 1000; // Milliseconds
|
||||
|
||||
/** The transport identifier for Bluetooth. */
|
||||
int TRANSPORT_ID_BLUETOOTH = 0;
|
||||
|
||||
/** The transport identifier for LAN. */
|
||||
int TRANSPORT_ID_LAN = 1;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.briarproject.api.keyagreement;
|
||||
|
||||
import org.briarproject.api.data.BdfList;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
@@ -7,9 +9,9 @@ import java.util.concurrent.Callable;
|
||||
*/
|
||||
public abstract class KeyAgreementListener {
|
||||
|
||||
private final TransportDescriptor descriptor;
|
||||
private final BdfList descriptor;
|
||||
|
||||
public KeyAgreementListener(TransportDescriptor descriptor) {
|
||||
public KeyAgreementListener(BdfList descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
@@ -17,7 +19,7 @@ public abstract class KeyAgreementListener {
|
||||
* Returns the descriptor that a remote peer can use to connect to this
|
||||
* listener.
|
||||
*/
|
||||
public TransportDescriptor getDescriptor() {
|
||||
public BdfList getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,40 @@
|
||||
package org.briarproject.api.keyagreement;
|
||||
|
||||
import org.briarproject.api.Bytes;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.data.BdfList;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* A BQP payload.
|
||||
*/
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class Payload implements Comparable<Payload> {
|
||||
|
||||
private final Bytes commitment;
|
||||
private final List<TransportDescriptor> descriptors;
|
||||
private final Map<TransportId, BdfList> descriptors;
|
||||
|
||||
public Payload(byte[] commitment, List<TransportDescriptor> descriptors) {
|
||||
public Payload(byte[] commitment, Map<TransportId, BdfList> descriptors) {
|
||||
this.commitment = new Bytes(commitment);
|
||||
this.descriptors = descriptors;
|
||||
}
|
||||
|
||||
/** Returns the commitment contained in this payload. */
|
||||
/**
|
||||
* Returns the commitment contained in this payload.
|
||||
*/
|
||||
public byte[] getCommitment() {
|
||||
return commitment.getBytes();
|
||||
}
|
||||
|
||||
/** Returns the transport descriptors contained in this payload. */
|
||||
public List<TransportDescriptor> getTransportDescriptors() {
|
||||
/**
|
||||
* Returns the transport descriptors contained in this payload.
|
||||
*/
|
||||
public Map<TransportId, BdfList> getTransportDescriptors() {
|
||||
return descriptors;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.briarproject.api.keyagreement;
|
||||
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface PayloadParser {
|
||||
|
||||
Payload parse(byte[] raw) throws IOException;
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package org.briarproject.api.keyagreement;
|
||||
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.properties.TransportProperties;
|
||||
|
||||
/**
|
||||
* Describes how to connect to a device over a short-range transport.
|
||||
*/
|
||||
public class TransportDescriptor {
|
||||
|
||||
private final TransportId id;
|
||||
private final TransportProperties properties;
|
||||
|
||||
public TransportDescriptor(TransportId id, TransportProperties properties) {
|
||||
this.id = id;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/** Returns the transport identifier. */
|
||||
public TransportId getIdentifier() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/** Returns the transport properties. */
|
||||
public TransportProperties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,26 @@
|
||||
package org.briarproject.api.plugins;
|
||||
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.plugins.duplex.DuplexPlugin;
|
||||
import org.briarproject.api.plugins.simplex.SimplexPlugin;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Responsible for starting transport plugins at startup and stopping them at
|
||||
* shutdown.
|
||||
*/
|
||||
@NotNullByDefault
|
||||
public interface PluginManager {
|
||||
|
||||
/**
|
||||
* Returns the plugin for the given transport, or null if no such plugin
|
||||
* has been created.
|
||||
*/
|
||||
@Nullable
|
||||
Plugin getPlugin(TransportId t);
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,8 @@ package org.briarproject.api.plugins.duplex;
|
||||
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.crypto.PseudoRandom;
|
||||
import org.briarproject.api.data.BdfList;
|
||||
import org.briarproject.api.keyagreement.KeyAgreementListener;
|
||||
import org.briarproject.api.keyagreement.TransportDescriptor;
|
||||
import org.briarproject.api.plugins.Plugin;
|
||||
|
||||
/** An interface for transport plugins that support duplex communication. */
|
||||
@@ -40,5 +40,5 @@ public interface DuplexPlugin extends Plugin {
|
||||
* Returns null if no connection can be established within the given time.
|
||||
*/
|
||||
DuplexTransportConnection createKeyAgreementConnection(
|
||||
byte[] remoteCommitment, TransportDescriptor d, long timeout);
|
||||
byte[] remoteCommitment, BdfList descriptor, long timeout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user