diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/crypto/gpg/gpgbin/encrypt.go | 2 | ||||
-rw-r--r-- | lib/crypto/gpg/gpgbin/sign.go | 2 | ||||
-rw-r--r-- | lib/crypto/gpg/reader.go | 22 | ||||
-rw-r--r-- | lib/crypto/pgp/pgp.go | 8 | ||||
-rw-r--r-- | lib/oauthbearer.go | 2 |
5 files changed, 18 insertions, 18 deletions
diff --git a/lib/crypto/gpg/gpgbin/encrypt.go b/lib/crypto/gpg/gpgbin/encrypt.go index 9ca45269..79003fd5 100644 --- a/lib/crypto/gpg/gpgbin/encrypt.go +++ b/lib/crypto/gpg/gpgbin/encrypt.go @@ -33,7 +33,7 @@ func Encrypt(r io.Reader, to []string, from string) ([]byte, error) { var md models.MessageDetails err = parse(outRdr, &md) if err != nil { - return nil, fmt.Errorf("gpg: failure to encrypt: %v. check public key(s)", err) + return nil, fmt.Errorf("gpg: failure to encrypt: %w. check public key(s)", err) } var buf bytes.Buffer _, _ = io.Copy(&buf, md.Body) diff --git a/lib/crypto/gpg/gpgbin/sign.go b/lib/crypto/gpg/gpgbin/sign.go index caf31d14..314c3fc3 100644 --- a/lib/crypto/gpg/gpgbin/sign.go +++ b/lib/crypto/gpg/gpgbin/sign.go @@ -26,7 +26,7 @@ func Sign(r io.Reader, from string) ([]byte, string, error) { var md models.MessageDetails err = parse(outRdr, &md) if err != nil { - return nil, "", fmt.Errorf("failed to parse messagedetails: %v", err) + return nil, "", fmt.Errorf("failed to parse messagedetails: %w", err) } var buf bytes.Buffer _, _ = io.Copy(&buf, md.Body) diff --git a/lib/crypto/gpg/reader.go b/lib/crypto/gpg/reader.go index 40da82f8..07553c97 100644 --- a/lib/crypto/gpg/reader.go +++ b/lib/crypto/gpg/reader.go @@ -61,12 +61,12 @@ func Read(r io.Reader) (*Reader, error) { func newEncryptedReader(h textproto.Header, mr *textproto.MultipartReader) (*Reader, error) { p, err := mr.NextPart() if err != nil { - return nil, fmt.Errorf("gpgmail: failed to read first part in multipart/encrypted message: %v", err) + return nil, fmt.Errorf("gpgmail: failed to read first part in multipart/encrypted message: %w", err) } t, _, err := mime.ParseMediaType(p.Header.Get("Content-Type")) if err != nil { - return nil, fmt.Errorf("gpgmail: failed to parse Content-Type of first part in multipart/encrypted message: %v", err) + return nil, fmt.Errorf("gpgmail: failed to parse Content-Type of first part in multipart/encrypted message: %w", err) } if !strings.EqualFold(t, "application/pgp-encrypted") { return nil, fmt.Errorf("gpgmail: first part in multipart/encrypted message has type %q, not application/pgp-encrypted", t) @@ -74,7 +74,7 @@ func newEncryptedReader(h textproto.Header, mr *textproto.MultipartReader) (*Rea metadata, err := textproto.ReadHeader(bufio.NewReader(p)) if err != nil { - return nil, fmt.Errorf("gpgmail: failed to parse application/pgp-encrypted part: %v", err) + return nil, fmt.Errorf("gpgmail: failed to parse application/pgp-encrypted part: %w", err) } if s := metadata.Get("Version"); s != "1" { return nil, fmt.Errorf("gpgmail: unsupported PGP/MIME version: %q", s) @@ -82,11 +82,11 @@ func newEncryptedReader(h textproto.Header, mr *textproto.MultipartReader) (*Rea p, err = mr.NextPart() if err != nil { - return nil, fmt.Errorf("gpgmail: failed to read second part in multipart/encrypted message: %v", err) + return nil, fmt.Errorf("gpgmail: failed to read second part in multipart/encrypted message: %w", err) } t, _, err = mime.ParseMediaType(p.Header.Get("Content-Type")) if err != nil { - return nil, fmt.Errorf("gpgmail: failed to parse Content-Type of second part in multipart/encrypted message: %v", err) + return nil, fmt.Errorf("gpgmail: failed to parse Content-Type of second part in multipart/encrypted message: %w", err) } if !strings.EqualFold(t, "application/octet-stream") { return nil, fmt.Errorf("gpgmail: second part in multipart/encrypted message has type %q, not application/octet-stream", t) @@ -94,13 +94,13 @@ func newEncryptedReader(h textproto.Header, mr *textproto.MultipartReader) (*Rea md, err := gpgbin.Decrypt(p) if err != nil { - return nil, fmt.Errorf("gpgmail: failed to read PGP message: %v", err) + return nil, fmt.Errorf("gpgmail: failed to read PGP message: %w", err) } cleartext := bufio.NewReader(md.Body) cleartextHeader, err := textproto.ReadHeader(cleartext) if err != nil { - return nil, fmt.Errorf("gpgmail: failed to read encrypted header: %v", err) + return nil, fmt.Errorf("gpgmail: failed to read encrypted header: %w", err) } t, params, err := mime.ParseMediaType(cleartextHeader.Get("Content-Type")) @@ -114,7 +114,7 @@ func newEncryptedReader(h textproto.Header, mr *textproto.MultipartReader) (*Rea mr := textproto.NewMultipartReader(cleartext, params["boundary"]) mds, err := newSignedReader(cleartextHeader, mr, micalg) if err != nil { - return nil, fmt.Errorf("gpgmail: failed to read encapsulated multipart/signed message: %v", err) + return nil, fmt.Errorf("gpgmail: failed to read encapsulated multipart/signed message: %w", err) } mds.MessageDetails.IsEncrypted = md.IsEncrypted mds.MessageDetails.DecryptedWith = md.DecryptedWith @@ -136,7 +136,7 @@ func newSignedReader(h textproto.Header, mr *textproto.MultipartReader, micalg s micalg = strings.ToLower(micalg) p, err := mr.NextPart() if err != nil { - return nil, fmt.Errorf("gpgmail: failed to read signed part in multipart/signed message: %v", err) + return nil, fmt.Errorf("gpgmail: failed to read signed part in multipart/signed message: %w", err) } var headerBuf bytes.Buffer _ = textproto.WriteHeader(&headerBuf, p.Header) @@ -147,12 +147,12 @@ func newSignedReader(h textproto.Header, mr *textproto.MultipartReader, micalg s sig, err := mr.NextPart() if err != nil { - return nil, fmt.Errorf("gpgmail: failed to read pgp part in multipart/signed message: %v", err) + return nil, fmt.Errorf("gpgmail: failed to read pgp part in multipart/signed message: %w", err) } md, err := gpgbin.Verify(&msg, sig) if err != nil { - return nil, fmt.Errorf("gpgmail: failed to read PGP message: %v", err) + return nil, fmt.Errorf("gpgmail: failed to read PGP message: %w", err) } if md.Micalg != micalg && md.SignatureError == "" { md.SignatureError = "gpg: header hash does not match actual sig hash" diff --git a/lib/crypto/pgp/pgp.go b/lib/crypto/pgp/pgp.go index 579395f9..689bae3f 100644 --- a/lib/crypto/pgp/pgp.go +++ b/lib/crypto/pgp/pgp.go @@ -33,7 +33,7 @@ func (m *Mail) Init() error { logging.Infof("Initializing PGP keyring") err := os.MkdirAll(path.Join(xdg.DataHome(), "aerc"), 0o700) if err != nil { - return fmt.Errorf("failed to create data directory: %v", err) + return fmt.Errorf("failed to create data directory: %w", err) } lockpath := path.Join(xdg.DataHome(), "aerc", "keyring.lock") @@ -290,16 +290,16 @@ func (m *Mail) ExportKey(k string) (io.Reader, error) { pks := bytes.NewBuffer(nil) err = entity.Serialize(pks) if err != nil { - return nil, fmt.Errorf("pgp: error exporting key: %v", err) + return nil, fmt.Errorf("pgp: error exporting key: %w", err) } pka := bytes.NewBuffer(nil) w, err := armor.Encode(pka, "PGP PUBLIC KEY BLOCK", map[string]string{}) if err != nil { - return nil, fmt.Errorf("pgp: error exporting key: %v", err) + return nil, fmt.Errorf("pgp: error exporting key: %w", err) } _, err = w.Write(pks.Bytes()) if err != nil { - return nil, fmt.Errorf("pgp: error exporting key: %v", err) + return nil, fmt.Errorf("pgp: error exporting key: %w", err) } w.Close() return pka, nil diff --git a/lib/oauthbearer.go b/lib/oauthbearer.go index 4954830f..063866ba 100644 --- a/lib/oauthbearer.go +++ b/lib/oauthbearer.go @@ -23,7 +23,7 @@ func (c *OAuthBearer) ExchangeRefreshToken(refreshToken string) (*oauth2.Token, func (c *OAuthBearer) Authenticate(username string, password string, client *client.Client) error { if ok, err := client.SupportAuth(sasl.OAuthBearer); err != nil || !ok { - return fmt.Errorf("OAuthBearer not supported %v", err) + return fmt.Errorf("OAuthBearer not supported %w", err) } if c.OAuth2.Endpoint.TokenURL != "" { |