Pad out each chunk

This commit is contained in:
John R. Bradley
2018-07-13 22:18:52 -05:00
committed by Sean DuBois
parent 22e98b0dfb
commit a1874f912d
2 changed files with 12 additions and 4 deletions

View File

@@ -115,6 +115,14 @@ func (i *InitCommon) Marshal() ([]byte, error) {
}
out = append(out, pp...)
// Chunks (including Type, Length, and Value fields) are padded out
// by the sender with all zero bytes to be a multiple of 4 bytes
// long. This padding MUST NOT be more than 3 bytes in total. The
// Chunk Length value does not include terminating padding of the
// chunk. *However, it does include padding of any variable-length
// parameter except the last parameter in the chunk.* The receiver
// MUST ignore the padding.
if idx != len(i.params)-1 {
padding := make([]byte, getPadding(len(pp), 4))
out = append(out, padding...)