mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Partial implementation of the invitation protocol (untested).
This commit is contained in:
@@ -15,6 +15,11 @@ public interface CryptoComponent {
|
||||
|
||||
ErasableKey deriveMacKey(byte[] secret, boolean initiator);
|
||||
|
||||
byte[][] deriveInitialSecrets(byte[] theirPublicKey, KeyPair ourKeyPair,
|
||||
int invitationCode, boolean initiator);
|
||||
|
||||
int deriveConfirmationCode(byte[] secret, boolean initiator);
|
||||
|
||||
byte[] deriveNextSecret(byte[] secret, int index, long connection);
|
||||
|
||||
KeyPair generateKeyPair();
|
||||
@@ -25,6 +30,8 @@ public interface CryptoComponent {
|
||||
|
||||
MessageDigest getMessageDigest();
|
||||
|
||||
PseudoRandom getPseudoRandom(int seed);
|
||||
|
||||
SecureRandom getSecureRandom();
|
||||
|
||||
Cipher getTagCipher();
|
||||
|
||||
6
api/net/sf/briar/api/crypto/PseudoRandom.java
Normal file
6
api/net/sf/briar/api/crypto/PseudoRandom.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package net.sf.briar.api.crypto;
|
||||
|
||||
public interface PseudoRandom {
|
||||
|
||||
byte[] nextBytes(int bytes);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
public interface IncomingInvitationCallback extends InvitationCallback {
|
||||
|
||||
int enterInvitationCode();
|
||||
}
|
||||
14
api/net/sf/briar/api/plugins/InvitationCallback.java
Normal file
14
api/net/sf/briar/api/plugins/InvitationCallback.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
public interface InvitationCallback {
|
||||
|
||||
boolean isCancelled();
|
||||
|
||||
int enterConfirmationCode(int code);
|
||||
|
||||
void showProgress(String... message);
|
||||
|
||||
void showFailure(String... message);
|
||||
|
||||
void showSuccess();
|
||||
}
|
||||
14
api/net/sf/briar/api/plugins/InvitationConstants.java
Normal file
14
api/net/sf/briar/api/plugins/InvitationConstants.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
public interface InvitationConstants {
|
||||
|
||||
static final long INVITATION_TIMEOUT = 60 * 1000; // 1 minute
|
||||
|
||||
static final int CODE_BITS = 19; // Codes must fit into six decimal digits
|
||||
|
||||
static final int MAX_CODE = 1 << CODE_BITS - 1;
|
||||
|
||||
static final int HASH_LENGTH = 48;
|
||||
|
||||
static final int MAX_PUBLIC_KEY_LENGTH = 120;
|
||||
}
|
||||
12
api/net/sf/briar/api/plugins/InvitationStarter.java
Normal file
12
api/net/sf/briar/api/plugins/InvitationStarter.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import net.sf.briar.api.plugins.duplex.DuplexPlugin;
|
||||
|
||||
public interface InvitationStarter {
|
||||
|
||||
void startIncomingInvitation(DuplexPlugin plugin,
|
||||
IncomingInvitationCallback callback);
|
||||
|
||||
void startOutgoingInvitation(DuplexPlugin plugin,
|
||||
OutgoingInvitationCallback callback);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
public interface OutgoingInvitationCallback extends InvitationCallback {
|
||||
|
||||
void showInvitationCode(int code);
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
package net.sf.briar.api.plugins;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sf.briar.api.plugins.duplex.DuplexPlugin;
|
||||
import net.sf.briar.api.plugins.simplex.SimplexPlugin;
|
||||
|
||||
public interface PluginManager {
|
||||
|
||||
/**
|
||||
@@ -12,4 +17,10 @@ public interface PluginManager {
|
||||
* Stops the plugins and returns the number of plugins successfully stopped.
|
||||
*/
|
||||
int stop();
|
||||
|
||||
/** Returns any duplex plugins that support invitations. */
|
||||
Collection<DuplexPlugin> getDuplexInvitationPlugins();
|
||||
|
||||
/** Returns any simplex plugins that support invitations. */
|
||||
Collection<SimplexPlugin> getSimplexInvitationPlugins();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.sf.briar.api.plugins.duplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.crypto.PseudoRandom;
|
||||
import net.sf.briar.api.plugins.Plugin;
|
||||
|
||||
/** An interface for transport plugins that support duplex communication. */
|
||||
@@ -17,11 +18,11 @@ public interface DuplexPlugin extends Plugin {
|
||||
* Starts the invitation process from the inviter's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
DuplexTransportConnection sendInvitation(int code, long timeout);
|
||||
DuplexTransportConnection sendInvitation(PseudoRandom r, long timeout);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the invitee's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
DuplexTransportConnection acceptInvitation(int code, long timeout);
|
||||
DuplexTransportConnection acceptInvitation(PseudoRandom r, long timeout);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.sf.briar.api.plugins.simplex;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.crypto.PseudoRandom;
|
||||
import net.sf.briar.api.plugins.Plugin;
|
||||
|
||||
/** An interface for transport plugins that support simplex communication. */
|
||||
@@ -24,23 +25,24 @@ public interface SimplexPlugin extends Plugin {
|
||||
* Starts the invitation process from the inviter's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
SimplexTransportWriter sendInvitation(int code, long timeout);
|
||||
SimplexTransportWriter sendInvitation(PseudoRandom r, long timeout);
|
||||
|
||||
/**
|
||||
* Starts the invitation process from the invitee's side. Returns null if
|
||||
* no connection can be established within the given timeout.
|
||||
*/
|
||||
SimplexTransportReader acceptInvitation(int code, long timeout);
|
||||
SimplexTransportReader acceptInvitation(PseudoRandom r, long timeout);
|
||||
|
||||
/**
|
||||
* Continues the invitation process from the invitee's side. Returns null
|
||||
* if no connection can be established within the given timeout.
|
||||
*/
|
||||
SimplexTransportWriter sendInvitationResponse(int code, long timeout);
|
||||
SimplexTransportWriter sendInvitationResponse(PseudoRandom r, long timeout);
|
||||
|
||||
/**
|
||||
* Continues the invitation process from the inviter's side. Returns null
|
||||
* if no connection can be established within the given timeout.
|
||||
*/
|
||||
SimplexTransportReader acceptInvitationResponse(int code, long timeout);
|
||||
SimplexTransportReader acceptInvitationResponse(PseudoRandom r,
|
||||
long timeout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user