Skip to content

Commit

Permalink
pk: minor code restyling
Browse files Browse the repository at this point in the history
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
  • Loading branch information
valeriosetti committed Mar 16, 2023
1 parent 73b3c45 commit 86ed005
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions library/pk.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,17 +479,13 @@ int mbedtls_pk_verify_restartable(mbedtls_pk_context *ctx,


#if defined(MBEDTLS_USE_PSA_CRYPTO)
if (ctx->pk_info->type == MBEDTLS_PK_RSA) {
return ctx->pk_info->verify_func(ctx->pk_ctx, md_alg, hash, hash_len,
sig, sig_len);
} else {
if (ctx->pk_info->type != MBEDTLS_PK_RSA) {
return ctx->pk_info->verify_func(ctx, md_alg, hash, hash_len,
sig, sig_len);
}
#else /* MBEDTLS_USE_PSA_CRYPTO */
} else
#endif/* MBEDTLS_USE_PSA_CRYPTO */
return ctx->pk_info->verify_func(ctx->pk_ctx, md_alg, hash, hash_len,
sig, sig_len);
#endif /* MBEDTLS_USE_PSA_CRYPTO */
}

/*
Expand Down Expand Up @@ -820,14 +816,11 @@ int mbedtls_pk_check_pair(const mbedtls_pk_context *pub,
}

#if defined(MBEDTLS_USE_PSA_CRYPTO)
if (pub->pk_info->type == MBEDTLS_PK_RSA) {
return prv->pk_info->check_pair_func(pub->pk_ctx, prv->pk_ctx, f_rng, p_rng);
} else {
if (pub->pk_info->type != MBEDTLS_PK_RSA) {
return prv->pk_info->check_pair_func(pub, prv, f_rng, p_rng);
}
#else
return prv->pk_info->check_pair_func(pub->pk_ctx, prv->pk_ctx, f_rng, p_rng);
} else
#endif
return prv->pk_info->check_pair_func(pub->pk_ctx, prv->pk_ctx, f_rng, p_rng);
}

/*
Expand Down Expand Up @@ -909,7 +902,7 @@ int mbedtls_pk_get_ec_public_key_props(mbedtls_pk_context *pk,
if ((pk == NULL) || (ec_curve == NULL) || (bits == NULL)) {
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
}
if ((pk->MBEDTLS_PRIVATE(pk_ec_family) == 0) ||
if ((pk->MBEDTLS_PRIVATE(pk_ec_family) == 0) ||
(pk->MBEDTLS_PRIVATE(pk_bits) == 0)) {
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
}
Expand Down

0 comments on commit 86ed005

Please sign in to comment.