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 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) HasLabel(label string) bool
- func (k *Key) Updated(ts int64) *Key
- func (k *Key) WithLabel(label string) *Key
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"`
Type string `json:"type,omitempty" msgpack:"type,omitempty"`
Private []byte `json:"priv,omitempty" msgpack:"priv,omitempty"`
Public []byte `json:"pub,omitempty" msgpack:"pub,omitempty"`
CreatedAt int64 `json:"cts,omitempty" msgpack:"cts,omitempty"`
UpdatedAt int64 `json:"uts,omitempty" msgpack:"uts,omitempty"`
// Optional fields
Labels []string `json:"labels,omitempty" msgpack:"labels,omitempty"`
Notes string `json:"notes,omitempty" msgpack:"notes,omitempty"`
// Application specific fields
Token string `json:"token,omitempty" msgpack:"token,omitempty"`
}
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.