Documentation
¶
Overview ¶
Package api provides a standard key format for serialization to JSON or msgpack, and conversions to and from specific key types.
Index ¶
- func EncodeKey(key *Key, password string) (string, error)
- type Ext
- type Key
- func (k *Key) As() keys.Key
- func (k *Key) AsEdX25519() *keys.EdX25519Key
- func (k *Key) AsEdX25519Public() *keys.EdX25519PublicKey
- func (k *Key) AsPublic() keys.Key
- func (k *Key) AsRSA() *keys.RSAKey
- func (k *Key) AsRSAPublic() *keys.RSAPublicKey
- func (k *Key) AsX25519() *keys.X25519Key
- func (k *Key) AsX25519Public() *keys.X25519PublicKey
- func (k *Key) Check() error
- func (k *Key) Copy() *Key
- func (k *Key) Created(ts int64) *Key
- func (k *Key) Equal(o *Key) bool
- func (k *Key) ExtBool(key string) bool
- func (k *Key) ExtString(key string) string
- func (k Key) HasLabel(label string) bool
- func (k *Key) IsEdX25519() bool
- func (k *Key) IsX25519() bool
- func (k *Key) SetExtBool(key string, val bool)
- func (k *Key) SetExtString(key string, val string)
- func (k *Key) Updated(ts int64) *Key
- func (k *Key) WithLabels(labels ...string) *Key
- func (k *Key) WithNotes(notes string) *Key
- type Labels
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Key ¶
type Key struct { ID keys.ID `json:"id,omitempty" msgpack:"id,omitempty" db:"id"` Type string `json:"type,omitempty" msgpack:"type,omitempty" db:"type"` Private []byte `json:"priv,omitempty" msgpack:"priv,omitempty" db:"private"` Public []byte `json:"pub,omitempty" msgpack:"pub,omitempty" db:"public"` CreatedAt int64 `json:"cts,omitempty" msgpack:"cts,omitempty" db:"createdAt"` UpdatedAt int64 `json:"uts,omitempty" msgpack:"uts,omitempty" db:"updatedAt"` // Optional fields Labels Labels `json:"labels,omitempty" msgpack:"labels,omitempty" db:"labels"` Notes string `json:"notes,omitempty" msgpack:"notes,omitempty" db:"notes"` // Extension (json marshalled to db) Ext Ext `json:"ext,omitempty" msgpack:"ext,omitempty" db:"ext"` // Deleted flag Deleted bool `json:"del,omitempty" msgpack:"del,omitempty" db:"del"` }
Key is a concrete type for the keys.Key interface, which can be serialized and converted to concrete key types like keys.EdX25519Key. It also includes additional fields and metadata.
func ParseKey ¶ added in v0.1.20
ParseKey tries to determine what key type and parses the key bytes.
func (*Key) AsEdX25519 ¶
func (k *Key) AsEdX25519() *keys.EdX25519Key
AsEdX25519 returns a *EdX25519Key. Returns nil if we can't resolve.
func (*Key) AsEdX25519Public ¶
func (k *Key) AsEdX25519Public() *keys.EdX25519PublicKey
AsEdX25519Public returns a *EdX25519PublicKey. Returns nil if we can't resolve.
func (*Key) AsRSAPublic ¶
func (k *Key) AsRSAPublic() *keys.RSAPublicKey
AsRSAPublic returns a RSAPublicKey. Returns nil if we can't resolve.
func (*Key) AsX25519 ¶
AsX25519 returns a X25519Key. If key is a EdX25519Key, it's converted to a X25519Key. Returns nil if we can't resolve.
func (*Key) AsX25519Public ¶
func (k *Key) AsX25519Public() *keys.X25519PublicKey
AsX25519Public returns a X25519PublicKey. Returns nil if we can't resolve.
func (*Key) IsEdX25519 ¶ added in v0.1.21
IsEdX25519 returns true if EdX25519Key.
func (*Key) SetExtBool ¶ added in v0.1.22
func (*Key) SetExtString ¶ added in v0.1.22
func (*Key) WithLabels ¶ added in v0.1.21
WithLabels returns key with labels added.