mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-25 09:02:48 +00:00
Remove certain null pointer checks when only MD_LIGHT enabled
When MD_LIGHT is enabled but MD_C is not then certain null pointer checks can be removed on functions that take an mbedtls_md_context_t * as a parameter, since MD_LIGHT does not support these null pointers. Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
parent
cd33413a55
commit
73cfde8f85
13
library/md.c
13
library/md.c
@ -376,7 +376,12 @@ int mbedtls_md_clone(mbedtls_md_context_t *dst,
|
|||||||
|
|
||||||
int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac)
|
int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac)
|
||||||
{
|
{
|
||||||
if (md_info == NULL || ctx == NULL) {
|
#if defined(MBEDTLS_MD_C)
|
||||||
|
if (ctx == NULL) {
|
||||||
|
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (md_info == NULL) {
|
||||||
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,9 +460,11 @@ int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info
|
|||||||
|
|
||||||
int mbedtls_md_starts(mbedtls_md_context_t *ctx)
|
int mbedtls_md_starts(mbedtls_md_context_t *ctx)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_MD_C)
|
||||||
if (ctx == NULL || ctx->md_info == NULL) {
|
if (ctx == NULL || ctx->md_info == NULL) {
|
||||||
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_MD_SOME_PSA)
|
#if defined(MBEDTLS_MD_SOME_PSA)
|
||||||
if (ctx->engine == MBEDTLS_MD_ENGINE_PSA) {
|
if (ctx->engine == MBEDTLS_MD_ENGINE_PSA) {
|
||||||
@ -504,9 +511,11 @@ int mbedtls_md_starts(mbedtls_md_context_t *ctx)
|
|||||||
|
|
||||||
int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
|
int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_MD_C)
|
||||||
if (ctx == NULL || ctx->md_info == NULL) {
|
if (ctx == NULL || ctx->md_info == NULL) {
|
||||||
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_MD_SOME_PSA)
|
#if defined(MBEDTLS_MD_SOME_PSA)
|
||||||
if (ctx->engine == MBEDTLS_MD_ENGINE_PSA) {
|
if (ctx->engine == MBEDTLS_MD_ENGINE_PSA) {
|
||||||
@ -551,9 +560,11 @@ int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, siz
|
|||||||
|
|
||||||
int mbedtls_md_finish(mbedtls_md_context_t *ctx, unsigned char *output)
|
int mbedtls_md_finish(mbedtls_md_context_t *ctx, unsigned char *output)
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_MD_C)
|
||||||
if (ctx == NULL || ctx->md_info == NULL) {
|
if (ctx == NULL || ctx->md_info == NULL) {
|
||||||
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_MD_SOME_PSA)
|
#if defined(MBEDTLS_MD_SOME_PSA)
|
||||||
if (ctx->engine == MBEDTLS_MD_ENGINE_PSA) {
|
if (ctx->engine == MBEDTLS_MD_ENGINE_PSA) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user