util

package
v0.0.0-...-89805ac Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Argon2SaltSize represents the recommended salt size for argon2, which is 16 bytes
	// https://tools.ietf.org/id/draft-irtf-cfrg-argon2-05.html#rfc.section.3.1
	Argon2SaltSize = 16
)

Variables

This section is empty.

Functions

func Argon2KeyGen

func Argon2KeyGen(password string, salt []byte, keyLen int) ([]byte, error)

Argon2KeyGen returns an encoded string generation of a key generated using the go crypto argon2 impl specifically, the Argon2id version, a "hybrid version of Argon2 combining Argon2i and Argon2d."

func GenerateSalt

func GenerateSalt(size int) ([]byte, error)

GenerateSalt generates a random salt value for a given size

func GetKeyIDFromJWT

func GetKeyIDFromJWT(token keyaccess.JWT) (string, error)

func GetMethodForDID

func GetMethodForDID(did string) (string, error)

GetMethodForDID gets a DID method from a did, the second part of the did (e.g. did:test:abcd, the method is 'test')

func LoggingError

func LoggingError(err error) error

LoggingError is a utility to combine logging an error, and returning and error

func LoggingErrorMsg

func LoggingErrorMsg(err error, msg string) error

LoggingErrorMsg is a utility to combine logging an error, and returning and error with a message

func LoggingErrorMsgf

func LoggingErrorMsgf(err error, msg string, args ...any) error

LoggingErrorMsgf is a utility to combine logging an error, and returning and error with a formatted message

func LoggingNewError

func LoggingNewError(msg string) error

LoggingNewError is a utility to create an error from a message, log it, and return it as an error

func LoggingNewErrorf

func LoggingNewErrorf(msg string, args ...any) error

LoggingNewErrorf is a utility to create an error from a formatted message, log it, and return it as an error

func ParseJWT

func ParseJWT(token keyaccess.JWT) (*jws.Signature, jwt.Token, error)

ParseJWT parses a JWT token and returns the jws signature and jwt claims

func SanitizeLog

func SanitizeLog(log string) string

SanitizeLog prevents certain classes of injection attacks before logging https://codeql.github.com/codeql-query-help/go/go-log-injection/

func XChaCha20Poly1305Decrypt

func XChaCha20Poly1305Decrypt(key, data []byte) ([]byte, error)

XChaCha20Poly1305Decrypt takes a 32 byte key and uses XChaCha20-Poly1305 to decrypt a piece of data

func XChaCha20Poly1305Encrypt

func XChaCha20Poly1305Encrypt(key, data []byte) ([]byte, error)

XChaCha20Poly1305Encrypt takes a 32 byte key and uses XChaCha20-Poly1305 to encrypt a piece of data

Types

This section is empty.

Jump to

Keyboard shortcuts

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