We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 782aac0 commit 4bf0f02Copy full SHA for 4bf0f02
pkg/pgp/key.go
@@ -8,6 +8,7 @@ package pgp
8
import (
9
"crypto"
10
"math"
11
+ "sync"
12
"time"
13
14
"github.com/ProtonMail/go-crypto/openpgp"
@@ -19,6 +20,7 @@ import (
19
20
type Key struct {
21
key *pgpcrypto.Key
22
keyring *pgpcrypto.KeyRing
23
+ mu sync.Mutex
24
}
25
26
// GenerateKey generates a new PGP key pair.
@@ -77,6 +79,9 @@ func (p *Key) Verify(data, signature []byte) error {
77
79
78
80
// Sign signs the given data using the private key.
81
func (p *Key) Sign(data []byte) ([]byte, error) {
82
+ p.mu.Lock()
83
+ defer p.mu.Unlock()
84
+
85
message := pgpcrypto.NewPlainMessage(data)
86
87
signature, err := p.keyring.SignDetached(message)
0 commit comments