Добавлена обработка ошибок при расшифровке TLS

This commit is contained in:
serega6531
2020-04-26 04:37:20 +03:00
parent fd50fff1a2
commit 6f5ceb6174
3 changed files with 120 additions and 81 deletions

View File

@@ -9,6 +9,8 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
public class TlsDecryptorTest {
@Test
@@ -21,6 +23,14 @@ public class TlsDecryptorTest {
TlsDecryptor decryptor = new TlsDecryptor(packets, keysHolder);
decryptor.decryptTls();
assertTrue(decryptor.isParsed(), "TLS not parsed");
List<Packet> parsed = decryptor.getParsedPackets();
assertNotNull(parsed, "Parsed packets list is null");
assertEquals(4, parsed.size(), "Wrong packets list size");
assertTrue(new String(parsed.get(0).getContent()).contains("GET /"), "Wrong content at the start");
assertTrue(new String(parsed.get(3).getContent()).contains("Not Found"), "Wrong content at the end");
}
}

View File

@@ -1,26 +0,0 @@
package ru.serega6531.packmate;
import org.junit.jupiter.api.Test;
import org.pcap4j.packet.IllegalRawDataException;
import ru.serega6531.packmate.model.Packet;
import ru.serega6531.packmate.service.optimization.tls.TlsPacket;
import java.io.IOException;
import java.util.List;
public class TlsPacketTest {
@Test
public void testHandshake() throws IOException, IllegalRawDataException {
List<Packet> packets = new PackmateDumpFileLoader("tls-wolfram.pkmt").getPackets();
for (int i = 0; i < packets.size(); i++) {
Packet packet = packets.get(i);
System.out.println("Packet " + i + ", incoming: " + packet.isIncoming());
byte[] content = packet.getContent();
TlsPacket tlsPacket = TlsPacket.newPacket(content, 0, content.length);
System.out.println(tlsPacket.toString());
}
}
}