mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Moved stream crypto to crypto component.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package org.briarproject.api.crypto;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface StreamDecrypter {
|
||||
|
||||
/**
|
||||
* Reads a frame, decrypts its payload into the given buffer and returns
|
||||
* the payload length, or -1 if no more frames can be read from the stream.
|
||||
* @throws java.io.IOException if an error occurs while reading the frame,
|
||||
* or if authenticated decryption fails.
|
||||
*/
|
||||
int readFrame(byte[] payload) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.briarproject.api.crypto;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.briarproject.api.transport.StreamContext;
|
||||
|
||||
public interface StreamDecrypterFactory {
|
||||
|
||||
/** Creates a {@link StreamDecrypter} for decrypting a transport stream. */
|
||||
StreamDecrypter createStreamDecrypter(InputStream in, int maxFrameLength,
|
||||
StreamContext ctx);
|
||||
|
||||
/**
|
||||
* Creates a {@link StreamDecrypter} for decrypting an invitation stream.
|
||||
*/
|
||||
StreamDecrypter createInvitationStreamDecrypter(InputStream in,
|
||||
int maxFrameLength, byte[] secret, boolean alice);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.briarproject.api.crypto;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface StreamEncrypter {
|
||||
|
||||
/** Encrypts the given frame and writes it to the stream. */
|
||||
void writeFrame(byte[] payload, int payloadLength, boolean finalFrame)
|
||||
throws IOException;
|
||||
|
||||
/** Flushes the stream. */
|
||||
void flush() throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.briarproject.api.crypto;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.briarproject.api.transport.StreamContext;
|
||||
|
||||
public interface StreamEncrypterFactory {
|
||||
|
||||
/** Creates a {@link StreamEncrypter} for encrypting a transport stream. */
|
||||
StreamEncrypter createStreamEncrypter(OutputStream out,
|
||||
int maxFrameLength, StreamContext ctx);
|
||||
|
||||
/**
|
||||
* Creates a {@link StreamEncrypter} for encrypting an invitation stream.
|
||||
*/
|
||||
StreamEncrypter createInvitationStreamEncrypter(OutputStream out,
|
||||
int maxFrameLength, byte[] secret, boolean alice);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package org.briarproject.api.transport;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/** Decrypts and authenticates data received over an underlying transport. */
|
||||
public interface StreamReader {
|
||||
|
||||
/**
|
||||
* Returns an input stream from which the decrypted, authenticated data can
|
||||
* be read.
|
||||
*/
|
||||
InputStream getInputStream();
|
||||
}
|
||||
@@ -4,11 +4,17 @@ import java.io.InputStream;
|
||||
|
||||
public interface StreamReaderFactory {
|
||||
|
||||
/** Creates a {@link StreamReader} for a transport connection. */
|
||||
StreamReader createStreamReader(InputStream in, int maxFrameLength,
|
||||
/**
|
||||
* Creates an {@link java.io.InputStream InputStream} for reading from a
|
||||
* transport stream.
|
||||
*/
|
||||
InputStream createStreamReader(InputStream in, int maxFrameLength,
|
||||
StreamContext ctx);
|
||||
|
||||
/** Creates a {@link StreamReader} for an invitation connection. */
|
||||
StreamReader createInvitationStreamReader(InputStream in,
|
||||
/**
|
||||
* Creates an {@link java.io.InputStream InputStream} for reading from an
|
||||
* invitation stream.
|
||||
*/
|
||||
InputStream createInvitationStreamReader(InputStream in,
|
||||
int maxFrameLength, byte[] secret, boolean alice);
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package org.briarproject.api.transport;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
/** Encrypts and authenticates data to be sent over an underlying transport. */
|
||||
public interface StreamWriter {
|
||||
|
||||
/**
|
||||
* Returns an output stream to which unencrypted, unauthenticated data can
|
||||
* be written.
|
||||
*/
|
||||
OutputStream getOutputStream();
|
||||
}
|
||||
@@ -4,11 +4,17 @@ import java.io.OutputStream;
|
||||
|
||||
public interface StreamWriterFactory {
|
||||
|
||||
/** Creates a {@link StreamWriter} for a transport connection. */
|
||||
StreamWriter createStreamWriter(OutputStream out, int maxFrameLength,
|
||||
/**
|
||||
* Creates an {@link java.io.OutputStream OutputStream} for writing to a
|
||||
* transport stream
|
||||
*/
|
||||
OutputStream createStreamWriter(OutputStream out, int maxFrameLength,
|
||||
StreamContext ctx);
|
||||
|
||||
/** Creates a {@link StreamWriter} for an invitation connection. */
|
||||
StreamWriter createInvitationStreamWriter(OutputStream out,
|
||||
/**
|
||||
* Creates an {@link java.io.OutputStream OutputStream} for writing to an
|
||||
* invitation stream.
|
||||
*/
|
||||
OutputStream createInvitationStreamWriter(OutputStream out,
|
||||
int maxFrameLength, byte[] secret, boolean alice);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user