mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-11-03 20:33:16 +03:00 
			
		
		
		
	add #ifdefs to reduce switch size
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
		@@ -392,45 +392,71 @@ psa_ecc_family_t mbedtls_ecc_group_to_psa(mbedtls_ecp_group_id grpid,
 | 
			
		||||
                                          size_t *bits)
 | 
			
		||||
{
 | 
			
		||||
    switch (grpid) {
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_SECP192R1:
 | 
			
		||||
            *bits = 192;
 | 
			
		||||
            return PSA_ECC_FAMILY_SECP_R1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_SECP224R1:
 | 
			
		||||
            *bits = 224;
 | 
			
		||||
            return PSA_ECC_FAMILY_SECP_R1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_SECP256R1:
 | 
			
		||||
            *bits = 256;
 | 
			
		||||
            return PSA_ECC_FAMILY_SECP_R1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_SECP384R1:
 | 
			
		||||
            *bits = 384;
 | 
			
		||||
            return PSA_ECC_FAMILY_SECP_R1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_SECP521R1:
 | 
			
		||||
            *bits = 521;
 | 
			
		||||
            return PSA_ECC_FAMILY_SECP_R1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_BP256R1:
 | 
			
		||||
            *bits = 256;
 | 
			
		||||
            return PSA_ECC_FAMILY_BRAINPOOL_P_R1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_BP384R1:
 | 
			
		||||
            *bits = 384;
 | 
			
		||||
            return PSA_ECC_FAMILY_BRAINPOOL_P_R1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_BP512R1:
 | 
			
		||||
            *bits = 512;
 | 
			
		||||
            return PSA_ECC_FAMILY_BRAINPOOL_P_R1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_CURVE25519:
 | 
			
		||||
            *bits = 255;
 | 
			
		||||
            return PSA_ECC_FAMILY_MONTGOMERY;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_SECP192K1:
 | 
			
		||||
            *bits = 192;
 | 
			
		||||
            return PSA_ECC_FAMILY_SECP_K1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_SECP224K1:
 | 
			
		||||
            *bits = 224;
 | 
			
		||||
            return PSA_ECC_FAMILY_SECP_K1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_SECP256K1:
 | 
			
		||||
            *bits = 256;
 | 
			
		||||
            return PSA_ECC_FAMILY_SECP_K1;
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
 | 
			
		||||
        case MBEDTLS_ECP_DP_CURVE448:
 | 
			
		||||
            *bits = 448;
 | 
			
		||||
            return PSA_ECC_FAMILY_MONTGOMERY;
 | 
			
		||||
#endif
 | 
			
		||||
        default:
 | 
			
		||||
            *bits = 0;
 | 
			
		||||
            return 0;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user