Encrypter and decrypter for segmented transports (untested).

This commit is contained in:
akwizgran
2012-01-13 11:54:55 +00:00
parent ab9b05448d
commit 90e54d94e6
17 changed files with 264 additions and 115 deletions

View File

@@ -0,0 +1,9 @@
package net.sf.briar.api.plugins;
import java.io.IOException;
public interface FrameSink {
/** Writes the given frame. */
void writeFrame(byte[] b, int len) throws IOException;
}

View File

@@ -0,0 +1,12 @@
package net.sf.briar.api.plugins;
import java.io.IOException;
public interface FrameSource {
/**
* Reads a frame into the given buffer and returns its length, or -1 if no
* more frames can be read.
*/
int readFrame(byte[] b) throws IOException;
}

View File

@@ -1,22 +1,15 @@
package net.sf.briar.api.plugins.duplex;
import java.io.IOException;
import net.sf.briar.api.plugins.FrameSink;
import net.sf.briar.api.plugins.FrameSource;
/**
* An interface for reading and writing data over a duplex segmented transport.
* The connection is not responsible for encrypting/decrypting or authenticating
* the data.
*/
public interface DuplexSegmentedTransportConnection {
/**
* Reads a frame into the given buffer and returns its length, or -1 if no
* more frames can be read.
*/
int readFrame(byte[] b) throws IOException;
/** Writes the given frame to the transport. */
void writeFrame(byte[] b, int len) throws IOException;
public interface DuplexSegmentedTransportConnection extends FrameSource,
FrameSink {
/**
* Returns true if the output stream should be flushed after each packet.

View File

@@ -1,19 +1,13 @@
package net.sf.briar.api.plugins.simplex;
import java.io.IOException;
import net.sf.briar.api.plugins.FrameSource;
/**
* An interface for reading data from a simplex segmented transport. The reader
* is not responsible for decrypting or authenticating the data before
* returning it.
*/
public interface SimplexSegmentedTransportReader {
/**
* Reads a frame into the given buffer and returns its length, or -1 if no
* more frames can be read.
*/
int readFrame(byte[] b) throws IOException;
public interface SimplexSegmentedTransportReader extends FrameSource {
/**
* Closes the reader and disposes of any associated resources. The first

View File

@@ -1,7 +1,5 @@
package net.sf.briar.api.plugins.simplex;
import java.io.IOException;
/**
* An interface for writing data to a simplex segmented transport. The writer is
* not responsible for authenticating or encrypting the data before writing it.
@@ -11,9 +9,6 @@ public interface SimplexSegmentedTransportWriter {
/** Returns the capacity of the transport in bytes. */
long getCapacity();
/** Writes the given frame to the transport. */
void writeFrame(byte[] b, int len) throws IOException;
/**
* Returns true if the output stream should be flushed after each packet.
*/