key

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxSize is the maximum byte size of an encoded key.
	MaxSize = 1 << 20

	// Size is the byte size of a cryptographic key.
	Size = 256 / 8
)

Variables

This section is empty.

Functions

func Len added in v0.22.3

func Len(a kes.KeyAlgorithm) int

Len returns the length of keys for the given Algorithm in bytes.

Types

type Key

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

Key is a symmetric cryptographic key.

func New

func New(algorithm kes.KeyAlgorithm, key []byte, owner kes.Identity) (Key, error)

New returns an new Key for the given cryptographic algorithm. The key len must match algorithm's key size. The returned key is owned to the specified identity.

func Parse

func Parse(b []byte) (Key, error)

Parse parses b as encoded Key.

func Random added in v0.19.2

func Random(algorithm kes.KeyAlgorithm, owner kes.Identity) (Key, error)

Random generates a new random Key for the cryptographic algorithm. The returned key is owned to the specified identity.

func (*Key) Algorithm added in v0.19.2

func (k *Key) Algorithm() kes.KeyAlgorithm

Algorithm returns the cryptographic algorithm for which the key can be used.

func (*Key) Clone added in v0.19.2

func (k *Key) Clone() Key

Clone returns a deep copy of the key.

func (*Key) CreatedAt added in v0.19.2

func (k *Key) CreatedAt() time.Time

CreatedAt returns the point in time when the key has been created.

func (*Key) CreatedBy added in v0.19.2

func (k *Key) CreatedBy() kes.Identity

CreatedBy returns the identity that created the key.

func (*Key) Equal

func (k *Key) Equal(other Key) bool

Equal returns true if and only if both keys are identical.

func (*Key) ID

func (k *Key) ID() string

ID returns the k's key ID.

func (Key) MarshalBinary added in v0.20.0

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

MarshalBinary returns the Key's binary representation.

func (Key) MarshalText added in v0.19.2

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

MarshalText returns the key's text representation.

func (*Key) UnmarshalBinary added in v0.20.0

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

UnmarshalBinary unmarshals the Key's binary representation.

func (*Key) UnmarshalText added in v0.19.2

func (k *Key) UnmarshalText(text []byte) error

UnmarshalText parses and decodes text as encoded key.

func (*Key) Unwrap

func (k *Key) Unwrap(ciphertext, associatedData []byte) ([]byte, error)

Unwrap decrypts the ciphertext and returns the resulting plaintext.

It verifies that the associatedData matches the value used when the ciphertext has been generated.

func (*Key) Wrap

func (k *Key) Wrap(plaintext, associatedData []byte) ([]byte, error)

Wrap encrypts the given plaintext and binds the associatedData to the returned ciphertext.

To unwrap the ciphertext the same associatedData has to be provided again.

Jump to

Keyboard shortcuts

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