crypto

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package crypto implements security and crypto related functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sha1Hash

func Sha1Hash(value string) string

Sha1Hash returns a SHA1 hash for the given value.

func Sha512Hash

func Sha512Hash(value string) string

Sha512Hash returns a SHA512 hash for the given value.

func Sha512SaltedHash

func Sha512SaltedHash(value string, salt string) string

Sha512SaltedHash returns a SHA512 hash for the given value and salt.

Types

type HashAlgorithm added in v0.7.7

type HashAlgorithm string

HashAlgorithm used for the names of the supported hash algorithms.

const (
	SHA256 HashAlgorithm = "SHA256"
	SHA384 HashAlgorithm = "SHA384"
	SHA512 HashAlgorithm = "SHA512"
)

type KeyLoader added in v0.7.6

type KeyLoader interface {
	// LoadKeys returns a ManagedKey for a specific client and a bool indicating whether a key exists or not.
	LoadKeys(client *config.Client) (*ManagedKey, bool)
	ServerSecretLoader
}

KeyLoader defines how to get ManagedKey for a specific client.

type ManagedKey added in v0.7.6

type ManagedKey struct {
	Id            string
	Clients       []*config.Client
	Server        bool
	Key           *jwk.Key
	HashAlgorithm HashAlgorithm
}

ManagedKey defines a combination of keys defined for config.Client.

type ServerSecretLoader added in v0.7.6

type ServerSecretLoader interface {
	// GetServerKey returns the private key of the server.
	GetServerKey() jwt.SignEncryptParseOption
}

ServerSecretLoader defines how to receive a private server key.

func NewServerSecretLoader added in v0.7.6

func NewServerSecretLoader() ServerSecretLoader

NewServerSecretLoader creates a ServerSecretLoader based on the current config.Config.

type SigningPrivateKey

type SigningPrivateKey struct {
	PrivateKey         interface{}
	SignatureAlgorithm jwa.SignatureAlgorithm
	HashAlgorithm      HashAlgorithm
}

SigningPrivateKey defines a combination of private key, signing and hash algorithm.

func LoadPrivateKey

func LoadPrivateKey(filename string) (*SigningPrivateKey, error)

LoadPrivateKey loads a private key from a given filename.

Jump to

Keyboard shortcuts

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