aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/crypto.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-01-19 19:21:13 +0800
committerFelix Lange <fjl@twurst.com>2015-02-06 07:00:35 +0800
commit1803c65e4097b9d6cb83f72a8a09aeddcc01f685 (patch)
tree0393c085d821d9f65b83568b54f243b2f037f13c /p2p/crypto.go
parent489d956283390b701473edd4a597afea2c426d41 (diff)
downloadgo-tangerine-1803c65e4097b9d6cb83f72a8a09aeddcc01f685.tar
go-tangerine-1803c65e4097b9d6cb83f72a8a09aeddcc01f685.tar.gz
go-tangerine-1803c65e4097b9d6cb83f72a8a09aeddcc01f685.tar.bz2
go-tangerine-1803c65e4097b9d6cb83f72a8a09aeddcc01f685.tar.lz
go-tangerine-1803c65e4097b9d6cb83f72a8a09aeddcc01f685.tar.xz
go-tangerine-1803c65e4097b9d6cb83f72a8a09aeddcc01f685.tar.zst
go-tangerine-1803c65e4097b9d6cb83f72a8a09aeddcc01f685.zip
integrate cryptoId into peer and connection lifecycle
Diffstat (limited to 'p2p/crypto.go')
-rw-r--r--p2p/crypto.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/p2p/crypto.go b/p2p/crypto.go
index 37c6e1fc9..728b8e884 100644
--- a/p2p/crypto.go
+++ b/p2p/crypto.go
@@ -53,6 +53,21 @@ func newCryptoId(id ClientIdentity) (self *cryptoId, err error) {
return
}
+func (self *cryptoId) Run(remotePubKeyDER []byte) (rw *secretRW) {
+ if self.initiator {
+ auth, initNonce, randomPrvKey, randomPubKey, err := initiator.initAuth(remotePubKeyDER, sessionToken)
+
+ respNonce, remoteRandomPubKey, _, _ := initiator.verifyAuthResp(response)
+ } else {
+ // we are listening connection. we are responders in the haandshake.
+ // Extract info from the authentication. The initiator starts by sending us a handshake that we need to respond to.
+ response, remoteRespNonce, remoteInitNonce, remoteRandomPrivKey, _ := responder.verifyAuth(auth, sessionToken, pubInit)
+
+ }
+ initSessionToken, initSecretRW, _ := initiator.newSession(initNonce, respNonce, auth, randomPrvKey, remoteRandomPubKey)
+ respSessionToken, respSecretRW, _ := responder.newSession(remoteInitNonce, remoteRespNonce, auth, remoteRandomPrivKey, randomPubKey)
+}
+
/* startHandshake is called by peer if it initiated the connection.
By protocol spec, the party who initiates the connection (initiator) will send an 'auth' packet
New: authInitiator -> E(remote-pubk, S(ecdhe-random, ecdh-shared-secret^nonce) || H(ecdhe-random-pubk) || pubk || nonce || 0x0)