diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-04-25 08:30:43 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-04-27 09:46:11 +0200 |
commit | d09636ee0b9957ed60fc01224ddfbb03c4f4b7fa (patch) | |
tree | 5f0ec8c9ad11a0f638c25dbd896a518e983dc779 /lib/crypto/crypto.go | |
parent | afe35839eddfaf43be0f791e97a926a15d91fc02 (diff) | |
download | aerc-d09636ee0b9957ed60fc01224ddfbb03c4f4b7fa.tar.gz |
refactor: refactor pgp implementation
This commit refactors the internal PGP implementation to make way for
GPG integration.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/crypto/crypto.go')
-rw-r--r-- | lib/crypto/crypto.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/crypto/crypto.go b/lib/crypto/crypto.go new file mode 100644 index 00000000..47cb9544 --- /dev/null +++ b/lib/crypto/crypto.go @@ -0,0 +1,28 @@ +package crypto + +import ( + "bytes" + "io" + "log" + + "git.sr.ht/~rjarry/aerc/lib/crypto/pgp" + "git.sr.ht/~rjarry/aerc/models" + "github.com/ProtonMail/go-crypto/openpgp" + "github.com/emersion/go-message/mail" +) + +type Provider interface { + Decrypt(io.Reader, openpgp.PromptFunction) (*models.MessageDetails, error) + Encrypt(*bytes.Buffer, []string, string, openpgp.PromptFunction, *mail.Header) (io.WriteCloser, error) + Sign(*bytes.Buffer, string, openpgp.PromptFunction, *mail.Header) (io.WriteCloser, error) + ImportKeys(io.Reader) error + Init(*log.Logger) error + Close() +} + +func New(s string) Provider { + switch s { + default: + return &pgp.Mail{} + } +} |