Debian Codegraph @

server/backend/crypto_fast.go

raw
1 package backend
2
3 import "github.com/ProtonMail/gopenpgp/v2/crypto"
4
5 var preCompKey *crypto.Key
6
7 func init() {
8 key, err := crypto.GenerateKey("name", "email", "rsa", 1024)
9 if err != nil {
10 panic(err)
11 }
12
13 preCompKey = key
14 }
15
16 // FastGenerateKey is a fast version of GenerateKey that uses a pre-computed key.
17 // This is useful for testing but is incredibly insecure.
18 func FastGenerateKey(_, _ string, passphrase []byte, _ string, _ int) (string, error) {
19 encKey, err := preCompKey.Lock(passphrase)
20 if err != nil {
21 return "", err
22 }
23
24 return encKey.Armor()
25 }