18
18
import de .rub .nds .tlsattacker .core .constants .SignatureAndHashAlgorithm ;
19
19
import de .rub .nds .tlsattacker .core .protocol .message .ECDHEServerKeyExchangeMessage ;
20
20
import de .rub .nds .tlsattacker .core .protocol .message .HandshakeMessage ;
21
- import de .rub .nds .tlsattacker .core .protocol .message .ServerHelloMessage ;
22
- import de .rub .nds .tlsattacker .core .protocol .message .extension .KeyShareExtensionMessage ;
23
- import de .rub .nds .tlsattacker .core .protocol .message .extension .keyshare .KeyShareStoreEntry ;
24
21
import de .rub .nds .tlsattacker .core .state .State ;
25
22
import de .rub .nds .tlsattacker .core .state .TlsContext ;
26
23
import de .rub .nds .tlsattacker .core .workflow .ParallelExecutor ;
@@ -55,7 +52,6 @@ public class NamedCurvesProbe extends TlsProbe {
55
52
private boolean testUsingTls13 = true ;
56
53
57
54
// curves used for ecdsa in key exchange
58
- private List <NamedGroup > ecdsaPkGroupsStatic ;
59
55
private List <NamedGroup > ecdsaPkGroupsEphemeral ;
60
56
private List <NamedGroup > ecdsaPkGroupsTls13 ;
61
57
@@ -64,6 +60,8 @@ public class NamedCurvesProbe extends TlsProbe {
64
60
private List <NamedGroup > ecdsaCertSigGroupsEphemeral ;
65
61
private List <NamedGroup > ecdsaCertSigGroupsTls13 ;
66
62
63
+ private TestResult ignoresEcdsaGroupDisparity = TestResult .FALSE ;
64
+
67
65
public NamedCurvesProbe (ScannerConfig config , ParallelExecutor parallelExecutor ) {
68
66
super (parallelExecutor , ProbeType .NAMED_GROUPS , config );
69
67
}
@@ -83,7 +81,7 @@ public ProbeResult executeTest() {
83
81
groupsRsa = getSupportedNamedGroupsRsa ();
84
82
}
85
83
if (testUsingEcdsaStatic ) {
86
- groupsEcdsaStatic = getSupportedNamedGroupsEcdsa (getEcdsaStaticCiphersuites (), ecdsaPkGroupsStatic ,
84
+ groupsEcdsaStatic = getSupportedNamedGroupsEcdsa (getEcdsaStaticCiphersuites (), null ,
87
85
ecdsaCertSigGroupsStatic );
88
86
}
89
87
if (testUsingEcdsaEphemeral ) {
@@ -101,7 +99,7 @@ public ProbeResult executeTest() {
101
99
groupsEcdsaStatic , groupsEcdsaEphemeral );
102
100
103
101
return new NamedGroupResult (overallSupported , groupsTls13 , supportsExplicitPrime , supportsExplicitChar2 ,
104
- groupsDependOnCiphersuite );
102
+ groupsDependOnCiphersuite , ignoresEcdsaGroupDisparity );
105
103
} catch (Exception E ) {
106
104
LOGGER .error ("Could not scan for " + getProbeName (), E );
107
105
return getCouldNotExecuteResult ();
@@ -140,54 +138,57 @@ private Map<NamedGroup, NamedCurveWitness> getSupportedNamedGroupsEcdsa(List<Cip
140
138
Config tlsConfig = getBasicConfig ();
141
139
tlsConfig .setDefaultClientSupportedCiphersuites (cipherSuites );
142
140
List <NamedGroup > toTestList = new ArrayList <>(Arrays .asList (NamedGroup .values ()));
141
+
142
+ TlsContext context ;
143
+ NamedGroup selectedGroup = null ;
144
+ NamedGroup certificateGroup = null ;
145
+ NamedGroup certificateSigGroup = null ;
146
+ // place signing groups at the bottom of the list, the server should
147
+ // choose
148
+ // all other first
143
149
if (pkGroups != null ) {
144
- TlsContext context ;
145
- NamedGroup selectedGroup = null ;
146
- NamedGroup certificateGroup = null ;
147
- NamedGroup certificateSigGroup = null ;
148
- // place signing groups at the bottom of the list, the server should
149
- // choose
150
- // all other first
151
150
placeRequiredGroupsLast (toTestList , pkGroups );
152
- if (sigGroups != null ) {
153
- placeRequiredGroupsLast (toTestList , sigGroups );
154
- }
155
-
156
- do {
157
- context = testCurves (toTestList , tlsConfig );
151
+ }
152
+ if (sigGroups != null ) {
153
+ placeRequiredGroupsLast (toTestList , sigGroups );
154
+ }
158
155
159
- if (context != null ) {
156
+ do {
157
+ context = testCurves (toTestList , tlsConfig );
160
158
161
- selectedGroup = context .getSelectedGroup ();
162
- certificateGroup = context .getEcCertificateCurve ();
163
- certificateSigGroup = context .getEcCertificateSignatureCurve ();
159
+ if (context != null ) {
164
160
165
- // remove groups that are not required by the server even
166
- // if they are used for the certificate or KEX signature
167
- if (!toTestList .contains (certificateGroup )) {
168
- certificateGroup = null ;
169
- }
170
- if (!toTestList .contains (certificateSigGroup )) {
171
- certificateSigGroup = null ;
172
- }
161
+ selectedGroup = context .getSelectedGroup ();
162
+ certificateGroup = context .getEcCertificateCurve ();
163
+ certificateSigGroup = context .getEcCertificateSignatureCurve ();
173
164
174
- if (! toTestList . contains ( selectedGroup )) {
175
- LOGGER . debug ( "Server chose a Curve we did not offer!" );
176
- break ;
177
- }
178
- if ( cipherSuites . get ( 0 ). isEphemeral ()) {
179
- namedCurveMap . put ( selectedGroup , new NamedCurveWitness ( null , certificateGroup , null ,
180
- certificateSigGroup , context . getSelectedCipherSuite ()));
181
- } else {
182
- namedCurveMap . put ( selectedGroup , new NamedCurveWitness ( certificateGroup , null ,
183
- certificateSigGroup , null , context . getSelectedCipherSuite ()));
165
+ // remove groups that are not required by the server even
166
+ // if they are used for the certificate or KEX signature
167
+ if (! toTestList . contains ( certificateGroup ) && certificateSigGroup != null ) {
168
+ ignoresEcdsaGroupDisparity = TestResult . TRUE ;
169
+ certificateGroup = null ;
170
+ }
171
+ if (! toTestList . contains ( certificateSigGroup ) && certificateSigGroup != null ) {
172
+ ignoresEcdsaGroupDisparity = TestResult . TRUE ;
173
+ certificateSigGroup = null ;
174
+ }
184
175
185
- }
176
+ if (!toTestList .contains (selectedGroup )) {
177
+ LOGGER .debug ("Server chose a Curve we did not offer!" );
178
+ break ;
179
+ }
180
+ if (cipherSuites .get (0 ).isEphemeral ()) {
181
+ namedCurveMap .put (selectedGroup , new NamedCurveWitness (certificateGroup , null , certificateSigGroup ,
182
+ context .getSelectedCipherSuite ()));
183
+ } else {
184
+ namedCurveMap .put (selectedGroup ,
185
+ new NamedCurveWitness (null , certificateSigGroup , null , context .getSelectedCipherSuite ()));
186
186
187
- toTestList .remove (selectedGroup );
188
187
}
189
- } while (context != null && toTestList .size () > 0 );
190
- }
188
+
189
+ toTestList .remove (selectedGroup );
190
+ }
191
+ } while (context != null && toTestList .size () > 0 );
191
192
return namedCurveMap ;
192
193
}
193
194
@@ -276,7 +277,6 @@ public void adjustConfig(SiteReport report) {
276
277
if (report .getResult (AnalyzedProperty .SUPPORTS_TLS_1_3 ) != TestResult .TRUE ) {
277
278
testUsingTls13 = false ;
278
279
}
279
- ecdsaPkGroupsStatic = report .getEcdsaPkGroupsStatic ();
280
280
ecdsaPkGroupsEphemeral = report .getEcdsaPkGroupsEphemeral ();
281
281
ecdsaPkGroupsTls13 = report .getEcdsaPkGroupsTls13 ();
282
282
@@ -288,7 +288,7 @@ public void adjustConfig(SiteReport report) {
288
288
@ Override
289
289
public ProbeResult getCouldNotExecuteResult () {
290
290
return new NamedGroupResult (new HashMap <>(), new HashMap <>(), TestResult .COULD_NOT_TEST ,
291
- TestResult .COULD_NOT_TEST , TestResult .COULD_NOT_TEST );
291
+ TestResult .COULD_NOT_TEST , TestResult .COULD_NOT_TEST , TestResult . COULD_NOT_TEST );
292
292
}
293
293
294
294
private TestResult getExplicitCurveSupport (EllipticCurveType curveType ) {
@@ -377,11 +377,13 @@ private Map<NamedGroup, NamedCurveWitness> getTls13SupportedGroups() {
377
377
certificateGroup = context .getEcCertificateCurve ();
378
378
certificateSigGroup = context .getEcCertificateSignatureCurve ();
379
379
380
- if (!toTestList .contains (certificateGroup )) {
380
+ if (!toTestList .contains (certificateGroup ) && certificateGroup != null ) {
381
+ ignoresEcdsaGroupDisparity = TestResult .TRUE ;
381
382
certificateGroup = null ;
382
383
}
383
384
384
- if (!toTestList .contains (certificateSigGroup )) {
385
+ if (!toTestList .contains (certificateSigGroup ) && certificateSigGroup != null ) {
386
+ ignoresEcdsaGroupDisparity = TestResult .TRUE ;
385
387
certificateSigGroup = null ;
386
388
}
387
389
@@ -391,8 +393,8 @@ private Map<NamedGroup, NamedCurveWitness> getTls13SupportedGroups() {
391
393
break ;
392
394
}
393
395
394
- namedCurveMap .put (selectedGroup , new NamedCurveWitness (null , certificateGroup , null ,
395
- certificateSigGroup , context .getSelectedCipherSuite ()));
396
+ namedCurveMap .put (selectedGroup , new NamedCurveWitness (certificateGroup , null , certificateSigGroup ,
397
+ context .getSelectedCipherSuite ()));
396
398
toTestList .remove (selectedGroup );
397
399
}
398
400
} while (context != null && !toTestList .isEmpty ());
@@ -461,7 +463,6 @@ private Map<NamedGroup, NamedCurveWitness> composeFullMap(Map<NamedGroup, NamedC
461
463
}
462
464
if (groupsEcdsaStatic .containsKey (group )) {
463
465
witness .getCipherSuites ().addAll (groupsEcdsaStatic .get (group ).getCipherSuites ());
464
- witness .setEcdsaPkGroupStatic (groupsEcdsaStatic .get (group ).getEcdsaPkGroupStatic ());
465
466
witness .setEcdsaSigGroupStatic (groupsEcdsaStatic .get (group ).getEcdsaSigGroupStatic ());
466
467
}
467
468
if (groupsEcdsaEphemeral .containsKey (group )) {
0 commit comments