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 EncryptKey(key *Key, sender *keys.EdX25519Key, recipient keys.ID, armored bool) ([]byte, 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) EncryptWithPassword(password string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncryptKey ¶
func EncryptKey(key *Key, sender *keys.EdX25519Key, recipient keys.ID, armored bool) ([]byte, error)
EncryptKey creates encrypted key from a sender to a recipient.
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"` // Optional fields Notes string `json:"notes,omitempty" msgpack:"notes,omitempty"` CreatedAt int64 `json:"cts,omitempty" msgpack:"cts,omitempty"` UpdatedAt int64 `json:"uts,omitempty" msgpack:"uts,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 DecryptKey ¶
DecryptKey decrypts a key from a sender.
func DecryptKeyWithPassword ¶
DecryptKeyWithPassword decrypts a key using a password.
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.