Skip to content
Snippets Groups Projects
Commit cea76cce authored by akwizgran's avatar akwizgran
Browse files

Use consistent wording.

parent 067af18a
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,7 @@ class FrameEncoder {
ByteUtils.writeUint16(plaintextLength, aad, 4);
}
static void encodeHeader(byte[] header, boolean lastFrame,
static void encodeHeader(byte[] header, boolean finalFrame,
int payloadLength) {
if(header.length < HEADER_LENGTH) throw new IllegalArgumentException();
if(payloadLength < 0)
......@@ -38,10 +38,10 @@ class FrameEncoder {
if(payloadLength > MAX_FRAME_LENGTH - HEADER_LENGTH - MAC_LENGTH)
throw new IllegalArgumentException();
ByteUtils.writeUint16(payloadLength, header, 0);
if(lastFrame) header[0] |= 0x80;
if(finalFrame) header[0] |= 0x80;
}
static boolean isLastFrame(byte[] header) {
static boolean isFinalFrame(byte[] header) {
if(header.length < HEADER_LENGTH) throw new IllegalArgumentException();
return (header[0] & 0x80) == 0x80;
}
......
......@@ -28,7 +28,7 @@ class IncomingEncryptionLayer implements FrameReader {
private final int frameLength;
private long frameNumber;
private boolean readTag, lastFrame;
private boolean readTag, finalFrame;
/** Constructor for the initiator's side of a connection. */
IncomingEncryptionLayer(InputStream in, Cipher tagCipher,
......@@ -45,7 +45,7 @@ class IncomingEncryptionLayer implements FrameReader {
ciphertext = new byte[frameLength];
frameNumber = 0L;
readTag = true;
lastFrame = false;
finalFrame = false;
}
/** Constructor for the responder's side of a connection. */
......@@ -62,11 +62,11 @@ class IncomingEncryptionLayer implements FrameReader {
ciphertext = new byte[frameLength];
frameNumber = 0L;
readTag = false;
lastFrame = false;
finalFrame = false;
}
public int readFrame(byte[] frame) throws IOException {
if(lastFrame) return -1;
if(finalFrame) return -1;
// Read the tag if required
if(readTag) {
int offset = 0;
......@@ -113,8 +113,8 @@ class IncomingEncryptionLayer implements FrameReader {
throw new RuntimeException(badCipher);
}
// Decode and validate the header
lastFrame = FrameEncoder.isLastFrame(frame);
if(!lastFrame && ciphertextLength < frameLength)
finalFrame = FrameEncoder.isFinalFrame(frame);
if(!finalFrame && ciphertextLength < frameLength)
throw new EOFException();
int payloadLength = FrameEncoder.getPayloadLength(frame);
if(payloadLength > plaintextLength - HEADER_LENGTH)
......
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