GODT-1779: Remove go-imap

This commit is contained in:
James Houlahan
2022-08-26 17:00:21 +02:00
parent 3b0bc1ca15
commit 39433fe707
593 changed files with 12725 additions and 91626 deletions

30
internal/user/crypto.go Normal file
View File

@ -0,0 +1,30 @@
package user
import (
"github.com/ProtonMail/gopenpgp/v2/crypto"
"gitlab.protontech.ch/go/liteapi"
)
func unlockKeyRings(user liteapi.User, addresses []liteapi.Address, keyPass []byte) (*crypto.KeyRing, map[string]*crypto.KeyRing, error) {
userKR, err := user.Keys.Unlock(keyPass, nil)
if err != nil {
return nil, nil, err
}
addrKRs := make(map[string]*crypto.KeyRing)
for _, address := range addresses {
if !address.HasKeys.Bool() {
continue
}
addrKR, err := address.Keys.Unlock(keyPass, userKR)
if err != nil {
return nil, nil, err
}
addrKRs[address.ID] = addrKR
}
return userKR, addrKRs, nil
}