Skip to content

Commit 36887c2

Browse files
authored
Merge branch 'master' into nimrod_SNI
2 parents 45096ff + bb2b5a5 commit 36887c2

File tree

8 files changed

+33
-8
lines changed

8 files changed

+33
-8
lines changed

TLS-Core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<plugin>
7474
<groupId>org.jacoco</groupId>
7575
<artifactId>jacoco-maven-plugin</artifactId>
76-
<version>0.7.9</version>
76+
<version>0.8.4</version>
7777
<reportSets>
7878
<reportSet>
7979
<reports>

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/crypto/ec/CurveFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class CurveFactory {
1818
*
1919
* @param name
2020
* The name of the curve, that should be returned.
21+
* @return EllipticCurve for the provided NamedGroup
2122
*/
2223
public static EllipticCurve getCurve(NamedGroup name) {
2324
switch (name) {
@@ -78,7 +79,8 @@ public static EllipticCurve getCurve(NamedGroup name) {
7879
case SECT571R1:
7980
return new EllipticCurveSECT571R1();
8081
default:
81-
throw new UnsupportedOperationException("The provided curve '" + name + "' is not supported.");
82+
throw new UnsupportedOperationException("The provided group '" + name
83+
+ "' is not supported by this method.");
8284

8385
}
8486
}

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/protocol/handler/ECDHClientKeyExchangeHandler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package de.rub.nds.tlsattacker.core.protocol.handler;
1010

1111
import de.rub.nds.tlsattacker.core.constants.NamedGroup;
12+
import de.rub.nds.tlsattacker.core.crypto.ec.FieldElementF2m;
1213
import de.rub.nds.tlsattacker.core.crypto.ec.Point;
1314
import de.rub.nds.tlsattacker.core.crypto.ec.PointFormatter;
1415
import de.rub.nds.tlsattacker.core.protocol.message.ECDHClientKeyExchangeMessage;
@@ -57,7 +58,10 @@ private void adjustClientPublicKey(ECDHClientKeyExchangeMessage message) {
5758
NamedGroup usedGroup = tlsContext.getChooser().getSelectedNamedGroup();
5859
if (usedGroup == NamedGroup.ECDH_X25519 || usedGroup == NamedGroup.ECDH_X448) {
5960
LOGGER.debug("Adjusting Montgomery EC PublicKey");
60-
tlsContext.setClientEcPublicKey(Point.createPoint(new BigInteger(serializedPoint), null, usedGroup));
61+
// TODO This is only a temporary solution. Montgomory Curves need to
62+
// be integrated into the new EC framework
63+
tlsContext.setClientEcPublicKey(new Point(new FieldElementF2m(new BigInteger(serializedPoint), null),
64+
new FieldElementF2m(new BigInteger(serializedPoint), null)));
6165
} else {
6266
LOGGER.debug("Adjusting EC Point");
6367
Point publicKey = PointFormatter.formatFromByteArray(usedGroup, serializedPoint);

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/protocol/handler/ECDHEServerKeyExchangeHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import de.rub.nds.tlsattacker.core.constants.AlgorithmResolver;
1212
import de.rub.nds.tlsattacker.core.constants.NamedGroup;
13+
import de.rub.nds.tlsattacker.core.crypto.ec.FieldElementF2m;
1314
import de.rub.nds.tlsattacker.core.crypto.ec.Point;
1415
import de.rub.nds.tlsattacker.core.crypto.ec.PointFormatter;
1516
import de.rub.nds.tlsattacker.core.protocol.message.ECDHEServerKeyExchangeMessage;
@@ -61,8 +62,11 @@ protected void adjustECParameter(ECDHEServerKeyExchangeMessage message) {
6162
}
6263
if (group == NamedGroup.ECDH_X448 || group == NamedGroup.ECDH_X25519) {
6364
LOGGER.debug("Adjusting Montgomery EC Point");
64-
Point publicKey = Point.createPoint(new BigInteger(message.getPublicKey().getValue()), null, group);
65-
tlsContext.setServerEcPublicKey(publicKey);
65+
// TODO This is only a temporary solution. Montgomory Curves need to
66+
// be integrated into the new EC framework
67+
tlsContext.setServerEcPublicKey(new Point(new FieldElementF2m(new BigInteger(message.getPublicKey()
68+
.getValue()), null), new FieldElementF2m(new BigInteger(message.getPublicKey().getValue()), null)));
69+
6670
} else if (group != null) {
6771
LOGGER.debug("Adjusting EC Point");
6872
Point publicKeyPoint = PointFormatter.formatFromByteArray(group, message.getPublicKey().getValue());

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/protocol/handler/extension/SignatureAndHashAlgorithmsExtensionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void adjustTLSExtensionContext(SignatureAndHashAlgorithmsExtensionMessage
4444
byte[] algoBytes = Arrays.copyOfRange(signatureAndHashBytes, i, i
4545
+ HandshakeByteLength.SIGNATURE_HASH_ALGORITHM);
4646
SignatureAndHashAlgorithm algo = SignatureAndHashAlgorithm.getSignatureAndHashAlgorithm(algoBytes);
47-
if (algo.getSignatureAlgorithm() == null || algo.getHashAlgorithm() == null) {
47+
if (algo == null || algo.getSignatureAlgorithm() == null || algo.getHashAlgorithm() == null) {
4848
LOGGER.warn("Unknown SignatureAndHashAlgorithm:" + ArrayConverter.bytesToHexString(algoBytes));
4949
} else {
5050
algoList.add(algo);

Transport/src/main/java/de/rub/nds/tlsattacker/transport/TransportHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111
import java.io.ByteArrayOutputStream;
1212
import java.io.IOException;
13+
import java.io.InputStream;
1314
import java.io.OutputStream;
1415
import java.io.PushbackInputStream;
1516
import java.net.SocketException;
16-
17+
import java.net.SocketTimeoutException;
1718
import org.apache.logging.log4j.LogManager;
1819
import org.apache.logging.log4j.Logger;
1920

Transport/src/main/java/de/rub/nds/tlsattacker/transport/udp/stream/UdpInputStream.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public int read() throws IOException {
6868
} catch (InterruptedException _) {
6969
}
7070
}
71-
7271
index++;
7372
return dataBuffer[index - 1] & 0xff;
7473
}

Transport/src/test/java/de/rub/nds/tlsattacker/transport/udp/ClientUdpTransportHandlerTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,19 @@ public void testFetchData() throws Exception {
8585
udpTH.closeConnection();
8686
}
8787
}
88+
89+
@Test
90+
public void testFetchTimeout() throws Exception {
91+
ClientUdpTransportHandler udpTH = new ClientUdpTransportHandler(1, localhost.getHostName(), 12345);
92+
udpTH.initialize();
93+
udpTH.setTimeout(1);
94+
95+
byte[] rxData;
96+
rxData = udpTH.fetchData();
97+
assertEquals(0, rxData.length);
98+
rxData = udpTH.fetchData();
99+
assertEquals(0, rxData.length);
100+
udpTH.closeConnection();
101+
102+
}
88103
}

0 commit comments

Comments
 (0)