wgkey

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package wgkey contains types and helpers for WireGuard keys. It is very similar to package tailscale.com/types/key, which is also used for curve25519 keys. These keys are used for WireGuard clients; those keys are used in other curve25519 clients.

Index

Constants

View Source
const Size = 32

Size is the number of bytes in a curve25519 key.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key [Size]byte

A Key is a curve25519 key. It is used by WireGuard to represent public and preshared keys.

func NewPreshared

func NewPreshared() (*Key, error)

NewPreshared generates a new random Key.

func Parse

func Parse(b64 string) (*Key, error)

func ParseHex

func ParseHex(s string) (Key, error)

func (Key) AppendTo added in v1.10.0

func (k Key) AppendTo(b []byte) []byte

func (Key) Base64

func (k Key) Base64() string

func (Key) Equal

func (k Key) Equal(k2 Key) bool

func (Key) HexString

func (k Key) HexString() string

func (*Key) IsZero

func (k *Key) IsZero() bool

func (*Key) LessThan

func (a *Key) LessThan(b *Key) bool

func (Key) MarshalJSON

func (k Key) MarshalJSON() ([]byte, error)

func (*Key) ShortString

func (k *Key) ShortString() string

func (Key) String

func (k Key) String() string

func (*Key) UnmarshalJSON

func (k *Key) UnmarshalJSON(b []byte) error

type Private

type Private [Size]byte

A Private is a curve25519 key. It is used by WireGuard to represent private keys.

func NewPrivate

func NewPrivate() (Private, error)

NewPrivate generates a new curve25519 secret key. It conforms to the format described on https://cr.yp.to/ecdh.html.

func ParsePrivate

func ParsePrivate(b64 string) (*Private, error)

func ParsePrivateHex

func ParsePrivateHex(v string) (Private, error)

func (Private) AppendTo added in v1.10.0

func (k Private) AppendTo(b []byte) []byte

func (*Private) Equal

func (k *Private) Equal(k2 Private) bool

func (*Private) HexString

func (k *Private) HexString() string

func (*Private) IsZero

func (k *Private) IsZero() bool

func (Private) MarshalText

func (k Private) MarshalText() ([]byte, error)

func (*Private) Public

func (k *Private) Public() Key

Public computes the public key matching this curve25519 secret key.

func (*Private) String

func (k *Private) String() string

func (*Private) UnmarshalText

func (k *Private) UnmarshalText(b []byte) error

type Symmetric

type Symmetric [chacha20poly1305.KeySize]byte

Symmetric is a chacha20poly1305 key. It is used by WireGuard to represent pre-shared symmetric keys.

func ParseSymmetric

func ParseSymmetric(b64 string) (Symmetric, error)

func ParseSymmetricHex

func ParseSymmetricHex(s string) (Symmetric, error)

func (Symmetric) Base64

func (k Symmetric) Base64() string

func (Symmetric) Equal

func (k Symmetric) Equal(k2 Symmetric) bool

func (Symmetric) HexString

func (k Symmetric) HexString() string

func (Symmetric) IsZero

func (k Symmetric) IsZero() bool

func (Symmetric) String

func (k Symmetric) String() string

Jump to

Keyboard shortcuts

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