Fix Attachment Error 15212

Change AttachmentKeys format from ID:Key to ID:{Algorithm,Key}.
This commit is contained in:
Dmitry Valter 2020-03-02 02:28:49 +03:00 committed by Simon Ser
parent b6073991b8
commit ea106494fe
1 changed files with 9 additions and 6 deletions

View File

@ -403,15 +403,15 @@ type MessagePackageSet struct {
Body string // Encrypted body data packet
// Only if cleartext is sent
BodyKey *MessageBodyKey `json:",omitempty"`
AttachmentKeys map[string]string
BodyKey *PackedKey `json:",omitempty"`
AttachmentKeys map[string]*PackedKey `json:",omitempty"`
bodyKey *packet.EncryptedKey
attachmentKeys map[string]*packet.EncryptedKey
signature int
}
type MessageBodyKey struct {
type PackedKey struct {
Algorithm string
Key string
}
@ -513,14 +513,17 @@ func (set *MessagePackageSet) AddCleartext(addr string) (*MessagePackage, error)
set.Type |= MessagePackageCleartext
if set.BodyKey == nil || set.AttachmentKeys == nil {
set.BodyKey = &MessageBodyKey{
set.BodyKey = &PackedKey{
Algorithm: cipherFunctionString(set.bodyKey.CipherFunc),
Key: base64.StdEncoding.EncodeToString(set.bodyKey.Key),
}
set.AttachmentKeys = make(map[string]string, len(set.attachmentKeys))
set.AttachmentKeys = make(map[string]*PackedKey, len(set.attachmentKeys))
for att, key := range set.attachmentKeys {
set.AttachmentKeys[att] = base64.StdEncoding.EncodeToString(key.Key)
set.AttachmentKeys[att] = &PackedKey{
Algorithm: cipherFunctionString(key.CipherFunc),
Key: base64.StdEncoding.EncodeToString(key.Key),
}
}
}