key

package
v0.0.0-...-0db62fc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
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) MarshalBSONValue

func (c *ControlPublic) MarshalBSONValue() (bsontype.Type, []byte, error)

func (ControlPublic) MarshalText

func (c ControlPublic) MarshalText() (text []byte, err error)

func (*ControlPublic) UnmarshalBSONValue

func (c *ControlPublic) UnmarshalBSONValue(b bsontype.Type, bytes []byte) 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

type NakedKey [Len]byte

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 deprecated

func UnveilPrivate(private NodePrivate) NakedKey

UnveilPrivate is a function to get a NakedKey from a NodePrivate.

Deprecated: nobody should be using this

func (NakedKey) Debug

func (n NakedKey) Debug() string

func (NakedKey) HexString

func (n NakedKey) HexString() string

func (NakedKey) IsZero

func (n NakedKey) IsZero() bool

IsZero reports whether k is the zero value.

type NodePrivate

type NodePrivate struct {
	// contains filtered or unexported fields
}

func NewNode

func NewNode() NodePrivate

NewNode creates and returns a new node private key.

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 (k 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) MarshalBSONValue

func (n *NodePublic) MarshalBSONValue() (bsontype.Type, []byte, error)

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) UnmarshalBSONValue

func (n *NodePublic) UnmarshalBSONValue(b bsontype.Type, bytes []byte) error

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

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) MarshalBSONValue

func (s *SessionPublic) MarshalBSONValue() (bsontype.Type, []byte, error)

func (SessionPublic) MarshalText

func (s SessionPublic) MarshalText() (text []byte, err error)

func (SessionPublic) ToByteSlice

func (s SessionPublic) ToByteSlice() []byte

func (*SessionPublic) UnmarshalBSONValue

func (s *SessionPublic) UnmarshalBSONValue(b bsontype.Type, bytes []byte) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL