fix: resolve P2P data plane decrypt failure and improve test environment
- Fix key derivation in both sdk/agent.go and internal/vl1/noise.go: sort public keys before hashing, use shared key for send/recv - Adjust docker-compose port mappings to 7150-7153 range (within 7000-7200) - Add GOPROXY env to Dockerfiles for Go module download in restricted networks - Verified: all 3 clients connect with 2 peers each, zero decrypt errors
This commit is contained in:
18
sdk/agent.go
18
sdk/agent.go
@@ -636,25 +636,17 @@ func isBroadcastMAC(dst []byte) bool {
|
||||
}
|
||||
|
||||
func deriveKeys(psk, localPub, remotePub []byte) ([32]byte, [32]byte) {
|
||||
var first, second []byte
|
||||
if bytes.Compare(localPub, remotePub) <= 0 {
|
||||
first, second = localPub, remotePub
|
||||
} else {
|
||||
first, second := localPub, remotePub
|
||||
if bytes.Compare(localPub, remotePub) > 0 {
|
||||
first, second = remotePub, localPub
|
||||
}
|
||||
h := sha256.New()
|
||||
h.Write(psk)
|
||||
h.Write(first)
|
||||
h.Write(second)
|
||||
var sendKey [32]byte
|
||||
copy(sendKey[:], h.Sum(nil))
|
||||
|
||||
h2 := sha256.New()
|
||||
h2.Write(sendKey[:])
|
||||
h2.Write([]byte("reverse"))
|
||||
var recvKey [32]byte
|
||||
copy(recvKey[:], h2.Sum(nil))
|
||||
return sendKey, recvKey
|
||||
var key [32]byte
|
||||
copy(key[:], h.Sum(nil))
|
||||
return key, key
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user