This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build
go build ./...
# Test all
go test ./...
# Run a single test
go test -run TestFunctionName ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
# Fuzz testing
go test -fuzz=FuzzXxx -fuzztime=30s ./...No Makefile — standard Go tooling only. Linting is not configured in CI; use go vet ./... locally.
This is a single-package library (github.com/yaronf/httpsign) implementing RFC 9421 (HTTP Message Signatures). All code lives in the root package with no sub-packages.
client.go / handler.go ← High-level HTTP integration (wrap http.Client / http.Handler)
│
signatures.go ← Mid-level API: SignRequest, SignResponse, VerifyRequest, VerifyResponse
│
message.go / httpparse.go ← RFC 9421 message canonicalization and signature base string construction
│
crypto.go / ecdsa.go ← Signer / Verifier types and algorithm implementations
│
fields.go / digest.go ← Component field abstraction + Content-Digest header support
Signer/Verifier(crypto.go) — hold algorithm, key, and signing config. Created viaNewXxxSigner/NewXxxVerifierconstructors (HMAC-SHA256, RSA, RSA-PSS, P-256, P-384, Ed25519, JWS).SignConfig/VerifyConfig(config.go) — builder-style configuration for signature metadata (keyID, nonce, tag, expiry, clock tolerance). Constructed viaNewSignConfig()/NewVerifyConfig()with method chaining.Fields(fields.go) — specifies which HTTP components (headers, derived components) to include in the signature. Use theFields("header1", "@method", ...)helper orNewFields()for complex cases.Message/MessageDetails(message.go) — internal canonicalized request/response representation.MessageDetailsis the public output ofRequestDetails/ResponseDetails.HandlerConfig/ClientConfig(config.go) — configures server-side and client-side HTTP wrappers.
The library supports both lestrrat-go/jwx/v2 (kept for backward compatibility) and lestrrat-go/jwx/v3 (recommended for new code). Use NewJWSSignerV3 / NewJWSVerifierV3 for new integrations.
digest.go provides GenerateContentDigestHeader and ValidateContentDigestHeader. When @content-digest is listed in Fields, the library automatically generates/validates the header. Supported schemes: sha-256, sha-512.
signatures_test.gocontains the full RFC 9421 test vector suite (134 KB) — do not modify without understanding the spec.fuzz_test.gohas fuzz entry points; seed corpus lives intestdata/fuzz/.http2_test.goandtrailer_test.gocover HTTP/2 and trailer-header edge cases.- Tests use
github.com/stretchr/testifyassertions andgithub.com/andreyvit/difffor readable diffs.
Accept-Signatureheader is unimplemented.- Response
Content-Typeis only signed when explicitly set on the response — this is intentional (more secure than net/http default behavior).