Skip to contentSkip to conversation

cipher: Allow zero byte input for AEAD cipher

PATCH Applied Inga Stotland 2 participants 2 messages Sep 10, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cipher: Allow zero byte input for AEAD cipher

For AEAD-based cipher, either the plaintext or the associated data may contain zero bytes.

Add extra checks to disallow combinations of NULL input data and nonzero data length.

---
 ell/cipher.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
ell/cipher.c +4 -1
index 866fdb5..6b8528c 100644
@@ -607,7 +607,10 @@ LIB_EXPORT bool l_aead_cipher_encrypt(struct l_aead_cipher *cipher,
 	if (unlikely(!cipher))
 		return false;
 
-	if (unlikely(!in) || unlikely(!out))
+	if (unlikely(!in && !ad) || unlikely(!out))
+		return false;
+
+	if (unlikely(!in && in_len) || unlikely(!ad && ad_len))
 		return false;
 
 	if (cipher->type == L_AEAD_CIPHER_AES_CCM) {
Signature · 1 line
2.31.1
#1 lore raw

Hi Inga,

Quoted 9 lines · Inga Stotland

For AEAD-based cipher, either the plaintext or the associated data may contain zero bytes.

Add extra checks to disallow combinations of NULL input data and nonzero data length.

---
  ell/cipher.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

Applied, thanks.

Regards,
-Denis