mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Implement BQP transport descriptors
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package org.briarproject.api.keyagreement;
|
||||
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
|
||||
|
||||
public class KeyAgreementConnection {
|
||||
private final DuplexTransportConnection conn;
|
||||
private final TransportId id;
|
||||
|
||||
public KeyAgreementConnection(DuplexTransportConnection conn,
|
||||
TransportId id) {
|
||||
this.conn = conn;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DuplexTransportConnection getConnection() {
|
||||
return conn;
|
||||
}
|
||||
|
||||
public TransportId getTransportId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.briarproject.api.keyagreement;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* An class for managing a particular key agreement listener.
|
||||
*/
|
||||
public abstract class KeyAgreementListener {
|
||||
|
||||
private final TransportDescriptor descriptor;
|
||||
|
||||
public KeyAgreementListener(TransportDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the descriptor that a remote peer can use to connect to this
|
||||
* listener.
|
||||
*/
|
||||
public TransportDescriptor getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts listening for incoming connections, and returns a Callable that
|
||||
* will return a KeyAgreementConnection when an incoming connection is
|
||||
* received.
|
||||
*/
|
||||
public abstract Callable<KeyAgreementConnection> listen();
|
||||
|
||||
/**
|
||||
* Closes the underlying server socket.
|
||||
*/
|
||||
public abstract void close();
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -19,4 +19,7 @@ public interface PluginManager {
|
||||
|
||||
/** Returns any running duplex plugins that support invitations. */
|
||||
Collection<DuplexPlugin> getInvitationPlugins();
|
||||
|
||||
/** Returns any running duplex plugins that support key agreement. */
|
||||
Collection<DuplexPlugin> getKeyAgreementPlugins();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.briarproject.api.plugins.duplex;
|
||||
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.crypto.PseudoRandom;
|
||||
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. */
|
||||
@@ -24,4 +26,19 @@ public interface DuplexPlugin extends Plugin {
|
||||
*/
|
||||
DuplexTransportConnection createInvitationConnection(PseudoRandom r,
|
||||
long timeout, boolean alice);
|
||||
|
||||
/** Returns true if the plugin supports short-range key agreement. */
|
||||
boolean supportsKeyAgreement();
|
||||
|
||||
/**
|
||||
* Returns a listener that can be used to perform key agreement.
|
||||
*/
|
||||
KeyAgreementListener createKeyAgreementListener(byte[] localCommitment);
|
||||
|
||||
/**
|
||||
* Attempts to connect to the remote peer specified in the given descriptor.
|
||||
* Returns null if no connection can be established within the given time.
|
||||
*/
|
||||
DuplexTransportConnection createKeyAgreementConnection(
|
||||
byte[] remoteCommitment, TransportDescriptor d, long timeout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user