nacl

package
v0.9.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncPrefix = "ACORNENC:"
	EncSuffix = "::"
)

Variables

This section is empty.

Functions

func DecryptNamespacedData

func DecryptNamespacedData(ctx context.Context, c kclient.Reader, data []byte, namespace string) ([]byte, error)

func DecryptNamespacedDataMap

func DecryptNamespacedDataMap(ctx context.Context, c kclient.Reader, data map[string][]byte, ownerNamespace string) (map[string][]byte, error)

func ErrNamespaceKeyNotFound

func ErrNamespaceKeyNotFound(err error) bool

func GetPublicKey

func GetPublicKey(ctx context.Context, c kclient.Reader, namespace string) (string, error)

func IsAcornEncryptedData

func IsAcornEncryptedData(data []byte) bool

func KeyBytesToB64String

func KeyBytesToB64String(key *[32]byte) string

func NewErrKeyNotFound

func NewErrKeyNotFound(ns bool) error

Types

type EncryptedData

type EncryptedData struct {
	PublicKey        string `json:"publicKey"`
	EncryptedContent string `json:"encryptedContent"`
}

func Encrypt

func Encrypt(msg, recipientPublicKey string) (*EncryptedData, error)

func (*EncryptedData) Marshal

func (f *EncryptedData) Marshal() (string, error)

type ErrDecryptionKeyNotAvailable

type ErrDecryptionKeyNotAvailable struct{}

func (*ErrDecryptionKeyNotAvailable) Error

type ErrKeyNotFound

type ErrKeyNotFound struct {
	NamespaceKeyNotFound bool
}

func (*ErrKeyNotFound) Error

func (k *ErrKeyNotFound) Error() string

type ErrUnableToDecrypt

type ErrUnableToDecrypt struct {
	Errs []error
}

func (*ErrUnableToDecrypt) Error

func (utd *ErrUnableToDecrypt) Error() string

type MultiEncryptedData

type MultiEncryptedData map[string]string

func MultipleKeyEncrypt

func MultipleKeyEncrypt(msg string, keys []string) (MultiEncryptedData, error)

func (MultiEncryptedData) Marshal

func (f MultiEncryptedData) Marshal() (string, error)

type NaclKey

type NaclKey struct {
	AcornNamespace string
	Primary        *bool
	PublicKey      *[32]byte
	// contains filtered or unexported fields
}

func GetOrCreatePrimaryNaclKey

func GetOrCreatePrimaryNaclKey(ctx context.Context, c kclient.Client, namespace string) (*NaclKey, error)

func GetPrimaryNaclKey

func GetPrimaryNaclKey(ctx context.Context, c kclient.Reader, publicKey, namespace string) (*NaclKey, error)

func (*NaclKey) Decrypt

func (k *NaclKey) Decrypt(encData []byte) ([]byte, error)

type NaclKeys

type NaclKeys map[string]*NaclKey

func GetAllNaclKeys

func GetAllNaclKeys(ctx context.Context, c kclient.Reader, namespace string) (NaclKeys, error)

Jump to

Keyboard shortcuts

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