Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
d71990d8
Commit
d71990d8
authored
May 06, 2015
by
Dominic Tarr
Browse files
make comments describe what code actually does.
parent
54b11063
Changes
1
Show whitespace changes
Inline
Side-by-side
crypto/secio/protocol.go
View file @
d71990d8
...
@@ -144,7 +144,7 @@ func (s *secureSession) handshake(ctx context.Context, insecure io.ReadWriter) e
...
@@ -144,7 +144,7 @@ func (s *secureSession) handshake(ctx context.Context, insecure io.ReadWriter) e
// =============================================================================
// =============================================================================
// step 1.2 Selection -- select/agree on best encryption parameters
// step 1.2 Selection -- select/agree on best encryption parameters
// to determine order, use cmp(H(
lr||rpk), H(rr||lpk
)).
// to determine order, use cmp(H(
remote_pubkey||local_rand), H(local_pubkey||remote_rand
)).
oh1
:=
u
.
Hash
(
append
(
proposeIn
.
GetPubkey
(),
nonceOut
...
))
oh1
:=
u
.
Hash
(
append
(
proposeIn
.
GetPubkey
(),
nonceOut
...
))
oh2
:=
u
.
Hash
(
append
(
myPubKeyBytes
,
proposeIn
.
GetRand
()
...
))
oh2
:=
u
.
Hash
(
append
(
myPubKeyBytes
,
proposeIn
.
GetRand
()
...
))
order
:=
bytes
.
Compare
(
oh1
,
oh2
)
order
:=
bytes
.
Compare
(
oh1
,
oh2
)
...
@@ -203,7 +203,7 @@ func (s *secureSession) handshake(ctx context.Context, insecure io.ReadWriter) e
...
@@ -203,7 +203,7 @@ func (s *secureSession) handshake(ctx context.Context, insecure io.ReadWriter) e
return
err
return
err
}
}
// Receive + Parse their
Propose packet and generate an
Exchange packet.
// Receive + Parse their Exchange packet.
exchangeIn
:=
new
(
pb
.
Exchange
)
exchangeIn
:=
new
(
pb
.
Exchange
)
if
_
,
err
:=
readMsgCtx
(
ctx
,
s
.
insecureM
,
exchangeIn
);
err
!=
nil
{
if
_
,
err
:=
readMsgCtx
(
ctx
,
s
.
insecureM
,
exchangeIn
);
err
!=
nil
{
return
err
return
err
...
@@ -278,7 +278,7 @@ func (s *secureSession) handshake(ctx context.Context, insecure io.ReadWriter) e
...
@@ -278,7 +278,7 @@ func (s *secureSession) handshake(ctx context.Context, insecure io.ReadWriter) e
// log.Debug("2.3 mac + cipher.")
// log.Debug("2.3 mac + cipher.")
// =============================================================================
// =============================================================================
// step 3. Finish -- send expected message
(the nonces),
verify encryption works
// step 3. Finish -- send expected message
to
verify encryption works
(send local nonce)
// setup ETM ReadWriter
// setup ETM ReadWriter
w
:=
NewETMWriter
(
s
.
insecure
,
s
.
local
.
cipher
,
s
.
local
.
mac
)
w
:=
NewETMWriter
(
s
.
insecure
,
s
.
local
.
cipher
,
s
.
local
.
mac
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment