wgtypes

package
v0.0.0-...-5c775dd Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT, MIT Imports: 5 Imported by: 0

Documentation

Overview

Package wgtypes provides shared types for the wgctrl family of packages.

Index

Constants

View Source
const KeyLen = 32 // wgh.KeyLen

KeyLen is the expected key length for a WireGuard key.

View Source
const KeyPairLen = KeyLen * 2

KeyPairLen is the expected key buffer size for a private and public WireGuard key.

Variables

View Source
var ErrUpdateOnlyNotSupported = errors.New("the UpdateOnly flag is not supported by this platform")

ErrUpdateOnlyNotSupported is returned due to missing kernel support of the PeerConfig UpdateOnly flag.

Functions

func FillKeyPair

func FillKeyPair(p []byte) error

FillKeyPair generates a Key suitable for use as a private key from a cryptographically safe source.

Types

type Key

type Key []byte

A Key is a public, private, or pre-shared secret key. The Key constructor functions in this package can be used to create Keys suitable for each of these applications.

func (Key) String

func (k Key) String() string

String returns the base64-encoded string representation of a Key.

ParseKey can be used to produce a new Key from this string.

type KeyPair

type KeyPair []byte

func GenerateKeyPair

func GenerateKeyPair() (KeyPair, error)

GenerateKeyPair generates a Key suitable for use as a private key from a cryptographically safe source.

func NewKeyPair

func NewKeyPair(b []byte) (KeyPair, error)

NewKeyPair creates a Key from an existing byte slice. The byte slice must be exactly 32 bytes in length.

func ParseKeyPair

func ParseKeyPair(s string) (KeyPair, error)

ParseKeyPair parses a Key from a base64-encoded string, as produced by the Key.String method.

func (KeyPair) PrivateKey

func (k KeyPair) PrivateKey() Key

PrivateKey returns the private key portion of the key pair.

func (KeyPair) PublicKey

func (k KeyPair) PublicKey() Key

PublicKey returns the public key portion of the key pair.

Jump to

Keyboard shortcuts

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