Lines Matching full:if
10 #if defined(MBEDTLS_PK_WRITE_C)
21 #if defined(MBEDTLS_RSA_C)
24 #if defined(MBEDTLS_ECP_C)
29 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS)
32 #if defined(MBEDTLS_RSA_C) || defined(MBEDTLS_PK_HAVE_ECC_KEYS)
35 #if defined(MBEDTLS_ECDSA_C)
38 #if defined(MBEDTLS_PEM_WRITE_C)
42 #if defined(MBEDTLS_USE_PSA_CRYPTO)
49 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS)
50 #if defined(MBEDTLS_PK_HAVE_RFC8410_CURVES)
55 #if defined(MBEDTLS_ECP_HAVE_CURVE25519) in mbedtls_pk_is_rfc8410()
56 if (id == MBEDTLS_ECP_DP_CURVE25519) { in mbedtls_pk_is_rfc8410()
60 #if defined(MBEDTLS_ECP_HAVE_CURVE448) in mbedtls_pk_is_rfc8410()
61 if (id == MBEDTLS_ECP_DP_CURVE448) { in mbedtls_pk_is_rfc8410()
68 #if defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_PEM_WRITE_C)
75 if (psa_get_key_attributes(pk->priv_id, &key_attrs) != PSA_SUCCESS) { in pk_get_opaque_ec_family()
87 #if defined(MBEDTLS_USE_PSA_CRYPTO)
94 if (psa_get_key_attributes(pk->priv_id, &opaque_attrs) != PSA_SUCCESS) { in pk_get_opaque_key_type()
104 #if defined(MBEDTLS_RSA_C)
122 if ((ret = mbedtls_rsa_export(rsa, NULL, NULL, NULL, NULL, &T)) != 0 || in pk_write_rsa_pubkey()
129 if ((ret = mbedtls_rsa_export(rsa, &T, NULL, NULL, NULL, NULL)) != 0 || in pk_write_rsa_pubkey()
138 if (ret < 0) { in pk_write_rsa_pubkey()
150 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS)
151 #if defined(MBEDTLS_PK_USE_PSA_EC_DATA)
158 if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_OPAQUE) { in pk_write_ec_pubkey()
159 if (psa_export_public_key(pk->priv_id, buf, sizeof(buf), &len) != PSA_SUCCESS) { in pk_write_ec_pubkey()
167 if (*p < start || (size_t) (*p - start) < len) { in pk_write_ec_pubkey()
181 #if defined(MBEDTLS_USE_PSA_CRYPTO) in pk_write_ec_pubkey()
189 #if defined(MBEDTLS_USE_PSA_CRYPTO) in pk_write_ec_pubkey()
190 if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_OPAQUE) { in pk_write_ec_pubkey()
191 if (psa_export_public_key(pk->priv_id, buf, sizeof(buf), &len) != PSA_SUCCESS) { in pk_write_ec_pubkey()
200 if ((ret = mbedtls_ecp_point_write_binary(&ec->grp, &ec->Q, in pk_write_ec_pubkey()
207 if (*p < start || (size_t) (*p - start) < len) { in pk_write_ec_pubkey()
231 if ((ret = mbedtls_oid_get_oid_by_ec_grp(grp_id, &oid, &oid_len)) != 0) { in pk_write_ec_param()
243 #if defined(MBEDTLS_PK_USE_PSA_EC_DATA)
252 if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_OPAQUE) { in pk_write_ec_private()
254 if (status != PSA_SUCCESS) { in pk_write_ec_private()
260 if (status != PSA_SUCCESS) { in pk_write_ec_private()
277 #if defined(MBEDTLS_USE_PSA_CRYPTO) in pk_write_ec_private()
284 #if defined(MBEDTLS_USE_PSA_CRYPTO) in pk_write_ec_private()
285 if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_OPAQUE) { in pk_write_ec_private()
287 if (status != PSA_SUCCESS) { in pk_write_ec_private()
298 if (ret != 0) { in pk_write_ec_private()
310 #if defined(MBEDTLS_USE_PSA_CRYPTO)
317 if (*p < start) { in pk_write_opaque_pubkey()
322 if (psa_export_public_key(pk->priv_id, start, buffer_size, in pk_write_opaque_pubkey()
340 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_write_pubkey()
341 if (mbedtls_pk_get_type(key) == MBEDTLS_PK_RSA) { in mbedtls_pk_write_pubkey()
345 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_pubkey()
346 if (mbedtls_pk_get_type(key) == MBEDTLS_PK_ECKEY) { in mbedtls_pk_write_pubkey()
350 #if defined(MBEDTLS_USE_PSA_CRYPTO) in mbedtls_pk_write_pubkey()
351 if (mbedtls_pk_get_type(key) == MBEDTLS_PK_OPAQUE) { in mbedtls_pk_write_pubkey()
367 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_pubkey_der()
372 if (size == 0) { in mbedtls_pk_write_pubkey_der()
380 if (c - buf < 1) { in mbedtls_pk_write_pubkey_der()
396 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_pubkey_der()
397 if (pk_type == MBEDTLS_PK_ECKEY) { in mbedtls_pk_write_pubkey_der()
401 #if defined(MBEDTLS_USE_PSA_CRYPTO) in mbedtls_pk_write_pubkey_der()
402 if (pk_type == MBEDTLS_PK_OPAQUE) { in mbedtls_pk_write_pubkey_der()
404 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_pubkey_der()
405 if (PSA_KEY_TYPE_IS_ECC(opaque_key_type)) { in mbedtls_pk_write_pubkey_der()
410 if (PSA_KEY_TYPE_IS_RSA(opaque_key_type)) { in mbedtls_pk_write_pubkey_der()
415 /* `pk_type` will have been changed to non-opaque by here if this function can handle it */ in mbedtls_pk_write_pubkey_der()
416 if (pk_type == MBEDTLS_PK_OPAQUE) { in mbedtls_pk_write_pubkey_der()
421 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_pubkey_der()
422 if (pk_type == MBEDTLS_PK_ECKEY) { in mbedtls_pk_write_pubkey_der()
427 if (ret == 0) { in mbedtls_pk_write_pubkey_der()
431 } else if (ret == MBEDTLS_ERR_OID_NOT_FOUND) { in mbedtls_pk_write_pubkey_der()
439 if (oid_len == 0) { in mbedtls_pk_write_pubkey_der()
440 if ((ret = mbedtls_oid_get_oid_by_pk_alg(pk_type, &oid, in mbedtls_pk_write_pubkey_der()
456 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS)
457 #if defined(MBEDTLS_PK_HAVE_RFC8410_CURVES)
489 if ((ret = mbedtls_oid_get_oid_by_ec_grp_algid(grp_id, &oid, &oid_len)) != 0) { in pk_write_ec_rfc8410_der()
527 if (*p - buf < 1) { in pk_write_ec_der()
566 #if defined(MBEDTLS_RSA_C)
573 #if defined(MBEDTLS_USE_PSA_CRYPTO) in pk_write_rsa_der()
574 if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_OPAQUE) { in pk_write_rsa_der()
578 if (psa_export_key(pk->priv_id, tmp, sizeof(tmp), &tmp_len) != PSA_SUCCESS) { in pk_write_rsa_der()
598 if ((ret = mbedtls_rsa_export_crt(rsa, NULL, NULL, &T)) != 0 || in pk_write_rsa_der()
605 if ((ret = mbedtls_rsa_export_crt(rsa, NULL, &T, NULL)) != 0 || in pk_write_rsa_der()
612 if ((ret = mbedtls_rsa_export_crt(rsa, &T, NULL, NULL)) != 0 || in pk_write_rsa_der()
619 if ((ret = mbedtls_rsa_export(rsa, NULL, NULL, in pk_write_rsa_der()
627 if ((ret = mbedtls_rsa_export(rsa, NULL, &T, in pk_write_rsa_der()
635 if ((ret = mbedtls_rsa_export(rsa, NULL, NULL, in pk_write_rsa_der()
643 if ((ret = mbedtls_rsa_export(rsa, NULL, NULL, in pk_write_rsa_der()
651 if ((ret = mbedtls_rsa_export(rsa, &T, NULL, in pk_write_rsa_der()
661 if (ret < 0) { in pk_write_rsa_der()
679 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_write_key_der()
682 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_key_der()
685 #if defined(MBEDTLS_USE_PSA_CRYPTO) in mbedtls_pk_write_key_der()
689 if (size == 0) { in mbedtls_pk_write_key_der()
695 #if defined(MBEDTLS_USE_PSA_CRYPTO) in mbedtls_pk_write_key_der()
696 if (mbedtls_pk_get_type(key) == MBEDTLS_PK_OPAQUE) { in mbedtls_pk_write_key_der()
698 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_write_key_der()
701 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_key_der()
707 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_write_key_der()
708 if ((mbedtls_pk_get_type(key) == MBEDTLS_PK_RSA) || is_rsa_opaque) { in mbedtls_pk_write_key_der()
712 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_key_der()
713 if ((mbedtls_pk_get_type(key) == MBEDTLS_PK_ECKEY) || is_ec_opaque) { in mbedtls_pk_write_key_der()
714 #if defined(MBEDTLS_PK_HAVE_RFC8410_CURVES) in mbedtls_pk_write_key_der()
715 if (mbedtls_pk_is_rfc8410(key)) { in mbedtls_pk_write_key_der()
725 #if defined(MBEDTLS_PEM_WRITE_C)
750 if ((ret = mbedtls_pk_write_pubkey_der(key, output_buf, in mbedtls_pk_write_pubkey_pem()
755 if ((ret = mbedtls_pem_write_buffer(PEM_BEGIN_PUBLIC_KEY, PEM_END_PUBLIC_KEY, in mbedtls_pk_write_pubkey_pem()
770 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_key_pem()
772 #if defined(MBEDTLS_PK_HAVE_RFC8410_CURVES) in mbedtls_pk_write_key_pem()
776 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_write_key_pem()
780 if ((ret = mbedtls_pk_write_key_der(key, output_buf, sizeof(output_buf))) < 0) { in mbedtls_pk_write_key_pem()
784 #if defined(MBEDTLS_USE_PSA_CRYPTO) in mbedtls_pk_write_key_pem()
785 if (mbedtls_pk_get_type(key) == MBEDTLS_PK_OPAQUE) { in mbedtls_pk_write_key_pem()
788 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_write_key_pem()
791 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_key_pem()
793 #if defined(MBEDTLS_PK_HAVE_RFC8410_CURVES) in mbedtls_pk_write_key_pem()
794 if (pk_get_opaque_ec_family(key) == PSA_ECC_FAMILY_MONTGOMERY) { in mbedtls_pk_write_key_pem()
802 #if defined(MBEDTLS_RSA_C) in mbedtls_pk_write_key_pem()
803 if ((mbedtls_pk_get_type(key) == MBEDTLS_PK_RSA) || is_rsa_opaque) { in mbedtls_pk_write_key_pem()
808 #if defined(MBEDTLS_PK_HAVE_ECC_KEYS) in mbedtls_pk_write_key_pem()
809 if ((mbedtls_pk_get_type(key) == MBEDTLS_PK_ECKEY) || is_ec_opaque) { in mbedtls_pk_write_key_pem()
810 #if defined(MBEDTLS_PK_HAVE_RFC8410_CURVES) in mbedtls_pk_write_key_pem()
811 if (is_montgomery_opaque || in mbedtls_pk_write_key_pem()
826 if ((ret = mbedtls_pem_write_buffer(begin, end, in mbedtls_pk_write_key_pem()