55 "crypto"
66 "crypto/sha256"
77 "encoding/hex"
8+ "errors"
89 "fmt"
910 "io"
1011 "math/big"
@@ -13,7 +14,6 @@ import (
1314
1415 "github.com/ProtonMail/gopenpgp/v2/armor"
1516 "github.com/ProtonMail/gopenpgp/v2/constants"
16- "github.com/pkg/errors"
1717
1818 openpgp "github.com/ProtonMail/go-crypto/openpgp"
1919 packet "github.com/ProtonMail/go-crypto/openpgp/packet"
@@ -117,14 +117,14 @@ func (key *Key) Lock(passphrase []byte) (*Key, error) {
117117 if lockedKey .entity .PrivateKey != nil && ! lockedKey .entity .PrivateKey .Dummy () {
118118 err = lockedKey .entity .PrivateKey .Encrypt (passphrase )
119119 if err != nil {
120- return nil , errors . Wrap ( err , "gopenpgp: error in locking key" )
120+ return nil , fmt . Errorf ( "gopenpgp: error in locking key: %w" , err )
121121 }
122122 }
123123
124124 for _ , sub := range lockedKey .entity .Subkeys {
125125 if sub .PrivateKey != nil && ! sub .PrivateKey .Dummy () {
126126 if err := sub .PrivateKey .Encrypt (passphrase ); err != nil {
127- return nil , errors . Wrap ( err , "gopenpgp: error in locking sub key" )
127+ return nil , fmt . Errorf ( "gopenpgp: error in locking sub key: %w" , err )
128128 }
129129 }
130130 }
@@ -162,14 +162,14 @@ func (key *Key) Unlock(passphrase []byte) (*Key, error) {
162162 if unlockedKey .entity .PrivateKey != nil && ! unlockedKey .entity .PrivateKey .Dummy () {
163163 err = unlockedKey .entity .PrivateKey .Decrypt (passphrase )
164164 if err != nil {
165- return nil , errors . Wrap ( err , "gopenpgp: error in unlocking key" )
165+ return nil , fmt . Errorf ( "gopenpgp: error in unlocking key: %w" , err )
166166 }
167167 }
168168
169169 for _ , sub := range unlockedKey .entity .Subkeys {
170170 if sub .PrivateKey != nil && ! sub .PrivateKey .Dummy () {
171171 if err := sub .PrivateKey .Decrypt (passphrase ); err != nil {
172- return nil , errors . Wrap ( err , "gopenpgp: error in unlocking sub key" )
172+ return nil , fmt . Errorf ( "gopenpgp: error in unlocking sub key: %w" , err )
173173 }
174174 }
175175 }
@@ -198,7 +198,7 @@ func (key *Key) Serialize() ([]byte, error) {
198198 }
199199
200200 if err != nil {
201- return nil , errors . Wrap ( err , "gopenpgp: error in serializing key" )
201+ return nil , fmt . Errorf ( "gopenpgp: error in serializing key: %w" , err )
202202 }
203203
204204 return buffer .Bytes (), nil
@@ -254,7 +254,7 @@ func (key *Key) GetArmoredPublicKeyWithCustomHeaders(comment, version string) (s
254254func (key * Key ) GetPublicKey () (b []byte , err error ) {
255255 var outBuf bytes.Buffer
256256 if err = key .entity .Serialize (& outBuf ); err != nil {
257- return nil , errors . Wrap ( err , "gopenpgp: error in serializing public key" )
257+ return nil , fmt . Errorf ( "gopenpgp: error in serializing public key: %w" , err )
258258 }
259259
260260 return outBuf .Bytes (), nil
@@ -417,7 +417,7 @@ func (key *Key) readFrom(r io.Reader, armored bool) error {
417417 entities , err = openpgp .ReadKeyRing (r )
418418 }
419419 if err != nil {
420- return errors . Wrap ( err , "gopenpgp: error in reading key ring" )
420+ return fmt . Errorf ( "gopenpgp: error in reading key ring: %w" , err )
421421 }
422422
423423 if len (entities ) > 1 {
@@ -473,7 +473,7 @@ func generateKey(
473473
474474 newEntity , err := openpgp .NewEntity (name , comments , email , cfg )
475475 if err != nil {
476- return nil , errors . Wrap ( err , "gopengpp: error in encoding new entity" )
476+ return nil , fmt . Errorf ( "gopengpp: error in encoding new entity: %w" , err )
477477 }
478478
479479 if newEntity .PrivateKey == nil {
0 commit comments