@@ -141,22 +141,25 @@ func (s *secureSession) runHandshake() error {
141
141
142
142
// log.Debugf("1.0 Propose: nonce:%s exchanges:%s ciphers:%s hashes:%s",
143
143
// nonceOut, SupportedExchanges, SupportedCiphers, SupportedHashes)
144
+ log .Debugf ("1.0 Propose: %v" , proposeOut )
144
145
145
146
// Send Propose packet (respects ctx)
146
147
proposeOutBytes , err := writeMsgCtx (ctx , s .insecureM , proposeOut )
147
148
if err != nil {
149
+ log .Debugf ("1.0 %s" , err )
148
150
return err
149
151
}
150
152
151
153
// Receive + Parse their Propose packet and generate an Exchange packet.
152
154
proposeIn := new (pb.Propose )
153
155
proposeInBytes , err := readMsgCtx (ctx , s .insecureM , proposeIn )
154
156
if err != nil {
157
+ log .Debugf ("1.0.1 %s" , err )
155
158
return err
156
159
}
157
160
158
- // log.Debugf("1.0.1 Propose recv: nonce:%s exchanges:%s ciphers:%s hashes:%s",
159
- // proposeIn.GetRand(), proposeIn.GetExchanges(), proposeIn.GetCiphers(), proposeIn.GetHashes())
161
+ log .Debugf ("1.0.1 Propose recv: nonce:%s exchanges:%s ciphers:%s hashes:%s" ,
162
+ proposeIn .GetRand (), proposeIn .GetExchanges (), proposeIn .GetCiphers (), proposeIn .GetHashes ())
160
163
161
164
// =============================================================================
162
165
// step 1.1 Identify -- get identity from their key
@@ -207,8 +210,8 @@ func (s *secureSession) runHandshake() error {
207
210
s .remote .cipherT = s .local .cipherT
208
211
s .remote .hashT = s .local .hashT
209
212
210
- // log.Debugf("1.2 selection: exchange:%s cipher:%s hash:%s",
211
- // s.local.curveT, s.local.cipherT, s.local.hashT)
213
+ log .Debugf ("1.2 selection: exchange:%s cipher:%s hash:%s" ,
214
+ s .local .curveT , s .local .cipherT , s .local .hashT )
212
215
213
216
// =============================================================================
214
217
// step 2. Exchange -- exchange (signed) ephemeral keys. verify signatures.
@@ -224,7 +227,7 @@ func (s *secureSession) runHandshake() error {
224
227
selectionOut .Write (s .local .ephemeralPubKey )
225
228
selectionOutBytes := selectionOut .Bytes ()
226
229
227
- // log.Debugf("2.0 exchange: %v", selectionOutBytes)
230
+ log .Debugf ("2.0 exchange: %v" , selectionOutBytes )
228
231
exchangeOut := new (pb.Exchange )
229
232
exchangeOut .Epubkey = s .local .ephemeralPubKey
230
233
exchangeOut .Signature , err = s .localKey .Sign (selectionOutBytes )
@@ -254,21 +257,21 @@ func (s *secureSession) runHandshake() error {
254
257
selectionIn .Write (proposeOutBytes )
255
258
selectionIn .Write (s .remote .ephemeralPubKey )
256
259
selectionInBytes := selectionIn .Bytes ()
257
- // log.Debugf("2.0.1 exchange recv: %v", selectionInBytes)
260
+ log .Debugf ("2.0.1 exchange recv: %v" , selectionInBytes )
258
261
259
262
// u.POut("Remote Peer Identified as %s\n", s.remote)
260
263
sigOK , err := s .remote .permanentPubKey .Verify (selectionInBytes , exchangeIn .GetSignature ())
261
264
if err != nil {
262
- // log.Error("2.1 Verify: failed: %s", err)
265
+ log .Error ("2.1 Verify: failed: %s" , err )
263
266
return err
264
267
}
265
268
266
269
if ! sigOK {
267
270
err := errors .New ("Bad signature!" )
268
- // log.Error("2.1 Verify: failed: %s", err)
271
+ log .Error ("2.1 Verify: failed: %s" , err )
269
272
return err
270
273
}
271
- // log.Debugf("2.1 Verify: signature verified.")
274
+ log .Debugf ("2.1 Verify: signature verified." )
272
275
273
276
// =============================================================================
274
277
// step 2.2. Keys -- generate keys for mac + encryption
@@ -295,8 +298,8 @@ func (s *secureSession) runHandshake() error {
295
298
s .local .keys = k1
296
299
s .remote .keys = k2
297
300
298
- // log.Debug("2.2 keys:\n\tshared: %v\n\tk1: %v\n\tk2: %v",
299
- // s.sharedSecret, s.local.keys, s.remote.keys)
301
+ log .Debug ("2.2 keys:\n \t shared: %v\n \t k1: %v\n \t k2: %v" ,
302
+ s .sharedSecret , s .local .keys , s .remote .keys )
300
303
301
304
// =============================================================================
302
305
// step 2.3. MAC + Cipher -- prepare MAC + cipher
@@ -309,7 +312,7 @@ func (s *secureSession) runHandshake() error {
309
312
return err
310
313
}
311
314
312
- // log.Debug("2.3 mac + cipher.")
315
+ log .Debug ("2.3 mac + cipher." )
313
316
314
317
// =============================================================================
315
318
// step 3. Finish -- send expected message to verify encryption works (send local nonce)
@@ -319,7 +322,7 @@ func (s *secureSession) runHandshake() error {
319
322
r := NewETMReader (s .insecure , s .remote .cipher , s .remote .mac )
320
323
s .secure = msgio .Combine (w , r ).(msgio.ReadWriteCloser )
321
324
322
- // log.Debug("3.0 finish. sending: %v", proposeIn.GetRand())
325
+ log .Debug ("3.0 finish. sending: %v" , proposeIn .GetRand ())
323
326
// send their Nonce.
324
327
if _ , err := s .secure .Write (proposeIn .GetRand ()); err != nil {
325
328
return fmt .Errorf ("Failed to write Finish nonce: %s" , err )
@@ -331,7 +334,7 @@ func (s *secureSession) runHandshake() error {
331
334
return fmt .Errorf ("Failed to read Finish nonce: %s" , err )
332
335
}
333
336
334
- // log.Debug("3.0 finish.\n\texpect: %v\n\tactual: %v", nonceOut, nonceOut2)
337
+ log .Debug ("3.0 finish.\n \t expect: %v\n \t actual: %v" , nonceOut , nonceOut2 )
335
338
if ! bytes .Equal (nonceOut , nonceOut2 ) {
336
339
return fmt .Errorf ("Failed to read our encrypted nonce: %s != %s" , nonceOut2 , nonceOut )
337
340
}
0 commit comments