77 * Licensed under Apache License 2.0
88 * http://www.apache.org/licenses/LICENSE-2.0
99 */
10+
1011package de .rub .nds .tlsattacker .core .protocol .handler ;
1112
1213import de .rub .nds .modifiablevariable .util .ArrayConverter ;
@@ -61,7 +62,7 @@ public void adjustTlsContextAfterSerialize(KeyUpdateMessage message) {
6162 @ Override
6263 public ProtocolMessageParser getParser (byte [] message , int pointer ) {
6364 return new KeyUpdateParser (pointer , message , tlsContext .getChooser ().getSelectedProtocolVersion (),
64- tlsContext .getConfig ());
65+ tlsContext .getConfig ());
6566
6667 }
6768
@@ -76,31 +77,31 @@ public ProtocolMessageSerializer getSerializer(KeyUpdateMessage message) {
7677 }
7778
7879 private void adjustApplicationTrafficSecrets () {
79- HKDFAlgorithm hkdfAlgortihm = AlgorithmResolver . getHKDFAlgorithm ( tlsContext . getChooser ()
80- .getSelectedCipherSuite ());
80+ HKDFAlgorithm hkdfAlgortihm =
81+ AlgorithmResolver . getHKDFAlgorithm ( tlsContext . getChooser () .getSelectedCipherSuite ());
8182
8283 try {
8384 Mac mac = Mac .getInstance (hkdfAlgortihm .getMacAlgorithm ().getJavaName ());
8485
8586 if (tlsContext .getChooser ().getTalkingConnectionEnd () == ConnectionEndType .CLIENT ) {
8687
87- byte [] clientApplicationTrafficSecret = HKDFunction . expandLabel ( hkdfAlgortihm ,
88- tlsContext .getClientApplicationTrafficSecret (), HKDFunction . TRAFFICUPD , new byte [ 0 ] ,
89- mac .getMacLength ());
88+ byte [] clientApplicationTrafficSecret =
89+ HKDFunction . expandLabel ( hkdfAlgortihm , tlsContext .getClientApplicationTrafficSecret (),
90+ HKDFunction . TRAFFICUPD , new byte [ 0 ], mac .getMacLength ());
9091
9192 tlsContext .setClientApplicationTrafficSecret (clientApplicationTrafficSecret );
9293 LOGGER .debug ("Set clientApplicationTrafficSecret in Context to "
93- + ArrayConverter .bytesToHexString (clientApplicationTrafficSecret ));
94+ + ArrayConverter .bytesToHexString (clientApplicationTrafficSecret ));
9495
9596 } else {
9697
97- byte [] serverApplicationTrafficSecret = HKDFunction . expandLabel ( hkdfAlgortihm ,
98- tlsContext .getServerApplicationTrafficSecret (), HKDFunction . TRAFFICUPD , new byte [ 0 ] ,
99- mac .getMacLength ());
98+ byte [] serverApplicationTrafficSecret =
99+ HKDFunction . expandLabel ( hkdfAlgortihm , tlsContext .getServerApplicationTrafficSecret (),
100+ HKDFunction . TRAFFICUPD , new byte [ 0 ], mac .getMacLength ());
100101
101102 tlsContext .setServerApplicationTrafficSecret (serverApplicationTrafficSecret );
102103 LOGGER .debug ("Set serverApplicationTrafficSecret in Context to "
103- + ArrayConverter .bytesToHexString (serverApplicationTrafficSecret ));
104+ + ArrayConverter .bytesToHexString (serverApplicationTrafficSecret ));
104105
105106 }
106107
@@ -112,8 +113,8 @@ private void adjustApplicationTrafficSecrets() {
112113 private KeySet getKeySet (TlsContext context , Tls13KeySetType keySetType ) {
113114 try {
114115 LOGGER .debug ("Generating new KeySet" );
115- KeySet keySet = KeySetGenerator . generateKeySet ( context , context . getChooser (). getSelectedProtocolVersion (),
116- keySetType );
116+ KeySet keySet =
117+ KeySetGenerator . generateKeySet ( context , context . getChooser (). getSelectedProtocolVersion (), keySetType );
117118
118119 return keySet ;
119120 } catch (NoSuchAlgorithmException | CryptoException ex ) {
@@ -125,8 +126,8 @@ private void setRecordCipher(Tls13KeySetType keySetType) {
125126 try {
126127 int AEAD_IV_LENGTH = 12 ;
127128 KeySet keySet ;
128- HKDFAlgorithm hkdfAlgortihm = AlgorithmResolver . getHKDFAlgorithm ( tlsContext . getChooser ()
129- .getSelectedCipherSuite ());
129+ HKDFAlgorithm hkdfAlgortihm =
130+ AlgorithmResolver . getHKDFAlgorithm ( tlsContext . getChooser () .getSelectedCipherSuite ());
130131
131132 if (tlsContext .getChooser ().getTalkingConnectionEnd () == ConnectionEndType .CLIENT ) {
132133
@@ -145,52 +146,54 @@ private void setRecordCipher(Tls13KeySetType keySetType) {
145146 if (tlsContext .getChooser ().getConnectionEndType () == ConnectionEndType .CLIENT ) {
146147
147148 keySet .setClientWriteIv (HKDFunction .expandLabel (hkdfAlgortihm ,
148- tlsContext .getClientApplicationTrafficSecret (), HKDFunction .IV , new byte [0 ], AEAD_IV_LENGTH ));
149+ tlsContext .getClientApplicationTrafficSecret (), HKDFunction .IV , new byte [0 ], AEAD_IV_LENGTH ));
149150
150- keySet .setClientWriteKey (HKDFunction .expandLabel (hkdfAlgortihm ,
151- tlsContext .getClientApplicationTrafficSecret (), HKDFunction .KEY , new byte [0 ],
152- AlgorithmResolver .getCipher (tlsContext .getChooser ().getSelectedCipherSuite ()).getKeySize ()));
151+ keySet .setClientWriteKey (HKDFunction .expandLabel (hkdfAlgortihm , tlsContext
152+ .getClientApplicationTrafficSecret (), HKDFunction .KEY , new byte [0 ], AlgorithmResolver
153+ .getCipher (tlsContext .getChooser ().getSelectedCipherSuite ()).getKeySize ()));
153154 } else {
154155
155156 keySet .setServerWriteIv (HKDFunction .expandLabel (hkdfAlgortihm ,
156- tlsContext .getServerApplicationTrafficSecret (), HKDFunction .IV , new byte [0 ], AEAD_IV_LENGTH ));
157+ tlsContext .getServerApplicationTrafficSecret (), HKDFunction .IV , new byte [0 ], AEAD_IV_LENGTH ));
157158
158- keySet .setServerWriteKey (HKDFunction .expandLabel (hkdfAlgortihm ,
159- tlsContext .getServerApplicationTrafficSecret (), HKDFunction .KEY , new byte [0 ],
160- AlgorithmResolver .getCipher (tlsContext .getChooser ().getSelectedCipherSuite ()).getKeySize ()));
159+ keySet .setServerWriteKey (HKDFunction .expandLabel (hkdfAlgortihm , tlsContext
160+ .getServerApplicationTrafficSecret (), HKDFunction .KEY , new byte [0 ], AlgorithmResolver
161+ .getCipher (tlsContext .getChooser ().getSelectedCipherSuite ()).getKeySize ()));
161162 }
162163
163- RecordCipher recordCipherClient = RecordCipherFactory .getRecordCipher (tlsContext , keySet , tlsContext
164- .getChooser ().getSelectedCipherSuite ());
164+ RecordCipher recordCipherClient =
165+ RecordCipherFactory .getRecordCipher (tlsContext , keySet , tlsContext .getChooser ()
166+ .getSelectedCipherSuite ());
165167 tlsContext .getRecordLayer ().setRecordCipher (recordCipherClient );
166168
167169 tlsContext .setWriteSequenceNumber (0 );
168170 tlsContext .getRecordLayer ().updateEncryptionCipher ();
169171
170172 } else if (tlsContext .getChooser ().getTalkingConnectionEnd () != tlsContext .getChooser ()
171- .getConnectionEndType ()) {
173+ .getConnectionEndType ()) {
172174
173175 if (tlsContext .getChooser ().getTalkingConnectionEnd () == ConnectionEndType .SERVER ) {
174176
175177 keySet .setServerWriteIv (HKDFunction .expandLabel (hkdfAlgortihm ,
176- tlsContext .getServerApplicationTrafficSecret (), HKDFunction .IV , new byte [0 ], AEAD_IV_LENGTH ));
178+ tlsContext .getServerApplicationTrafficSecret (), HKDFunction .IV , new byte [0 ], AEAD_IV_LENGTH ));
177179
178- keySet .setServerWriteKey (HKDFunction .expandLabel (hkdfAlgortihm ,
179- tlsContext .getServerApplicationTrafficSecret (), HKDFunction .KEY , new byte [0 ],
180- AlgorithmResolver .getCipher (tlsContext .getChooser ().getSelectedCipherSuite ()).getKeySize ()));
180+ keySet .setServerWriteKey (HKDFunction .expandLabel (hkdfAlgortihm , tlsContext
181+ .getServerApplicationTrafficSecret (), HKDFunction .KEY , new byte [0 ], AlgorithmResolver
182+ .getCipher (tlsContext .getChooser ().getSelectedCipherSuite ()).getKeySize ()));
181183
182184 } else {
183185
184186 keySet .setClientWriteIv (HKDFunction .expandLabel (hkdfAlgortihm ,
185- tlsContext .getClientApplicationTrafficSecret (), HKDFunction .IV , new byte [0 ], AEAD_IV_LENGTH ));
187+ tlsContext .getClientApplicationTrafficSecret (), HKDFunction .IV , new byte [0 ], AEAD_IV_LENGTH ));
186188
187- keySet .setClientWriteKey (HKDFunction .expandLabel (hkdfAlgortihm ,
188- tlsContext .getClientApplicationTrafficSecret (), HKDFunction .KEY , new byte [0 ],
189- AlgorithmResolver .getCipher (tlsContext .getChooser ().getSelectedCipherSuite ()).getKeySize ()));
189+ keySet .setClientWriteKey (HKDFunction .expandLabel (hkdfAlgortihm , tlsContext
190+ .getClientApplicationTrafficSecret (), HKDFunction .KEY , new byte [0 ], AlgorithmResolver
191+ .getCipher (tlsContext .getChooser ().getSelectedCipherSuite ()).getKeySize ()));
190192 }
191193
192- RecordCipher recordCipherClient = RecordCipherFactory .getRecordCipher (tlsContext , keySet , tlsContext
193- .getChooser ().getSelectedCipherSuite ());
194+ RecordCipher recordCipherClient =
195+ RecordCipherFactory .getRecordCipher (tlsContext , keySet , tlsContext .getChooser ()
196+ .getSelectedCipherSuite ());
194197 tlsContext .getRecordLayer ().setRecordCipher (recordCipherClient );
195198
196199 tlsContext .setReadSequenceNumber (0 );
0 commit comments