forked from Silverfish/proton-bridge
rename
This commit is contained in:
@ -291,7 +291,7 @@ func signAttachment(encrypter *crypto.KeyRing, data io.Reader) (signature io.Rea
|
||||
return bytes.NewReader(sig.GetBinary()), nil
|
||||
}
|
||||
|
||||
func createPackets(
|
||||
func encryptAndEncodeSessionKeys(
|
||||
pubkey *crypto.KeyRing,
|
||||
bodyKey *crypto.SessionKey,
|
||||
attkeys map[string]*crypto.SessionKey,
|
||||
@ -315,7 +315,7 @@ func createPackets(
|
||||
return
|
||||
}
|
||||
|
||||
func encryptSymmetric(
|
||||
func encryptSymmDecryptKey(
|
||||
kr *crypto.KeyRing,
|
||||
textToEncrypt string,
|
||||
) (decryptedKey *crypto.SessionKey, symEncryptedData []byte, err error) {
|
||||
|
||||
@ -24,13 +24,14 @@ import (
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
)
|
||||
|
||||
// Draft actions
|
||||
const (
|
||||
DraftActionReply = 0
|
||||
DraftActionReplyAll = 1
|
||||
DraftActionForward = 2
|
||||
)
|
||||
|
||||
// Message package types.
|
||||
// Message send package types.
|
||||
const (
|
||||
InternalPackage = 1
|
||||
EncryptedOutsidePackage = 2
|
||||
@ -40,13 +41,14 @@ const (
|
||||
ClearMIMEPackage = 32
|
||||
)
|
||||
|
||||
// Signature types.
|
||||
// Send signature types.
|
||||
const (
|
||||
SignatureNone = 0
|
||||
SignatureDetached = 1
|
||||
SignatureAttachedArmored = 2
|
||||
)
|
||||
|
||||
// DraftReq defines paylod for creating drafts
|
||||
type DraftReq struct {
|
||||
Message *Message
|
||||
ParentID string `json:",omitempty"`
|
||||
@ -77,19 +79,19 @@ type AlgoKey struct {
|
||||
}
|
||||
|
||||
type MessageAddress struct {
|
||||
Type int
|
||||
BodyKeyPacket string // base64-encoded key packet.
|
||||
Signature int // 0 = None, 1 = Detached, 2 = Attached/Armored
|
||||
AttachmentKeyPackets map[string]string
|
||||
Type int
|
||||
EncryptedBodyKeyPacket string `json:"BodyKeyPacket"` // base64-encoded key packet.
|
||||
Signature int
|
||||
EncryptedAttachmentKeyPackets map[string]string `json:"AttachmentKeyPackets"`
|
||||
}
|
||||
|
||||
type MessagePackage struct {
|
||||
Addresses map[string]*MessageAddress
|
||||
Type int
|
||||
MIMEType string
|
||||
Body string // base64-encoded encrypted data packet.
|
||||
BodyKey AlgoKey // base64-encoded session key (only if cleartext recipients).
|
||||
AttachmentKeys map[string]AlgoKey // Only include if cleartext & attachments.
|
||||
Addresses map[string]*MessageAddress
|
||||
Type int
|
||||
MIMEType string
|
||||
EncryptedBody string `json:"Body"` // base64-encoded encrypted data packet.
|
||||
DecryptedBodyKey AlgoKey `json:"BodyKey"` // base64-encoded session key (only if cleartext recipients).
|
||||
DecryptedAttachmentKeys map[string]AlgoKey `json:"AttachmentKeys"` // Only include if cleartext & attachments.
|
||||
}
|
||||
|
||||
func newMessagePackage(
|
||||
@ -97,32 +99,32 @@ func newMessagePackage(
|
||||
attKeys map[string]AlgoKey,
|
||||
) (pkg *MessagePackage) {
|
||||
pkg = &MessagePackage{
|
||||
Body: base64.StdEncoding.EncodeToString(send.data),
|
||||
Addresses: send.addressMap,
|
||||
MIMEType: send.contentType,
|
||||
Type: send.sharedScheme,
|
||||
EncryptedBody: base64.StdEncoding.EncodeToString(send.ciphertext),
|
||||
Addresses: send.addressMap,
|
||||
MIMEType: send.contentType,
|
||||
Type: send.sharedScheme,
|
||||
}
|
||||
|
||||
if send.sharedScheme&ClearPackage == ClearPackage ||
|
||||
send.sharedScheme&ClearMIMEPackage == ClearMIMEPackage {
|
||||
pkg.BodyKey.Key = send.key.GetBase64Key()
|
||||
pkg.BodyKey.Algorithm = send.key.Algo
|
||||
pkg.DecryptedBodyKey.Key = send.decryptedBodyKey.GetBase64Key()
|
||||
pkg.DecryptedBodyKey.Algorithm = send.decryptedBodyKey.Algo
|
||||
}
|
||||
|
||||
if attKeys != nil && send.sharedScheme&ClearPackage == ClearPackage {
|
||||
pkg.AttachmentKeys = attKeys
|
||||
pkg.DecryptedAttachmentKeys = attKeys
|
||||
}
|
||||
|
||||
return pkg
|
||||
}
|
||||
|
||||
type sendData struct {
|
||||
key *crypto.SessionKey //body session key
|
||||
addressMap map[string]*MessageAddress
|
||||
sharedScheme int
|
||||
data []byte // ciphertext
|
||||
body string // cleartext
|
||||
contentType string
|
||||
decryptedBodyKey *crypto.SessionKey //body session key
|
||||
addressMap map[string]*MessageAddress
|
||||
sharedScheme int
|
||||
ciphertext []byte
|
||||
cleartext string
|
||||
contentType string
|
||||
}
|
||||
|
||||
type SendMessageReq struct {
|
||||
@ -148,9 +150,9 @@ func NewSendMessageReq(
|
||||
req.plain.addressMap = make(map[string]*MessageAddress)
|
||||
req.rich.addressMap = make(map[string]*MessageAddress)
|
||||
|
||||
req.mime.body = mimeBody
|
||||
req.plain.body = plainBody
|
||||
req.rich.body = richBody
|
||||
req.mime.cleartext = mimeBody
|
||||
req.plain.cleartext = plainBody
|
||||
req.rich.cleartext = richBody
|
||||
|
||||
req.attKeys = attKeys
|
||||
req.kr = kr
|
||||
@ -219,8 +221,8 @@ func (req *SendMessageReq) addNonMIMERecipient(
|
||||
return errMultipartInNonMIME
|
||||
}
|
||||
|
||||
if send.key == nil {
|
||||
if send.key, send.data, err = encryptSymmetric(req.kr, send.body); err != nil {
|
||||
if send.decryptedBodyKey == nil {
|
||||
if send.decryptedBodyKey, send.ciphertext, err = encryptSymmDecryptKey(req.kr, send.cleartext); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -237,7 +239,7 @@ func (req *SendMessageReq) addNonMIMERecipient(
|
||||
}
|
||||
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
@ -254,8 +256,8 @@ func (req *SendMessageReq) addMIMERecipient(
|
||||
) (err error) {
|
||||
|
||||
req.mime.contentType = ContentTypeMultipartMixed
|
||||
if req.mime.key == nil {
|
||||
if req.mime.key, req.mime.data, err = encryptSymmetric(req.kr, req.mime.body); err != nil {
|
||||
if req.mime.decryptedBodyKey == nil {
|
||||
if req.mime.decryptedBodyKey, req.mime.ciphertext, err = encryptSymmDecryptKey(req.kr, req.mime.cleartext); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -267,11 +269,11 @@ func (req *SendMessageReq) addMIMERecipient(
|
||||
// Attachment keys are not needed because attachments are part
|
||||
// of MIME body and therefore attachments are encrypted with
|
||||
// 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 {
|
||||
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 {
|
||||
req.mime.addressMap[email] = &MessageAddress{Type: sendScheme, Signature: signature}
|
||||
}
|
||||
|
||||
@ -76,19 +76,19 @@ func (td *testData) prepareAndCheck(t *testing.T) {
|
||||
r.True(ok, "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)
|
||||
|
||||
if len(td.attKeys) == 0 {
|
||||
r.Len(haveAddress.AttachmentKeyPackets, 0)
|
||||
r.Len(haveAddress.EncryptedAttachmentKeyPackets, 0)
|
||||
} else {
|
||||
r.Equal(
|
||||
len(wantAddress.AttachmentKeyPackets),
|
||||
len(haveAddress.AttachmentKeyPackets),
|
||||
len(wantAddress.EncryptedAttachmentKeyPackets),
|
||||
len(haveAddress.EncryptedAttachmentKeyPackets),
|
||||
"pkg %d email %s", i, email,
|
||||
)
|
||||
for attID, wantAttKey := range wantAddress.AttachmentKeyPackets {
|
||||
haveAttKey, ok := haveAddress.AttachmentKeyPackets[attID]
|
||||
for attID, wantAttKey := range wantAddress.EncryptedAttachmentKeyPackets {
|
||||
haveAttKey, ok := haveAddress.EncryptedAttachmentKeyPackets[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)
|
||||
}
|
||||
@ -98,24 +98,24 @@ func (td *testData) prepareAndCheck(t *testing.T) {
|
||||
r.Equal(wantPackage.Type, havePackage.Type, "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
|
||||
haveBodyKey := havePackage.BodyKey
|
||||
wantBodyKey := wantPackage.DecryptedBodyKey
|
||||
haveBodyKey := havePackage.DecryptedBodyKey
|
||||
|
||||
shouldBeEmpty(wantBodyKey.Algorithm)(t, haveBodyKey.Algorithm, "pkg %d", i)
|
||||
shouldBeEmpty(wantBodyKey.Key)(t, haveBodyKey.Key, "pkg %d", i)
|
||||
|
||||
if len(td.attKeys) == 0 {
|
||||
r.Len(havePackage.AttachmentKeys, 0)
|
||||
r.Len(havePackage.DecryptedAttachmentKeys, 0)
|
||||
} else {
|
||||
r.Equal(
|
||||
len(wantPackage.AttachmentKeys),
|
||||
len(havePackage.AttachmentKeys),
|
||||
len(wantPackage.DecryptedAttachmentKeys),
|
||||
len(havePackage.DecryptedAttachmentKeys),
|
||||
"pkg %d", i,
|
||||
)
|
||||
for attID, wantAttKey := range wantPackage.AttachmentKeys {
|
||||
haveAttKey, ok := havePackage.AttachmentKeys[attID]
|
||||
for attID, wantAttKey := range wantPackage.DecryptedAttachmentKeys {
|
||||
haveAttKey, ok := havePackage.DecryptedAttachmentKeys[attID]
|
||||
r.True(ok, "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)
|
||||
@ -149,15 +149,15 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"html@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "not-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "not-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: InternalPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
Type: InternalPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -169,15 +169,15 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"plain@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "not-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "not-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: InternalPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
Body: "non-empty",
|
||||
Type: InternalPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -200,40 +200,40 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"internal1@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "not-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "not-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
"internal3@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "not-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "not-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: InternalPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
Body: "non-empty",
|
||||
Type: InternalPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"internal2@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "not-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "not-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
"internal4@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "not-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "not-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: InternalPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
Type: InternalPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -250,11 +250,11 @@ func TestSendReq(t *testing.T) {
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
},
|
||||
Type: ClearPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
AttachmentKeys: attAlgoKeys,
|
||||
Type: ClearPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
DecryptedAttachmentKeys: attAlgoKeys,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -270,11 +270,11 @@ func TestSendReq(t *testing.T) {
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
},
|
||||
Type: ClearPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
AttachmentKeys: attAlgoKeys,
|
||||
Type: ClearPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
DecryptedAttachmentKeys: attAlgoKeys,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -290,10 +290,10 @@ func TestSendReq(t *testing.T) {
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
},
|
||||
Type: ClearMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
Type: ClearMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -309,10 +309,10 @@ func TestSendReq(t *testing.T) {
|
||||
Signature: SignatureDetached,
|
||||
},
|
||||
},
|
||||
Type: ClearMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
Type: ClearMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -343,10 +343,10 @@ func TestSendReq(t *testing.T) {
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
},
|
||||
Type: ClearMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
Type: ClearMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
},
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
@ -355,11 +355,11 @@ func TestSendReq(t *testing.T) {
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
},
|
||||
Type: ClearPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
AttachmentKeys: attAlgoKeys,
|
||||
Type: ClearPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
DecryptedAttachmentKeys: attAlgoKeys,
|
||||
},
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
@ -368,11 +368,11 @@ func TestSendReq(t *testing.T) {
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
},
|
||||
Type: ClearPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
AttachmentKeys: attAlgoKeys,
|
||||
Type: ClearPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
DecryptedAttachmentKeys: attAlgoKeys,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -385,14 +385,14 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"mime@gpg.com": {
|
||||
Type: PGPMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
Type: PGPMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
},
|
||||
},
|
||||
Type: PGPMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
Body: "non-empty",
|
||||
Type: PGPMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -404,15 +404,15 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"inline-plain@gpg.com": {
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: PGPInlinePackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
Body: "non-empty",
|
||||
Type: PGPInlinePackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -424,15 +424,15 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"inline-html@gpg.com": {
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: PGPInlinePackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
Type: PGPInlinePackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -456,40 +456,40 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"mime@gpg.com": {
|
||||
Type: PGPMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
Type: PGPMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
},
|
||||
},
|
||||
Type: PGPMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
Body: "non-empty",
|
||||
Type: PGPMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"inline-plain@gpg.com": {
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: PGPInlinePackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
Body: "non-empty",
|
||||
Type: PGPInlinePackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"inline-html@gpg.com": {
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: PGPInlinePackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
Type: PGPInlinePackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -503,21 +503,21 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"inline-html@gpg.com": {
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
"internal@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: PGPInlinePackage | InternalPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
Type: PGPInlinePackage | InternalPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -530,21 +530,21 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"inline-plain@gpg.com": {
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
"internal@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: PGPInlinePackage | InternalPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
Body: "non-empty",
|
||||
Type: PGPInlinePackage | InternalPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
EncryptedBody: "non-empty",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -557,21 +557,21 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"internal@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "not-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "not-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
"html@email.com": {
|
||||
Type: ClearPackage,
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
},
|
||||
Type: InternalPackage | ClearPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
AttachmentKeys: attAlgoKeys,
|
||||
Type: InternalPackage | ClearPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
DecryptedAttachmentKeys: attAlgoKeys,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -584,21 +584,21 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"internal@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "not-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "not-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
"html@email.com": {
|
||||
Type: ClearPackage,
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
},
|
||||
Type: InternalPackage | ClearPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
AttachmentKeys: attAlgoKeys,
|
||||
Type: InternalPackage | ClearPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
DecryptedAttachmentKeys: attAlgoKeys,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -611,21 +611,21 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"inline-html@gpg.com": {
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
"html@email.com": {
|
||||
Type: ClearPackage,
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
},
|
||||
Type: PGPInlinePackage | ClearPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
AttachmentKeys: attAlgoKeys,
|
||||
Type: PGPInlinePackage | ClearPackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
DecryptedAttachmentKeys: attAlgoKeys,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -642,17 +642,17 @@ func TestSendReq(t *testing.T) {
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
"inline-plain@gpg.com": {
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: PGPInlinePackage | ClearPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
AttachmentKeys: attAlgoKeys,
|
||||
Type: PGPInlinePackage | ClearPackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
DecryptedAttachmentKeys: attAlgoKeys,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -665,19 +665,19 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"mime@gpg.com": {
|
||||
Type: PGPMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
Type: PGPMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
},
|
||||
"signed@email.com": {
|
||||
Type: ClearMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
},
|
||||
},
|
||||
Type: ClearMIMEPackage | PGPMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
Type: ClearMIMEPackage | PGPMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -690,19 +690,19 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"mime@gpg.com": {
|
||||
Type: PGPMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
Type: PGPMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
},
|
||||
"mime@email.com": { // can this be combined ?
|
||||
Type: ClearMIMEPackage,
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
},
|
||||
Type: ClearMIMEPackage | PGPMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
Type: ClearMIMEPackage | PGPMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -724,9 +724,9 @@ func TestSendReq(t *testing.T) {
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{ // TODO can this three be combined
|
||||
"mime@gpg.com": {
|
||||
Type: PGPMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
Type: PGPMIMEPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
},
|
||||
"mime@email.com": {
|
||||
Type: ClearMIMEPackage,
|
||||
@ -737,60 +737,60 @@ func TestSendReq(t *testing.T) {
|
||||
Signature: SignatureDetached,
|
||||
},
|
||||
},
|
||||
Type: ClearMIMEPackage | PGPMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
Type: ClearMIMEPackage | PGPMIMEPackage,
|
||||
MIMEType: ContentTypeMultipartMixed,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
},
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"plain@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "not-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "not-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
"plain@email.com": {
|
||||
Type: ClearPackage,
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
"inline-plain@gpg.com": {
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: InternalPackage | ClearPackage | PGPInlinePackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
AttachmentKeys: attAlgoKeys,
|
||||
Type: InternalPackage | ClearPackage | PGPInlinePackage,
|
||||
MIMEType: ContentTypePlainText,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
DecryptedAttachmentKeys: attAlgoKeys,
|
||||
},
|
||||
{
|
||||
Addresses: map[string]*MessageAddress{
|
||||
"html@pm.me": {
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "not-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: InternalPackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "not-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
"html@email.com": {
|
||||
Type: ClearPackage,
|
||||
Signature: SignatureNone,
|
||||
},
|
||||
"inline-html@gpg.com": {
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
BodyKeyPacket: "non-empty",
|
||||
AttachmentKeyPackets: attKeyPackets,
|
||||
Type: PGPInlinePackage,
|
||||
Signature: SignatureDetached,
|
||||
EncryptedBodyKeyPacket: "non-empty",
|
||||
EncryptedAttachmentKeyPackets: attKeyPackets,
|
||||
},
|
||||
},
|
||||
Type: InternalPackage | ClearPackage | PGPInlinePackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
Body: "non-empty",
|
||||
BodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
AttachmentKeys: attAlgoKeys,
|
||||
Type: InternalPackage | ClearPackage | PGPInlinePackage,
|
||||
MIMEType: ContentTypeHTML,
|
||||
EncryptedBody: "non-empty",
|
||||
DecryptedBodyKey: AlgoKey{"non-empty", "non-empty"},
|
||||
DecryptedAttachmentKeys: attAlgoKeys,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user