encrypt

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AesJOSEEncryption

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

AesJOSEEncryption implements JOSEEncryptionProvider for AES based key algorithm

func (*AesJOSEEncryption) Decrypt

func (a *AesJOSEEncryption) Decrypt(encData string) ([]byte, error)

Decrypt implements JOSEDecrypter interface for AesJOSEEncryption

func (*AesJOSEEncryption) Encrypt

func (a *AesJOSEEncryption) Encrypt(bytes []byte) (string, error)

Encrypt implements JOSEEncrypter interface for AesJOSEEncryption

type JOSEDecrypter

type JOSEDecrypter interface {
	Decrypt(string) ([]byte, error)
}

JOSEDecrypter provides the necessary interface for a jose-decrypter implementation

type JOSEEncrypter

type JOSEEncrypter interface {
	Encrypt([]byte) (string, error)
}

JOSEEncrypter provides the necessary interface for a jose-encrypter implementation

type JOSEEncryptionProvider

type JOSEEncryptionProvider interface {
	JOSEEncrypter
	JOSEDecrypter
}

JOSEEncryptionProvider provides the complete interface necessary to manage JOSE encryption/decryption

func NewAesJOSEEncryption

func NewAesJOSEEncryption(keySource JOSEKeySource) (JOSEEncryptionProvider, error)

NewAesJOSEEncryption creates a new AES based JOSE encrypter

type JOSEKeyFileSource

type JOSEKeyFileSource struct {
	// KeysFilePath maintains the fil path that maintains the keys for encryption
	// Keys-file needs to maintain keys in this format {"activeKeyId":<>, keys:[{"kty":<>,"kid":<>,"k":<>,"alg":<>}]]}
	KeysFilePath string
	// JwkSet maintains all the keys configuration from key-file
	// and in a format that allows us to use jose's library functions effectively
	JwkSet JWKSet
}

JOSEKeyFileSource loads keys from a file

func (*JOSEKeyFileSource) GetActiveKey

func (js *JOSEKeyFileSource) GetActiveKey() jose.JSONWebKey

GetActiveKey loads the active key from the key source

func (*JOSEKeyFileSource) Init

func (js *JOSEKeyFileSource) Init() error

Init initializes and validates the key configuration TODO: Explore and add support for automatically initing once during Load function using sync.

func (*JOSEKeyFileSource) Load

func (js *JOSEKeyFileSource) Load(keyID string) (jose.JSONWebKey, error)

Load function loads a specific key-id details from that key source

type JOSEKeySource

type JOSEKeySource interface {
	// Init function should be called once to initialize based on the provided config
	// This is a good place to add any implementation specific validation
	Init() error
	// GetActiveKey returns the active key used for encryption
	GetActiveKey() jose.JSONWebKey
	// Load return the key looked up by keyID. This is particularly useful during decryption
	Load(keyID string) (jose.JSONWebKey, error)
}

JOSEKeySource is an interface that provides necessary interface to support fetching jose keys with the support for key rotation

type JWKSet

type JWKSet struct {
	ActiveKeyID string `json:"activeKeyId"`
	jose.JSONWebKeySet
}

JWKSet maintains all the keys configuration from key-file and in a format that allows us to use jose's library functions effectively

type Key

type Key struct {
	Kty string `json:"kty"`
	Kid string `json:"kid"`
	K   string `json:"k"`
	Alg string `json:"alg"`
}

type Keys

type Keys struct {
	ActiveKeyId string `json:"activeKeyId"`
	Keys        []Key  `json:"keys"`
}

Jump to

Keyboard shortcuts

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