mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-03 01:13:37 +00:00
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>
This commit is contained in:
parent
111159b89c
commit
cd25d22526
@ -320,15 +320,6 @@ int mbedtls_cipher_setkey(mbedtls_cipher_context_t *ctx,
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user