Compare commits
1 Commits
master
...
noise-expe
Author | SHA1 | Date | |
---|---|---|---|
3c54c74ac3 |
@ -64,3 +64,22 @@ PublicKey returns the public key as a crypto.PublicKey.
|
||||
func (keys_and_cert *KeysAndCert) SigningPublicKey() (signing_public_key crypto.SigningPublicKey)
|
||||
```
|
||||
SigningPublicKey returns the signing public key.
|
||||
|
||||
#### type PrivateKeysAndCert
|
||||
|
||||
```go
|
||||
type PrivateKeysAndCert struct {
|
||||
KeysAndCert
|
||||
PK_KEY crypto.PrivateKey
|
||||
SPK_KEY crypto.PrivateKey
|
||||
}
|
||||
```
|
||||
|
||||
PrivateKeysAndCert contains a KeysAndCert along with the corresponding private
|
||||
keys for the Public Key and the Signing Public Key
|
||||
|
||||
#### func NewPrivateKeysAndCert
|
||||
|
||||
```go
|
||||
func NewPrivateKeysAndCert() (*PrivateKeysAndCert, error)
|
||||
```
|
||||
|
@ -44,6 +44,12 @@ func (router_address RouterAddress) Bytes() []byte
|
||||
```
|
||||
Bytes returns the router address as a []byte.
|
||||
|
||||
#### func (RouterAddress) CapsString
|
||||
|
||||
```go
|
||||
func (router_address RouterAddress) CapsString() I2PString
|
||||
```
|
||||
|
||||
#### func (RouterAddress) Cost
|
||||
|
||||
```go
|
||||
@ -77,6 +83,13 @@ func (router_address RouterAddress) Host() (net.Addr, error)
|
||||
func (router_address RouterAddress) HostString() I2PString
|
||||
```
|
||||
|
||||
#### func (*RouterAddress) IPVersion
|
||||
|
||||
```go
|
||||
func (router_address *RouterAddress) IPVersion() string
|
||||
```
|
||||
IPVersion returns a string "4" for IPv4 or 6 for IPv6
|
||||
|
||||
#### func (RouterAddress) InitializationVector
|
||||
|
||||
```go
|
||||
@ -112,7 +125,7 @@ func (router_address RouterAddress) IntroducerTagString(num int) I2PString
|
||||
```go
|
||||
func (router_address *RouterAddress) Network() string
|
||||
```
|
||||
Network implements net.Addr. It returns the transport type
|
||||
Network implements net.Addr. It returns the transport type plus 4 or 6
|
||||
|
||||
#### func (RouterAddress) Options
|
||||
|
||||
|
@ -57,6 +57,13 @@ func (router_info *RouterInfo) IdentHash() Hash
|
||||
```
|
||||
IndentHash returns the identity hash (sha256 sum) for this RouterInfo.
|
||||
|
||||
#### func (RouterInfo) Network
|
||||
|
||||
```go
|
||||
func (router_info RouterInfo) Network() string
|
||||
```
|
||||
Network implements net.Addr
|
||||
|
||||
#### func (RouterInfo) Options
|
||||
|
||||
```go
|
||||
|
@ -2,7 +2,7 @@
|
||||
--
|
||||
import "github.com/go-i2p/go-i2p/lib/crypto"
|
||||
|
||||
package for i2p specific cryptography
|
||||
package for i2p specific crpytography
|
||||
|
||||
## Usage
|
||||
|
||||
@ -12,72 +12,7 @@ const (
|
||||
OPAD = byte(0x5C)
|
||||
)
|
||||
```
|
||||
#### type AESSymmetricKey
|
||||
```go
|
||||
type AESSymmetricKey struct {
|
||||
Key []byte // AES key (must be 16, 24, or 32 bytes for AES-128, AES-192, AES-256)
|
||||
IV []byte // Initialization Vector (must be 16 bytes for AES)
|
||||
}
|
||||
```
|
||||
|
||||
AESSymmetricKey represents a symmetric key for AES encryption/decryption
|
||||
|
||||
#### func (AESSymmetricKey) NewEncrypter
|
||||
|
||||
```go
|
||||
func (k *AESSymmetricKey) NewEncrypter() (Encrypter, error)
|
||||
```
|
||||
NewEncrypter creates a new AESSymmetricEncrypter
|
||||
|
||||
#### func (AESSymmetricKey) NewDecrypter
|
||||
|
||||
```go
|
||||
func (k *AESSymmetricKey) NewDecrypter() (Decrypter, error)
|
||||
```
|
||||
NewDecrypter creates a new AESSymmetricDecrypter
|
||||
|
||||
#### func (AESSymmetricKey) Len
|
||||
|
||||
```go
|
||||
func (k *AESSymmetricKey) Len() int
|
||||
```
|
||||
Len returns the length of the key
|
||||
|
||||
#### type AESSymmetricEncrypter
|
||||
|
||||
```go
|
||||
type AESSymmetricEncrypter struct {
|
||||
Key []byte
|
||||
IV []byte
|
||||
}
|
||||
```
|
||||
|
||||
AESSymmetricEncrypter implements the Encrypter interface using AES
|
||||
|
||||
#### func (*AESSymmetricEncrypter) Encrypt
|
||||
|
||||
```go
|
||||
func (e *AESSymmetricEncrypter) Encrypt(data []byte) ([]byte, error)
|
||||
```
|
||||
Encrypt encrypts data using AES-CBC with PKCS#7 padding
|
||||
|
||||
#### type AESSymmetricDecrypter
|
||||
|
||||
```go
|
||||
type AESSymmetricDecrypter struct {
|
||||
Key []byte
|
||||
IV []byte
|
||||
}
|
||||
```
|
||||
|
||||
AESSymmetricDecrypter implements the Decrypter interface using AES
|
||||
|
||||
#### func (*AESSymmetricDecrypter) Decrypt
|
||||
|
||||
```go
|
||||
func (d *AESSymmetricDecrypter) Decrypt(data []byte) ([]byte, error)
|
||||
```
|
||||
Decrypt decrypts data using AES-CBC with PKCS#7 padding
|
||||
```go
|
||||
var (
|
||||
ElgDecryptFail = errors.New("failed to decrypt elgamal encrypted data")
|
||||
@ -93,6 +28,10 @@ var (
|
||||
)
|
||||
```
|
||||
|
||||
```go
|
||||
var Curve25519EncryptTooBig = errors.New("failed to encrypt data, too big for Curve25519")
|
||||
```
|
||||
|
||||
```go
|
||||
var Ed25519EncryptTooBig = errors.New("failed to encrypt data, too big for Ed25519")
|
||||
```
|
||||
@ -108,6 +47,180 @@ func ElgamalGenerate(priv *elgamal.PrivateKey, rand io.Reader) (err error)
|
||||
```
|
||||
generate an elgamal key pair
|
||||
|
||||
#### type AESSymmetricDecrypter
|
||||
|
||||
```go
|
||||
type AESSymmetricDecrypter struct {
|
||||
Key []byte
|
||||
IV []byte
|
||||
}
|
||||
```
|
||||
|
||||
AESSymmetricDecrypter implements the Decrypter interface using AES
|
||||
|
||||
#### func (*AESSymmetricDecrypter) Decrypt
|
||||
|
||||
```go
|
||||
func (d *AESSymmetricDecrypter) Decrypt(data []byte) ([]byte, error)
|
||||
```
|
||||
Decrypt decrypts data using AES-CBC with PKCS#7 padding
|
||||
|
||||
#### func (*AESSymmetricDecrypter) DecryptNoPadding
|
||||
|
||||
```go
|
||||
func (d *AESSymmetricDecrypter) DecryptNoPadding(data []byte) ([]byte, error)
|
||||
```
|
||||
DecryptNoPadding decrypts data using AES-CBC without padding
|
||||
|
||||
#### type AESSymmetricEncrypter
|
||||
|
||||
```go
|
||||
type AESSymmetricEncrypter struct {
|
||||
Key []byte
|
||||
IV []byte
|
||||
}
|
||||
```
|
||||
|
||||
AESSymmetricEncrypter implements the Encrypter interface using AES
|
||||
|
||||
#### func (*AESSymmetricEncrypter) Encrypt
|
||||
|
||||
```go
|
||||
func (e *AESSymmetricEncrypter) Encrypt(data []byte) ([]byte, error)
|
||||
```
|
||||
Encrypt encrypts data using AES-CBC with PKCS#7 padding
|
||||
|
||||
#### func (*AESSymmetricEncrypter) EncryptNoPadding
|
||||
|
||||
```go
|
||||
func (e *AESSymmetricEncrypter) EncryptNoPadding(data []byte) ([]byte, error)
|
||||
```
|
||||
EncryptNoPadding encrypts data using AES-CBC without padding
|
||||
|
||||
#### type AESSymmetricKey
|
||||
|
||||
```go
|
||||
type AESSymmetricKey struct {
|
||||
Key []byte // AES key (must be 16, 24, or 32 bytes for AES-128, AES-192, AES-256)
|
||||
IV []byte // Initialization Vector (must be 16 bytes for AES)
|
||||
}
|
||||
```
|
||||
|
||||
AESSymmetricKey represents a symmetric key for AES encryption/decryption
|
||||
|
||||
#### func (*AESSymmetricKey) Len
|
||||
|
||||
```go
|
||||
func (k *AESSymmetricKey) Len() int
|
||||
```
|
||||
Len returns the length of the key
|
||||
|
||||
#### func (*AESSymmetricKey) NewDecrypter
|
||||
|
||||
```go
|
||||
func (k *AESSymmetricKey) NewDecrypter() (Decrypter, error)
|
||||
```
|
||||
NewDecrypter creates a new AESSymmetricDecrypter
|
||||
|
||||
#### func (*AESSymmetricKey) NewEncrypter
|
||||
|
||||
```go
|
||||
func (k *AESSymmetricKey) NewEncrypter() (Encrypter, error)
|
||||
```
|
||||
NewEncrypter creates a new AESSymmetricEncrypter
|
||||
|
||||
#### type Curve25519Encryption
|
||||
|
||||
```go
|
||||
type Curve25519Encryption struct {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### func (*Curve25519Encryption) Encrypt
|
||||
|
||||
```go
|
||||
func (curve25519 *Curve25519Encryption) Encrypt(data []byte) (enc []byte, err error)
|
||||
```
|
||||
|
||||
#### func (*Curve25519Encryption) EncryptPadding
|
||||
|
||||
```go
|
||||
func (curve25519 *Curve25519Encryption) EncryptPadding(data []byte, zeroPadding bool) (encrypted []byte, err error)
|
||||
```
|
||||
|
||||
#### type Curve25519PrivateKey
|
||||
|
||||
```go
|
||||
type Curve25519PrivateKey curve25519.PrivateKey
|
||||
```
|
||||
|
||||
|
||||
#### type Curve25519PublicKey
|
||||
|
||||
```go
|
||||
type Curve25519PublicKey []byte
|
||||
```
|
||||
|
||||
|
||||
#### func (Curve25519PublicKey) Len
|
||||
|
||||
```go
|
||||
func (k Curve25519PublicKey) Len() int
|
||||
```
|
||||
|
||||
#### func (Curve25519PublicKey) NewEncrypter
|
||||
|
||||
```go
|
||||
func (elg Curve25519PublicKey) NewEncrypter() (enc Encrypter, err error)
|
||||
```
|
||||
|
||||
#### func (Curve25519PublicKey) NewVerifier
|
||||
|
||||
```go
|
||||
func (k Curve25519PublicKey) NewVerifier() (v Verifier, err error)
|
||||
```
|
||||
|
||||
#### type Curve25519Signer
|
||||
|
||||
```go
|
||||
type Curve25519Signer struct {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### func (*Curve25519Signer) Sign
|
||||
|
||||
```go
|
||||
func (s *Curve25519Signer) Sign(data []byte) (sig []byte, err error)
|
||||
```
|
||||
|
||||
#### func (*Curve25519Signer) SignHash
|
||||
|
||||
```go
|
||||
func (s *Curve25519Signer) SignHash(h []byte) (sig []byte, err error)
|
||||
```
|
||||
|
||||
#### type Curve25519Verifier
|
||||
|
||||
```go
|
||||
type Curve25519Verifier struct {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### func (*Curve25519Verifier) Verify
|
||||
|
||||
```go
|
||||
func (v *Curve25519Verifier) Verify(data, sig []byte) (err error)
|
||||
```
|
||||
|
||||
#### func (*Curve25519Verifier) VerifyHash
|
||||
|
||||
```go
|
||||
func (v *Curve25519Verifier) VerifyHash(h, sig []byte) (err error)
|
||||
```
|
||||
|
||||
#### type DSAPrivateKey
|
||||
|
||||
```go
|
||||
|
@ -77,7 +77,7 @@ close every transport that this transport muxer has
|
||||
```go
|
||||
func (tmux *TransportMuxer) Compatible(routerInfo router_info.RouterInfo) (compat bool)
|
||||
```
|
||||
is there a transport that we mux that is compatible with this router info?
|
||||
is there a transport that we mux that is compatable with this router info?
|
||||
|
||||
#### func (*TransportMuxer) GetSession
|
||||
|
||||
|
254
lib/transport/noise/doc.md
Normal file
254
lib/transport/noise/doc.md
Normal file
@ -0,0 +1,254 @@
|
||||
# noise
|
||||
--
|
||||
import "github.com/go-i2p/go-i2p/lib/transport/noise"
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
const (
|
||||
NOISE_DH_CURVE25519 = 1
|
||||
|
||||
NOISE_CIPHER_CHACHAPOLY = 1
|
||||
NOISE_CIPHER_AESGCM = 2
|
||||
|
||||
NOISE_HASH_SHA256 = 3
|
||||
|
||||
NOISE_PATTERN_XK = 11
|
||||
|
||||
MaxPayloadSize = 65537
|
||||
)
|
||||
```
|
||||
|
||||
```go
|
||||
var ExampleNoiseListener net.Listener = exampleNoiseTransport
|
||||
```
|
||||
ExampleNoiseListener is not a real Noise Listener, do not use it. It is exported
|
||||
so that it can be confirmed that the transport implements net.Listener
|
||||
|
||||
```go
|
||||
var (
|
||||
ExampleNoiseSession net.Conn = exampleNoiseSession.(*NoiseSession)
|
||||
)
|
||||
```
|
||||
|
||||
#### func ComposeInitiatorHandshakeMessage
|
||||
|
||||
```go
|
||||
func ComposeInitiatorHandshakeMessage(s noise.DHKey, rs []byte, payload []byte, ePrivate []byte) (negData, msg []byte, state *noise.HandshakeState, err error)
|
||||
```
|
||||
|
||||
#### func ComposeReceiverHandshakeMessage
|
||||
|
||||
```go
|
||||
func ComposeReceiverHandshakeMessage(s noise.DHKey, rs []byte, payload []byte, ePrivate []byte) (negData, msg []byte, state *noise.HandshakeState, err error)
|
||||
```
|
||||
|
||||
#### func NewNoiseTransportSession
|
||||
|
||||
```go
|
||||
func NewNoiseTransportSession(ri router_info.RouterInfo) (transport.TransportSession, error)
|
||||
```
|
||||
|
||||
#### type NoiseSession
|
||||
|
||||
```go
|
||||
type NoiseSession struct {
|
||||
router_info.RouterInfo
|
||||
*noise.CipherState
|
||||
sync.Mutex
|
||||
*sync.Cond
|
||||
*NoiseTransport // The parent transport, which "Dialed" the connection to the peer whith whom we established the session
|
||||
RecvQueue *cb.Queue
|
||||
SendQueue *cb.Queue
|
||||
SendKey noise.DHKey
|
||||
RecvKey noise.DHKey
|
||||
HandKey noise.DHKey
|
||||
VerifyCallback VerifyCallbackFunc
|
||||
|
||||
Conn net.Conn
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### func (*NoiseSession) Close
|
||||
|
||||
```go
|
||||
func (s *NoiseSession) Close() error
|
||||
```
|
||||
|
||||
#### func (*NoiseSession) LocalAddr
|
||||
|
||||
```go
|
||||
func (s *NoiseSession) LocalAddr() net.Addr
|
||||
```
|
||||
|
||||
#### func (*NoiseSession) QueueSendI2NP
|
||||
|
||||
```go
|
||||
func (s *NoiseSession) QueueSendI2NP(msg i2np.I2NPMessage)
|
||||
```
|
||||
|
||||
#### func (*NoiseSession) Read
|
||||
|
||||
```go
|
||||
func (c *NoiseSession) Read(b []byte) (int, error)
|
||||
```
|
||||
|
||||
#### func (*NoiseSession) ReadNextI2NP
|
||||
|
||||
```go
|
||||
func (s *NoiseSession) ReadNextI2NP() (i2np.I2NPMessage, error)
|
||||
```
|
||||
|
||||
#### func (*NoiseSession) RemoteAddr
|
||||
|
||||
```go
|
||||
func (noise_session *NoiseSession) RemoteAddr() net.Addr
|
||||
```
|
||||
RemoteAddr implements net.Conn
|
||||
|
||||
#### func (*NoiseSession) RunIncomingHandshake
|
||||
|
||||
```go
|
||||
func (c *NoiseSession) RunIncomingHandshake() error
|
||||
```
|
||||
|
||||
#### func (*NoiseSession) RunOutgoingHandshake
|
||||
|
||||
```go
|
||||
func (c *NoiseSession) RunOutgoingHandshake() error
|
||||
```
|
||||
|
||||
#### func (*NoiseSession) SendQueueSize
|
||||
|
||||
```go
|
||||
func (s *NoiseSession) SendQueueSize() int
|
||||
```
|
||||
|
||||
#### func (*NoiseSession) SetDeadline
|
||||
|
||||
```go
|
||||
func (noise_session *NoiseSession) SetDeadline(t time.Time) error
|
||||
```
|
||||
SetDeadline implements net.Conn
|
||||
|
||||
#### func (*NoiseSession) SetReadDeadline
|
||||
|
||||
```go
|
||||
func (noise_session *NoiseSession) SetReadDeadline(t time.Time) error
|
||||
```
|
||||
SetReadDeadline implements net.Conn
|
||||
|
||||
#### func (*NoiseSession) SetWriteDeadline
|
||||
|
||||
```go
|
||||
func (noise_session *NoiseSession) SetWriteDeadline(t time.Time) error
|
||||
```
|
||||
SetWriteDeadline implements net.Conn
|
||||
|
||||
#### func (*NoiseSession) Write
|
||||
|
||||
```go
|
||||
func (c *NoiseSession) Write(b []byte) (int, error)
|
||||
```
|
||||
|
||||
#### type NoiseTransport
|
||||
|
||||
```go
|
||||
type NoiseTransport struct {
|
||||
sync.Mutex
|
||||
router_identity.RouterIdentity
|
||||
*noise.CipherState
|
||||
Listener net.Listener
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### func NewNoiseTransport
|
||||
|
||||
```go
|
||||
func NewNoiseTransport(netSocket net.Listener) *NoiseTransport
|
||||
```
|
||||
NewNoiseTransport create a NoiseTransport using a supplied net.Listener
|
||||
|
||||
#### func NewNoiseTransportSocket
|
||||
|
||||
```go
|
||||
func NewNoiseTransportSocket() (*NoiseTransport, error)
|
||||
```
|
||||
NewNoiseTransportSocket creates a Noise transport socket with a random host and
|
||||
port.
|
||||
|
||||
#### func (*NoiseTransport) Accept
|
||||
|
||||
```go
|
||||
func (noopt *NoiseTransport) Accept() (net.Conn, error)
|
||||
```
|
||||
Accept a connection on a listening socket.
|
||||
|
||||
#### func (*NoiseTransport) Addr
|
||||
|
||||
```go
|
||||
func (noopt *NoiseTransport) Addr() net.Addr
|
||||
```
|
||||
Addr of the transport, for now this is returning the IP:Port the transport is
|
||||
listening on, but this might actually be the router identity
|
||||
|
||||
#### func (*NoiseTransport) Close
|
||||
|
||||
```go
|
||||
func (noopt *NoiseTransport) Close() error
|
||||
```
|
||||
close the transport cleanly blocks until done returns an error if one happens
|
||||
|
||||
#### func (*NoiseTransport) Compatable
|
||||
|
||||
```go
|
||||
func (noopt *NoiseTransport) Compatable(routerInfo router_info.RouterInfo) bool
|
||||
```
|
||||
Compatable return true if a routerInfo is compatable with this transport
|
||||
|
||||
#### func (*NoiseTransport) Compatible
|
||||
|
||||
```go
|
||||
func (noopt *NoiseTransport) Compatible(routerInfo router_info.RouterInfo) bool
|
||||
```
|
||||
|
||||
#### func (*NoiseTransport) GetSession
|
||||
|
||||
```go
|
||||
func (noopt *NoiseTransport) GetSession(routerInfo router_info.RouterInfo) (transport.TransportSession, error)
|
||||
```
|
||||
Obtain a transport session with a router given its RouterInfo. If a session with
|
||||
this router is NOT already made attempt to create one and block until made or
|
||||
until an error happens returns an established TransportSession and nil on
|
||||
success returns nil and an error on error
|
||||
|
||||
#### func (*NoiseTransport) Handshake
|
||||
|
||||
```go
|
||||
func (c *NoiseTransport) Handshake(routerInfo router_info.RouterInfo) error
|
||||
```
|
||||
|
||||
#### func (*NoiseTransport) Name
|
||||
|
||||
```go
|
||||
func (noopt *NoiseTransport) Name() string
|
||||
```
|
||||
Name of the transport TYPE, in this case `noise`
|
||||
|
||||
#### func (*NoiseTransport) SetIdentity
|
||||
|
||||
```go
|
||||
func (noopt *NoiseTransport) SetIdentity(ident router_identity.RouterIdentity) (err error)
|
||||
```
|
||||
SetIdentity will set the router identity for this transport. will bind if the
|
||||
underlying socket is not already if the underlying socket is already bound
|
||||
update the RouterIdentity returns any errors that happen if they do
|
||||
|
||||
#### type VerifyCallbackFunc
|
||||
|
||||
```go
|
||||
type VerifyCallbackFunc func(publicKey []byte, data []byte) error
|
||||
```
|
@ -5,6 +5,21 @@
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
const (
|
||||
NOISE_DH_CURVE25519 = 1
|
||||
|
||||
NOISE_CIPHER_CHACHAPOLY = 1
|
||||
NOISE_CIPHER_AESGCM = 2
|
||||
|
||||
NOISE_HASH_SHA256 = 3
|
||||
|
||||
NOISE_PATTERN_XK = 11
|
||||
|
||||
MaxPayloadSize = math.MaxUint16 - 16 - uint16Size /*data len*/
|
||||
)
|
||||
```
|
||||
|
||||
```go
|
||||
const (
|
||||
NTCP_PROTOCOL_VERSION = 2
|
||||
@ -13,6 +28,22 @@ const (
|
||||
)
|
||||
```
|
||||
|
||||
#### func DeobfuscateEphemeralKey
|
||||
|
||||
```go
|
||||
func DeobfuscateEphemeralKey(message []byte, aesKey *crypto.AESSymmetricKey) ([]byte, error)
|
||||
```
|
||||
DeobfuscateEphemeralKey decrypts the ephemeral public key in the message using
|
||||
AES-256-CBC without padding
|
||||
|
||||
#### func ObfuscateEphemeralKey
|
||||
|
||||
```go
|
||||
func ObfuscateEphemeralKey(message []byte, aesKey *crypto.AESSymmetricKey) ([]byte, error)
|
||||
```
|
||||
ObfuscateEphemeralKey encrypts the ephemeral public key in the message using
|
||||
AES-256-CBC without padding
|
||||
|
||||
#### type Session
|
||||
|
||||
```go
|
||||
|
Reference in New Issue
Block a user