Documentation ¶
Index ¶
- Variables
- func Credential(privateKey *rsa.PrivateKey, userID protocol.UserID, peerID protocol.PeerID, ...) ([]byte, error)
- func Hash(password, salt string) string
- func VerifyCredential(publicKey *rsa.PublicKey, credential []byte) (userID protocol.UserID, peerID protocol.PeerID, ip net.IP, valid bool)
- type DHKey
- type DHKeyBytes
- func (k DHKeyBytes) B32() *[keySize]byte
- func (k DHKeyBytes) Bytes() []byte
- func (k DHKeyBytes) IsZero() bool
- func (k DHKeyBytes) Len() int
- func (k DHKeyBytes) MarshalText() ([]byte, error)
- func (k DHKeyBytes) ShortString() string
- func (k DHKeyBytes) String() string
- func (k *DHKeyBytes) UnmarshalText(txt []byte) error
- type DHPrivate
- type DHPublic
Constants ¶
This section is empty.
Variables ¶
var ( // CipherSuite represents the cipher suite which is used to handshake between node and relay server. CipherSuite = noise.NewCipherSuite(noise.DH25519, noise.CipherChaChaPoly, noise.HashBLAKE2s) // HandshakePatternNN represents the handshake pattern which is used to exchange the DH key. HandshakePatternNN = noise.HandshakeNN HandshakePatternIK = noise.HandshakeIK )
Functions ¶
func Credential ¶
func Credential(privateKey *rsa.PrivateKey, userID protocol.UserID, peerID protocol.PeerID, ip net.IP, lease time.Duration) ([]byte, error)
Credential returns a credential to identity the Peer, which contains the expiration time and the reclaimed IP address. All requests relevant to IP address, the credential is required. We will verify the triple: -> (PeerID, IP, Expiration). The schema of credential: | PeerID | PeerID | Expiration | IPLen | IP | | 8 bytes | 8 bytes | 8 bytes | 1 byte | Variant | The credential delivered to the client will be encrypted by secret key. The secret key is a private key only held by the gateway.
Types ¶
type DHKey ¶
DHKey a noise.DHkey wrapper for PairMesh
func FromNoiseDHKey ¶
FromNoiseDHKey generate a DHKey from noise.DHKey
func (*DHKey) ToNoiseDHKey ¶
ToNoiseDHKey re-generate noise.DHKey from DHKey
type DHKeyBytes ¶
type DHKeyBytes [keySize]byte
func (DHKeyBytes) B32 ¶
func (k DHKeyBytes) B32() *[keySize]byte
B32 returns k as the *[32]byte type that's used by the golang.org/x/crypto packages. This allocates; it might not be appropriate for performance-sensitive paths.
func (DHKeyBytes) Bytes ¶
func (k DHKeyBytes) Bytes() []byte
func (DHKeyBytes) IsZero ¶
func (k DHKeyBytes) IsZero() bool
IsZero reports whether the DHPrivate p is the zero value.
func (DHKeyBytes) Len ¶
func (k DHKeyBytes) Len() int
func (DHKeyBytes) MarshalText ¶
func (k DHKeyBytes) MarshalText() ([]byte, error)
func (DHKeyBytes) ShortString ¶
func (k DHKeyBytes) ShortString() string
ShortString returns the PairMesh conventional debug representation of a public key: the first five base64 digits of the key, in square brackets.
func (DHKeyBytes) String ¶
func (k DHKeyBytes) String() string
func (*DHKeyBytes) UnmarshalText ¶
func (k *DHKeyBytes) UnmarshalText(txt []byte) error