Documentation
¶
Overview ¶
Package key contains Session, Node, and Control key definitions, private and public, and associated functions.
Index ¶
- Constants
- type ControlPrivate
- func (c ControlPrivate) AppendText(b []byte) ([]byte, error)
- func (c ControlPrivate) Equal(other ControlPrivate) bool
- func (c ControlPrivate) IsZero() bool
- func (c ControlPrivate) MarshalText() ([]byte, error)
- func (c ControlPrivate) OpenFromNode(p NodePublic, ciphertext []byte) (cleartext []byte, ok bool)
- func (c ControlPrivate) OpenFromSession(p SessionPublic, ciphertext []byte) (cleartext []byte, ok bool)
- func (c ControlPrivate) Public() ControlPublic
- func (c ControlPrivate) SealToNode(p NodePublic, cleartext []byte) (ciphertext []byte)
- func (c *ControlPrivate) UnmarshalText(b []byte) error
- type ControlPublic
- type CryptoPair
- type NakedKey
- type NodePrivate
- func (n NodePrivate) AppendText(b []byte) ([]byte, error)
- func (n NodePrivate) Equal(other NodePrivate) bool
- func (n NodePrivate) IsZero() bool
- func (n NodePrivate) Marshal() string
- func (n NodePrivate) MarshalText() ([]byte, error)
- func (n NodePrivate) OpenFrom(p NodePublic, ciphertext []byte) (cleartext []byte, ok bool)
- func (n NodePrivate) OpenFromControl(p ControlPublic, ciphertext []byte) (cleartext []byte, ok bool)
- func (n NodePrivate) Public() NodePublic
- func (n NodePrivate) SealTo(p NodePublic, cleartext []byte) (ciphertext []byte)
- func (n NodePrivate) SealToControl(p ControlPublic, cleartext []byte) (ciphertext []byte)
- func (n *NodePrivate) UnmarshalText(b []byte) error
- type NodePublic
- func (n NodePublic) AppendText(b []byte) ([]byte, error)
- func (n NodePublic) Debug() string
- func (n NodePublic) HexString() string
- func (n NodePublic) IsZero() bool
- func (n NodePublic) Marshal() string
- func (n NodePublic) MarshalText() ([]byte, error)
- func (n *NodePublic) UnmarshalText(b []byte) error
- type SessionPrivate
- type SessionPublic
- func (s SessionPublic) AppendText(b []byte) ([]byte, error)
- func (s SessionPublic) Debug() string
- func (s SessionPublic) HexString() string
- func (s SessionPublic) IsZero() bool
- func (s SessionPublic) MarshalText() (text []byte, err error)
- func (s SessionPublic) ToByteSlice() []byte
- func (s *SessionPublic) UnmarshalText(text []byte) error
- type SessionShared
Constants ¶
const Len = 32
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControlPrivate ¶
type ControlPrivate struct {
// contains filtered or unexported fields
}
func NewControlPrivate ¶
func NewControlPrivate() ControlPrivate
NewControlPrivate creates and returns a new control private key.
func (ControlPrivate) AppendText ¶
func (c ControlPrivate) AppendText(b []byte) ([]byte, error)
AppendText implements encoding.TextAppender.
func (ControlPrivate) Equal ¶
func (c ControlPrivate) Equal(other ControlPrivate) bool
func (ControlPrivate) IsZero ¶
func (c ControlPrivate) IsZero() bool
IsZero reports whether k is the zero value.
func (ControlPrivate) MarshalText ¶
func (c ControlPrivate) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (ControlPrivate) OpenFromNode ¶
func (c ControlPrivate) OpenFromNode(p NodePublic, ciphertext []byte) (cleartext []byte, ok bool)
func (ControlPrivate) OpenFromSession ¶
func (c ControlPrivate) OpenFromSession(p SessionPublic, ciphertext []byte) (cleartext []byte, ok bool)
func (ControlPrivate) Public ¶
func (c ControlPrivate) Public() ControlPublic
func (ControlPrivate) SealToNode ¶
func (c ControlPrivate) SealToNode(p NodePublic, cleartext []byte) (ciphertext []byte)
func (*ControlPrivate) UnmarshalText ¶
func (c *ControlPrivate) UnmarshalText(b []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type ControlPublic ¶
type ControlPublic NakedKey
func UnmarshalControlPublic ¶
func UnmarshalControlPublic(s string) (*ControlPublic, error)
func (ControlPublic) AppendText ¶
func (c ControlPublic) AppendText(b []byte) ([]byte, error)
func (ControlPublic) Debug ¶
func (c ControlPublic) Debug() string
func (ControlPublic) HexString ¶
func (c ControlPublic) HexString() string
func (ControlPublic) IsZero ¶
func (c ControlPublic) IsZero() bool
func (ControlPublic) MarshalText ¶
func (c ControlPublic) MarshalText() (text []byte, err error)
func (*ControlPublic) UnmarshalText ¶
func (c *ControlPublic) UnmarshalText(text []byte) error
type CryptoPair ¶
type CryptoPair[Pub publicKey] interface {
// contains filtered or unexported methods
}
type NakedKey ¶
NakedKey is the 32-byte underlying key.
Only ever used for public interfaces, very dangerous to use directly, due to the security implications.
func UnveilPrivate ¶
func UnveilPrivate(private NodePrivate) NakedKey
UnveilPrivate is a function to get a NakedKey from a NodePrivate.
//Deprecated: nobody should be using this
type NodePrivate ¶
type NodePrivate struct {
// contains filtered or unexported fields
}
func NodePrivateFrom ¶
func NodePrivateFrom(key NakedKey) NodePrivate
func UnmarshalPrivate ¶
func UnmarshalPrivate(s string) (*NodePrivate, error)
func (NodePrivate) AppendText ¶
func (n NodePrivate) AppendText(b []byte) ([]byte, error)
AppendText implements encoding.TextAppender.
func (NodePrivate) Equal ¶
func (n NodePrivate) Equal(other NodePrivate) bool
Equal reports whether k and other are the same key.
func (NodePrivate) IsZero ¶
func (n NodePrivate) IsZero() bool
IsZero reports whether k is the zero value.
func (NodePrivate) Marshal ¶
func (n NodePrivate) Marshal() string
func (NodePrivate) MarshalText ¶
func (n NodePrivate) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (NodePrivate) OpenFrom ¶
func (n NodePrivate) OpenFrom(p NodePublic, ciphertext []byte) (cleartext []byte, ok bool)
OpenFrom opens the NaCl box ciphertext, which must be a value created by SealTo, and returns the inner cleartext if ciphertext is a valid box from p to k.
func (NodePrivate) OpenFromControl ¶
func (n NodePrivate) OpenFromControl(p ControlPublic, ciphertext []byte) (cleartext []byte, ok bool)
func (NodePrivate) Public ¶
func (n NodePrivate) Public() NodePublic
func (NodePrivate) SealTo ¶
func (n NodePrivate) SealTo(p NodePublic, cleartext []byte) (ciphertext []byte)
SealTo wraps cleartext into a NaCl box (see golang.org/x/crypto/nacl) to p, authenticated from k, using a random nonce.
The returned ciphertext is a 24-byte nonce concatenated with the box value.
func (NodePrivate) SealToControl ¶
func (n NodePrivate) SealToControl(p ControlPublic, cleartext []byte) (ciphertext []byte)
func (*NodePrivate) UnmarshalText ¶
func (n *NodePrivate) UnmarshalText(b []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type NodePublic ¶
type NodePublic NakedKey
func UnmarshalPublic ¶
func UnmarshalPublic(s string) (*NodePublic, error)
func (NodePublic) AppendText ¶
func (n NodePublic) AppendText(b []byte) ([]byte, error)
AppendText implements encoding.TextAppender. It appends a typed prefix followed by hex encoded represtation of k to b.
func (NodePublic) Debug ¶
func (n NodePublic) Debug() string
func (NodePublic) HexString ¶
func (n NodePublic) HexString() string
func (NodePublic) IsZero ¶
func (n NodePublic) IsZero() bool
func (NodePublic) Marshal ¶
func (n NodePublic) Marshal() string
func (NodePublic) MarshalText ¶
func (n NodePublic) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler. It returns a typed prefix followed by a hex encoded representation of k.
func (*NodePublic) UnmarshalText ¶
func (n *NodePublic) UnmarshalText(b []byte) error
UnmarshalText implements encoding.TextUnmarshaler. It expects a typed prefix followed by a hex encoded representation of k.
type SessionPrivate ¶
type SessionPrivate struct {
// contains filtered or unexported fields
}
func DevNewSessionFromPrivate
deprecated
func DevNewSessionFromPrivate(priv NodePrivate) SessionPrivate
DevNewSessionFromPrivate creates a new SessionPrivate by copying a NodePrivate
Deprecated: Must only be used for development.
func NewSession ¶
func NewSession() SessionPrivate
NewSession creates and returns a new session private key.
func (SessionPrivate) Equal ¶
func (s SessionPrivate) Equal(other SessionPrivate) bool
Equal reports whether k and other are the same key.
func (SessionPrivate) IsZero ¶
func (s SessionPrivate) IsZero() bool
IsZero reports whether k is the zero value.
func (SessionPrivate) Public ¶
func (s SessionPrivate) Public() SessionPublic
Public returns the SessionPublic for k. Panics if SessionPrivate is zero.
func (SessionPrivate) SealToControl ¶
func (s SessionPrivate) SealToControl(p ControlPublic, cleartext []byte) (ciphertext []byte)
func (SessionPrivate) Shared ¶
func (s SessionPrivate) Shared(p SessionPublic) SessionShared
Shared returns the SessionShared for communication between k and p.
type SessionPublic ¶
type SessionPublic NakedKey
func MakeSessionPublic ¶
func MakeSessionPublic(raw [32]byte) SessionPublic
MakeSessionPublic parses a 32-byte raw value as a SessionPublic.
This should be used only when deserializing a SessionPublic from a binary protocol.
func (SessionPublic) AppendText ¶
func (s SessionPublic) AppendText(b []byte) ([]byte, error)
func (SessionPublic) Debug ¶
func (s SessionPublic) Debug() string
func (SessionPublic) HexString ¶
func (s SessionPublic) HexString() string
func (SessionPublic) IsZero ¶
func (s SessionPublic) IsZero() bool
IsZero reports whether k is the zero value.
func (SessionPublic) MarshalText ¶
func (s SessionPublic) MarshalText() (text []byte, err error)
func (SessionPublic) ToByteSlice ¶
func (s SessionPublic) ToByteSlice() []byte
func (*SessionPublic) UnmarshalText ¶
func (s *SessionPublic) UnmarshalText(text []byte) error
type SessionShared ¶
type SessionShared struct {
// contains filtered or unexported fields
}
func (SessionShared) Equal ¶
func (k SessionShared) Equal(other SessionShared) bool
Equal reports whether k and other are the same key.
func (SessionShared) IsZero ¶
func (k SessionShared) IsZero() bool
func (SessionShared) Open ¶
func (k SessionShared) Open(ciphertext []byte) (cleartext []byte, ok bool)
Open opens the NaCl box ciphertext, which must be a value created by Seal, and returns the inner cleartext if ciphertext is a valid box using shared secret k.
func (SessionShared) Seal ¶
func (k SessionShared) Seal(cleartext []byte) (ciphertext []byte)
Seal wraps cleartext into a NaCl box (see golang.org/x/crypto/nacl), using k as the shared secret and a random nonce.