Skip to content

Commit aa5f1c3

Browse files
joostjagerGeorgeTsagk
authored andcommitted
sphinx: add minPaddedOnionErrorLength constant
1 parent 98bd564 commit aa5f1c3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

crypto.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,14 @@ func onionEncrypt(sharedSecret *Hash256, data []byte) []byte {
311311
return p
312312
}
313313

314-
// minOnionErrorLength is the minimally expected length of the onion error
315-
// message. Including padding, all messages on the wire should be at least 256
316-
// bytes. We then add the size of the sha256 HMAC as well.
317-
const minOnionErrorLength = 2 + 2 + 256 + sha256.Size
314+
// minPaddedOnionErrorLength is the minimally expected length of the padded
315+
// onion error message including two uint16s for the length of the message and
316+
// the length of the padding.
317+
const minPaddedOnionErrorLength = 2 + 2 + 256
318+
319+
// minOnionErrorLength is the minimally expected length of the complete onion
320+
// error message including the HMAC.
321+
const minOnionErrorLength = minPaddedOnionErrorLength + sha256.Size
318322

319323
// DecryptError attempts to decrypt the passed encrypted error response. The
320324
// onion failure is encrypted in backward manner, starting from the node where

0 commit comments

Comments
 (0)