Skip to content
Snippets Groups Projects
Commit 651aeb48 authored by Thomas's avatar Thomas
Browse files

Clarifying comments

parent 9a16cf6e
No related branches found
No related tags found
No related merge requests found
Pipeline #12577 passed
......@@ -25,6 +25,9 @@ import static org.briarproject.bramble.api.transport.TransportConstants.STREAM_H
import static org.briarproject.bramble.util.ByteUtils.INT_16_BYTES;
import static org.briarproject.bramble.util.ByteUtils.INT_64_BYTES;
/**
* See the BTP-Specs to understand whats going on here
*/
@NotThreadSafe
@NotNullByDefault
class StreamEncrypterImpl implements StreamEncrypter {
......@@ -81,9 +84,9 @@ class StreamEncrypterImpl implements StreamEncrypter {
FrameEncoder.encodeNonce(frameNonce, frameNumber, true);
try {
cipher.init(true, frameKey, frameNonce);
int encrypted = cipher.process(frameHeader, 0,
int encryptedLength = cipher.process(frameHeader, 0,
FRAME_HEADER_PLAINTEXT_LENGTH, frameCiphertext, 0);
if (encrypted != FRAME_HEADER_LENGTH) throw new RuntimeException();
if (encryptedLength != FRAME_HEADER_LENGTH) throw new RuntimeException();
} catch (GeneralSecurityException badCipher) {
throw new RuntimeException(badCipher);
}
......@@ -129,10 +132,10 @@ class StreamEncrypterImpl implements StreamEncrypter {
// Encrypt and authenticate the stream header key
try {
cipher.init(true, streamHeaderKey, streamHeaderNonce);
int encrypted = cipher.process(streamHeaderPlaintext, 0,
int encryptedLength = cipher.process(streamHeaderPlaintext, 0,
STREAM_HEADER_PLAINTEXT_LENGTH, streamHeaderCiphertext,
STREAM_HEADER_NONCE_LENGTH);
if (encrypted != STREAM_HEADER_PLAINTEXT_LENGTH + MAC_LENGTH)
if (encryptedLength != STREAM_HEADER_PLAINTEXT_LENGTH + MAC_LENGTH)
throw new RuntimeException();
} catch (GeneralSecurityException badCipher) {
throw new RuntimeException(badCipher);
......
......@@ -26,6 +26,10 @@ import static org.briarproject.bramble.api.sync.RecordTypes.REQUEST;
import static org.briarproject.bramble.api.sync.RecordTypes.VERSIONS;
import static org.briarproject.bramble.api.sync.SyncConstants.PROTOCOL_VERSION;
/**
* see the BSP-Specs
*/
@NotThreadSafe
@NotNullByDefault
class SyncRecordWriterImpl implements SyncRecordWriter {
......
......@@ -22,7 +22,7 @@ class StreamWriterImpl extends OutputStream implements StreamWriter {
private final StreamEncrypter encrypter;
private final byte[] payload;
///@var length Stores how long the content that is currently in the buffer "payload" is.
private int length = 0;
StreamWriterImpl(StreamEncrypter encrypter) {
......@@ -68,7 +68,8 @@ class StreamWriterImpl extends OutputStream implements StreamWriter {
@Override
public void write(byte[] b, int off, int len) throws IOException {
int available = payload.length - length;
//Frame Segmentation
int available = payload.length - length; // available = How much free space ther is at the end of the buffer "payload"
while (available <= len) {
System.arraycopy(b, off, payload, length, available);
length += available;
......
......@@ -63,6 +63,9 @@ class TransportKeyManagerImpl implements TransportKeyManager {
@GuardedBy("lock")
private final Map<KeySetId, MutableTransportKeySet> keys = new HashMap<>();
/**
* List of all Tags
*/
@GuardedBy("lock")
private final Map<Bytes, TagContext> inContexts = new HashMap<>();
@GuardedBy("lock")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment