@@ -50,6 +50,9 @@ type Custom struct {
50
50
InsecureAllowWeakRSA bool
51
51
// InsecureAllowDecryptionWithSigningKeys is a flag to enable to decrypt with signing keys for compatibility reasons.
52
52
InsecureAllowDecryptionWithSigningKeys bool
53
+ // MaxDecompressedMessageSize sets the maximum decompressed messages size that can be read
54
+ // before throwing an error.
55
+ MaxDecompressedMessageSize int64
53
56
}
54
57
55
58
// Custom implements the profile interfaces:
@@ -75,6 +78,7 @@ func (p *Custom) EncryptionConfig() *packet.Config {
75
78
AEADConfig : p .AeadEncryption ,
76
79
S2KConfig : p .S2kEncryption ,
77
80
InsecureAllowDecryptionWithSigningKeys : p .InsecureAllowDecryptionWithSigningKeys ,
81
+ MaxDecompressedMessageSize : p .maxDecompressedMessageSize (),
78
82
}
79
83
if p .DisableIntendedRecipients {
80
84
intendedRecipients := false
@@ -100,7 +104,8 @@ func (p *Custom) KeyEncryptionConfig() *packet.Config {
100
104
101
105
func (p * Custom ) SignConfig () * packet.Config {
102
106
config := & packet.Config {
103
- DefaultHash : p .Hash ,
107
+ DefaultHash : p .Hash ,
108
+ MaxDecompressedMessageSize : p .maxDecompressedMessageSize (),
104
109
}
105
110
if p .SignHash != nil {
106
111
config .DefaultHash = * p .SignHash
@@ -124,3 +129,10 @@ func (p *Custom) CompressionConfig() *packet.Config {
124
129
DefaultCompressionAlgo : p .CompressionAlgorithm ,
125
130
}
126
131
}
132
+
133
+ func (p * Custom ) maxDecompressedMessageSize () * int64 {
134
+ if p .MaxDecompressedMessageSize == 0 {
135
+ return nil
136
+ }
137
+ return & p .MaxDecompressedMessageSize
138
+ }
0 commit comments