ShortPaddingGenerator extends PaddingVectorGenerator { List<ByteArrayXorModification> createFlippedModifications(int byteLength) { List<ByteArrayXorModification> modificationList = new LinkedList<>(); modificationList.add(new ByteArrayXorModification(new byte[] { 0x01 }, byteLength - 1)); modificationList.add(new ByteArrayXorModification(new byte[] { 0x08 }, byteLength / 2)); modificationList.add(new ByteArrayXorModification(new byte[] { (byte) 0x80 }, 0)); return modificationList; }  @Override List<PaddingVector> getVectors(CipherSuite suite, ProtocolVersion version);  }
@Test public void testCreateFlippedModifications() { List<ByteArrayXorModification> modifications = generator.createFlippedModifications(10); ModifiableByteArray array = new ModifiableByteArray(); array.setOriginalValue(new byte[10]); byte[] expected = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; array.setModification(modifications.get(0)); assertArrayEquals("Last byte should be xored with 0x01", expected, array.getValue()); expected = new byte[] { 0, 0, 0, 0, 0, 8, 0, 0, 0, 0 }; array.setModification(modifications.get(1)); assertArrayEquals("Middle byte should be xored with 0x08", expected, array.getValue()); expected = new byte[] { (byte) 128, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; array.setModification(modifications.get(2)); assertArrayEquals("First byte should be xored with 0x80", expected, array.getValue()); }