Documentation ¶
Overview ¶
Package pgp contains the logic related to the PGP key management.
Index ¶
- Constants
- type Key
- func (p *Key) Armor() (string, error)
- func (p *Key) ArmorPublic() (string, error)
- func (p *Key) Fingerprint() string
- func (p *Key) IsExpired(clockSkew time.Duration) bool
- func (p *Key) IsPrivate() bool
- func (p *Key) IsUnlocked() (bool, error)
- func (p *Key) Sign(data []byte) ([]byte, error)
- func (p *Key) Validate(opt ...ValidationOption) error
- func (p *Key) Verify(data, signature []byte) error
- type ValidationOption
Constants ¶
const ( DefaultMaxAllowedLifetime = 8 * time.Hour DefaultAllowedClockSkew = 5 * time.Minute DefaultValidEmailAsName = true )
Key validation defaults.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key represents a PGP key. It can be a public key or a private & public key pair.
func GenerateKey ¶
GenerateKey generates a new PGP key pair.
func (*Key) ArmorPublic ¶
ArmorPublic returns only the public key in armored format.
func (*Key) Fingerprint ¶
Fingerprint returns the fingerprint of the key.
func (*Key) IsExpired ¶ added in v0.2.1
IsExpired returns true if the key is expired with clock skew.
func (*Key) IsUnlocked ¶
IsUnlocked returns true if the private key is unlocked.
func (*Key) Validate ¶
func (p *Key) Validate(opt ...ValidationOption) error
Validate validates the key.
type ValidationOption ¶ added in v0.2.3
type ValidationOption func(*validationOptions)
ValidationOption represents a functional validation option.
func WithAllowedClockSkew ¶ added in v0.2.3
func WithAllowedClockSkew(allowedClockSkew time.Duration) ValidationOption
WithAllowedClockSkew sets the allowed clock skew in the key expiration validation.
func WithMaxAllowedLifetime ¶ added in v0.2.3
func WithMaxAllowedLifetime(maxAllowedLifetime time.Duration) ValidationOption
WithMaxAllowedLifetime customizes the max allowed key lifetime in the validation.
func WithValidEmailAsName ¶ added in v0.2.3
func WithValidEmailAsName(validEmailAsName bool) ValidationOption
WithValidEmailAsName sets whether the validation should be performed on the name to be a valid email address.