jwa

package
v0.0.62 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	HS256 = "HS256"
	HS384 = "HS384"
	HS512 = "HS512"
	RS256 = "RS256"
	RS384 = "RS384"
	RS512 = "RS512"
	ES256 = "ES256"
	ES384 = "ES384"
	ES512 = "ES512"
	PS256 = "PS256"
	PS384 = "PS384"
	PS512 = "PS512"
	None  = "none"
)

Variables

View Source
var (
	ErrInvalidKeyReceived          = errors.New("jwa: invalid key received")
	ErrFailedToVerifySignature     = errors.New("jwa: failed to verify signature")
	ErrAlgorithmNoneIsNotSupported = errors.New("jwa: algorithm 'none' is not supported")
	ErrNotImplemented              = errors.New("jwa: not implemented")
)

Functions

func DeregisterJWSAlgorithm added in v0.0.62

func DeregisterJWSAlgorithm(alg string)

func RegisterJWSAlgorithm

func RegisterJWSAlgorithm(alg string, jwsAlgorithm JWSAlgorithm)

func RegisterJWSAlgorithmFunc

func RegisterJWSAlgorithmFunc(alg string, sign SignFunc, verify VerifyFunc)

Types

type JWSAlgorithm

type JWSAlgorithm interface {
	Sign(key any, signingInput string) (signatureEncoded string, err error)
	Verify(key any, signingInput string, signatureEncoded string) (err error)
}

JWSAlgorithm

3.1. "alg" (Algorithm) Header Parameter Values for JWS

The table below is the set of "alg" (algorithm) Header Parameter
values defined by this specification for use with JWS, each of which
is explained in more detail in the following sections:

+--------------+-------------------------------+--------------------+
| "alg" Param  | Digital Signature or MAC      | Implementation     |
| Value        | Algorithm                     | Requirements       |
+--------------+-------------------------------+--------------------+
| HS256        | HMAC using SHA-256            | Required           |
| HS384        | HMAC using SHA-384            | Optional           |
| HS512        | HMAC using SHA-512            | Optional           |
| RS256        | RSASSA-PKCS1-v1_5 using       | Recommended        |
|              | SHA-256                       |                    |
| RS384        | RSASSA-PKCS1-v1_5 using       | Optional           |
|              | SHA-384                       |                    |
| RS512        | RSASSA-PKCS1-v1_5 using       | Optional           |
|              | SHA-512                       |                    |
| ES256        | ECDSA using P-256 and SHA-256 | Recommended+       |
| ES384        | ECDSA using P-384 and SHA-384 | Optional           |
| ES512        | ECDSA using P-521 and SHA-512 | Optional           |
| PS256        | RSASSA-PSS using SHA-256 and  | Optional           |
|              | MGF1 with SHA-256             |                    |
| PS384        | RSASSA-PSS using SHA-384 and  | Optional           |
|              | MGF1 with SHA-384             |                    |
| PS512        | RSASSA-PSS using SHA-512 and  | Optional           |
|              | MGF1 with SHA-512             |                    |
| none         | No digital signature or MAC   | Optional           |
|              | performed                     |                    |
+--------------+-------------------------------+--------------------+

The use of "+" in the Implementation Requirements column indicates
that the requirement strength is likely to be increased in a future
version of the specification.

See Appendix A.1 for a table cross-referencing the JWS digital
signature and MAC "alg" (algorithm) values defined in this
specification with the equivalent identifiers used by other standards
and software packages.

func JWS

func JWS(alg string) JWSAlgorithm

type JWSAlgorithmFunc added in v0.0.62

type JWSAlgorithmFunc struct {
	SignFunc   SignFunc
	VerifyFunc VerifyFunc
}

func (JWSAlgorithmFunc) Sign added in v0.0.62

func (alg JWSAlgorithmFunc) Sign(key any, signingInput string) (signatureEncoded string, err error)

func (JWSAlgorithmFunc) Verify added in v0.0.62

func (alg JWSAlgorithmFunc) Verify(key any, signingInput string, signatureEncoded string) (err error)

type SignFunc added in v0.0.62

type SignFunc func(key any, signingInput string) (signatureEncoded string, err error)

type VerifyFunc added in v0.0.62

type VerifyFunc func(key any, signingInput string, signatureEncoded string) (err error)

Jump to

Keyboard shortcuts

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