Skip to content

Module github.com/bide-ai/bide/signer/awskms ​

Go module github.com/bide-ai/bide/signer/awskms; all modules.

signer/awskms ​

github.com/bide-ai/bide/signer/awskms · pkg.go.dev · Stability: core

Package awskms is an audit.Signer whose Ed25519 or ECDSA P-256 private key lives in AWS KMS.

Constants

  • const DefaultTimeout = 30 * time.Second: DefaultTimeout bounds each KMS call when Config.Timeout is zero.
  • const MaxMessageSize = 4096: MaxMessageSize is the longest message KMS signs (the raw-message limit of kms:Sign).

Variables

  • var ErrNoEd25519: ErrNoEd25519 means Config.Scheme is Ed25519 and the KMS key is not an Ed25519 signing key.
  • var ErrNoP256: ErrNoP256 means Config.Scheme is audit.AlgECDSAP256 and the KMS key is not an ECDSA P-256 signing key.
  • var ErrMessageTooLarge: ErrMessageTooLarge means the message is longer than KMS signs (MaxMessageSize).

type API ​

go
type API interface {
	GetPublicKey(ctx context.Context, in *kms.GetPublicKeyInput, optFns ...func(*kms.Options)) (*kms.GetPublicKeyOutput, error)
	Sign(ctx context.Context, in *kms.SignInput, optFns ...func(*kms.Options)) (*kms.SignOutput, error)
}

API is the part of the KMS client the signer uses.

type Config ​

go
type Config struct {
	Client API

	KeyID string

	Scheme audit.Alg

	Timeout time.Duration

	GrantTokens []string
}

Config selects the KMS key.

type Signer ​

go
type Signer struct {
	// contains filtered or unexported fields
}

Signer signs with an Ed25519 or ECDSA P-256 KMS key (see Config.Scheme).

Constructors and functions

  • func Open(ctx context.Context, cfg Config) (*Signer, error): Open resolves the key, checks that it is a signing key of Config.Scheme, reads its public key, and signs once to prove the key and the caller's kms:Sign permission.

Methods

  • func (s *Signer) Alg() audit.Alg: Alg reports the signature scheme (Config.Scheme, audit.AlgEd25519 by default).
  • func (s *Signer) Format(f fmt.State, _ rune): Format writes String for every verb.
  • func (s *Signer) KeyARN() string: KeyARN is the ARN of the KMS key the signer signs with.
  • func (s *Signer) PublicKey() []byte: PublicKey returns the public key of the KMS key (32 bytes for Ed25519, the 65-byte uncompressed point for P-256), in the encoding audit.NewVerifier reads.
  • func (s *Signer) Sign(message []byte) ([]byte, error): Sign returns KMS's signature over message in the encoding audit verifies.
  • func (s *Signer) String() string: String describes the signer by its key identity (audit.KeyID of the public key).

Apache-2.0 licensed.