| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 1 | /** | 
|  | 2 | * \file ssl_ciphersuites_internal.h | 
|  | 3 | * | 
|  | 4 | * \brief Internal part of the public "ssl_ciphersuites.h". | 
|  | 5 | */ | 
|  | 6 | /* | 
|  | 7 | *  Copyright The Mbed TLS Contributors | 
|  | 8 | *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later | 
|  | 9 | */ | 
|  | 10 | #ifndef MBEDTLS_SSL_CIPHERSUITES_INTERNAL_H | 
|  | 11 | #define MBEDTLS_SSL_CIPHERSUITES_INTERNAL_H | 
|  | 12 |  | 
|  | 13 | #include "mbedtls/pk.h" | 
| Ben Taylor | 1030f80 | 2025-07-15 14:55:41 +0100 | [diff] [blame] | 14 | #if defined(MBEDTLS_PK_HAVE_PRIVATE_HEADER) | 
|  | 15 | #include <mbedtls/private/pk_private.h> | 
|  | 16 | #endif /* MBEDTLS_PK_HAVE_PRIVATE_HEADER */ | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 17 |  | 
|  | 18 | #if defined(MBEDTLS_PK_C) | 
|  | 19 | mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg(const mbedtls_ssl_ciphersuite_t *info); | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 20 | psa_algorithm_t mbedtls_ssl_get_ciphersuite_sig_pk_psa_alg(const mbedtls_ssl_ciphersuite_t *info); | 
|  | 21 | psa_key_usage_t mbedtls_ssl_get_ciphersuite_sig_pk_psa_usage(const mbedtls_ssl_ciphersuite_t *info); | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 22 | mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_alg(const mbedtls_ssl_ciphersuite_t *info); | 
|  | 23 | #endif /* MBEDTLS_PK_C */ | 
|  | 24 |  | 
|  | 25 | int mbedtls_ssl_ciphersuite_uses_ec(const mbedtls_ssl_ciphersuite_t *info); | 
|  | 26 | int mbedtls_ssl_ciphersuite_uses_psk(const mbedtls_ssl_ciphersuite_t *info); | 
|  | 27 |  | 
|  | 28 | #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PFS_ENABLED) | 
|  | 29 | static inline int mbedtls_ssl_ciphersuite_has_pfs(const mbedtls_ssl_ciphersuite_t *info) | 
|  | 30 | { | 
|  | 31 | switch (info->MBEDTLS_PRIVATE(key_exchange)) { | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 32 | case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: | 
|  | 33 | case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK: | 
|  | 34 | case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: | 
|  | 35 | case MBEDTLS_KEY_EXCHANGE_ECJPAKE: | 
|  | 36 | return 1; | 
|  | 37 |  | 
|  | 38 | default: | 
|  | 39 | return 0; | 
|  | 40 | } | 
|  | 41 | } | 
|  | 42 | #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PFS_ENABLED */ | 
|  | 43 |  | 
|  | 44 | #if defined(MBEDTLS_KEY_EXCHANGE_SOME_NON_PFS_ENABLED) | 
|  | 45 | static inline int mbedtls_ssl_ciphersuite_no_pfs(const mbedtls_ssl_ciphersuite_t *info) | 
|  | 46 | { | 
|  | 47 | switch (info->MBEDTLS_PRIVATE(key_exchange)) { | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 48 | case MBEDTLS_KEY_EXCHANGE_PSK: | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 49 | return 1; | 
|  | 50 |  | 
|  | 51 | default: | 
|  | 52 | return 0; | 
|  | 53 | } | 
|  | 54 | } | 
|  | 55 | #endif /* MBEDTLS_KEY_EXCHANGE_SOME_NON_PFS_ENABLED */ | 
|  | 56 |  | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 57 | static inline int mbedtls_ssl_ciphersuite_cert_req_allowed(const mbedtls_ssl_ciphersuite_t *info) | 
|  | 58 | { | 
|  | 59 | switch (info->MBEDTLS_PRIVATE(key_exchange)) { | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 60 | case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 61 | case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: | 
|  | 62 | return 1; | 
|  | 63 |  | 
|  | 64 | default: | 
|  | 65 | return 0; | 
|  | 66 | } | 
|  | 67 | } | 
|  | 68 |  | 
|  | 69 | static inline int mbedtls_ssl_ciphersuite_uses_srv_cert(const mbedtls_ssl_ciphersuite_t *info) | 
|  | 70 | { | 
|  | 71 | switch (info->MBEDTLS_PRIVATE(key_exchange)) { | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 72 | case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 73 | case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: | 
|  | 74 | return 1; | 
|  | 75 |  | 
|  | 76 | default: | 
|  | 77 | return 0; | 
|  | 78 | } | 
|  | 79 | } | 
|  | 80 |  | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 81 | #if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED) | 
|  | 82 | static inline int mbedtls_ssl_ciphersuite_uses_ecdhe(const mbedtls_ssl_ciphersuite_t *info) | 
|  | 83 | { | 
|  | 84 | switch (info->MBEDTLS_PRIVATE(key_exchange)) { | 
|  | 85 | case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: | 
|  | 86 | case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: | 
|  | 87 | case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK: | 
|  | 88 | return 1; | 
|  | 89 |  | 
|  | 90 | default: | 
|  | 91 | return 0; | 
|  | 92 | } | 
|  | 93 | } | 
|  | 94 | #endif /* MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED) */ | 
|  | 95 |  | 
|  | 96 | #if defined(MBEDTLS_KEY_EXCHANGE_WITH_SERVER_SIGNATURE_ENABLED) | 
|  | 97 | static inline int mbedtls_ssl_ciphersuite_uses_server_signature( | 
|  | 98 | const mbedtls_ssl_ciphersuite_t *info) | 
|  | 99 | { | 
|  | 100 | switch (info->MBEDTLS_PRIVATE(key_exchange)) { | 
| Valerio Setti | d929106 | 2024-01-17 09:48:06 +0100 | [diff] [blame] | 101 | case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: | 
|  | 102 | case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: | 
|  | 103 | return 1; | 
|  | 104 |  | 
|  | 105 | default: | 
|  | 106 | return 0; | 
|  | 107 | } | 
|  | 108 | } | 
|  | 109 | #endif /* MBEDTLS_KEY_EXCHANGE_WITH_SERVER_SIGNATURE_ENABLED */ | 
|  | 110 |  | 
|  | 111 | #endif /* MBEDTLS_SSL_CIPHERSUITES_INTERNAL_H */ |