This commit is contained in:
Jakub
2020-11-18 19:52:57 +01:00
committed by Jakub Cuth
parent 152046bf97
commit 87c8228cd0
3 changed files with 266 additions and 264 deletions

View File

@ -291,7 +291,7 @@ func signAttachment(encrypter *crypto.KeyRing, data io.Reader) (signature io.Rea
return bytes.NewReader(sig.GetBinary()), nil return bytes.NewReader(sig.GetBinary()), nil
} }
func createPackets( func encryptAndEncodeSessionKeys(
pubkey *crypto.KeyRing, pubkey *crypto.KeyRing,
bodyKey *crypto.SessionKey, bodyKey *crypto.SessionKey,
attkeys map[string]*crypto.SessionKey, attkeys map[string]*crypto.SessionKey,
@ -315,7 +315,7 @@ func createPackets(
return return
} }
func encryptSymmetric( func encryptSymmDecryptKey(
kr *crypto.KeyRing, kr *crypto.KeyRing,
textToEncrypt string, textToEncrypt string,
) (decryptedKey *crypto.SessionKey, symEncryptedData []byte, err error) { ) (decryptedKey *crypto.SessionKey, symEncryptedData []byte, err error) {

View File

@ -24,13 +24,14 @@ import (
"github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/ProtonMail/gopenpgp/v2/crypto"
) )
// Draft actions
const ( const (
DraftActionReply = 0 DraftActionReply = 0
DraftActionReplyAll = 1 DraftActionReplyAll = 1
DraftActionForward = 2 DraftActionForward = 2
) )
// Message package types. // Message send package types.
const ( const (
InternalPackage = 1 InternalPackage = 1
EncryptedOutsidePackage = 2 EncryptedOutsidePackage = 2
@ -40,13 +41,14 @@ const (
ClearMIMEPackage = 32 ClearMIMEPackage = 32
) )
// Signature types. // Send signature types.
const ( const (
SignatureNone = 0 SignatureNone = 0
SignatureDetached = 1 SignatureDetached = 1
SignatureAttachedArmored = 2 SignatureAttachedArmored = 2
) )
// DraftReq defines paylod for creating drafts
type DraftReq struct { type DraftReq struct {
Message *Message Message *Message
ParentID string `json:",omitempty"` ParentID string `json:",omitempty"`
@ -78,18 +80,18 @@ type AlgoKey struct {
type MessageAddress struct { type MessageAddress struct {
Type int Type int
BodyKeyPacket string // base64-encoded key packet. EncryptedBodyKeyPacket string `json:"BodyKeyPacket"` // base64-encoded key packet.
Signature int // 0 = None, 1 = Detached, 2 = Attached/Armored Signature int
AttachmentKeyPackets map[string]string EncryptedAttachmentKeyPackets map[string]string `json:"AttachmentKeyPackets"`
} }
type MessagePackage struct { type MessagePackage struct {
Addresses map[string]*MessageAddress Addresses map[string]*MessageAddress
Type int Type int
MIMEType string MIMEType string
Body string // base64-encoded encrypted data packet. EncryptedBody string `json:"Body"` // base64-encoded encrypted data packet.
BodyKey AlgoKey // base64-encoded session key (only if cleartext recipients). DecryptedBodyKey AlgoKey `json:"BodyKey"` // base64-encoded session key (only if cleartext recipients).
AttachmentKeys map[string]AlgoKey // Only include if cleartext & attachments. DecryptedAttachmentKeys map[string]AlgoKey `json:"AttachmentKeys"` // Only include if cleartext & attachments.
} }
func newMessagePackage( func newMessagePackage(
@ -97,7 +99,7 @@ func newMessagePackage(
attKeys map[string]AlgoKey, attKeys map[string]AlgoKey,
) (pkg *MessagePackage) { ) (pkg *MessagePackage) {
pkg = &MessagePackage{ pkg = &MessagePackage{
Body: base64.StdEncoding.EncodeToString(send.data), EncryptedBody: base64.StdEncoding.EncodeToString(send.ciphertext),
Addresses: send.addressMap, Addresses: send.addressMap,
MIMEType: send.contentType, MIMEType: send.contentType,
Type: send.sharedScheme, Type: send.sharedScheme,
@ -105,23 +107,23 @@ func newMessagePackage(
if send.sharedScheme&ClearPackage == ClearPackage || if send.sharedScheme&ClearPackage == ClearPackage ||
send.sharedScheme&ClearMIMEPackage == ClearMIMEPackage { send.sharedScheme&ClearMIMEPackage == ClearMIMEPackage {
pkg.BodyKey.Key = send.key.GetBase64Key() pkg.DecryptedBodyKey.Key = send.decryptedBodyKey.GetBase64Key()
pkg.BodyKey.Algorithm = send.key.Algo pkg.DecryptedBodyKey.Algorithm = send.decryptedBodyKey.Algo
} }
if attKeys != nil && send.sharedScheme&ClearPackage == ClearPackage { if attKeys != nil && send.sharedScheme&ClearPackage == ClearPackage {
pkg.AttachmentKeys = attKeys pkg.DecryptedAttachmentKeys = attKeys
} }
return pkg return pkg
} }
type sendData struct { type sendData struct {
key *crypto.SessionKey //body session key decryptedBodyKey *crypto.SessionKey //body session key
addressMap map[string]*MessageAddress addressMap map[string]*MessageAddress
sharedScheme int sharedScheme int
data []byte // ciphertext ciphertext []byte
body string // cleartext cleartext string
contentType string contentType string
} }
@ -148,9 +150,9 @@ func NewSendMessageReq(
req.plain.addressMap = make(map[string]*MessageAddress) req.plain.addressMap = make(map[string]*MessageAddress)
req.rich.addressMap = make(map[string]*MessageAddress) req.rich.addressMap = make(map[string]*MessageAddress)
req.mime.body = mimeBody req.mime.cleartext = mimeBody
req.plain.body = plainBody req.plain.cleartext = plainBody
req.rich.body = richBody req.rich.cleartext = richBody
req.attKeys = attKeys req.attKeys = attKeys
req.kr = kr req.kr = kr
@ -219,8 +221,8 @@ func (req *SendMessageReq) addNonMIMERecipient(
return errMultipartInNonMIME return errMultipartInNonMIME
} }
if send.key == nil { if send.decryptedBodyKey == nil {
if send.key, send.data, err = encryptSymmetric(req.kr, send.body); err != nil { if send.decryptedBodyKey, send.ciphertext, err = encryptSymmDecryptKey(req.kr, send.cleartext); err != nil {
return err return err
} }
} }
@ -237,7 +239,7 @@ func (req *SendMessageReq) addNonMIMERecipient(
} }
if doEncrypt { if doEncrypt {
newAddress.BodyKeyPacket, newAddress.AttachmentKeyPackets, err = createPackets(pubkey, send.key, req.attKeys) newAddress.EncryptedBodyKeyPacket, newAddress.EncryptedAttachmentKeyPackets, err = encryptAndEncodeSessionKeys(pubkey, send.decryptedBodyKey, req.attKeys)
if err != nil { if err != nil {
return err return err
} }
@ -254,8 +256,8 @@ func (req *SendMessageReq) addMIMERecipient(
) (err error) { ) (err error) {
req.mime.contentType = ContentTypeMultipartMixed req.mime.contentType = ContentTypeMultipartMixed
if req.mime.key == nil { if req.mime.decryptedBodyKey == nil {
if req.mime.key, req.mime.data, err = encryptSymmetric(req.kr, req.mime.body); err != nil { if req.mime.decryptedBodyKey, req.mime.ciphertext, err = encryptSymmDecryptKey(req.kr, req.mime.cleartext); err != nil {
return err return err
} }
} }
@ -267,11 +269,11 @@ func (req *SendMessageReq) addMIMERecipient(
// Attachment keys are not needed because attachments are part // Attachment keys are not needed because attachments are part
// of MIME body and therefore attachments are encrypted with // of MIME body and therefore attachments are encrypted with
// body session key. // body session key.
mimeBodyPacket, _, err := createPackets(pubkey, req.mime.key, map[string]*crypto.SessionKey{}) mimeBodyPacket, _, err := encryptAndEncodeSessionKeys(pubkey, req.mime.decryptedBodyKey, map[string]*crypto.SessionKey{})
if err != nil { if err != nil {
return err return err
} }
req.mime.addressMap[email] = &MessageAddress{Type: sendScheme, BodyKeyPacket: mimeBodyPacket, Signature: signature} req.mime.addressMap[email] = &MessageAddress{Type: sendScheme, EncryptedBodyKeyPacket: mimeBodyPacket, Signature: signature}
} else { } else {
req.mime.addressMap[email] = &MessageAddress{Type: sendScheme, Signature: signature} req.mime.addressMap[email] = &MessageAddress{Type: sendScheme, Signature: signature}
} }

View File

@ -76,19 +76,19 @@ func (td *testData) prepareAndCheck(t *testing.T) {
r.True(ok, "pkg %d email %s", i, email) r.True(ok, "pkg %d email %s", i, email)
r.Equal(wantAddress.Type, haveAddress.Type, "pkg %d email %s", i, email) r.Equal(wantAddress.Type, haveAddress.Type, "pkg %d email %s", i, email)
shouldBeEmpty(wantAddress.BodyKeyPacket)(t, haveAddress.BodyKeyPacket, "pkg %d email %s", i, email) shouldBeEmpty(wantAddress.EncryptedBodyKeyPacket)(t, haveAddress.EncryptedBodyKeyPacket, "pkg %d email %s", i, email)
r.Equal(wantAddress.Signature, haveAddress.Signature, "pkg %d email %s", i, email) r.Equal(wantAddress.Signature, haveAddress.Signature, "pkg %d email %s", i, email)
if len(td.attKeys) == 0 { if len(td.attKeys) == 0 {
r.Len(haveAddress.AttachmentKeyPackets, 0) r.Len(haveAddress.EncryptedAttachmentKeyPackets, 0)
} else { } else {
r.Equal( r.Equal(
len(wantAddress.AttachmentKeyPackets), len(wantAddress.EncryptedAttachmentKeyPackets),
len(haveAddress.AttachmentKeyPackets), len(haveAddress.EncryptedAttachmentKeyPackets),
"pkg %d email %s", i, email, "pkg %d email %s", i, email,
) )
for attID, wantAttKey := range wantAddress.AttachmentKeyPackets { for attID, wantAttKey := range wantAddress.EncryptedAttachmentKeyPackets {
haveAttKey, ok := haveAddress.AttachmentKeyPackets[attID] haveAttKey, ok := haveAddress.EncryptedAttachmentKeyPackets[attID]
r.True(ok, "pkg %d email %s att %s", i, email, attID) r.True(ok, "pkg %d email %s att %s", i, email, attID)
shouldBeEmpty(wantAttKey)(t, haveAttKey, "pkg %d email %s att %s", i, email, attID) shouldBeEmpty(wantAttKey)(t, haveAttKey, "pkg %d email %s att %s", i, email, attID)
} }
@ -98,24 +98,24 @@ func (td *testData) prepareAndCheck(t *testing.T) {
r.Equal(wantPackage.Type, havePackage.Type, "pkg %d", i) r.Equal(wantPackage.Type, havePackage.Type, "pkg %d", i)
r.Equal(wantPackage.MIMEType, havePackage.MIMEType, "pkg %d", i) r.Equal(wantPackage.MIMEType, havePackage.MIMEType, "pkg %d", i)
shouldBeEmpty(wantPackage.Body)(t, havePackage.Body, "pkg %d", i) shouldBeEmpty(wantPackage.EncryptedBody)(t, havePackage.EncryptedBody, "pkg %d", i)
wantBodyKey := wantPackage.BodyKey wantBodyKey := wantPackage.DecryptedBodyKey
haveBodyKey := havePackage.BodyKey haveBodyKey := havePackage.DecryptedBodyKey
shouldBeEmpty(wantBodyKey.Algorithm)(t, haveBodyKey.Algorithm, "pkg %d", i) shouldBeEmpty(wantBodyKey.Algorithm)(t, haveBodyKey.Algorithm, "pkg %d", i)
shouldBeEmpty(wantBodyKey.Key)(t, haveBodyKey.Key, "pkg %d", i) shouldBeEmpty(wantBodyKey.Key)(t, haveBodyKey.Key, "pkg %d", i)
if len(td.attKeys) == 0 { if len(td.attKeys) == 0 {
r.Len(havePackage.AttachmentKeys, 0) r.Len(havePackage.DecryptedAttachmentKeys, 0)
} else { } else {
r.Equal( r.Equal(
len(wantPackage.AttachmentKeys), len(wantPackage.DecryptedAttachmentKeys),
len(havePackage.AttachmentKeys), len(havePackage.DecryptedAttachmentKeys),
"pkg %d", i, "pkg %d", i,
) )
for attID, wantAttKey := range wantPackage.AttachmentKeys { for attID, wantAttKey := range wantPackage.DecryptedAttachmentKeys {
haveAttKey, ok := havePackage.AttachmentKeys[attID] haveAttKey, ok := havePackage.DecryptedAttachmentKeys[attID]
r.True(ok, "pkg %d att %s", i, attID) r.True(ok, "pkg %d att %s", i, attID)
shouldBeEmpty(wantAttKey.Key)(t, haveAttKey.Key, "pkg %d att %s", i, attID) shouldBeEmpty(wantAttKey.Key)(t, haveAttKey.Key, "pkg %d att %s", i, attID)
shouldBeEmpty(wantAttKey.Algorithm)(t, haveAttKey.Algorithm, "pkg %d att %s", i, attID) shouldBeEmpty(wantAttKey.Algorithm)(t, haveAttKey.Algorithm, "pkg %d att %s", i, attID)
@ -151,13 +151,13 @@ func TestSendReq(t *testing.T) {
"html@pm.me": { "html@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "not-empty", EncryptedBodyKeyPacket: "not-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: InternalPackage, Type: InternalPackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
}, },
}, },
@ -171,13 +171,13 @@ func TestSendReq(t *testing.T) {
"plain@pm.me": { "plain@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "not-empty", EncryptedBodyKeyPacket: "not-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: InternalPackage, Type: InternalPackage,
MIMEType: ContentTypePlainText, MIMEType: ContentTypePlainText,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
}, },
}, },
@ -202,38 +202,38 @@ func TestSendReq(t *testing.T) {
"internal1@pm.me": { "internal1@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "not-empty", EncryptedBodyKeyPacket: "not-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
"internal3@pm.me": { "internal3@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "not-empty", EncryptedBodyKeyPacket: "not-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: InternalPackage, Type: InternalPackage,
MIMEType: ContentTypePlainText, MIMEType: ContentTypePlainText,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
{ {
Addresses: map[string]*MessageAddress{ Addresses: map[string]*MessageAddress{
"internal2@pm.me": { "internal2@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "not-empty", EncryptedBodyKeyPacket: "not-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
"internal4@pm.me": { "internal4@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "not-empty", EncryptedBodyKeyPacket: "not-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: InternalPackage, Type: InternalPackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
}, },
}, },
@ -252,9 +252,9 @@ func TestSendReq(t *testing.T) {
}, },
Type: ClearPackage, Type: ClearPackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
AttachmentKeys: attAlgoKeys, DecryptedAttachmentKeys: attAlgoKeys,
}, },
}, },
}, },
@ -272,9 +272,9 @@ func TestSendReq(t *testing.T) {
}, },
Type: ClearPackage, Type: ClearPackage,
MIMEType: ContentTypePlainText, MIMEType: ContentTypePlainText,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
AttachmentKeys: attAlgoKeys, DecryptedAttachmentKeys: attAlgoKeys,
}, },
}, },
}, },
@ -292,8 +292,8 @@ func TestSendReq(t *testing.T) {
}, },
Type: ClearMIMEPackage, Type: ClearMIMEPackage,
MIMEType: ContentTypeMultipartMixed, MIMEType: ContentTypeMultipartMixed,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
}, },
}, },
}, },
@ -311,8 +311,8 @@ func TestSendReq(t *testing.T) {
}, },
Type: ClearMIMEPackage, Type: ClearMIMEPackage,
MIMEType: ContentTypeMultipartMixed, MIMEType: ContentTypeMultipartMixed,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
}, },
}, },
}, },
@ -345,8 +345,8 @@ func TestSendReq(t *testing.T) {
}, },
Type: ClearMIMEPackage, Type: ClearMIMEPackage,
MIMEType: ContentTypeMultipartMixed, MIMEType: ContentTypeMultipartMixed,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
}, },
{ {
Addresses: map[string]*MessageAddress{ Addresses: map[string]*MessageAddress{
@ -357,9 +357,9 @@ func TestSendReq(t *testing.T) {
}, },
Type: ClearPackage, Type: ClearPackage,
MIMEType: ContentTypePlainText, MIMEType: ContentTypePlainText,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
AttachmentKeys: attAlgoKeys, DecryptedAttachmentKeys: attAlgoKeys,
}, },
{ {
Addresses: map[string]*MessageAddress{ Addresses: map[string]*MessageAddress{
@ -370,9 +370,9 @@ func TestSendReq(t *testing.T) {
}, },
Type: ClearPackage, Type: ClearPackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
AttachmentKeys: attAlgoKeys, DecryptedAttachmentKeys: attAlgoKeys,
}, },
}, },
}, },
@ -387,12 +387,12 @@ func TestSendReq(t *testing.T) {
"mime@gpg.com": { "mime@gpg.com": {
Type: PGPMIMEPackage, Type: PGPMIMEPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
}, },
}, },
Type: PGPMIMEPackage, Type: PGPMIMEPackage,
MIMEType: ContentTypeMultipartMixed, MIMEType: ContentTypeMultipartMixed,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
}, },
}, },
@ -406,13 +406,13 @@ func TestSendReq(t *testing.T) {
"inline-plain@gpg.com": { "inline-plain@gpg.com": {
Type: PGPInlinePackage, Type: PGPInlinePackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: PGPInlinePackage, Type: PGPInlinePackage,
MIMEType: ContentTypePlainText, MIMEType: ContentTypePlainText,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
}, },
}, },
@ -426,13 +426,13 @@ func TestSendReq(t *testing.T) {
"inline-html@gpg.com": { "inline-html@gpg.com": {
Type: PGPInlinePackage, Type: PGPInlinePackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: PGPInlinePackage, Type: PGPInlinePackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
}, },
}, },
@ -458,38 +458,38 @@ func TestSendReq(t *testing.T) {
"mime@gpg.com": { "mime@gpg.com": {
Type: PGPMIMEPackage, Type: PGPMIMEPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
}, },
}, },
Type: PGPMIMEPackage, Type: PGPMIMEPackage,
MIMEType: ContentTypeMultipartMixed, MIMEType: ContentTypeMultipartMixed,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
{ {
Addresses: map[string]*MessageAddress{ Addresses: map[string]*MessageAddress{
"inline-plain@gpg.com": { "inline-plain@gpg.com": {
Type: PGPInlinePackage, Type: PGPInlinePackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: PGPInlinePackage, Type: PGPInlinePackage,
MIMEType: ContentTypePlainText, MIMEType: ContentTypePlainText,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
{ {
Addresses: map[string]*MessageAddress{ Addresses: map[string]*MessageAddress{
"inline-html@gpg.com": { "inline-html@gpg.com": {
Type: PGPInlinePackage, Type: PGPInlinePackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: PGPInlinePackage, Type: PGPInlinePackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
}, },
}, },
@ -505,19 +505,19 @@ func TestSendReq(t *testing.T) {
"inline-html@gpg.com": { "inline-html@gpg.com": {
Type: PGPInlinePackage, Type: PGPInlinePackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
"internal@pm.me": { "internal@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: PGPInlinePackage | InternalPackage, Type: PGPInlinePackage | InternalPackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
}, },
}, },
@ -532,19 +532,19 @@ func TestSendReq(t *testing.T) {
"inline-plain@gpg.com": { "inline-plain@gpg.com": {
Type: PGPInlinePackage, Type: PGPInlinePackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
"internal@pm.me": { "internal@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: PGPInlinePackage | InternalPackage, Type: PGPInlinePackage | InternalPackage,
MIMEType: ContentTypePlainText, MIMEType: ContentTypePlainText,
Body: "non-empty", EncryptedBody: "non-empty",
}, },
}, },
}, },
@ -559,8 +559,8 @@ func TestSendReq(t *testing.T) {
"internal@pm.me": { "internal@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "not-empty", EncryptedBodyKeyPacket: "not-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
"html@email.com": { "html@email.com": {
Type: ClearPackage, Type: ClearPackage,
@ -569,9 +569,9 @@ func TestSendReq(t *testing.T) {
}, },
Type: InternalPackage | ClearPackage, Type: InternalPackage | ClearPackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
AttachmentKeys: attAlgoKeys, DecryptedAttachmentKeys: attAlgoKeys,
}, },
}, },
}, },
@ -586,8 +586,8 @@ func TestSendReq(t *testing.T) {
"internal@pm.me": { "internal@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "not-empty", EncryptedBodyKeyPacket: "not-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
"html@email.com": { "html@email.com": {
Type: ClearPackage, Type: ClearPackage,
@ -596,9 +596,9 @@ func TestSendReq(t *testing.T) {
}, },
Type: InternalPackage | ClearPackage, Type: InternalPackage | ClearPackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
AttachmentKeys: attAlgoKeys, DecryptedAttachmentKeys: attAlgoKeys,
}, },
}, },
}, },
@ -613,8 +613,8 @@ func TestSendReq(t *testing.T) {
"inline-html@gpg.com": { "inline-html@gpg.com": {
Type: PGPInlinePackage, Type: PGPInlinePackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
"html@email.com": { "html@email.com": {
Type: ClearPackage, Type: ClearPackage,
@ -623,9 +623,9 @@ func TestSendReq(t *testing.T) {
}, },
Type: PGPInlinePackage | ClearPackage, Type: PGPInlinePackage | ClearPackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
AttachmentKeys: attAlgoKeys, DecryptedAttachmentKeys: attAlgoKeys,
}, },
}, },
}, },
@ -644,15 +644,15 @@ func TestSendReq(t *testing.T) {
"inline-plain@gpg.com": { "inline-plain@gpg.com": {
Type: PGPInlinePackage, Type: PGPInlinePackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: PGPInlinePackage | ClearPackage, Type: PGPInlinePackage | ClearPackage,
MIMEType: ContentTypePlainText, MIMEType: ContentTypePlainText,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
AttachmentKeys: attAlgoKeys, DecryptedAttachmentKeys: attAlgoKeys,
}, },
}, },
}, },
@ -667,7 +667,7 @@ func TestSendReq(t *testing.T) {
"mime@gpg.com": { "mime@gpg.com": {
Type: PGPMIMEPackage, Type: PGPMIMEPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
}, },
"signed@email.com": { "signed@email.com": {
Type: ClearMIMEPackage, Type: ClearMIMEPackage,
@ -676,8 +676,8 @@ func TestSendReq(t *testing.T) {
}, },
Type: ClearMIMEPackage | PGPMIMEPackage, Type: ClearMIMEPackage | PGPMIMEPackage,
MIMEType: ContentTypeMultipartMixed, MIMEType: ContentTypeMultipartMixed,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
}, },
}, },
}, },
@ -692,7 +692,7 @@ func TestSendReq(t *testing.T) {
"mime@gpg.com": { "mime@gpg.com": {
Type: PGPMIMEPackage, Type: PGPMIMEPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
}, },
"mime@email.com": { // can this be combined ? "mime@email.com": { // can this be combined ?
Type: ClearMIMEPackage, Type: ClearMIMEPackage,
@ -701,8 +701,8 @@ func TestSendReq(t *testing.T) {
}, },
Type: ClearMIMEPackage | PGPMIMEPackage, Type: ClearMIMEPackage | PGPMIMEPackage,
MIMEType: ContentTypeMultipartMixed, MIMEType: ContentTypeMultipartMixed,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
}, },
}, },
}, },
@ -726,7 +726,7 @@ func TestSendReq(t *testing.T) {
"mime@gpg.com": { "mime@gpg.com": {
Type: PGPMIMEPackage, Type: PGPMIMEPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
}, },
"mime@email.com": { "mime@email.com": {
Type: ClearMIMEPackage, Type: ClearMIMEPackage,
@ -739,16 +739,16 @@ func TestSendReq(t *testing.T) {
}, },
Type: ClearMIMEPackage | PGPMIMEPackage, Type: ClearMIMEPackage | PGPMIMEPackage,
MIMEType: ContentTypeMultipartMixed, MIMEType: ContentTypeMultipartMixed,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
}, },
{ {
Addresses: map[string]*MessageAddress{ Addresses: map[string]*MessageAddress{
"plain@pm.me": { "plain@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "not-empty", EncryptedBodyKeyPacket: "not-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
"plain@email.com": { "plain@email.com": {
Type: ClearPackage, Type: ClearPackage,
@ -757,23 +757,23 @@ func TestSendReq(t *testing.T) {
"inline-plain@gpg.com": { "inline-plain@gpg.com": {
Type: PGPInlinePackage, Type: PGPInlinePackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: InternalPackage | ClearPackage | PGPInlinePackage, Type: InternalPackage | ClearPackage | PGPInlinePackage,
MIMEType: ContentTypePlainText, MIMEType: ContentTypePlainText,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
AttachmentKeys: attAlgoKeys, DecryptedAttachmentKeys: attAlgoKeys,
}, },
{ {
Addresses: map[string]*MessageAddress{ Addresses: map[string]*MessageAddress{
"html@pm.me": { "html@pm.me": {
Type: InternalPackage, Type: InternalPackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "not-empty", EncryptedBodyKeyPacket: "not-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
"html@email.com": { "html@email.com": {
Type: ClearPackage, Type: ClearPackage,
@ -782,15 +782,15 @@ func TestSendReq(t *testing.T) {
"inline-html@gpg.com": { "inline-html@gpg.com": {
Type: PGPInlinePackage, Type: PGPInlinePackage,
Signature: SignatureDetached, Signature: SignatureDetached,
BodyKeyPacket: "non-empty", EncryptedBodyKeyPacket: "non-empty",
AttachmentKeyPackets: attKeyPackets, EncryptedAttachmentKeyPackets: attKeyPackets,
}, },
}, },
Type: InternalPackage | ClearPackage | PGPInlinePackage, Type: InternalPackage | ClearPackage | PGPInlinePackage,
MIMEType: ContentTypeHTML, MIMEType: ContentTypeHTML,
Body: "non-empty", EncryptedBody: "non-empty",
BodyKey: AlgoKey{"non-empty", "non-empty"}, DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
AttachmentKeys: attAlgoKeys, DecryptedAttachmentKeys: attAlgoKeys,
}, },
}, },
}, },