Documentation ¶
Index ¶
- Constants
- Variables
- func WithAlg(alg bool) func(s *sigOptions)
- func WithCoveredComponents(components ...string) func(s *sigOptions)
- func WithCreated(b bool) func(s *sigOptions)
- func WithMaxAge(duration time.Duration) func(s *sigOptions)
- func WithNoCoveredComponents() func(s *sigOptions)
- func WithNonce(nonce bool) func(s *sigOptions)
- func WithSigNamer(namer func() string) func(s *sigOptions)
- type AlgorithmName
- type Signer
- type SignerOption
- type SigningAlgorithm
- type Verifier
- type VerifyingAlgorithm
Constants ¶
View Source
const ( SignatureInputHeaderName = "Signature-Input" SignatureHeaderName = "Signature" DigestHeaderName = "Digest" )
Variables ¶
View Source
var ( ErrorUnknownAlgorithm = errors.New("algorithm name not in HTTP Signature Algorithms Registry") ErrorAlgorithmKeyMismatch = errors.New("wrong private key type for specified algorithm") ErrorEmptyKeyId = errors.New("expected a non-empty key ID") ErrorUnknownKeyId = errors.New("key ID provided, but key lookup failed") ErrorInvalidSigLength = errors.New("the base64-decoded signature has an unexpected length") ErrorUnsupportedDigestAlgorithm = errors.New("a digest header was found, but it didn't contain a digest in a supported algorithm") ErrorMissingSig = errors.New("missing 'Signature' header") ErrorMalformedSigInput = errors.New("malformed 'Signature-Input' header") ErrorMalformedSig = errors.New("malformed 'Signature' header") ErrorMissingSigParamsValue = errors.New("missing expected params for sigid in 'Signature-Input' header") ErrorVerifyFailed = errors.New("failed to verify signature") ErrorDigestMismatch = errors.New("failed to verify content hash in 'Digest' header") )
Functions ¶
func WithCoveredComponents ¶
func WithCoveredComponents(components ...string) func(s *sigOptions)
func WithCreated ¶
func WithCreated(b bool) func(s *sigOptions)
WithCreated ensures that signatures created by a Signer with this option set have a created signature parameter.
func WithMaxAge ¶
func WithNoCoveredComponents ¶
func WithNoCoveredComponents() func(s *sigOptions)
func WithSigNamer ¶
func WithSigNamer(namer func() string) func(s *sigOptions)
Types ¶
type AlgorithmName ¶
type AlgorithmName string
const ( AlgorithmRsaPssSha512 AlgorithmName = "rsa-pss-sha512" AlgorithmRsaV15Sha256 AlgorithmName = "rsa-v1_5-sha256" AlgorithmEcdsaP256Sha256 AlgorithmName = "ecdsa-p256-sha256" AlgorithmHmacSha256 AlgorithmName = "hmac-sha256" AlgorithmEd25519 AlgorithmName = "ed25519" )
type Signer ¶
type Signer interface { Sign(req *http.Request) error SignResponse(ctx context.Context, resp *http.Response) error }
Signer objects sign HTTP requests.
func NewSigner ¶
func NewSigner(alg SigningAlgorithm, opts ...SignerOption) (Signer, error)
NewSigner returns a Signer that can be used to create and attach HTTP message signatures to http.Request and http.Response structs.
type SignerOption ¶
type SignerOption func(options *sigOptions)
type SigningAlgorithm ¶
type SigningAlgorithm interface { KeyId() string AlgName() AlgorithmName Sign(input []byte) ([]byte, error) }
func NewAsymmetricSigningAlgorithm ¶
func NewAsymmetricSigningAlgorithm(algName AlgorithmName, privKey crypto.Signer, keyId string) (SigningAlgorithm, error)
func NewHmacSha256SigningAlgorithm ¶
func NewHmacSha256SigningAlgorithm(key []byte, keyId string) (SigningAlgorithm, error)
type Verifier ¶
type Verifier interface { Verify(req *http.Request, body []byte) error VerifyResponse(ctx context.Context, resp *http.Response, body []byte) error }
func NewVerifier ¶
func NewVerifier(algFinder func(ctx context.Context, keyName string, headers http.Header) (VerifyingAlgorithm, bool), opts ...SignerOption) (Verifier, error)
NewVerifier creates a Verifier instance to verify HTTP Message Signatures and is safe for concurrent use from multiple goroutines. It is intended that you create a single Verifier instance and reuse it across messages. The algFinder parameter is called by the Verifier to find a public key to verify the request with - the header parameter to algFinder MUST NOT be modified.
type VerifyingAlgorithm ¶
type VerifyingAlgorithm interface { KeyId() string AlgName() AlgorithmName Verify(input, sig []byte) (bool, error) }
func NewAsymmetricVerifyingAlgorithm ¶
func NewAsymmetricVerifyingAlgorithm(algName AlgorithmName, pubKey crypto.PublicKey, keyId string) (VerifyingAlgorithm, error)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package component contains constants defined in section 2.3: Specialty Components.
|
Package component contains constants defined in section 2.3: Specialty Components. |
internal
|
|
Click to show internal directories.
Click to hide internal directories.