From 0ff77b10e1c08020e116455c3a6ea264a497283d Mon Sep 17 00:00:00 2001 From: Siddharth Chandrasekaran Date: Thu, 28 Nov 2019 15:01:06 +0530 Subject: [PATCH] crypto: api: New capability flag CAP_NO_IV_PREFIX Zephyr crypto API currently does not allow IV to be treated as separate entity. This is mostly due to fact that underlying libraries expect the IV to be prefixed to the cipher/plain text for performance reasons. But there are cases where the IV is derived from other sources and not directly transmitted to the other end. In such cases, it must be treated as a first class citizen. This patch adds a new capability flag `CAP_NO_IV_PREFIX` to the crypto API that allows operations without prefixing the IV to the cipher/plain text. When `CAP_NO_IV_PREFIX` is active (and supported), the IV passed to cipher_*_op() must not be modified. As a side effect, the length of the cipher/plain texts are equal; allowing for in-place encryption/decryption. Signed-off-by: Siddharth Chandrasekaran --- include/crypto/cipher_structs.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/crypto/cipher_structs.h b/include/crypto/cipher_structs.h index ecd8f520225..47bcd416664 100644 --- a/include/crypto/cipher_structs.h +++ b/include/crypto/cipher_structs.h @@ -172,6 +172,9 @@ struct cipher_ctx { /* Whether the hardware/driver supports autononce feature */ #define CAP_AUTONONCE BIT(7) +/* Don't prefix IV to cipher blocks */ +#define CAP_NO_IV_PREFIX BIT(8) + /* More flags to be added as necessary */