Skip to content

Commit 95a05eb

Browse files
committed
Merge origin/testsuite-compatibility into tls-testsuite
Conflicts: .gitignore src/main/java/de/rub/nds/modifiablevariable/ModifiableVariable.java
2 parents 860e091 + 689cf30 commit 95a05eb

File tree

5 files changed

+93
-1
lines changed

5 files changed

+93
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ buildNumber.properties
99
.mvn/timing.properties
1010
/nbproject/
1111
*.idea/
12-
ModifiableVariable.iml
12+
ModifiableVariable.iml

src/main/java/de/rub/nds/modifiablevariable/ModifiableVariable.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import de.rub.nds.modifiablevariable.biginteger.BigIntegerAddModification;
1313
import de.rub.nds.modifiablevariable.biginteger.BigIntegerExplicitValueModification;
1414
import de.rub.nds.modifiablevariable.biginteger.BigIntegerInteractiveModification;
15+
import de.rub.nds.modifiablevariable.biginteger.BigIntegerMultiplyModification;
1516
import de.rub.nds.modifiablevariable.biginteger.BigIntegerShiftLeftModification;
1617
import de.rub.nds.modifiablevariable.biginteger.BigIntegerShiftRightModification;
1718
import de.rub.nds.modifiablevariable.biginteger.BigIntegerSubtractModification;
@@ -73,6 +74,7 @@ public abstract class ModifiableVariable<E> implements Serializable {
7374
@XmlElement(type = BigIntegerExplicitValueModification.class, name = "BigIntegerExplicitValueModification"),
7475
@XmlElement(type = BigIntegerAddModification.class, name = "BigIntegerAddModification"),
7576
@XmlElement(type = BigIntegerInteractiveModification.class, name = "BigIntegerInteractiveModification"),
77+
@XmlElement(type = BigIntegerMultiplyModification.class, name = "BigIntegerMultiplyModification"),
7678
@XmlElement(type = BooleanToggleModification.class, name = "BooleanToggleModification"),
7779
@XmlElement(type = BooleanExplicitValueModification.class, name = "BooleanExplicitValueModification"),
7880
@XmlElement(type = ByteArrayXorModification.class, name = "ByteArrayXorModification"),

src/main/java/de/rub/nds/modifiablevariable/biginteger/BigIntegerModificationFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public static BigIntegerShiftRightModification shiftRight(final Integer shift) {
5858
return new BigIntegerShiftRightModification(shift);
5959
}
6060

61+
public static BigIntegerMultiplyModification multiply(final BigInteger factor) {
62+
return new BigIntegerMultiplyModification(factor);
63+
}
64+
6165
public static VariableModification<BigInteger> sub(final String subtrahend) {
6266
return sub(new BigInteger(subtrahend));
6367
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* ModifiableVariable - A Variable Concept for Runtime Modifications
3+
*
4+
* Copyright 2014-2017 Ruhr University Bochum / Hackmanit GmbH
5+
*
6+
* Licensed under Apache License 2.0
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*/
9+
package de.rub.nds.modifiablevariable.biginteger;
10+
11+
import de.rub.nds.modifiablevariable.VariableModification;
12+
import java.math.BigInteger;
13+
import java.util.Objects;
14+
import java.util.Random;
15+
import javax.xml.bind.annotation.XmlAccessType;
16+
import javax.xml.bind.annotation.XmlAccessorType;
17+
import javax.xml.bind.annotation.XmlRootElement;
18+
import javax.xml.bind.annotation.XmlType;
19+
20+
@XmlRootElement
21+
@XmlType(propOrder = { "factor", "modificationFilter" })
22+
@XmlAccessorType(XmlAccessType.FIELD)
23+
public class BigIntegerMultiplyModification extends VariableModification<BigInteger> {
24+
25+
private final static int MAX_FACTOR_LENGTH = 8;
26+
27+
private BigInteger factor;
28+
29+
public BigIntegerMultiplyModification() {
30+
31+
}
32+
33+
public BigIntegerMultiplyModification(BigInteger bi) {
34+
this.factor = bi;
35+
}
36+
37+
@Override
38+
protected BigInteger modifyImplementationHook(BigInteger input) {
39+
if (input == null) {
40+
input = BigInteger.ZERO;
41+
}
42+
return input.multiply(factor);
43+
}
44+
45+
public BigInteger getFactor() {
46+
return factor;
47+
}
48+
49+
public void setFactor(BigInteger factor) {
50+
this.factor = factor;
51+
}
52+
53+
@Override
54+
public VariableModification<BigInteger> getModifiedCopy() {
55+
return new BigIntegerMultiplyModification(factor.add(new BigInteger(MAX_FACTOR_LENGTH, new Random())));
56+
}
57+
58+
@Override
59+
public int hashCode() {
60+
int hash = 5;
61+
hash = 61 * hash + Objects.hashCode(this.factor);
62+
return hash;
63+
}
64+
65+
@Override
66+
public boolean equals(Object obj) {
67+
if (this == obj) {
68+
return true;
69+
}
70+
if (obj == null) {
71+
return false;
72+
}
73+
if (getClass() != obj.getClass()) {
74+
return false;
75+
}
76+
final BigIntegerMultiplyModification other = (BigIntegerMultiplyModification) obj;
77+
if (!Objects.equals(this.factor, other.factor)) {
78+
return false;
79+
}
80+
return true;
81+
}
82+
}

src/main/java/de/rub/nds/modifiablevariable/util/Modifiable.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ public static ModifiableBigInteger shiftRightBigInteger(Integer i) {
178178
return getModifiableBigIntegerWithModification(BigIntegerModificationFactory.shiftRight(i));
179179
}
180180

181+
public static ModifiableBigInteger multiplyBigInteger(BigInteger i) {
182+
return getModifiableBigIntegerWithModification(BigIntegerModificationFactory.multiply(i));
183+
}
184+
181185
public static ModifiableInteger shiftRight(Integer i) {
182186
return getModifiableIntegerWithModification(IntegerModificationFactory.shiftRight(i));
183187
}

0 commit comments

Comments
 (0)