@@ -235,10 +235,10 @@ func onionEncrypt(sharedSecret *Hash256, data []byte) []byte {
235
235
return p
236
236
}
237
237
238
- // onionErrorLength is the expected length of the onion error message.
239
- // Including padding, all messages on the wire should be 256 bytes. We then add
240
- // the size of the sha256 HMAC as well.
241
- const onionErrorLength = 2 + 2 + 256 + sha256 .Size
238
+ // minOnionErrorLength is the minimally expected length of the onion error
239
+ // message. Including padding, all messages on the wire should be at least 256
240
+ // bytes. We then add the size of the sha256 HMAC as well.
241
+ const minOnionErrorLength = 2 + 2 + 256 + sha256 .Size
242
242
243
243
// DecryptError attempts to decrypt the passed encrypted error response. The
244
244
// onion failure is encrypted in backward manner, starting from the node where
@@ -250,9 +250,9 @@ func (o *OnionErrorDecrypter) DecryptError(encryptedData []byte) (
250
250
* DecryptedError , error ) {
251
251
252
252
// Ensure the error message length is as expected.
253
- if len (encryptedData ) != onionErrorLength {
253
+ if len (encryptedData ) < minOnionErrorLength {
254
254
return nil , fmt .Errorf ("invalid error length: " +
255
- "expected %v got %v" , onionErrorLength ,
255
+ "expected at least %v got %v" , minOnionErrorLength ,
256
256
len (encryptedData ))
257
257
}
258
258
0 commit comments