Lines Matching full:if
10 #if defined(MBEDTLS_PK_C)
19 #if defined(MBEDTLS_RSA_C)
22 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS)
25 #if defined(MBEDTLS_ECDSA_C)
29 #if defined(MBEDTLS_PSA_CRYPTO_C)
44 #if defined(MBEDTLS_PSA_CRYPTO_C) in mbedtls_pk_init()
47 #if defined(MBEDTLS_PK_USE_PSA_EC_DATA) in mbedtls_pk_init()
60 if (ctx == NULL) { in mbedtls_pk_free()
64 if ((ctx->pk_info != NULL) && (ctx->pk_info->ctx_free_func != NULL)) { in mbedtls_pk_free()
68 #if defined(MBEDTLS_PK_USE_PSA_EC_DATA) in mbedtls_pk_free()
71 if ((ctx->pk_info != NULL) && (ctx->pk_info->type != MBEDTLS_PK_OPAQUE)) { in mbedtls_pk_free()
79 #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
94 if (ctx == NULL || ctx->pk_info == NULL || in mbedtls_pk_restart_free()
112 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_info_from_type()
116 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_info_from_type()
122 #if defined(MBEDTLS_PK_CAN_ECDSA_SOME) in mbedtls_pk_info_from_type()
137 if (info == NULL || ctx->pk_info != NULL) { in mbedtls_pk_setup()
141 if ((info->ctx_alloc_func != NULL) && in mbedtls_pk_setup()
151 #if defined(MBEDTLS_USE_PSA_CRYPTO)
162 if (ctx == NULL || ctx->pk_info != NULL) { in mbedtls_pk_setup_opaque()
166 if (PSA_SUCCESS != psa_get_key_attributes(key, &attributes)) { in mbedtls_pk_setup_opaque()
172 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_setup_opaque()
173 if (PSA_KEY_TYPE_IS_ECC_KEY_PAIR(type)) { in mbedtls_pk_setup_opaque()
177 if (type == PSA_KEY_TYPE_RSA_KEY_PAIR) { in mbedtls_pk_setup_opaque()
190 #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
202 if (ctx->pk_info != NULL) { in mbedtls_pk_setup_rsa_alt()
206 if ((ctx->pk_ctx = info->ctx_alloc_func()) == NULL) { in mbedtls_pk_setup_rsa_alt()
224 * Tell if a PK can do the operations of the given type
231 if (ctx == NULL || ctx->pk_info == NULL) { in mbedtls_pk_can_do()
238 #if defined(MBEDTLS_USE_PSA_CRYPTO)
240 * Tell if a PK can do the operations of the given PSA algorithm
250 if (ctx == NULL || ctx->pk_info == NULL) { in mbedtls_pk_can_do_ext()
255 if (PSA_ALG_IS_ECDSA(alg) == 0 && in mbedtls_pk_can_do_ext()
264 if (usage == 0 || in mbedtls_pk_can_do_ext()
272 if (PSA_ALG_IS_SIGN_HASH(alg) && in mbedtls_pk_can_do_ext()
277 if (mbedtls_pk_get_type(ctx) != MBEDTLS_PK_OPAQUE) { in mbedtls_pk_can_do_ext()
280 if (PSA_ALG_IS_ECDSA(alg) || PSA_ALG_IS_ECDH(alg)) { in mbedtls_pk_can_do_ext()
282 } else if (PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || in mbedtls_pk_can_do_ext()
285 } else if (PSA_ALG_IS_RSA_PSS(alg)) { in mbedtls_pk_can_do_ext()
291 if (ctx->pk_info->can_do(type) == 0) { in mbedtls_pk_can_do_ext()
318 if (status != PSA_SUCCESS) { in mbedtls_pk_can_do_ext()
327 if ((key_usage & usage) != usage) { in mbedtls_pk_can_do_ext()
338 if (alg == key_alg || alg == key_alg2) { in mbedtls_pk_can_do_ext()
343 * If key_alg or key_alg2 is a hash-and-sign with a wildcard for the hash, in mbedtls_pk_can_do_ext()
347 if (PSA_ALG_IS_SIGN_HASH(alg)) { in mbedtls_pk_can_do_ext()
349 if (PSA_ALG_IS_SIGN_HASH(key_alg) && in mbedtls_pk_can_do_ext()
355 if (PSA_ALG_IS_SIGN_HASH(key_alg2) && in mbedtls_pk_can_do_ext()
371 if (*hash_len != 0) { in pk_hashlen_helper()
377 if (*hash_len == 0) { in pk_hashlen_helper()
384 #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
386 * Helper to set up a restart context if needed
391 /* Don't do anything if already set up or invalid */ in pk_restart_setup()
392 if (ctx == NULL || ctx->pk_info != NULL) { in pk_restart_setup()
397 if (info->rs_alloc_func == NULL || info->rs_free_func == NULL) { in pk_restart_setup()
401 if ((ctx->rs_ctx = info->rs_alloc_func()) == NULL) { in pk_restart_setup()
420 if ((md_alg != MBEDTLS_MD_NONE || hash_len != 0) && hash == NULL) { in mbedtls_pk_verify_restartable()
424 if (ctx->pk_info == NULL || in mbedtls_pk_verify_restartable()
429 #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) in mbedtls_pk_verify_restartable()
430 /* optimization: use non-restartable version if restart disabled */ in mbedtls_pk_verify_restartable()
431 if (rs_ctx != NULL && in mbedtls_pk_verify_restartable()
436 if ((ret = pk_restart_setup(rs_ctx, ctx->pk_info)) != 0) { in mbedtls_pk_verify_restartable()
443 if (ret != MBEDTLS_ERR_ECP_IN_PROGRESS) { in mbedtls_pk_verify_restartable()
453 if (ctx->pk_info->verify_func == NULL) { in mbedtls_pk_verify_restartable()
480 if ((md_alg != MBEDTLS_MD_NONE || hash_len != 0) && hash == NULL) { in mbedtls_pk_verify_ext()
484 if (ctx->pk_info == NULL) { in mbedtls_pk_verify_ext()
488 if (!mbedtls_pk_can_do(ctx, type)) { in mbedtls_pk_verify_ext()
492 if (type != MBEDTLS_PK_RSASSA_PSS) { in mbedtls_pk_verify_ext()
494 if (options != NULL) { in mbedtls_pk_verify_ext()
501 #if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_PKCS1_V21) in mbedtls_pk_verify_ext()
505 #if SIZE_MAX > UINT_MAX in mbedtls_pk_verify_ext()
506 if (md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len) { in mbedtls_pk_verify_ext()
511 if (options == NULL) { in mbedtls_pk_verify_ext()
517 #if defined(MBEDTLS_USE_PSA_CRYPTO) in mbedtls_pk_verify_ext()
518 if (pss_opts->mgf1_hash_id == md_alg) { in mbedtls_pk_verify_ext()
533 if (key_len < 0) { in mbedtls_pk_verify_ext()
544 if (status != PSA_SUCCESS) { in mbedtls_pk_verify_ext()
560 if (status == PSA_SUCCESS && sig_len > mbedtls_pk_get_len(ctx)) { in mbedtls_pk_verify_ext()
564 if (status == PSA_SUCCESS) { in mbedtls_pk_verify_ext()
572 if (sig_len < mbedtls_pk_get_len(ctx)) { in mbedtls_pk_verify_ext()
581 if (ret != 0) { in mbedtls_pk_verify_ext()
585 if (sig_len > mbedtls_pk_get_len(ctx)) { in mbedtls_pk_verify_ext()
606 if ((md_alg != MBEDTLS_MD_NONE || hash_len != 0) && hash == NULL) { in mbedtls_pk_sign_restartable()
610 if (ctx->pk_info == NULL || pk_hashlen_helper(md_alg, &hash_len) != 0) { in mbedtls_pk_sign_restartable()
614 #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) in mbedtls_pk_sign_restartable()
615 /* optimization: use non-restartable version if restart disabled */ in mbedtls_pk_sign_restartable()
616 if (rs_ctx != NULL && in mbedtls_pk_sign_restartable()
621 if ((ret = pk_restart_setup(rs_ctx, ctx->pk_info)) != 0) { in mbedtls_pk_sign_restartable()
630 if (ret != MBEDTLS_ERR_ECP_IN_PROGRESS) { in mbedtls_pk_sign_restartable()
640 if (ctx->pk_info->sign_func == NULL) { in mbedtls_pk_sign_restartable()
663 #if defined(MBEDTLS_PSA_CRYPTO_C)
675 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_sign_ext()
680 if (ctx->pk_info == NULL) { in mbedtls_pk_sign_ext()
684 if (!mbedtls_pk_can_do(ctx, pk_type)) { in mbedtls_pk_sign_ext()
688 if (pk_type != MBEDTLS_PK_RSASSA_PSS) { in mbedtls_pk_sign_ext()
693 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_sign_ext()
695 if (psa_md_alg == 0) { in mbedtls_pk_sign_ext()
699 if (mbedtls_pk_get_type(ctx) == MBEDTLS_PK_OPAQUE) { in mbedtls_pk_sign_ext()
726 if (ctx->pk_info == NULL) { in mbedtls_pk_decrypt()
730 if (ctx->pk_info->decrypt_func == NULL) { in mbedtls_pk_decrypt()
746 if (ctx->pk_info == NULL) { in mbedtls_pk_encrypt()
750 if (ctx->pk_info->encrypt_func == NULL) { in mbedtls_pk_encrypt()
766 if (pub->pk_info == NULL || in mbedtls_pk_check_pair()
771 if (f_rng == NULL) { in mbedtls_pk_check_pair()
775 if (prv->pk_info->check_pair_func == NULL) { in mbedtls_pk_check_pair()
779 if (prv->pk_info->type == MBEDTLS_PK_RSA_ALT) { in mbedtls_pk_check_pair()
780 if (pub->pk_info->type != MBEDTLS_PK_RSA) { in mbedtls_pk_check_pair()
784 if ((prv->pk_info->type != MBEDTLS_PK_OPAQUE) && in mbedtls_pk_check_pair()
802 if (ctx == NULL || ctx->pk_info == NULL) { in mbedtls_pk_get_bitlen()
814 if (ctx->pk_info == NULL) { in mbedtls_pk_debug()
818 if (ctx->pk_info->debug_func == NULL) { in mbedtls_pk_debug()
831 if (ctx == NULL || ctx->pk_info == NULL) { in mbedtls_pk_get_name()
843 if (ctx == NULL || ctx->pk_info == NULL) { in mbedtls_pk_get_type()
850 #if defined(MBEDTLS_USE_PSA_CRYPTO)
863 #if !defined(MBEDTLS_PK_HAVE_ECC_KEYS) && !defined(MBEDTLS_RSA_C) in mbedtls_pk_wrap_as_opaque()
870 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_wrap_as_opaque()
871 if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_ECKEY) { in mbedtls_pk_wrap_as_opaque()
880 #if defined(MBEDTLS_PK_USE_PSA_EC_DATA) in mbedtls_pk_wrap_as_opaque()
883 if (status != PSA_SUCCESS) { in mbedtls_pk_wrap_as_opaque()
895 if ((ret = mbedtls_ecp_write_key(ec, d, d_len)) != 0) { in mbedtls_pk_wrap_as_opaque()
908 if (alg2 != PSA_ALG_NONE) { in mbedtls_pk_wrap_as_opaque()
915 if (status != PSA_SUCCESS) { in mbedtls_pk_wrap_as_opaque()
926 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_wrap_as_opaque()
927 if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_RSA) { in mbedtls_pk_wrap_as_opaque()
935 if (key_len <= 0) { in mbedtls_pk_wrap_as_opaque()
944 if (alg2 != PSA_ALG_NONE) { in mbedtls_pk_wrap_as_opaque()
955 if (status != PSA_SUCCESS) { in mbedtls_pk_wrap_as_opaque()