jwa

package
v0.0.60-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 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 DeleteJWSAlgorithm

func DeleteJWSAlgorithm(alg string)

func RegisterJWSAlgorithm

func RegisterJWSAlgorithm(alg string, jwsAlgorithm JWSAlgorithm)

func RegisterJWSAlgorithmFunc

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

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

Jump to

Keyboard shortcuts

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