* that encodes l(a) with a itself, and splitting the result into
* 16-octet blocks, and then padding the last block with zeroes if
* necessary.
*/
DatagramWriter writer = new DatagramWriter();
if (lengthA > 0 && lengthA < first) {
// 2 bytes (0x0001 ... 0xFEFF)
writer.writeLong(lengthA, 16);
} else if (lengthA >= first && lengthA < second) {
// 2 bytes (0xFFFE) + 4 octets of l(a)
int field = 0xFFFE;
writer.write(field, 16);
writer.writeLong(lengthA, 32);
} else {
// 2 bytes (0xFFFF) + 8 octets of l(a)
int field = 0xFFFF;
writer.write(field, 16);
writer.writeLong(lengthA, 64);
}
writer.writeBytes(a);
byte[] aEncoded = writer.toByteArray();
blocks.addAll(ByteArrayUtils.splitAndPad(aEncoded, BLOCK_SIZE));
}
/*
* After the (optional) additional authentication blocks have been
* added, we add the message blocks. The message blocks are formed by