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 {
536536	} 
537537} 
538538
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.  
541541pub  struct  MessageBuf ( Vec < u8 > ) ; 
542542impl  MessageBuf  { 
543543	/// Creates a new buffer from an encoded message (i.e. the two message-type bytes followed by 
@@ -548,6 +548,8 @@ impl MessageBuf {
548548		if  encoded_msg. len ( )  > LN_MAX_MSG_LEN  { 
549549			panic ! ( "Attempted to encrypt message longer than 65535 bytes!" ) ; 
550550		} 
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. 
551553		let  mut  res = Vec :: with_capacity ( encoded_msg. len ( )  + 16 * 2  + 2 ) ; 
552554		res. resize ( encoded_msg. len ( )  + 16  + 2 ,  0 ) ; 
553555		res[ 16  + 2 ..] . copy_from_slice ( & encoded_msg) ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments