File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -536,8 +536,8 @@ impl PeerChannelEncryptor {
536
536
}
537
537
}
538
538
539
- /// A buffer which stores an encoded message with some padding to allow for future
540
- /// encryption/MACing
539
+ /// A buffer which stores an encoded message (including the two message-type bytes) with some
540
+ /// padding to allow for future encryption/MACing.
541
541
pub struct MessageBuf ( Vec < u8 > ) ;
542
542
impl MessageBuf {
543
543
/// Creates a new buffer from an encoded message (i.e. the two message-type bytes followed by
@@ -548,6 +548,8 @@ impl MessageBuf {
548
548
if encoded_msg. len ( ) > LN_MAX_MSG_LEN {
549
549
panic ! ( "Attempted to encrypt message longer than 65535 bytes!" ) ;
550
550
}
551
+ // In addition to the message (continaing the two message type bytes), we also have to add
552
+ // the message length header (and its MAC) and the message MAC.
551
553
let mut res = Vec :: with_capacity ( encoded_msg. len ( ) + 16 * 2 + 2 ) ;
552
554
res. resize ( encoded_msg. len ( ) + 16 + 2 , 0 ) ;
553
555
res[ 16 + 2 ..] . copy_from_slice ( & encoded_msg) ;
You can’t perform that action at this time.
0 commit comments