Module github.com/bide-ai/bide/signer/azurekv
Go module github.com/bide-ai/bide/signer/azurekv; all modules.
signer/azurekv
github.com/bide-ai/bide/signer/azurekv · pkg.go.dev · Stability: core
Package azurekv is an audit.Signer whose ECDSA P-256 private key lives in Azure Key Vault or Azure Key Vault Managed HSM.
Constants
const DefaultTimeout = 30 * time.Second: DefaultTimeout bounds each Key Vault call when Config.Timeout is zero.
Variables
var ErrNoP256: ErrNoP256 means the key is not an ECDSA P-256 signing key: another key type, another curve, or a public point that is not on P-256.var ErrKeyUnusable: ErrKeyUnusable means the key cannot sign now: it is disabled, not yet valid, expired, or its key_ops lack "sign".var ErrNotHSM: ErrNotHSM means the key is software-protected and Config.AllowSoftwareKey is not set.var ErrExportable: ErrExportable means the key is marked exportable, so its private key can leave the service.var ErrKeyMismatch: ErrKeyMismatch means the service answered for a different key or version than the pinned one.
type API
go
type API interface {
GetKey(ctx context.Context, name string, version string, options *azkeys.GetKeyOptions) (azkeys.GetKeyResponse, error)
Sign(ctx context.Context, name string, version string, parameters azkeys.SignParameters, options *azkeys.SignOptions) (azkeys.SignResponse, error)
}API is the part of the azkeys client the signer uses.
type Config
go
type Config struct {
KeyID string
AllowSoftwareKey bool
HostSuffixes []string
Credential azcore.TokenCredential
Client API
Timeout time.Duration
Now func() time.Time
}Config selects the Key Vault key.
type Error
go
type Error struct {
Op string
Status int
Code string
// contains filtered or unexported fields
}Error is a failed Key Vault or credential call, reduced to what is safe to log: the operation, the HTTP status and Azure's error code.
Methods
func (e *Error) Error() string: Error describes the failure without any response content.func (e *Error) Unwrap() error: Unwrap returns context.DeadlineExceeded or context.Canceled for a timed-out or canceled call, and nil otherwise.
type Signer
go
type Signer struct {
// contains filtered or unexported fields
}Signer signs with an ECDSA P-256 Key Vault key.
Constructors and functions
func Open(ctx context.Context, cfg Config) (*Signer, error): Open reads and checks the pinned key (see the package comment) and signs once to prove the key and the caller's keys/sign permission.
Methods
func (s *Signer) Alg() audit.Alg: Alg reports the signature scheme, audit.AlgECDSAP256.func (s *Signer) Format(f fmt.State, _ rune): Format writes String for every verb.func (s *Signer) HSMProtected() bool: HSMProtected reports whether the key is HSM-protected (key type EC-HSM, and not hsmPlatform 0).func (s *Signer) KeyID() string: KeyID is the pinned key identifier, with its version.func (s *Signer) PublicKey() []byte: PublicKey returns the 65-byte uncompressed P-256 point, in the encoding audit.NewVerifier reads.func (s *Signer) Sign(message []byte) ([]byte, error): Sign returns the service's signature over the SHA-256 digest of message, as the canonical low-S r||s that audit verifies.func (s *Signer) String() string: String describes the signer by its key identity (audit.KeyID of the public key).