cipher.c: remove checks for CBC,XTS,KW,KWP in cipher_setkey
We have checks for CBC, XTS and KW modes in check_config.h. This
means we should never get a successful build with above three modes.
Therefore, the checks in cipher_setkey is not necessary as other
error will be emitted if asking for those modes in the cipher.
Additionally, removing the checks can save extra code size.
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
diff --git a/library/cipher.c b/library/cipher.c
index 909324a..33da580 100644
--- a/library/cipher.c
+++ b/library/cipher.c
@@ -320,15 +320,6 @@
return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA;
}
#if defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
- /* CBC, XTS, KW and KWP mode always need decryption, return an error to
- * indicate those modes are not available under
- * MBEDTLS_BLOCK_CIPHER_NO_DECRYPT. */
- if (MBEDTLS_MODE_CBC == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) ||
- MBEDTLS_MODE_XTS == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) ||
- MBEDTLS_MODE_KW == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) ||
- MBEDTLS_MODE_KWP == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) {
- return MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE;
- }
if (MBEDTLS_MODE_ECB == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) &&
MBEDTLS_DECRYPT == operation) {
return MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE;