algorithms

package
v0.0.0-...-c26a47f Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ECDSA_SHA256 = "ES256"
	ECDSA_SHA384 = "ES384"
	ECDSA_SHA512 = "ES512"
	EC256_KEYSZ  = 32 // 256 bits = 32 bytes
	EC348_KEYSZ  = 48 // 384 bits = 48 bytes
	EC512_KEYSZ  = 66 // 521 bits ~ 66 bytes
)
View Source
const (
	HMAC_SHA256 = "HS256"
	HMAC_SHA384 = "HS384"
	HMAC_SHA512 = "HS512"
)
View Source
const (
	RSA_SHA256 = "RS256"
	RSA_SHA384 = "RS384"
	RSA_SHA512 = "RS512"
)
View Source
const (
	RSAPSS_SHA256 = "PS256"
	RSAPSS_SHA384 = "PS384"
	RSAPSS_SHA512 = "PS512"
)

Variables

View Source
var (
	ErrInvalidKeyType   = errors.New("invalid key type")
	ErrInvalidSignature = errors.New("invalid signature for given key")
	ErrSignatureLength  = errors.New("invalid signature length")
	ErrNoneKey          = errors.New("\"none\" algorithm cannot use key")
)

List of possible errors.

View Source
var (
	AlgorithmEC256 = &ecdsaAlg{
		algorithm: algorithm{name: ECDSA_SHA256, hash: crypto.SHA256},
		keysz:     EC256_KEYSZ,
		curve:     elliptic.P256(),
	}
	AlgorithmEC384 = &ecdsaAlg{
		algorithm: algorithm{name: ECDSA_SHA384, hash: crypto.SHA384},
		keysz:     EC348_KEYSZ,
		curve:     elliptic.P384(),
	}
	AlgorithmEC512 = &ecdsaAlg{
		algorithm: algorithm{name: ECDSA_SHA512, hash: crypto.SHA512},
		keysz:     EC512_KEYSZ,
		curve:     elliptic.P521(),
	}
)

List of ECDSA algorithms.

View Source
var (
	AlgorithmHS256 = &hmacAlg{name: HMAC_SHA256, hash: crypto.SHA256}
	AlgorithmHS384 = &hmacAlg{name: HMAC_SHA384, hash: crypto.SHA384}
	AlgorithmHS512 = &hmacAlg{name: HMAC_SHA512, hash: crypto.SHA512}
)

List of HMAC algorithms.

View Source
var (
	AlgorithmRS256 = &rsaAlg{name: RSA_SHA256, hash: crypto.SHA256}
	AlgorithmRS384 = &rsaAlg{name: RSA_SHA384, hash: crypto.SHA384}
	AlgorithmRS512 = &rsaAlg{name: RSA_SHA512, hash: crypto.SHA512}
)

List of RSA algorithms.

View Source
var (
	AlgorithmPS256 = rsapssAlg{

		Options: &rsa.PSSOptions{
			SaltLength: rsa.PSSSaltLengthAuto,
			Hash:       crypto.SHA256,
		},
		// contains filtered or unexported fields
	}
	AlgorithmPS384 = rsapssAlg{

		Options: &rsa.PSSOptions{
			SaltLength: rsa.PSSSaltLengthAuto,
			Hash:       crypto.SHA384,
		},
		// contains filtered or unexported fields
	}
	AlgorithmPS512 = rsapssAlg{

		Options: &rsa.PSSOptions{
			SaltLength: rsa.PSSSaltLengthAuto,
			Hash:       crypto.SHA512,
		},
		// contains filtered or unexported fields
	}
)

List of RSA PSS algorithms.

View Source
var (
	AlgorithmNone = &noneAlg{name: "none"}
)

List of "none" algorithms.

Functions

This section is empty.

Types

type SigningAlgorithm

type SigningAlgorithm interface {
	Sign(data string, key []byte) ([]byte, error)
	Valid(data string, signature, key []byte) error
	Name() string
}

SigningAlgorithm represents the interface to an algorithm for signing JWTs.

Jump to

Keyboard shortcuts

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