mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Erase temporary secrets after deriving keys.
This commit is contained in:
@@ -6,7 +6,6 @@ import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
|
|||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -30,6 +29,7 @@ import org.briarproject.api.transport.StreamReaderFactory;
|
|||||||
import org.briarproject.api.transport.StreamWriter;
|
import org.briarproject.api.transport.StreamWriter;
|
||||||
import org.briarproject.api.transport.StreamWriterFactory;
|
import org.briarproject.api.transport.StreamWriterFactory;
|
||||||
import org.briarproject.api.transport.TagRecogniser;
|
import org.briarproject.api.transport.TagRecogniser;
|
||||||
|
import org.briarproject.util.ByteUtils;
|
||||||
|
|
||||||
class ConnectionManagerImpl implements ConnectionManager {
|
class ConnectionManagerImpl implements ConnectionManager {
|
||||||
|
|
||||||
@@ -96,21 +96,28 @@ class ConnectionManagerImpl implements ConnectionManager {
|
|||||||
|
|
||||||
private MessagingSession createIncomingSession(StreamContext ctx,
|
private MessagingSession createIncomingSession(StreamContext ctx,
|
||||||
TransportConnectionReader r) throws IOException {
|
TransportConnectionReader r) throws IOException {
|
||||||
InputStream in = r.getInputStream();
|
try {
|
||||||
StreamReader streamReader = streamReaderFactory.createStreamReader(in,
|
StreamReader streamReader = streamReaderFactory.createStreamReader(
|
||||||
r.getMaxFrameLength(), ctx);
|
r.getInputStream(), r.getMaxFrameLength(), ctx);
|
||||||
return messagingSessionFactory.createIncomingSession(ctx.getContactId(),
|
return messagingSessionFactory.createIncomingSession(
|
||||||
ctx.getTransportId(), streamReader.getInputStream());
|
ctx.getContactId(), ctx.getTransportId(),
|
||||||
|
streamReader.getInputStream());
|
||||||
|
} finally {
|
||||||
|
ByteUtils.erase(ctx.getSecret());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MessagingSession createOutgoingSession(StreamContext ctx,
|
private MessagingSession createOutgoingSession(StreamContext ctx,
|
||||||
TransportConnectionWriter w, boolean duplex) throws IOException {
|
TransportConnectionWriter w, boolean duplex) throws IOException {
|
||||||
OutputStream out = w.getOutputStream();
|
try {
|
||||||
StreamWriter streamWriter = streamWriterFactory.createStreamWriter(out,
|
StreamWriter streamWriter = streamWriterFactory.createStreamWriter(
|
||||||
w.getMaxFrameLength(), ctx);
|
w.getOutputStream(), w.getMaxFrameLength(), ctx);
|
||||||
return messagingSessionFactory.createOutgoingSession(ctx.getContactId(),
|
return messagingSessionFactory.createOutgoingSession(
|
||||||
ctx.getTransportId(), w.getMaxLatency(),
|
ctx.getContactId(), ctx.getTransportId(), w.getMaxLatency(),
|
||||||
duplex, streamWriter.getOutputStream());
|
duplex, streamWriter.getOutputStream());
|
||||||
|
} finally {
|
||||||
|
ByteUtils.erase(ctx.getSecret());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DispatchIncomingSimplexConnection implements Runnable {
|
private class DispatchIncomingSimplexConnection implements Runnable {
|
||||||
|
|||||||
Reference in New Issue
Block a user