mirror of
https://github.com/ProtonMail/go-proton-api.git
synced 2025-12-23 23:57:50 -05:00
fix: Only use first key to encrypt attachments and drafts
This commit is contained in:
@@ -19,12 +19,17 @@ func (c *Client) UploadAttachment(ctx context.Context, addrKR *crypto.KeyRing, r
|
|||||||
Attachment Attachment
|
Attachment Attachment
|
||||||
}
|
}
|
||||||
|
|
||||||
sig, err := addrKR.SignDetached(crypto.NewPlainMessage(req.Body))
|
kr, err := addrKR.FirstKey()
|
||||||
|
if err != nil {
|
||||||
|
return res.Attachment, fmt.Errorf("failed to get first key: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sig, err := kr.SignDetached(crypto.NewPlainMessage(req.Body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Attachment{}, fmt.Errorf("failed to sign attachment: %w", err)
|
return Attachment{}, fmt.Errorf("failed to sign attachment: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
enc, err := addrKR.EncryptAttachment(crypto.NewPlainMessage(req.Body), req.Filename)
|
enc, err := kr.EncryptAttachment(crypto.NewPlainMessage(req.Body), req.Filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Attachment{}, fmt.Errorf("failed to encrypt attachment: %w", err)
|
return Attachment{}, fmt.Errorf("failed to encrypt attachment: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ func (c *Client) CreateDraft(ctx context.Context, addrKR *crypto.KeyRing, req Cr
|
|||||||
Message Message
|
Message Message
|
||||||
}
|
}
|
||||||
|
|
||||||
enc, err := addrKR.Encrypt(crypto.NewPlainMessageFromString(req.Message.Body), nil)
|
kr, err := addrKR.FirstKey()
|
||||||
|
if err != nil {
|
||||||
|
return Message{}, fmt.Errorf("failed to get first key: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
enc, err := kr.Encrypt(crypto.NewPlainMessageFromString(req.Message.Body), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Message{}, fmt.Errorf("failed to encrypt draft: %w", err)
|
return Message{}, fmt.Errorf("failed to encrypt draft: %w", err)
|
||||||
}
|
}
|
||||||
@@ -40,7 +45,12 @@ func (c *Client) UpdateDraft(ctx context.Context, draftID string, addrKR *crypto
|
|||||||
}
|
}
|
||||||
|
|
||||||
if req.Message.Body != "" {
|
if req.Message.Body != "" {
|
||||||
enc, err := addrKR.Encrypt(crypto.NewPlainMessageFromString(req.Message.Body), nil)
|
kr, err := addrKR.FirstKey()
|
||||||
|
if err != nil {
|
||||||
|
return Message{}, fmt.Errorf("failed to get first key: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
enc, err := kr.Encrypt(crypto.NewPlainMessageFromString(req.Message.Body), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Message{}, fmt.Errorf("failed to encrypt draft: %w", err)
|
return Message{}, fmt.Errorf("failed to encrypt draft: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user