summaryrefslogtreecommitdiffstats
path: root/internal/compose
diff options
context:
space:
mode:
Diffstat (limited to 'internal/compose')
-rw-r--r--internal/compose/mime.go40
-rw-r--r--internal/compose/mime_test.go10
2 files changed, 0 insertions, 50 deletions
diff --git a/internal/compose/mime.go b/internal/compose/mime.go
index da68bd8..6bda7b5 100644
--- a/internal/compose/mime.go
+++ b/internal/compose/mime.go
@@ -88,46 +88,6 @@ func BuildMixed(text string, attachments []Attachment) (contentType, transferEnc
return `multipart/mixed; boundary="` + boundary + `"`, "7bit", builder.String(), nil
}
-func BuildOpenPGPMIME(armoredCiphertext string) (contentType, transferEncoding, body string, err error) {
- if strings.TrimSpace(armoredCiphertext) == "" || strings.Contains(armoredCiphertext, "\x00") {
- return "", "", "", errors.New("OpenPGP ciphertext is required")
- }
- boundary, err := boundary()
- if err != nil {
- return "", "", "", err
- }
- var builder strings.Builder
- writer := multipart.NewWriter(&builder)
- if err := writer.SetBoundary(boundary); err != nil {
- return "", "", "", err
- }
- versionHeader := make(textproto.MIMEHeader)
- versionHeader.Set("Content-Type", "application/pgp-encrypted")
- versionHeader.Set("Content-Description", "PGP/MIME version identification")
- part, err := writer.CreatePart(versionHeader)
- if err != nil {
- return "", "", "", err
- }
- if _, err := part.Write([]byte("Version: 1\r\n")); err != nil {
- return "", "", "", err
- }
- cipherHeader := make(textproto.MIMEHeader)
- cipherHeader.Set("Content-Type", "application/octet-stream; name=encrypted.asc")
- cipherHeader.Set("Content-Disposition", `inline; filename="encrypted.asc"`)
- cipherHeader.Set("Content-Description", "OpenPGP encrypted message")
- part, err = writer.CreatePart(cipherHeader)
- if err != nil {
- return "", "", "", err
- }
- if _, err := part.Write([]byte(normalizeCRLF(armoredCiphertext))); err != nil {
- return "", "", "", err
- }
- if err := writer.Close(); err != nil {
- return "", "", "", err
- }
- return `multipart/encrypted; protocol="application/pgp-encrypted"; boundary="` + boundary + `"`, "7bit", builder.String(), nil
-}
-
func boundary() (string, error) {
random := make([]byte, 12)
if _, err := rand.Read(random); err != nil {
diff --git a/internal/compose/mime_test.go b/internal/compose/mime_test.go
index 32fb6b2..6e8f0a0 100644
--- a/internal/compose/mime_test.go
+++ b/internal/compose/mime_test.go
@@ -19,13 +19,3 @@ func TestBuildMixed(t *testing.T) {
t.Fatalf("attachment missing: %q", body)
}
}
-
-func TestBuildOpenPGPMIME(t *testing.T) {
- contentType, _, body, err := BuildOpenPGPMIME("-----BEGIN PGP MESSAGE-----\nabc\n-----END PGP MESSAGE-----")
- if err != nil {
- t.Fatal(err)
- }
- if !strings.HasPrefix(contentType, "multipart/encrypted") || !strings.Contains(body, "Version: 1") || !strings.Contains(body, "BEGIN PGP MESSAGE") {
- t.Fatalf("invalid OpenPGP/MIME body: %q", body)
- }
-}