Skip to contentSkip to conversation

crypto: Check for l_cipher_decrypt error

PATCH Applied Andrew Zaborowski 2 participants 2 messages Feb 10, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: Check for l_cipher_decrypt error

---
 src/crypto.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
src/crypto.c +7 -1
index 563f17ce..6c70eb9a 100644
@@ -167,12 +167,18 @@ bool aes_unwrap(const uint8_t *kek, size_t kek_len, const uint8_t *in, size_t le
 		for (i = n; i >= 1; i--, t--) {
 			b[0] ^= L_CPU_TO_BE64(t);
 			b[1] = L_GET_UNALIGNED(r);
-			l_cipher_decrypt(cipher, b, b, 16);
+
+			if (!l_cipher_decrypt(cipher, b, b, 16)) {
+				b[0] = 0;
+				goto done;
+			}
+
 			L_PUT_UNALIGNED(b[1], r);
 			r -= 1;
 		}
 	}
 
+done:
 	l_cipher_free(cipher);
 	explicit_bzero(&b[1], 8);
 
Signature · 1 line
2.27.0
#1 lore raw

Hi Andrew,

Quoted 4 lines · Andrew Zaborowski
---
  src/crypto.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)

Applied, thanks.

Regards,
-Denis