mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-06-08 10:32:04 -04:00
Start working on de-obfuscating ephemeral keys from remote peers
This commit is contained in:
2
Makefile
2
Makefile
@ -27,7 +27,7 @@ clean:
|
|||||||
$(GO) clean -v
|
$(GO) clean -v
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
find . -name '*.go' -exec gofmt -w -s {} \;
|
find . -name '*.go' -exec gofumpt -w {} \;
|
||||||
|
|
||||||
info:
|
info:
|
||||||
echo "GOROOT: ${GOROOT}"
|
echo "GOROOT: ${GOROOT}"
|
||||||
|
44
lib/transport/noise/noise_obfs.go
Normal file
44
lib/transport/noise/noise_obfs.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package noise
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/aes"
|
||||||
|
"crypto/cipher"
|
||||||
|
"encoding/hex"
|
||||||
|
|
||||||
|
"github.com/flynn/noise"
|
||||||
|
"github.com/go-i2p/go-i2p/lib/common/router_address"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Noise obfuscation functions used in I2P NTCP2 and SSU2 Handshakes,
|
||||||
|
// including obfuscating the ephemeral keys with a known key and IV found
|
||||||
|
// in the netDb.
|
||||||
|
|
||||||
|
func AESDeObfuscateEphemeralKeys(cipherText string, config noise.Config, bob router_address.RouterAddress) (*noise.DHKey, error) {
|
||||||
|
bobsStaticKey, err := bob.StaticKey()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
bobsInitializatonVector, err := bob.InitializationVector()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
log.WithFields(
|
||||||
|
log.Fields{
|
||||||
|
"at": "(noise) AESObfuscateEphemeralKeys",
|
||||||
|
}).Debugf("getting ready to obfuscate our ephemeral keys with bob's static key %s and IV %s", bobsStaticKey, bobsInitializatonVector)
|
||||||
|
cipherTextDecoded, err := hex.DecodeString(cipherText)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
block, err := aes.NewCipher(bobsStaticKey[:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mode := cipher.NewCBCDecrypter(block, bobsInitializatonVector[:])
|
||||||
|
mode.CryptBlocks([]byte(cipherTextDecoded), []byte(cipherTextDecoded))
|
||||||
|
dhk := &noise.DHKey{
|
||||||
|
Private: cipherTextDecoded,
|
||||||
|
}
|
||||||
|
return dhk, nil
|
||||||
|
}
|
Reference in New Issue
Block a user