Documentation
¶
Overview ¶
Package jws signs and verifies detached-payload JWS (RFC 7515) signatures. It is payload-agnostic: callers decide what bytes get signed. Like client/utils/cosign, it lives outside api/*, which is proto types and data-shape glue only, never crypto libraries or I/O.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PublicKeyFromJWK ¶
PublicKeyFromJWK returns the signature-verification public key of key, skipping encryption-only keys and keys ToPublicKey rejects.
func Sign ¶
Sign produces a detached-payload JWS (RFC 7515) compact serialization over payload, using signer's own public key type to select the algorithm.
func ToPublicKey ¶
ToPublicKey returns v as a public key this package can verify with, or false for anything else (unsupported type, curve, or a too-small RSA key). Value-typed keys are returned as pointers.
func Verify ¶
Verify verifies a detached-payload JWS compact serialization signature over payload and succeeds if any of keys validates it. Each key's algorithm is derived from the key's own type (see jwsAlgorithmFor), not from the JWS's self-declared "alg" header. A key that can't be used (unsupported type) doesn't stop the remaining keys from being tried.
Types ¶
type KeySigner ¶
type KeySigner struct {
// contains filtered or unexported fields
}
KeySigner signs with a PEM-encoded private key (EC, RSA, or Ed25519), optionally password-protected.
func NewKeySigner ¶
NewKeySigner loads a PEM-encoded private key (EC PRIVATE KEY, RSA PRIVATE KEY, PKCS8 PRIVATE KEY, or a password-protected ENCRYPTED PRIVATE KEY; the PKCS8 forms also cover Ed25519). password is only used for an encrypted key and is ignored otherwise; pass nil for an unencrypted key.
type Signer ¶
type Signer interface {
Sign(payload []byte) (jwsCompact string, err error)
// Public returns the public key matching the signing key.
Public() crypto.PublicKey
}
Signer produces a detached-payload JWS (RFC 7515) compact serialization over payload, using key material supplied at construction time.