Documentation ¶
Index ¶
- Constants
- Variables
- type BuildInfo
- type Enclave
- func (e *Enclave) Admin(ctx context.Context) (kes.Identity, error)
- func (e *Enclave) AssignPolicy(ctx context.Context, policy string, identity kes.Identity) error
- func (e *Enclave) CreateKey(ctx context.Context, name string, key key.Key) error
- func (e *Enclave) DeleteIdentity(ctx context.Context, identity kes.Identity) error
- func (e *Enclave) DeleteKey(ctx context.Context, name string) error
- func (e *Enclave) DeletePolicy(ctx context.Context, name string) error
- func (e *Enclave) GetIdentity(ctx context.Context, identity kes.Identity) (auth.IdentityInfo, error)
- func (e *Enclave) GetKey(ctx context.Context, name string) (key.Key, error)
- func (e *Enclave) GetPolicy(ctx context.Context, name string) (auth.Policy, error)
- func (e *Enclave) ListIdentities(ctx context.Context) (auth.IdentityIterator, error)
- func (e *Enclave) ListKeys(ctx context.Context) (kms.Iter, error)
- func (e *Enclave) ListPolicies(ctx context.Context) (auth.PolicyIterator, error)
- func (e *Enclave) Locker() sync.Locker
- func (e *Enclave) RLocker() sync.Locker
- func (e *Enclave) SetAdmin(ctx context.Context, admin kes.Identity) error
- func (e *Enclave) SetPolicy(ctx context.Context, name string, policy auth.Policy) error
- func (e *Enclave) Status(ctx context.Context) (kms.State, error)
- func (e *Enclave) VerifyRequest(r *http.Request) error
- type EnclaveInfo
- type IdentityFS
- type KeyFS
- type PolicyFS
- type Sealer
- type Stanza
- type UnsealKey
- type Unsealer
- type Vault
- func (v *Vault) Admin(ctx context.Context) (kes.Identity, error)
- func (v *Vault) CreateEnclave(ctx context.Context, name string, admin kes.Identity) (EnclaveInfo, error)
- func (v *Vault) DeleteEnclave(ctx context.Context, name string) error
- func (v *Vault) GetEnclave(ctx context.Context, name string) (*Enclave, error)
- func (v *Vault) GetEnclaveInfo(ctx context.Context, name string) (EnclaveInfo, error)
- func (v *Vault) Locker() sync.Locker
- func (v *Vault) RLocker() sync.Locker
- func (v *Vault) Seal(ctx context.Context) error
- func (v *Vault) Unseal(ctx context.Context, keys ...UnsealKey) error
- type VaultFS
Constants ¶
const DefaultEnclaveName = "default"
DefaultEnclaveName is the default Enclave name used when the client does not specify the Enclave name explicitly.
Variables ¶
var ErrMoreUnsealKeysRequired = errors.New("sys: more unseal keys required")
ErrMoreUnsealKeysRequired is an error indicating that the Unsealer requires more UnsealKeys to decrypt the sealed key.
Functions ¶
This section is empty.
Types ¶
type BuildInfo ¶ added in v0.19.4
BuildInfo contains build information about a Go binary.
func BinaryInfo ¶ added in v0.19.4
func BinaryInfo() BuildInfo
BinaryInfo returns the BuildInfo of the binary itself.
It returns some default information when no build information has been compiled into the binary.
type Enclave ¶
type Enclave struct {
// contains filtered or unexported fields
}
An Enclave is a shielded environment within a Vault that stores keys, policies and identities.
func NewEnclave ¶
func NewEnclave(keys KeyFS, policies PolicyFS, identities IdentityFS) *Enclave
NewEnclave returns a new Enclave with the given key store, policy set and identity set.
func (*Enclave) AssignPolicy ¶
AssignPolicy assigns the policy to the identity.
func (*Enclave) CreateKey ¶
CreateKey stores the given key if and only if no entry with the given name exists.
It returns kes.ErrKeyExists if such an entry exists.
func (*Enclave) DeleteIdentity ¶
DeleteIdentity deletes the given identity.
func (*Enclave) DeletePolicy ¶
DeletePolicy deletes the policy associated with the given name.
func (*Enclave) GetIdentity ¶
func (e *Enclave) GetIdentity(ctx context.Context, identity kes.Identity) (auth.IdentityInfo, error)
GetIdentity returns metadata about the given identity.
func (*Enclave) GetKey ¶
GetKey returns the key associated with the given name.
It returns kes.ErrKeyNotFound if no such entry exists.
func (*Enclave) GetPolicy ¶
GetPolicy returns the policy associated with the given name.
It returns kes.ErrPolicyNotFound when no such entry exists.
func (*Enclave) ListIdentities ¶
ListIdentities returns an iterator over all identites within the Enclave.
The iterator makes no guarantees about whether concurrent changes to the enclave - i.e. assignment or deletion of identities - are reflected. It does not provide any ordering guarantees.
func (*Enclave) ListKeys ¶
ListKeys returns a new iterator over all keys within the Enclave.
The iterator makes no guarantees about whether concurrent changes to the enclave - i.e. creation or deletion of keys - are reflected. It does not provide any ordering guarantees.
func (*Enclave) ListPolicies ¶
ListPolicies returns a new iterator over all policies within the Enclave.
The iterator makes no guarantees about whether concurrent changes to the enclave - i.e. creation or deletion of policies - are reflected. It does not provide any ordering guarantees.
func (*Enclave) Locker ¶ added in v0.21.0
Locker returns a sync.Locker that locks the Enclave for writes.
func (*Enclave) RLocker ¶ added in v0.21.0
RLocker returns a sync.Locker that locks the Enclave for reads.
func (*Enclave) SetAdmin ¶ added in v0.21.0
SetAdmin sets the Enclave admin to the given identity. The new admin identity must not be an existing identity that is already assigned to a policy.
type EnclaveInfo ¶ added in v0.20.0
type EnclaveInfo struct { // Name is the Enclave's name. Name string // KeyStoreKey is the root encryption key used to // en/decrypt the key store. KeyStoreKey key.Key // PolicyKey is the root encryption key used to // en/decrypt the policy set. PolicyKey key.Key // IdentityKey is the root encryption key used to // en/decrypt the identity set. IdentityKey key.Key // CreatedAt is the point in time when the Enclave // got created. CreatedAt time.Time // CreatedBy is the identity that created the Enclave. CreatedBy kes.Identity }
EnclaveInfo contains information about an Enclave.
func (EnclaveInfo) MarshalBinary ¶ added in v0.20.0
func (e EnclaveInfo) MarshalBinary() ([]byte, error)
MarshalBinary returns the EnclaveInfo's binary representation.
func (*EnclaveInfo) UnmarshalBinary ¶ added in v0.20.0
func (e *EnclaveInfo) UnmarshalBinary(b []byte) error
UnmarshalBinary unmarshals the EnclaveInfo's binary representation.
type IdentityFS ¶ added in v0.21.0
type IdentityFS interface { // Admin returns the enclave admin identity. Admin(ctx context.Context) (kes.Identity, error) // SetAdmin sets the enclave admin to the given identity. // // The new admin identity must not be an existing identity // that is already assigned to a policy. SetAdmin(ctx context.Context, admin kes.Identity) error // AssignPolicy assigns the policy to the given identity. // // No policy must be assigned to the admin identity. AssignPolicy(ctx context.Context, policy string, identity kes.Identity) error // GetIdentity returns identity information for the given identity, // including the admin identity information. // // It returns ErrIdentityNotFound if no such identity exists. GetIdentity(ctx context.Context, identity kes.Identity) (auth.IdentityInfo, error) // DeleteIdentity deletes the identity information for the // specified identity. // // It returns ErrIdentityNotFound if no such identity exists. DeleteIdentity(ctx context.Context, identity kes.Identity) error // ListIdentities returns an iterator over all identities within // the enclave. ListIdentities(ctx context.Context) (auth.IdentityIterator, error) }
IdentityFS provides access to identities, including the admin identity, within a particular Enclave.
func NewIdentityFS ¶ added in v0.21.0
func NewIdentityFS(filename string, key key.Key) IdentityFS
NewIdentityFS returns a new IdentityFS that reads/writes identities from/to the given directory path and en/decrypts them with the given encryption key.
type KeyFS ¶ added in v0.21.0
type KeyFS interface { // CreateKey creates a new entry for the given key if and only // if no such entry exists already. // // It returns ErrKeyExists if such a key already exists. CreateKey(ctx context.Context, name string, key key.Key) error // GetKey returns the requested key. // // It returns ErrKeyNotFound if no such key exists. GetKey(ctx context.Context, name string) (key.Key, error) // DeleteKey deletes the specified key. // // It returns ErrKeyNotFound if no such key exists. DeleteKey(ctx context.Context, name string) error // ListKeys returns an iterator over all key entries. ListKeys(ctx context.Context) (kms.Iter, error) }
KeyFS provides access to cryptographic keys within a particular Enclave.
type PolicyFS ¶ added in v0.21.0
type PolicyFS interface { // SetPolicy creates or overwrites any existing policy with the // given one. SetPolicy(ctx context.Context, name string, policy auth.Policy) error // GetPolicy returns the requested policy. // // It returns ErrPolicyNotFound if no such policy exists. GetPolicy(ctx context.Context, name string) (auth.Policy, error) // DeletePolicy deletes the specified policy. // // It returns ErrPolicyNotFound if no such policy exists. DeletePolicy(ctx context.Context, name string) error // ListPolicies returns an iterator over all policy entries. ListPolicies(ctx context.Context) (auth.PolicyIterator, error) }
PolicyFS provides access to policies within a particular Enclave.
type Sealer ¶ added in v0.20.0
type Sealer interface { // Seal encrypts the given plaintext and // returns a Stanza and a set of UnsealKeys. // // The Stanza contains the sealed plaintext // data. The set of UnsealKeys are used by a // corresponding Unsealer to decrypt the stanza // and obtain the original plaintext. Seal(plaintext []byte) (*Stanza, []UnsealKey, error) }
A Sealer seals secrets, i.e. cryptographic keys.
func SealFromEnvironment ¶ added in v0.20.0
SealFromEnvironment returns a new Sealer that encrypts secrets using a key from the named environment variable. It returns an error if it fails to read a key from the named environment variable.
type Stanza ¶ added in v0.20.0
type Stanza struct { // Type describes the seal/unseal method used to // produce this Stanza. Type string // Body contains the sealed information. It's // an opaque byte string specific to the seal // method. Body []byte }
A Stanza describes a sealed value.
func (Stanza) MarshalBinary ¶ added in v0.20.0
MarshalBinary returns the Stanza's binary representation.
func (*Stanza) UnmarshalBinary ¶ added in v0.20.0
UnmarshalBinary unmarshals the Stanza's binary representation.
type UnsealKey ¶ added in v0.20.0
type UnsealKey interface {
String() string
}
An UnsealKey is a key generated by a Sealer that can (partially) unseal a Stanza.
type Unsealer ¶ added in v0.20.0
type Unsealer interface { // Unseal decrypts the given stanza with a set of // UnsealKeys and returns the plaintext data. // // Unseal returns MoreUnsealKeysRequired if at // least one more UnsealKey is required to decrypt // the Stanza. Unseal(*Stanza, ...UnsealKey) ([]byte, error) }
An Unsealer decrypts sealed secrets encrypted by the corresponding Sealer.
func UnsealFromEnvironment ¶ added in v0.20.0
func UnsealFromEnvironment() Unsealer
UnsealFromEnvironment returns a new Unsealer that decrypts sealed secrets using a key from the environment.
type Vault ¶
type Vault struct {
// contains filtered or unexported fields
}
A Vault manages a set of enclaves. It is either in a sealed or unsealed state. When sealed, any Vault operation, except unsealing, returns ErrSealed.
func NewVault ¶ added in v0.21.0
NewVault returns a new Vault that uses the given VaultFS to persist state.
func (*Vault) CreateEnclave ¶
func (v *Vault) CreateEnclave(ctx context.Context, name string, admin kes.Identity) (EnclaveInfo, error)
CreateEnclave creates a new enclave with the given name and enclave admin identity.
It returns ErrEnclaveExists if such an enclave already exists.
func (*Vault) DeleteEnclave ¶
DeleteEnclave deletes the enclave with the given name.
It returns ErrEnclaveNotFound if no such enclave exists.
func (*Vault) GetEnclave ¶
GetEnclave returns the Enclave with the given name.
It returns ErrEnclaveNotFound if no such enclave exists.
func (*Vault) GetEnclaveInfo ¶ added in v0.21.1
GetEnclaveInfo returns information about the specified enclave.
It returns ErrEnclaveNotFound if no such enclave exists.
func (*Vault) Locker ¶ added in v0.21.0
Locker returns a sync.Locker that locks the Vault for writes.
func (*Vault) RLocker ¶ added in v0.21.0
RLocker returns a sync.Locker that locks the Vault for reads.
type VaultFS ¶ added in v0.21.0
type VaultFS interface { // Seal seals the VaultFS. A sealed VaultFS must // be unsealed before it can process any new // requests. Seal(ctx context.Context) error // Unseal unseals a sealed VaultFS. Unseal(ctx context.Context, unsealKeys ...UnsealKey) error // Admin returns the current VaultFS admin identity. Admin(ctx context.Context) (kes.Identity, error) // CreateEnclave creates a new enclave with the given identity // as enclave admin. // // It returns ErrEnclaveExists if such an enclave already exists. CreateEnclave(ctx context.Context, name string, admin kes.Identity) (EnclaveInfo, error) // GetEnclave returns the requested enclave. // // It returns ErrEnclaveNotFound if no such enclave exists. GetEnclave(ctx context.Context, name string) (*Enclave, error) // GetEnclaveInfo returns information about the specified enclave. // // It returns ErrEnclaveNotFound if no such enclave exists. GetEnclaveInfo(ctx context.Context, name string) (EnclaveInfo, error) // DeleteEnclave deletes the specified enclave. // // It returns ErrEnclaveNotFound if no such enclave exists. DeleteEnclave(ctx context.Context, name string) error }
VaultFS provides access to Vault state.