Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
3b6385b1
Commit
3b6385b1
authored
Jan 19, 2015
by
zelig
Committed by
Felix Lange
Feb 05, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handshake test to crypto
parent
714b955d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
2 deletions
+54
-2
crypto.go
p2p/crypto.go
+0
-2
crypto_test.go
p2p/crypto_test.go
+54
-0
No files found.
p2p/crypto.go
View file @
3b6385b1
package
p2p
import
(
// "bytes"
"crypto/ecdsa"
"crypto/rand"
"fmt"
// "io"
"github.com/ethereum/go-ethereum/crypto"
"github.com/obscuren/ecies"
...
...
p2p/crypto_test.go
0 → 100644
View file @
3b6385b1
package
p2p
import
(
// "bytes"
"fmt"
"testing"
"github.com/ethereum/go-ethereum/crypto"
)
func
TestCryptoHandshake
(
t
*
testing
.
T
)
{
var
err
error
var
sessionToken
[]
byte
prvInit
,
_
:=
crypto
.
GenerateKey
()
pubInit
:=
&
prvInit
.
PublicKey
prvResp
,
_
:=
crypto
.
GenerateKey
()
pubResp
:=
&
prvResp
.
PublicKey
var
initiator
,
responder
*
cryptoId
if
initiator
,
err
=
newCryptoId
(
&
peerId
{
crypto
.
FromECDSA
(
prvInit
),
crypto
.
FromECDSAPub
(
pubInit
)});
err
!=
nil
{
return
}
if
responder
,
err
=
newCryptoId
(
&
peerId
{
crypto
.
FromECDSA
(
prvResp
),
crypto
.
FromECDSAPub
(
pubResp
)});
err
!=
nil
{
return
}
auth
,
initNonce
,
_
,
_
:=
initiator
.
initAuth
(
responder
.
pubKeyDER
,
sessionToken
)
response
,
remoteRespNonce
,
remoteInitNonce
,
remoteRandomPubKey
,
_
:=
responder
.
verifyAuth
(
auth
,
sessionToken
,
pubInit
)
respNonce
,
randomPubKey
,
_
,
_
:=
initiator
.
verifyAuthResp
(
response
)
fmt
.
Printf
(
"%x
\n
%x
\n
%x
\n
%x
\n
%x
\n
%x
\n
%x
\n
%x
\n
"
,
auth
,
initNonce
,
response
,
remoteRespNonce
,
remoteInitNonce
,
remoteRandomPubKey
,
respNonce
,
randomPubKey
)
// initSessionToken, initSecretRW, _ := initiator.newSession(initNonce, respNonce, auth, randomPubKey)
// respSessionToken, respSecretRW, _ := responder.newSession(remoteInitNonce, remoteRespNonce, auth, remoteRandomPubKey)
// if !bytes.Equal(initSessionToken, respSessionToken) {
// t.Errorf("session tokens do not match")
// }
// // aesSecret, macSecret, egressMac, ingressMac
// if !bytes.Equal(initSecretRW.aesSecret, respSecretRW.aesSecret) {
// t.Errorf("AES secrets do not match")
// }
// if !bytes.Equal(initSecretRW.macSecret, respSecretRW.macSecret) {
// t.Errorf("macSecrets do not match")
// }
// if !bytes.Equal(initSecretRW.egressMac, respSecretRW.egressMac) {
// t.Errorf("egressMacs do not match")
// }
// if !bytes.Equal(initSecretRW.ingressMac, respSecretRW.ingressMac) {
// t.Errorf("ingressMacs do not match")
// }
}
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