Files
shankar0123 21aeed4f4e legal: addlicense headers + normalize legacy variants (Phase 0 RED-4)
Phase 0 closure (Path B2, post-rewrite):

addlicense sweep — adds the canonical certctl LLC copyright + BUSL-1.1
SPDX header to every production Go file. Template:

  // Copyright 2026 certctl LLC. All rights reserved.
  // SPDX-License-Identifier: BUSL-1.1

Coverage: 338 / 338 production Go files (cmd/ + internal/, excluding
*_test.go and **/testdata/**). Pre-sweep coverage was 22 / 338 (6.5%);
post-sweep is 338 / 338 (100%).

Normalized 22 pre-existing legacy headers (`// Copyright (c) certctl`
+ `// SPDX-License-Identifier: BSL-1.1`) and 1 file using a
`Certctl Contributors` attribution. The legacy SPDX ID `BSL-1.1`
is non-standard; the official SPDX identifier for Business Source
License 1.1 is `BUSL-1.1` (capital U). All 338 files now share the
canonical form.

Generated via:
  addlicense -c "certctl LLC" -y 2026 \
    -f cowork/legal/copyright-header.tpl \
    -ignore '**/testdata/**' -ignore '**/*_test.go' \
    cmd/ internal/

Verification:
  find cmd internal -name '*.go' -not -name '*_test.go' \
    -not -path '*/testdata/*' \
    -exec grep -L '^// Copyright 2026 certctl LLC' {} \; | wc -l

  Returns: 0

gofmt clean. Header additions are comments only, no compile impact.

Closes: cowork/certctl-architecture-diligence-audit.html#fix-RED-4
2026-05-13 21:23:35 +00:00

58 lines
2.5 KiB
Go

// Copyright 2026 certctl LLC. All rights reserved.
// SPDX-License-Identifier: BUSL-1.1
package signer
import "context"
// Driver knows how to materialize a Signer from some external reference
// (a file path, a PKCS#11 URI, a cloud KMS key ID, etc.) and how to
// generate a fresh key with a given algorithm.
//
// Drivers are responsible for any side-effect storage: FileDriver writes
// generated keys to disk via the keystore.ensureKeyDirSecure +
// keymem.marshalPrivateKeyAndZeroize discipline (injected via the
// FileDriver's hooks); future PKCS11Driver delegates key generation to
// the token; cloud-KMS drivers call the provider API.
//
// All Driver methods take a context.Context for cancellation/deadline
// propagation. Drivers MUST honor ctx.Done() for any I/O they perform;
// purely-in-memory drivers (MemoryDriver) may return immediately
// regardless of ctx state.
//
// Adding a new driver does NOT require changing this interface or any
// existing driver. The driver lives in its own package
// (internal/crypto/signer/<name>) and is constructed by a typed
// factory (e.g., pkcs11.New(config)).
type Driver interface {
// Load resolves an existing key from ref and returns a Signer.
// ref interpretation is driver-specific:
//
// - FileDriver: filesystem path to a PEM-encoded private key
// - PKCS11Driver (future): pkcs11: URI per RFC 7512
// - CloudKMSDriver (future): provider-specific resource name
//
// Drivers MUST NOT log the contents of the loaded key (only the
// ref + Algorithm). Callers wrap the returned Signer's Sign method
// in their own logging if they need per-signature audit trail.
Load(ctx context.Context, ref string) (Signer, error)
// Generate creates a new key with the given algorithm and persists
// it to driver-specific storage (or in-memory for MemoryDriver).
// Returns a Signer wrapping the new key plus a ref string the
// caller passes to a subsequent Load call (e.g., the file path
// for FileDriver, the PKCS#11 URI for PKCS11Driver).
//
// If alg is not in the supported enum, Generate returns
// ErrUnsupportedAlgorithm without side effects (no file written,
// no token slot consumed).
Generate(ctx context.Context, alg Algorithm) (Signer, string, error)
// Name returns a stable identifier for the driver type. Used in
// structured logs and (eventually) in CRL distribution-point URLs
// when the URL embeds the signer kind. MUST be a single
// lowercase token without spaces ("file", "memory", "pkcs11",
// "aws-kms", "gcp-kms", "azure-kv").
Name() string
}