Documentation ¶
Index ¶
- Variables
- type AcceptSignatureBuilder
- type AcceptSignatureOption
- func WithContentDigestAlgorithmPreferences(prefs ...AlgorithmPreference) AcceptSignatureOption
- func WithExpectedComponents(identifiers ...string) AcceptSignatureOption
- func WithExpectedCreatedTimestamp(flag bool) AcceptSignatureOption
- func WithExpectedExpiresTimestamp(flag bool) AcceptSignatureOption
- func WithExpectedKey(key Key) AcceptSignatureOption
- func WithExpectedLabel(label string) AcceptSignatureOption
- func WithExpectedNonce(ng NonceGetter) AcceptSignatureOption
- func WithExpectedTag(tag string) AcceptSignatureOption
- type AlgorithmPreference
- type DigestAlgorithm
- type Key
- type KeyResolver
- type Message
- type NoApplicableSignatureError
- type NonceChecker
- type NonceCheckerFunc
- type NonceGetter
- type NonceGetterFunc
- type SignatureAlgorithm
- type SignatureNegotiationOption
- type SignatureParameter
- type Signer
- type SignerOption
- type Verifier
- type VerifierOption
- func WithCreatedTimestampRequired(flag bool) VerifierOption
- func WithExpiredTimestampRequired(flag bool) VerifierOption
- func WithMaxAge(d time.Duration) VerifierOption
- func WithNonceChecker(checker NonceChecker) VerifierOption
- func WithRequiredComponents(identifiers ...string) VerifierOption
- func WithRequiredTag(tag string, opts ...VerifierOption) VerifierOption
- func WithSignatureNegotiation(opts ...SignatureNegotiationOption) VerifierOption
- func WithValidateAllSignatures() VerifierOption
- func WithValidityTolerance(d time.Duration) VerifierOption
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedKeyType = errors.New("unsupported key type/format") ErrUnsupportedAlgorithm = errors.New("unknown/unsupported algorithm") ErrInvalidKeySize = errors.New("invalid key size") ErrNoKeyProvided = errors.New("no key provided") ErrInvalidSignature = errors.New("invalid signature") ErrVerificationFailed = errors.New("verification failed") ErrContentDigestMismatch = errors.New("content digest mismatch") ErrMalformedData = errors.New("malformed data") ErrUnsupportedComponentIdentifier = errors.New("unsupported component identifier") ErrInvalidComponentIdentifier = errors.New("invalid component identifier") ErrCanonicalization = errors.New("failed to canonicalize component") ErrMalformedSignatureParameter = errors.New("malformed signature parameter") ErrNoApplicableDigestFound = errors.New("no applicable digest found") ErrVerifierCreation = errors.New("verifier creation failed") ErrParameter = errors.New("parameter error") ErrValidity = errors.New("validity error") ErrMissingParameter = errors.New("missing parameter error") ErrSignatureNegotiationError = errors.New("signature negotiation error") )
Functions ¶
This section is empty.
Types ¶
type AcceptSignatureBuilder ¶
type AcceptSignatureBuilder struct {
// contains filtered or unexported fields
}
func NewAcceptSignature ¶
func NewAcceptSignature(opts ...AcceptSignatureOption) (*AcceptSignatureBuilder, error)
type AcceptSignatureOption ¶
type AcceptSignatureOption func(*AcceptSignatureBuilder) error
func WithContentDigestAlgorithmPreferences ¶
func WithContentDigestAlgorithmPreferences(prefs ...AlgorithmPreference) AcceptSignatureOption
func WithExpectedComponents ¶
func WithExpectedComponents(identifiers ...string) AcceptSignatureOption
func WithExpectedCreatedTimestamp ¶
func WithExpectedCreatedTimestamp(flag bool) AcceptSignatureOption
func WithExpectedExpiresTimestamp ¶
func WithExpectedExpiresTimestamp(flag bool) AcceptSignatureOption
func WithExpectedKey ¶
func WithExpectedKey(key Key) AcceptSignatureOption
func WithExpectedLabel ¶
func WithExpectedLabel(label string) AcceptSignatureOption
func WithExpectedNonce ¶
func WithExpectedNonce(ng NonceGetter) AcceptSignatureOption
func WithExpectedTag ¶
func WithExpectedTag(tag string) AcceptSignatureOption
type AlgorithmPreference ¶
type AlgorithmPreference struct { Algorithm DigestAlgorithm Preference int }
func (AlgorithmPreference) String ¶
func (p AlgorithmPreference) String() string
type DigestAlgorithm ¶
type DigestAlgorithm string
DigestAlgorithm is the digest algorithm to use. Available algorithms are: - SHA-256 (sha-256). - SHA-512 (sha-512).
const ( Sha256 DigestAlgorithm = "sha-256" Sha512 DigestAlgorithm = "sha-512" )
type Key ¶
type Key struct { // KeyID is the identifier of the key. KeyID string // Algorithm is the cryptographic algorithm to use with the key. Algorithm SignatureAlgorithm // Key is the actual key material, like public, private or a secret key. Key any }
Key is the key to use for signing or verifying.
type KeyResolver ¶
KeyResolver is used to resolve a key id to a verifying key.
type Message ¶
type Message struct { Context context.Context //nolint: containedctx Method string Authority string URL *url.URL Header http.Header Body func() (io.ReadCloser, error) RequestHeader http.Header RequestBody func() (io.ReadCloser, error) StatusCode int IsRequest bool }
Message is a representation of an HTTP request or response, containing the values needed to construct or validate a signature.
func MessageForResponse ¶
func MessageFromRequest ¶
func MessageFromResponse ¶
type NoApplicableSignatureError ¶
type NoApplicableSignatureError struct {
// contains filtered or unexported fields
}
func (*NoApplicableSignatureError) Error ¶
func (e *NoApplicableSignatureError) Error() string
func (*NoApplicableSignatureError) Is ¶
func (e *NoApplicableSignatureError) Is(err error) bool
func (*NoApplicableSignatureError) Negotiate ¶
func (e *NoApplicableSignatureError) Negotiate(header http.Header)
type NonceChecker ¶
NonceChecker is responsible for the verification of the nonce received in a signature, e.g. to prevent replay attacks, or to verify that the nonce is the expected one, like if requested using the Accept-Signature header.
type NonceCheckerFunc ¶
type NonceGetter ¶
NonceGetter represents a source of random nonces to go into resulting objects.
type NonceGetterFunc ¶
type SignatureAlgorithm ¶
type SignatureAlgorithm string
SignatureAlgorithm is the signature algorithm to use. Available algorithms are: - RSASSA-PKCS1-v1_5 using SHA-256 (rsa-v1_5-sha256). - RSASSA-PSS using SHA-512 (rsa-pss-sha512). - ECDSA using curve P-256 DSS and SHA-256 (ecdsa-p256-sha256). - ECDSA using curve P-384 DSS and SHA-384 (ecdsa-p384-sha384). - EdDSA using curve edwards25519 (ed25519). - HMAC using SHA-256 (hmac-sha256).
const ( RsaPkcs1v15Sha256 SignatureAlgorithm = "rsa-v1_5-sha256" RsaPkcs1v15Sha384 SignatureAlgorithm = "rsa-v1_5-sha384" RsaPkcs1v15Sha512 SignatureAlgorithm = "rsa-v1_5-sha512" RsaPssSha256 SignatureAlgorithm = "rsa-pss-sha256" RsaPssSha384 SignatureAlgorithm = "rsa-pss-sha384" RsaPssSha512 SignatureAlgorithm = "rsa-pss-sha512" EcdsaP256Sha256 SignatureAlgorithm = "ecdsa-p256-sha256" EcdsaP384Sha384 SignatureAlgorithm = "ecdsa-p384-sha384" EcdsaP521Sha512 SignatureAlgorithm = "ecdsa-p521-sha512" Ed25519 SignatureAlgorithm = "ed25519" HmacSha256 SignatureAlgorithm = "hmac-sha256" HmacSha384 SignatureAlgorithm = "hmac-sha384" HmacSha512 SignatureAlgorithm = "hmac-sha512" )
type SignatureNegotiationOption ¶
type SignatureNegotiationOption func(sno *sigNegotiationOpts)
func WithRequestedContentDigestAlgorithmPreferences ¶
func WithRequestedContentDigestAlgorithmPreferences(prefs ...AlgorithmPreference) SignatureNegotiationOption
func WithRequestedKey ¶
func WithRequestedKey(key Key) SignatureNegotiationOption
func WithRequestedLabel ¶
func WithRequestedLabel(label string) SignatureNegotiationOption
func WithRequestedNonce ¶
func WithRequestedNonce(ng NonceGetter) SignatureNegotiationOption
type SignatureParameter ¶
type SignatureParameter string
const ( KeyID SignatureParameter = "keyid" Alg SignatureParameter = "alg" Created SignatureParameter = "created" Expires SignatureParameter = "expires" Nonce SignatureParameter = "nonce" Tag SignatureParameter = "tag" )
type SignerOption ¶
type SignerOption func(s *signer) error
func WithComponents ¶
func WithComponents(identifiers ...string) SignerOption
WithComponents sets the HTTP fields / derived component names to be included in signing.
func WithContentDigestAlgorithm ¶
func WithContentDigestAlgorithm(alg DigestAlgorithm) SignerOption
func WithLabel ¶
func WithLabel(label string) SignerOption
WithLabel sets the label of the signature in the Signature-Input and Signature headers.
func WithNonce ¶
func WithNonce(ng NonceGetter) SignerOption
func WithTTL ¶
func WithTTL(ttl time.Duration) SignerOption
func WithTag ¶
func WithTag(tag string) SignerOption
type Verifier ¶
func NewVerifier ¶
func NewVerifier(resolver KeyResolver, opts ...VerifierOption) (Verifier, error)
NewVerifier creates a new verifier with the given options.
type VerifierOption ¶
func WithCreatedTimestampRequired ¶
func WithCreatedTimestampRequired(flag bool) VerifierOption
func WithExpiredTimestampRequired ¶
func WithExpiredTimestampRequired(flag bool) VerifierOption
func WithMaxAge ¶
func WithMaxAge(d time.Duration) VerifierOption
func WithNonceChecker ¶
func WithNonceChecker(checker NonceChecker) VerifierOption
func WithRequiredComponents ¶
func WithRequiredComponents(identifiers ...string) VerifierOption
WithRequiredComponents sets the HTTP fields / derived component names to be included in signing.
func WithRequiredTag ¶
func WithRequiredTag(tag string, opts ...VerifierOption) VerifierOption
func WithSignatureNegotiation ¶
func WithSignatureNegotiation(opts ...SignatureNegotiationOption) VerifierOption
func WithValidateAllSignatures ¶
func WithValidateAllSignatures() VerifierOption
func WithValidityTolerance ¶
func WithValidityTolerance(d time.Duration) VerifierOption
WithValidityTolerance sets the clock tolerance for verifying created and expires times.