Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ProtonMail/gopenpgp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d9f3052f715224ba7a5fc5f35ed2cad26fe5e355
Choose a base ref
..
head repository: ProtonMail/gopenpgp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 07a6094366623211e6156384b42315402f783430
Choose a head ref
Showing with 8 additions and 8 deletions.
  1. +2 −2 crypto/encryption.go
  2. +3 −3 crypto/encryption_handle.go
  3. +3 −3 profile/profile.go
4 changes: 2 additions & 2 deletions crypto/encryption.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package crypto
import "github.com/ProtonMail/go-crypto/openpgp/packet"

type EncryptionProfile interface {
EncryptionConfig(messageSizeHint int) *packet.Config
EncryptionConfig(messageSizeHint uint64) *packet.Config
CompressionConfig() *packet.Config
}

@@ -14,7 +14,7 @@ type PGPEncryption interface {
// expected size of the message, in order to set an appropriate chunk
// size when using AEAD. Nothing will break when the message size hint
// turns out to be wrong.
SetMessageSizeHint(messageSizeHint int)
SetMessageSizeHint(messageSizeHint uint64)
// EncryptingWriter returns a wrapper around underlying output Writer,
// such that any write-operation via the wrapper results in a write to an encrypted pgp message.
// If the output Writer is of type PGPSplitWriter, the output can be split to multiple writers
6 changes: 3 additions & 3 deletions crypto/encryption_handle.go
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ type encryptionHandle struct {
encryptionTimeOverride Clock
clock Clock

messageSizeHint int
messageSizeHint uint64
}

// --- Default decryption handle to build from
@@ -80,7 +80,7 @@ func defaultEncryptionHandle(profile EncryptionProfile, clock Clock) *encryption
// expected size of the message, in order to set an appropriate chunk
// size when using AEAD. Nothing will break when the message size hint
// turns out to be wrong.
func (eh *encryptionHandle) SetMessageSizeHint(messageSizeHint int) {
func (eh *encryptionHandle) SetMessageSizeHint(messageSizeHint uint64) {
eh.messageSizeHint = messageSizeHint
}

@@ -104,7 +104,7 @@ func (eh *encryptionHandle) EncryptingWriter(outputWriter Writer, encoding int8)

// Encrypt encrypts a plaintext message.
func (eh *encryptionHandle) Encrypt(message []byte) (*PGPMessage, error) {
eh.messageSizeHint = len(message)
eh.messageSizeHint = uint64(len(message))
pgpMessageBuffer := NewPGPMessageBuffer()
// Enforce that for a PGPMessage struct the output should not be armored.
encryptingWriter, err := eh.EncryptingWriter(pgpMessageBuffer, Bytes)
6 changes: 3 additions & 3 deletions profile/profile.go
Original file line number Diff line number Diff line change
@@ -68,18 +68,18 @@ func (p *Custom) KeyGenerationConfig(securityLevel int8) *packet.Config {
return cfg
}

func (p *Custom) EncryptionConfig(messageSizeHint int) *packet.Config {
func (p *Custom) EncryptionConfig(messageSizeHint uint64) *packet.Config {
config := &packet.Config{
DefaultHash: p.Hash,
DefaultCipher: p.CipherEncryption,
AEADConfig: p.AeadEncryption,
S2KConfig: p.S2kEncryption,
InsecureAllowDecryptionWithSigningKeys: p.InsecureAllowDecryptionWithSigningKeys,
}
if config.AEADConfig != nil {
if config.AEADConfig != nil && messageSizeHint != 0 {
chunkSize := config.AEADConfig.ChunkSize
if messageSizeHint*2 < 1<<(config.AEADConfig.ChunkSizeByte()+6) {
chunkSize = uint64(messageSizeHint * 2)
chunkSize = messageSizeHint * 2
}
config.AEADConfig = &packet.AEADConfig{
DefaultMode: config.AEADConfig.DefaultMode,