summaryrefslogtreecommitdiff
path: root/widgets/pgpinfo.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-04-25 08:30:43 -0500
committerRobin Jarry <robin@jarry.cc>2022-04-27 09:46:11 +0200
commitd09636ee0b9957ed60fc01224ddfbb03c4f4b7fa (patch)
tree5f0ec8c9ad11a0f638c25dbd896a518e983dc779 /widgets/pgpinfo.go
parentafe35839eddfaf43be0f791e97a926a15d91fc02 (diff)
downloadaerc-d09636ee0b9957ed60fc01224ddfbb03c4f4b7fa.zip
refactor: refactor pgp implementation
This commit refactors the internal PGP implementation to make way for GPG integration. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/pgpinfo.go')
-rw-r--r--widgets/pgpinfo.go27
1 files changed, 9 insertions, 18 deletions
diff --git a/widgets/pgpinfo.go b/widgets/pgpinfo.go
index 6c07ed9..8dc0570 100644
--- a/widgets/pgpinfo.go
+++ b/widgets/pgpinfo.go
@@ -1,22 +1,18 @@
package widgets
import (
- "errors"
-
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/ui"
-
- "github.com/ProtonMail/go-crypto/openpgp"
- pgperrors "github.com/ProtonMail/go-crypto/openpgp/errors"
+ "git.sr.ht/~rjarry/aerc/models"
)
type PGPInfo struct {
ui.Invalidatable
- details *openpgp.MessageDetails
+ details *models.MessageDetails
uiConfig config.UIConfig
}
-func NewPGPInfo(details *openpgp.MessageDetails, uiConfig config.UIConfig) *PGPInfo {
+func NewPGPInfo(details *models.MessageDetails, uiConfig config.UIConfig) *PGPInfo {
return &PGPInfo{details: details, uiConfig: uiConfig}
}
@@ -27,38 +23,33 @@ func (p *PGPInfo) DrawSignature(ctx *ui.Context) {
defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT)
// TODO: Nicer prompt for TOFU, fetch from keyserver, etc
- if errors.Is(p.details.SignatureError, pgperrors.ErrUnknownIssuer) ||
- p.details.SignedBy == nil {
+ if p.details.SignatureValidity == models.UnknownEntity ||
+ p.details.SignedBy == "" {
x := ctx.Printf(0, 0, warningStyle, "*")
x += ctx.Printf(x, 0, defaultStyle,
" Signed with unknown key (%8X); authenticity unknown",
p.details.SignedByKeyId)
- } else if p.details.SignatureError != nil {
+ } else if p.details.SignatureValidity != models.Valid {
x := ctx.Printf(0, 0, errorStyle, "Invalid signature!")
x += ctx.Printf(x, 0, errorStyle,
" This message may have been tampered with! (%s)",
- p.details.SignatureError.Error())
+ p.details.SignatureError)
} else {
- entity := p.details.SignedBy.Entity
- ident := entity.PrimaryIdentity()
-
x := ctx.Printf(0, 0, validStyle, "✓ Authentic ")
x += ctx.Printf(x, 0, defaultStyle,
"Signature from %s (%8X)",
- ident.Name, p.details.SignedByKeyId)
+ p.details.SignedBy, p.details.SignedByKeyId)
}
}
func (p *PGPInfo) DrawEncryption(ctx *ui.Context, y int) {
validStyle := p.uiConfig.GetStyle(config.STYLE_SUCCESS)
defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT)
- entity := p.details.DecryptedWith.Entity
- ident := entity.PrimaryIdentity()
x := ctx.Printf(0, y, validStyle, "✓ Encrypted ")
x += ctx.Printf(x, y, defaultStyle,
- "To %s (%8X) ", ident.Name, p.details.DecryptedWith.PublicKey.KeyId)
+ "To %s (%8X) ", p.details.DecryptedWith, p.details.DecryptedWithKeyId)
}
func (p *PGPInfo) Draw(ctx *ui.Context) {