types

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 12 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateHashFunction

func ValidateHashFunction(HashAlgorithm HashAlgorithm) bool

func ValidateMethod

func ValidateMethod(KeyType KeyType) bool

Types

type CryptoContext

type CryptoContext struct {
	Namespace string
	Group     string
	Context   context.Context
	Logger    CryptoLogger
	Engine    string
}

type CryptoContextError

type CryptoContextError struct {
	Err error
}

func (*CryptoContextError) Error

func (e *CryptoContextError) Error() string

type CryptoFilter

type CryptoFilter struct {
	Filter        regexp.Regexp
	CryptoContext CryptoContext
}

type CryptoHashParameter

type CryptoHashParameter struct {
	Identifier    CryptoIdentifier
	HashAlgorithm HashAlgorithm
}

type CryptoIdentifier

type CryptoIdentifier struct {
	KeyId         string
	CryptoContext CryptoContext
}

type CryptoKey

type CryptoKey struct {
	Key     []byte //pem format expected in case of key pair
	Version string
	CryptoKeyParameter
}

func (CryptoKey) GetJwk

func (key CryptoKey) GetJwk() (jwk.Key, error)

func (CryptoKey) GetPem

func (key CryptoKey) GetPem() (p *pem.Block, err error)

type CryptoKeyParameter

type CryptoKeyParameter struct {
	Identifier CryptoIdentifier
	KeyType    KeyType
	Params     json.RawMessage
}

type CryptoKeySet

type CryptoKeySet struct {
	Keys []CryptoKey
}

type CryptoLogLevel

type CryptoLogLevel string
const (
	DEBUG CryptoLogLevel = "DEBUG"
	INFO  CryptoLogLevel = "INFO"
	FATAL CryptoLogLevel = "FATAL"
	LOG   CryptoLogLevel = "LOG"
)

type CryptoLogger

type CryptoLogger interface {
	Log(level CryptoLogLevel, msg string, err error)
}

type CryptoProvider

type CryptoProvider interface {
	/*
		Crypto Context Creation Methods. Create the context before any other method.
	*/
	CreateCryptoContext(context CryptoContext) error
	DestroyCryptoContext(context CryptoContext) error
	IsCryptoContextExisting(context CryptoContext) (bool, error)

	/*
		Methods which are just working with created Crypto Context. Ensure that the existing context is checked before execute operations.
	*/
	GetNamespaces(context CryptoContext) ([]string, error)
	GenerateRandom(context CryptoContext, number int) ([]byte, error)
	Hash(parameter CryptoHashParameter, msg []byte) ([]byte, error)
	Encrypt(parameter CryptoIdentifier, data []byte) ([]byte, error)
	Decrypt(parameter CryptoIdentifier, data []byte) ([]byte, error)
	Sign(parameter CryptoIdentifier, data []byte) ([]byte, error)
	GetKeys(parameter CryptoFilter) (*CryptoKeySet, error)
	GetKey(parameter CryptoIdentifier) (*CryptoKey, error)
	Verify(parameter CryptoIdentifier, data []byte, signature []byte) (bool, error)
	GenerateKey(parameter CryptoKeyParameter) error
	IsKeyExisting(parameter CryptoIdentifier) (bool, error)
	DeleteKey(parameter CryptoIdentifier) error
	RotateKey(parameter CryptoIdentifier) error
	GetSupportedKeysAlgs() []KeyType
	GetSupportedHashAlgs() []HashAlgorithm
}

Crypto Provider Interface Behavior:

1. Crypto Context must be created before use of any function. Funcs must return CryptoContext Error, when Context not initialized. 2. Crypto Context should be destroyed when Context is not more required.

type CryptoProviderModule

type CryptoProviderModule interface {
	GetCryptoProvider() CryptoProvider
}

type HashAlgorithm

type HashAlgorithm string
const (
	Sha2224 HashAlgorithm = "sha2-224"
	Sha2256 HashAlgorithm = "sha2-256"
	Sha2384 HashAlgorithm = "sha2-384"
	Sha2512 HashAlgorithm = "sha2-512"
	Sha3224 HashAlgorithm = "sha3-224"
	Sha3256 HashAlgorithm = "sha3-256"
	Sha3384 HashAlgorithm = "sha3-384"
	Sha3512 HashAlgorithm = "sha3-512"
)

type KeyType

type KeyType string
const (
	Aes256GCM KeyType = "aes256-gcm96"
	Ed25519   KeyType = "ed25519"
	Ecdsap256 KeyType = "ecdsa-p256"
	Ecdsap384 KeyType = "ecdsa-p384"
	Ecdsap521 KeyType = "ecdsa-p521"
	Rsa2048   KeyType = "rsa-2048"
	Rsa3072   KeyType = "rsa-3072"
	Rsa4096   KeyType = "rsa-4096"
	KeyValue  KeyType = "keyValue"
)

Jump to

Keyboard shortcuts

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