key

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// LatestVersion latest key version implemented.
	LatestVersion = V1
	// LatestVersionLen latest key version maximum length.
	LatestVersionLen = V1KeyLen
	// UnknownVersion unknown key version (versions are numbered from 1).
	UnknownVersion = 0
)
View Source
const (
	V1       uint8 = 1
	V1KeyLen       = 1024
)

Variables

View Source
var (
	// ErrUnknownKeyVersion key version is not implemented in this build.
	ErrUnknownKeyVersion = errors.New("unknown key version")
	// ErrMissingKeyHeader missing header part of the key.
	ErrMissingKeyHeader = errors.New("missing key header")
	// ErrMalformedKeyHeader key header is malformed.
	ErrMalformedKeyHeader = errors.New("malformed key header")
)
View Source
var ErrMissingKeyType = errors.New("missing key type")
View Source
var LatestKeyLen = V1Len

LatestKeyLen computes the length of key of a latest version.

View Source
var LatestMaxKey = V1MaxKey()
View Source
var LatestMinKey = V1MinKey()
View Source
var V1MaxKey = func() []byte {
	var maxKey []byte
	for i := 0; i < keyV1BodyLen-1; i++ {
		maxKey = append(maxKey, 255)
	}
	return maxKey
}
View Source
var V1MinKey = func() []byte {
	var minKey []byte
	for i := 0; i < keyV1BodyLen-1; i++ {
		minKey = append(minKey, 0)
	}
	return minKey
}

Functions

func V1Len

func V1Len(userkeyLen int) int

V1Len computes length of a key.

Types

type Decoder

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

Decoder the Key decoder.

func NewDecoder

func NewDecoder(reader io.Reader) *Decoder

NewDecoder constructs a new Decoder.

func (Decoder) Decode

func (d Decoder) Decode(key *Key) error

type Encoder

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

Encoder the Key encoder.

func NewEncoder

func NewEncoder(writer io.Writer) *Encoder

NewEncoder constructs a new Encoder.

func (Encoder) Encode

func (e Encoder) Encode(key *Key) (int, error)

type Key

type Key struct {

	// KeyType type of Key - supported since V1.
	KeyType Type
	// Key data part of a Key - supported since V1.
	Key []byte
	// contains filtered or unexported fields
}

Key generic internal Key (not that field support might be dependent on the stored key version).

func DecodeBytes

func DecodeBytes(raw []byte) (Key, error)

DecodeBytes transforms raw bytes into a Key, input bytes are not copied.

type Type

type Type byte
const (
	// TypeUnknown unknown Key type.
	TypeUnknown Type = iota
	// TypeUser user Key type.
	TypeUser
	// TypeSystem system/internal Key type.
	TypeSystem
)

Jump to

Keyboard shortcuts

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