Skip to content

Commit 7f7c1ae

Browse files
feklwiic0ns
authored andcommitted
#170 Implemented Support for SSLv3 (#341)
* #170 Implemented Support for SSLv3 * #170 Implemented changes according to comments on pull-request 341 * Formated config * SSL3 HandshakeTest now uses BasicTlsServer Fixed Shutdown Method in BasicTlsServer * Moved StringUtils dependency to TLS-Attacker from Core
1 parent e3e785c commit 7f7c1ae

File tree

43 files changed

+1509
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1509
-218
lines changed

TLS-Client/src/test/java/de/rub/nds/tlsattacker/client/main/TlsClientTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ public void testExecuteWorkflows(PublicKeyAlgorithm algorithm, int port) {
149149
config.setDefaultTimeout(TIMEOUT);
150150
config.setEnforceSettings(false);
151151
List<String> serverList = Arrays.asList(tlsServer.getCipherSuites());
152+
config.setHighestProtocolVersion(ProtocolVersion.SSL3);
153+
testProtocolCompatibility(serverList, config, algorithm);
152154
config.setHighestProtocolVersion(ProtocolVersion.TLS10);
153155
testProtocolCompatibility(serverList, config, algorithm);
154156
config.setHighestProtocolVersion(ProtocolVersion.TLS11);
@@ -168,8 +170,10 @@ private void testProtocolCompatibility(List<String> serverList, Config config, P
168170
for (CipherSuite cs : CipherSuite.getImplemented()) {
169171
Set<PublicKeyAlgorithm> requiredAlgorithms = AlgorithmResolver.getRequiredKeystoreAlgorithms(cs);
170172
requiredAlgorithms.remove(algorithm);
171-
if (serverList.contains(cs.toString()) && cs.isSupportedInProtocol(config.getHighestProtocolVersion())
172-
&& requiredAlgorithms.isEmpty()) {
173+
final boolean serverSupportsCipherSuite = serverList.contains(cs.toString());
174+
final boolean cipherSuiteIsSupportedByProtocolVersion = cs.isSupportedInProtocol(config
175+
.getHighestProtocolVersion());
176+
if (serverSupportsCipherSuite && cipherSuiteIsSupportedByProtocolVersion && requiredAlgorithms.isEmpty()) {
173177
LinkedList<CipherSuite> cslist = new LinkedList<>();
174178
cslist.add(cs);
175179
config.setDefaultClientSupportedCiphersuites(cslist);

TLS-Core/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
<artifactId>Utils</artifactId>
2020
<version>${project.version}</version>
2121
</dependency>
22-
<dependency>
23-
<groupId>org.apache.commons</groupId>
24-
<artifactId>commons-lang3</artifactId>
25-
<version>3.1</version>
26-
</dependency>
2722
</dependencies>
2823
<name>TLS-Core</name>
2924
<build>

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/config/Config.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,11 +1742,11 @@ public Integer getDefaultTimeout() {
17421742
*/
17431743
public void setDefaultTimeout(Integer timeout) {
17441744
defaultTimeout = timeout;
1745-
1746-
if(connectionEnds != null) {
1747-
for (ConnectionEnd conEnd : connectionEnds) {
1748-
conEnd.setDefaultTimeout(defaultTimeout);
1749-
}
1745+
1746+
if (connectionEnds != null) {
1747+
for (ConnectionEnd conEnd : connectionEnds) {
1748+
conEnd.setDefaultTimeout(defaultTimeout);
1749+
}
17501750
}
17511751
}
17521752

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/constants/AlgorithmResolver.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,24 @@ public static CipherType getCipherType(CipherSuite cipherSuite) {
266266
throw new UnsupportedOperationException("Cipher suite " + cipherSuite + " is not supported yet.");
267267
}
268268

269-
public static MacAlgorithm getMacAlgorithm(CipherSuite cipherSuite) {
269+
public static MacAlgorithm getMacAlgorithm(ProtocolVersion protocolVersion, CipherSuite cipherSuite) {
270270
MacAlgorithm result = null;
271271
if (cipherSuite.isAEAD()) {
272272
result = MacAlgorithm.AEAD;
273273
} else {
274274
String cipher = cipherSuite.toString();
275275
if (cipher.contains("MD5")) {
276-
result = MacAlgorithm.HMAC_MD5;
276+
if (protocolVersion.isSSL()) {
277+
result = MacAlgorithm.SSLMAC_MD5;
278+
} else {
279+
result = MacAlgorithm.HMAC_MD5;
280+
}
277281
} else if (cipher.endsWith("SHA")) {
278-
result = MacAlgorithm.HMAC_SHA1;
282+
if (protocolVersion.isSSL()) {
283+
result = MacAlgorithm.SSLMAC_SHA1;
284+
} else {
285+
result = MacAlgorithm.HMAC_SHA1;
286+
}
279287
} else if (cipher.contains("SHA256")) {
280288
result = MacAlgorithm.HMAC_SHA256;
281289
} else if (cipher.contains("SHA384")) {

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/constants/CipherSuite.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88
*/
99
package de.rub.nds.tlsattacker.core.constants;
1010

11-
import de.rub.nds.modifiablevariable.util.ArrayConverter;
12-
import de.rub.nds.modifiablevariable.util.RandomHelper;
13-
import de.rub.nds.tlsattacker.core.exceptions.UnknownCiphersuiteException;
14-
import de.rub.nds.tlsattacker.core.state.TlsContext;
11+
import java.util.Arrays;
12+
import java.util.Collections;
1513
import java.util.HashMap;
14+
import java.util.HashSet;
1615
import java.util.LinkedList;
1716
import java.util.List;
1817
import java.util.Map;
1918
import java.util.Random;
19+
import java.util.Set;
20+
21+
import de.rub.nds.modifiablevariable.util.ArrayConverter;
22+
import de.rub.nds.tlsattacker.core.exceptions.UnknownCiphersuiteException;
2023

2124
/**
2225
* @author Juraj Somorovsky <juraj.somorovsky@rub.de>
@@ -542,12 +545,29 @@ public boolean isSCSV() {
542545
* @return
543546
*/
544547
public boolean isSupportedInProtocol(ProtocolVersion version) {
548+
if (version == ProtocolVersion.SSL3) {
549+
return SSL3_SUPPORTED_CIPHERSUITES.contains(this);
550+
}
545551
if (this.name().endsWith("256") || this.name().endsWith("384")) {
546552
return (version == ProtocolVersion.TLS12);
547553
}
548554
return true;
549555
}
550556

557+
public static final Set<CipherSuite> SSL3_SUPPORTED_CIPHERSUITES = Collections.unmodifiableSet(new HashSet<>(Arrays
558+
.asList(TLS_NULL_WITH_NULL_NULL, TLS_RSA_WITH_NULL_MD5, TLS_RSA_WITH_NULL_SHA,
559+
TLS_RSA_EXPORT_WITH_RC4_40_MD5, TLS_RSA_WITH_RC4_128_MD5, TLS_RSA_WITH_RC4_128_SHA,
560+
TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5, TLS_RSA_WITH_IDEA_CBC_SHA, TLS_RSA_EXPORT_WITH_DES40_CBC_SHA,
561+
TLS_RSA_WITH_DES_CBC_SHA, TLS_RSA_WITH_3DES_EDE_CBC_SHA, TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA,
562+
TLS_DH_DSS_WITH_DES_CBC_SHA, TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA,
563+
TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA, TLS_DH_RSA_WITH_DES_CBC_SHA,
564+
TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA, TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA,
565+
TLS_DHE_DSS_WITH_DES_CBC_SHA, TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA,
566+
TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, TLS_DHE_RSA_WITH_DES_CBC_SHA,
567+
TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, TLS_DH_anon_EXPORT_WITH_RC4_40_MD5,
568+
TLS_DH_anon_WITH_RC4_128_MD5, TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA, TLS_DH_anon_WITH_DES_CBC_SHA,
569+
TLS_DH_anon_WITH_3DES_EDE_CBC_SHA)));
570+
551571
public static List<CipherSuite> getImplemented() {
552572
List<CipherSuite> list = new LinkedList<>();
553573
list.add(TLS_RSA_WITH_3DES_EDE_CBC_SHA);

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/constants/DigestAlgorithm.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
public enum DigestAlgorithm {
1515

16+
SSL_DIGEST(""),
1617
LEGACY(""),
1718
SHA256("SHA-256"),
1819
SHA384("SHA-384");

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/constants/MacAlgorithm.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public enum MacAlgorithm {
1515

1616
NULL("null"),
1717
AEAD("null"),
18+
SSLMAC_MD5("SslMacMD5"), // supported by SunJCE
19+
SSLMAC_SHA1("SslMacSHA1"), // supported by SunJCE
1820
HMAC_MD5("HmacMD5"),
1921
HMAC_SHA1("HmacSHA1"),
2022
HMAC_SHA256("HmacSHA256"),

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/constants/ProtocolVersion.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,12 @@ public static ProtocolVersion getHighestProtocolVersion(List<ProtocolVersion> li
159159
public boolean isTLS13() {
160160
return this == TLS13 || this == TLS13_DRAFT20 || this == TLS13_DRAFT21;
161161
}
162+
163+
/**
164+
*
165+
* @return true, if protocol version SSL 2 or 3
166+
*/
167+
public boolean isSSL() {
168+
return this == SSL2 || this == SSL3;
169+
}
162170
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public byte[] digest(ProtocolVersion version, CipherSuite suite) {
5454
MessageDigest hash1;
5555
MessageDigest hash2 = null;
5656
DigestAlgorithm algorithm = AlgorithmResolver.getDigestAlgorithm(version, suite);
57-
if (algorithm == DigestAlgorithm.LEGACY) {
58-
57+
if (algorithm == DigestAlgorithm.SSL_DIGEST) {
58+
throw new RuntimeException("Unsupported DigestAlgorithm SSL_DIGEST");
59+
} else if (algorithm == DigestAlgorithm.LEGACY) {
5960
hash1 = MessageDigest.getInstance("MD5");
6061
hash2 = MessageDigest.getInstance("SHA-1");
61-
6262
} else {
6363
hash1 = MessageDigest.getInstance(algorithm.getJavaName());
6464
}

0 commit comments

Comments
 (0)