@cryptotaxi247 / kubo / commits / 0e185788f

Updated tests.

Brendan Mc committed Sep 3, 2014 at 21:28 UTC 0e185788fcb99f68b54f135efb08fbb05c1377d2
2 files changed +10 -11
identify/identify.go
+8 -9
@@ -4,8 +4,6 @@ package identify
4
5 import (
6 "bytes"
7 - "errors"
8 -
7 "crypto/aes"
8 "crypto/cipher"
9 "crypto/elliptic"
@@ -14,6 +12,7 @@ import (
12 "crypto/sha1"
13 "crypto/sha256"
14 "crypto/sha512"
15 + "errors"
16 "hash"
17 "math/big"
18 "strings"
@@ -86,12 +85,12 @@ func Handshake(self, remote *peer.Peer, in, out chan []byte) (chan []byte, chan
85 return nil, nil, err
86 }
87
89 - cipherType, err := selectBest(SupportedExchanges, helloResp.GetCiphers())
88 + cipherType, err := selectBest(SupportedCiphers, helloResp.GetCiphers())
89 if err != nil {
90 return nil, nil, err
91 }
92
94 - hashType, err := selectBest(SupportedExchanges, helloResp.GetHashes())
93 + hashType, err := selectBest(SupportedHashes, helloResp.GetHashes())
94 if err != nil {
95 return nil, nil, err
96 }
@@ -249,10 +248,10 @@ func IdFromPubKey(pk ci.PubKey) (peer.ID, error) {
248 func keyGenerator(cmp int, cipherType string, hashType string, secret []byte) ([]byte, []byte, []byte, []byte, []byte, []byte) {
249 var cipherKeySize int
250 switch cipherType {
252 - case "AES128":
253 - cipherKeySize = 2 * 16
254 - case "AES256":
255 - cipherKeySize = 2 * 32
251 + case "AES-128":
252 + cipherKeySize = 16
253 + case "AES-256":
254 + cipherKeySize = 32
255 }
256
257 ivSize := 16
@@ -387,7 +386,7 @@ func generateEPubKey(exchange string) ([]byte, func([]byte) ([]byte, error), err
386 // Verify and unpack node's public key.
387 curveSize := curve.Params().BitSize
388
390 - if len(theirPub) != (curveSize / 2) {
389 + if len(theirPub) != (curveSize / 4) {
390 return nil, errors.New("Malformed public key.")
391 }
392
identify/identify_test.go
+2 -2
@@ -41,13 +41,13 @@ func TestHandshake(t *testing.T) {
41 }
42
43 go func() {
44 - err := Handshake(pa, pb, cha, chb)
44 + _, _, err := Handshake(pa, pb, cha, chb)
45 if err != nil {
46 t.Fatal(err)
47 }
48 }()
49
50 - err = Handshake(pb, pa, chb, cha)
50 + _, _, err = Handshake(pb, pa, chb, cha)
51 if err != nil {
52 t.Fatal(err)
53 }