Open soloicesky opened 12 months ago
The cipher module does not support multipart operation with CCM. This is a bit unfortunate. But at this point, cipher.h
is a deprecated API. Please use the PSA API instead for multipart CCM.
Due to limited bandwidth, we are not going to implement multipart CCM in cipher.h. If you can make a pull request with passing tests before the 3.6 LTS release in February or March 2024, we'll try to review it, but I can't promise even that. After that, there will be no new features in cipher.h
.
您好,你的邮件已收到,我会尽快回复你。 best regards zaixing_liu
Suggested enhancement
GCM and CCM are both belongs to AEAD category, why we don't support write/check tag operation for CCM in
cipher.c
. see below code blocks: ···if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
int mbedtls_cipher_write_tag(mbedtls_cipher_context_t ctx, unsigned char tag, size_t tag_len) { if (ctx->cipher_info == NULL) { return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; }
if defined(MBEDTLS_USE_PSA_CRYPTO) && !defined(MBEDTLS_DEPRECATED_REMOVED)
endif / MBEDTLS_USE_PSA_CRYPTO && !MBEDTLS_DEPRECATED_REMOVED /
if defined(MBEDTLS_GCM_C)
endif
if defined(MBEDTLS_CHACHAPOLY_C)
endif
}
int mbedtls_cipher_check_tag(mbedtls_cipher_context_t ctx, const unsigned char tag, size_t tag_len) { unsigned char check_tag[16]; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
if defined(MBEDTLS_USE_PSA_CRYPTO) && !defined(MBEDTLS_DEPRECATED_REMOVED)
endif / MBEDTLS_USE_PSA_CRYPTO && !MBEDTLS_DEPRECATED_REMOVED /
if defined(MBEDTLS_GCM_C)
endif / MBEDTLS_GCM_C /
if defined(MBEDTLS_CHACHAPOLY_C)
endif / MBEDTLS_CHACHAPOLY_C /
exit: mbedtls_platform_zeroize(check_tag, tag_len); return ret; }
endif / MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C /
···
Justification
···
if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) || defined(MBEDTLS_CCM_C)
int mbedtls_cipher_write_tag(mbedtls_cipher_context_t ctx, unsigned char tag, size_t tag_len) { if (ctx->cipher_info == NULL) { return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; }
if defined(MBEDTLS_USE_PSA_CRYPTO) && !defined(MBEDTLS_DEPRECATED_REMOVED)
endif / MBEDTLS_USE_PSA_CRYPTO && !MBEDTLS_DEPRECATED_REMOVED /
if defined(MBEDTLS_GCM_C)
endif
if defined(MBEDTLS_CCM_C)
endif
if defined(MBEDTLS_CHACHAPOLY_C)
endif
}
int mbedtls_cipher_check_tag(mbedtls_cipher_context_t ctx, const unsigned char tag, size_t tag_len) { unsigned char check_tag[16]; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
if defined(MBEDTLS_USE_PSA_CRYPTO) && !defined(MBEDTLS_DEPRECATED_REMOVED)
endif / MBEDTLS_USE_PSA_CRYPTO && !MBEDTLS_DEPRECATED_REMOVED /
if defined(MBEDTLS_GCM_C)
endif / MBEDTLS_GCM_C /
if defined(MBEDTLS_GCM_C)
endif
if defined(MBEDTLS_CHACHAPOLY_C)
endif / MBEDTLS_CHACHAPOLY_C /
exit: mbedtls_platform_zeroize(check_tag, tag_len); return ret; }
endif / MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C || MBEDTLS_CCM_C /
···
Mbed TLS needs this because CCM is the same kind as GCM.