Skip to content

Commit

Permalink
handshake: embed the mask as an array into the aesHeaderProtector (#4324
Browse files Browse the repository at this point in the history
)
  • Loading branch information
marten-seemann committed Mar 3, 2024
1 parent 067e7db commit f856163
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/handshake/header_protector.go
Expand Up @@ -37,7 +37,7 @@ func newHeaderProtector(suite *cipherSuite, trafficSecret []byte, isLongHeader b
}

type aesHeaderProtector struct {
mask []byte
mask [16]byte // AES always has a 16 byte block size
block cipher.Block
isLongHeader bool
}
Expand All @@ -52,7 +52,6 @@ func newAESHeaderProtector(suite *cipherSuite, trafficSecret []byte, isLongHeade
}
return &aesHeaderProtector{
block: block,
mask: make([]byte, block.BlockSize()),
isLongHeader: isLongHeader,
}
}
Expand All @@ -69,7 +68,7 @@ func (p *aesHeaderProtector) apply(sample []byte, firstByte *byte, hdrBytes []by
if len(sample) != len(p.mask) {
panic("invalid sample size")
}
p.block.Encrypt(p.mask, sample)
p.block.Encrypt(p.mask[:], sample)
if p.isLongHeader {
*firstByte ^= p.mask[0] & 0xf
} else {
Expand Down

0 comments on commit f856163

Please sign in to comment.