Skip to content

Commit 755e795

Browse files
authored
Merge pull request #688 from tls-attacker/fix-invalidcurvevector-equals-hashcode
Fix BAD_PRACTICE/HE_EQUALS_USE_HASHCODE in InvalidCurveVector
2 parents 4bf62fc + 5f57fb1 commit 755e795

File tree

1 file changed

+26
-9
lines changed
  • TLS-Server-Scanner/src/main/java/de/rub/nds/tlsscanner/serverscanner/probe/invalidcurve/vector

1 file changed

+26
-9
lines changed

TLS-Server-Scanner/src/main/java/de/rub/nds/tlsscanner/serverscanner/probe/invalidcurve/vector/InvalidCurveVector.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import de.rub.nds.tlsscanner.core.vector.Vector;
1818
import java.util.LinkedList;
1919
import java.util.List;
20+
import java.util.Objects;
2021

2122
/** */
2223
public class InvalidCurveVector implements Vector {
@@ -137,18 +138,34 @@ public List<NamedGroup> getEcdsaRequiredGroups() {
137138
return ecdsaRequiredGroups;
138139
}
139140

140-
public boolean equals(InvalidCurveVector toCompare) {
141-
if (protocolVersion != toCompare.getProtocolVersion()
142-
|| cipherSuite != toCompare.getCipherSuite()
143-
|| namedGroup != toCompare.getNamedGroup()
144-
|| pointFormat != toCompare.getPointFormat()
145-
|| twistAttack != toCompare.isTwistAttack()
146-
|| attackInRenegotiation != toCompare.isAttackInRenegotiation()
147-
|| !ecdsaRequiredGroups.equals(toCompare.getEcdsaRequiredGroups())) {
141+
@Override
142+
public boolean equals(Object obj) {
143+
if (this == obj) {
144+
return true;
145+
}
146+
if (obj == null || getClass() != obj.getClass()) {
148147
return false;
149148
}
149+
InvalidCurveVector toCompare = (InvalidCurveVector) obj;
150+
return protocolVersion == toCompare.getProtocolVersion()
151+
&& cipherSuite == toCompare.getCipherSuite()
152+
&& namedGroup == toCompare.getNamedGroup()
153+
&& pointFormat == toCompare.getPointFormat()
154+
&& twistAttack == toCompare.isTwistAttack()
155+
&& attackInRenegotiation == toCompare.isAttackInRenegotiation()
156+
&& Objects.equals(ecdsaRequiredGroups, toCompare.getEcdsaRequiredGroups());
157+
}
150158

151-
return true;
159+
@Override
160+
public int hashCode() {
161+
return Objects.hash(
162+
protocolVersion,
163+
cipherSuite,
164+
namedGroup,
165+
pointFormat,
166+
twistAttack,
167+
attackInRenegotiation,
168+
ecdsaRequiredGroups);
152169
}
153170

154171
public void setEcdsaRequiredGroups(List<NamedGroup> ecdsaRequiredGroups) {

0 commit comments

Comments
 (0)