package primitiveset

import "github.com/google/tink/go/core/primitiveset"

Package primitiveset provides a container for a set of cryptographic primitives.

It provides also additional properties for the primitives it holds. In particular, one of the primitives in the set can be distinguished as "the primary" one.

Index

Types

type Entry

type Entry struct {
	KeyID      uint32
	Primitive  interface{}
	Prefix     string
	PrefixType tinkpb.OutputPrefixType
	Status     tinkpb.KeyStatusType
	TypeURL    string
}

Entry represents a single entry in the keyset. In addition to the actual primitive, it holds the identifier and status of the primitive.

type PrimitiveSet

type PrimitiveSet struct {
	// Primary entry.
	Primary *Entry

	// The primitives are stored in a map of (ciphertext prefix, list of
	// primitives sharing the prefix). This allows quickly retrieving the
	// primitives sharing some particular prefix.
	Entries map[string][]*Entry
}

PrimitiveSet is used for supporting key rotation: primitives in a set correspond to keys in a keyset. Users will usually work with primitive instances, which essentially wrap primitive sets. For example an instance of an AEAD-primitive for a given keyset holds a set of AEAD-primitives corresponding to the keys in the keyset, and uses the set members to do the actual crypto operations: to encrypt data the primary AEAD-primitive from the set is used, and upon decryption the ciphertext's prefix determines the id of the primitive from the set.

PrimitiveSet is a public to allow its use in implementations of custom primitives.

func New

func New() *PrimitiveSet

New returns an empty instance of PrimitiveSet.

func (*PrimitiveSet) Add

func (ps *PrimitiveSet) Add(p interface{}, key *tinkpb.Keyset_Key) (*Entry, error)

Add creates a new entry in the primitive set and returns the added entry.

func (*PrimitiveSet) EntriesForPrefix

func (ps *PrimitiveSet) EntriesForPrefix(prefix string) ([]*Entry, error)

EntriesForPrefix returns all primitives in the set that have the given prefix.

func (*PrimitiveSet) RawEntries

func (ps *PrimitiveSet) RawEntries() ([]*Entry, error)

RawEntries returns all primitives in the set that have RAW prefix.

Source Files

primitiveset.go

Version
v1.7.0 (latest)
Published
Aug 10, 2022
Platform
linux/amd64
Imports
3 packages
Last checked
3 months ago

Tools for package owners.