Use consistent wording.

This commit is contained in:
akwizgran
2012-08-29 18:48:42 +01:00
parent 067af18ac4
commit cea76cce7e
2 changed files with 9 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -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)