Skip to content

Commit ec960d8

Browse files
author
Patrick Weixler
committed
Added requested changes from reviewed pullrequest #734
1 parent cc14cf6 commit ec960d8

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99
*/
1010
package de.rub.nds.tlsattacker.core.constants;
1111

12-
import de.rub.nds.modifiablevariable.HoldsModifiableVariable;
12+
import de.rub.nds.modifiablevariable.ModifiableVariableFactory;
13+
import de.rub.nds.modifiablevariable.singlebyte.ModifiableByte;
1314

1415
public enum KeyUpdateRequest {
1516

1617
UPDATE_NOT_REQUESTED((byte) 0),
1718
UPDATE_REQUESTED((byte) 1);
1819

19-
@HoldsModifiableVariable
20-
private byte requestUpdate;
20+
private ModifiableByte requestUpdate;
2121

2222
private KeyUpdateRequest(byte requestUpdate) {
23-
this.requestUpdate = requestUpdate;
23+
this.requestUpdate = ModifiableVariableFactory.safelySetValue(this.requestUpdate, requestUpdate);
2424
}
2525

2626
public byte getValue() {
27-
return requestUpdate;
27+
return requestUpdate.getValue();
2828
}
2929

3030
}

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,17 @@ private void setRecordCipher(Tls13KeySetType keySetType) {
160160
AlgorithmResolver.getCipher(tlsContext.getChooser().getSelectedCipherSuite()).getKeySize()));
161161
}
162162

163+
RecordCipher recordCipherClient = RecordCipherFactory.getRecordCipher(tlsContext, keySet, tlsContext
164+
.getChooser().getSelectedCipherSuite());
165+
tlsContext.getRecordLayer().setRecordCipher(recordCipherClient);
166+
167+
tlsContext.setWriteSequenceNumber(0);
168+
tlsContext.getRecordLayer().updateEncryptionCipher();
169+
163170
} else if (tlsContext.getChooser().getTalkingConnectionEnd() != tlsContext.getChooser()
164171
.getConnectionEndType()) {
165172

166-
if (tlsContext.getChooser().getConnectionEndType() == ConnectionEndType.SERVER) {
173+
if (tlsContext.getChooser().getTalkingConnectionEnd() == ConnectionEndType.SERVER) {
167174

168175
keySet.setServerWriteIv(HKDFunction.expandLabel(hkdfAlgortihm,
169176
tlsContext.getServerApplicationTrafficSecret(), HKDFunction.IV, new byte[0], AEAD_IV_LENGTH));
@@ -182,19 +189,13 @@ private void setRecordCipher(Tls13KeySetType keySetType) {
182189
AlgorithmResolver.getCipher(tlsContext.getChooser().getSelectedCipherSuite()).getKeySize()));
183190
}
184191

185-
}
186-
187-
RecordCipher recordCipherClient = RecordCipherFactory.getRecordCipher(tlsContext, keySet, tlsContext
188-
.getChooser().getSelectedCipherSuite());
189-
tlsContext.getRecordLayer().setRecordCipher(recordCipherClient);
192+
RecordCipher recordCipherClient = RecordCipherFactory.getRecordCipher(tlsContext, keySet, tlsContext
193+
.getChooser().getSelectedCipherSuite());
194+
tlsContext.getRecordLayer().setRecordCipher(recordCipherClient);
190195

191-
if (tlsContext.getChooser().getTalkingConnectionEnd() == tlsContext.getChooser().getConnectionEndType()) {
192-
tlsContext.setWriteSequenceNumber(0);
193-
tlsContext.getRecordLayer().updateEncryptionCipher();
194-
} else if (tlsContext.getChooser().getTalkingConnectionEnd() != tlsContext.getChooser()
195-
.getConnectionEndType()) {
196196
tlsContext.setReadSequenceNumber(0);
197197
tlsContext.getRecordLayer().updateDecryptionCipher();
198+
198199
}
199200

200201
} catch (CryptoException ex) {

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/protocol/parser/KeyUpdateParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ private void parseUpdateRequest(KeyUpdateMessage msg) {
4141

4242
if (parseByteField(HandshakeByteLength.KEY_UPDATE_LENGTH) == KeyUpdateRequest.UPDATE_REQUESTED.getValue()) {
4343
msg.setRequestUpdate(KeyUpdateRequest.UPDATE_REQUESTED);
44-
} else
44+
} else {
4545
msg.setRequestUpdate(KeyUpdateRequest.UPDATE_NOT_REQUESTED);
46+
}
4647
LOGGER.debug("KeyUpdateValue: " + msg.getRequestUpdate());
4748

4849
}

0 commit comments

Comments
 (0)