Skip to content

Commit 86ed005

Browse files
committed
pk: minor code restyling
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
1 parent 73b3c45 commit 86ed005

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

library/pk.c

+7-14
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,13 @@ int mbedtls_pk_verify_restartable(mbedtls_pk_context *ctx,
479479

480480

481481
#if defined(MBEDTLS_USE_PSA_CRYPTO)
482-
if (ctx->pk_info->type == MBEDTLS_PK_RSA) {
483-
return ctx->pk_info->verify_func(ctx->pk_ctx, md_alg, hash, hash_len,
484-
sig, sig_len);
485-
} else {
482+
if (ctx->pk_info->type != MBEDTLS_PK_RSA) {
486483
return ctx->pk_info->verify_func(ctx, md_alg, hash, hash_len,
487484
sig, sig_len);
488-
}
489-
#else /* MBEDTLS_USE_PSA_CRYPTO */
485+
} else
486+
#endif/* MBEDTLS_USE_PSA_CRYPTO */
490487
return ctx->pk_info->verify_func(ctx->pk_ctx, md_alg, hash, hash_len,
491488
sig, sig_len);
492-
#endif /* MBEDTLS_USE_PSA_CRYPTO */
493489
}
494490

495491
/*
@@ -820,14 +816,11 @@ int mbedtls_pk_check_pair(const mbedtls_pk_context *pub,
820816
}
821817

822818
#if defined(MBEDTLS_USE_PSA_CRYPTO)
823-
if (pub->pk_info->type == MBEDTLS_PK_RSA) {
824-
return prv->pk_info->check_pair_func(pub->pk_ctx, prv->pk_ctx, f_rng, p_rng);
825-
} else {
819+
if (pub->pk_info->type != MBEDTLS_PK_RSA) {
826820
return prv->pk_info->check_pair_func(pub, prv, f_rng, p_rng);
827-
}
828-
#else
829-
return prv->pk_info->check_pair_func(pub->pk_ctx, prv->pk_ctx, f_rng, p_rng);
821+
} else
830822
#endif
823+
return prv->pk_info->check_pair_func(pub->pk_ctx, prv->pk_ctx, f_rng, p_rng);
831824
}
832825

833826
/*
@@ -909,7 +902,7 @@ int mbedtls_pk_get_ec_public_key_props(mbedtls_pk_context *pk,
909902
if ((pk == NULL) || (ec_curve == NULL) || (bits == NULL)) {
910903
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
911904
}
912-
if ((pk->MBEDTLS_PRIVATE(pk_ec_family) == 0) ||
905+
if ((pk->MBEDTLS_PRIVATE(pk_ec_family) == 0) ||
913906
(pk->MBEDTLS_PRIVATE(pk_bits) == 0)) {
914907
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
915908
}

0 commit comments

Comments
 (0)