mirror of
https://github.com/logos-messaging/noise.git
synced 2026-02-18 21:23:07 +00:00
Add BodyLen, rename EncryptedLen to BoxLen
This commit is contained in:
parent
0ab5aed0b2
commit
84d73f6f89
@ -78,7 +78,7 @@ func (c *Crypter) EncryptBox(dst []byte, ephKey *Key, plaintext []byte, padLen i
|
||||
}
|
||||
dstPrefixLen := len(dst)
|
||||
// Allocate a new slice that can fit the full encrypted box if the current dst doesn't fit
|
||||
if encLen := c.EncryptedLen(len(plaintext) + padLen); cap(dst)-len(dst) < encLen {
|
||||
if encLen := c.BoxLen(len(plaintext) + padLen); cap(dst)-len(dst) < encLen {
|
||||
newDst := make([]byte, len(dst), len(dst)+encLen)
|
||||
copy(newDst, dst)
|
||||
dst = newDst
|
||||
@ -97,10 +97,14 @@ func (c *Crypter) EncryptBox(dst []byte, ephKey *Key, plaintext []byte, padLen i
|
||||
return c.EncryptBody(dst, plaintext, dst[dstPrefixLen:], padLen), nil
|
||||
}
|
||||
|
||||
func (c *Crypter) EncryptedLen(n int) int {
|
||||
func (c *Crypter) BoxLen(n int) int {
|
||||
return n + (2 * c.Cipher.DHLen()) + (2 * c.Cipher.MACLen()) + 4
|
||||
}
|
||||
|
||||
func (c *Crypter) BodyLen(n int) int {
|
||||
return n + c.Cipher.MACLen() + 4
|
||||
}
|
||||
|
||||
func (c *Crypter) SetContext(cc []byte) {
|
||||
c.cipher(cc)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user