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 <siddharth@embedjournal.com>
This commit is contained in:
Siddharth Chandrasekaran 2019-11-28 15:01:06 +05:30 committed by Carles Cufí
commit 0ff77b10e1

View file

@ -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 */