mirror of
https://github.com/logos-messaging/noise.git
synced 2026-01-03 22:53:08 +00:00
Be defensive about short ciphertexts
This commit is contained in:
parent
23f8d99470
commit
36a0b41364
@ -291,6 +291,9 @@ func (n *noise255ctx) Encrypt(dst, plaintext, authtext []byte) []byte {
|
||||
var ErrAuthFailed = errors.New("box: message authentication failed")
|
||||
|
||||
func (n *noise255ctx) Decrypt(ciphertext, authtext []byte) ([]byte, error) {
|
||||
if len(ciphertext) < 16 {
|
||||
return nil, ErrAuthFailed
|
||||
}
|
||||
digest := ciphertext[len(ciphertext)-16:]
|
||||
ciphertext = ciphertext[:len(ciphertext)-16]
|
||||
c, keystream := n.key()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user