add temporary forced session token generation

This commit is contained in:
zelig 2015-01-21 16:53:13 +00:00 committed by Felix Lange
parent faa069a126
commit 54252ede31
2 changed files with 8 additions and 0 deletions

View File

@ -103,6 +103,9 @@ func (self *cryptoId) Run(conn io.ReadWriter, remotePubKeyS []byte, sessionToken
if auth, initNonce, randomPrivKey, _, err = self.startHandshake(remotePubKeyS, sessionToken); err != nil { if auth, initNonce, randomPrivKey, _, err = self.startHandshake(remotePubKeyS, sessionToken); err != nil {
return return
} }
if sessionToken != nil {
clogger.Debugf("session-token: %v", hexkey(sessionToken))
}
clogger.Debugf("initiator-nonce: %v", hexkey(initNonce)) clogger.Debugf("initiator-nonce: %v", hexkey(initNonce))
clogger.Debugf("initiator-random-private-key: %v", hexkey(crypto.FromECDSA(randomPrivKey))) clogger.Debugf("initiator-random-private-key: %v", hexkey(crypto.FromECDSA(randomPrivKey)))
randomPublicKeyS, _ := ExportPublicKey(&randomPrivKey.PublicKey) randomPublicKeyS, _ := ExportPublicKey(&randomPrivKey.PublicKey)

View File

@ -3,6 +3,7 @@ package p2p
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"crypto/rand"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -342,6 +343,10 @@ func (p *Peer) handleCryptoHandshake() (loop readLoop, err error) {
// it is survived by an encrypted readwriter // it is survived by an encrypted readwriter
var initiator bool var initiator bool
var sessionToken []byte var sessionToken []byte
sessionToken = make([]byte, keyLen)
if _, err = rand.Read(sessionToken); err != nil {
return
}
if p.dialAddr != nil { // this should have its own method Outgoing() bool if p.dialAddr != nil { // this should have its own method Outgoing() bool
initiator = true initiator = true
} }