Documentation ¶
Overview ¶
Package crypto contains cryptographic utilities.
Package crypto contains cryptographic utilities.
Index ¶
- Constants
- Variables
- func IsValidDefaultPSK(s string) bool
- func IsValidPSK(s string, length int) bool
- func IsValidPSKBytes(b []byte, length int) bool
- func ParseHostPublicKey(s string) (p2pcrypto.PubKey, error)
- func Rendezvous(keys ...wgtypes.Key) string
- func Sign(data []byte, psk PSK) ([]byte, error)
- func Verify(data, signature []byte, psk PSK) error
- type Key
- type PSK
- func (p PSK) DeterministicSign(data []byte) ([]byte, error)
- func (p PSK) DeterministicSignatureSize() int
- func (p PSK) DeterministicVerify(data, signature []byte) error
- func (p PSK) IsValid() bool
- func (p PSK) Sign(data []byte) ([]byte, error)
- func (p PSK) SignatureSize() int
- func (p PSK) String() string
- func (p PSK) Verify(data, signature []byte) error
Constants ¶
const DefaultPSKLength = 32
DefaultPSKLength is the default length of a PSK.
Variables ¶
var ErrInvalidSignature = fmt.Errorf("invalid signature")
ErrInvalidSignature is returned when a signature is invalid.
var ValidPSKChars = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
ValidPSKChars is the set of valid characters for a PSK.
Functions ¶
func IsValidDefaultPSK ¶
IsValidDefaultPSK returns true if the given string is a valid PSK.
func IsValidPSK ¶
IsValidPSK returns true if the given string is a valid PSK.
func IsValidPSKBytes ¶
IsValidPSKBytes returns true if the given byte slice is a valid PSK.
func ParseHostPublicKey ¶
ParseHostPublicKey parses the host public key from the given base64 encoded string.
func Rendezvous ¶
Rendezvous generates a rendezvous string for discovering the peers at the given public wireguard keys.
Types ¶
type Key ¶
type Key interface { // PrivateKey returns the WireGuard private key derived from the // given key. PrivateKey() wgtypes.Key // PublicKey returns the public WireGuard key derived from the given key. PublicKey() wgtypes.Key // HostKey returns a libp2p compatible host key-pair. HostKey() p2pcrypto.PrivKey // PublicHostString returns the base64 encoded string representation of the full host public key. PublicHostString() string // String return the base64 encoded string representation of the key. String() string // Rendezvous generates a rendezvous string for discovering the peers at the given // public wireguard keys. Rendezvous(keys ...wgtypes.Key) string }
Key is a private key used for encryption and identity over libp2p and WireGuard tunnels.
func MustGenerateKey ¶
func MustGenerateKey() Key
MustGenerateKey generates a new private key or panics.
func ParseKeyFromBytes ¶
ParseKey parses a private key from the given bytes.
type PSK ¶
type PSK []byte
PSK is a pre-shared key.
func GeneratePSKWithLength ¶
GeneratePSKWithLength generates a PSK with a given length.
func MustGeneratePSK ¶
func MustGeneratePSK() PSK
MustGeneratePSK generates a PSK and panics on error.
func (PSK) DeterministicSign ¶
DeterministicSign creates a signature of the given data using this PSK.
func (PSK) DeterministicSignatureSize ¶
func (PSK) DeterministicVerify ¶
DeterministicVerify verifies the given signature against the given data using this PSK.