#define LEVEL_SUITEB192 "SUITEB192"
#define LEVEL_EXPORT "EXPORT"
+#define SET_LEVEL(to_set) \
+ if (priority_cache->level == 0 || priority_cache->level > to_set) \
+ priority_cache->level = to_set
+
static
int check_level(const char* level, gnutls_priority_t priority_cache, int add)
{
sign_priority_default);
func (&priority_cache->supported_ecc, supported_ecc_normal);
- if (priority_cache->level == 0)
- priority_cache->level = GNUTLS_SEC_PARAM_VERY_WEAK;
+ SET_LEVEL(GNUTLS_SEC_PARAM_VERY_WEAK);
return 1;
}
else if (strcasecmp (level, LEVEL_NORMAL) == 0)
sign_priority_default);
func (&priority_cache->supported_ecc, supported_ecc_normal);
- if (priority_cache->level == 0)
- priority_cache->level = GNUTLS_SEC_PARAM_VERY_WEAK;
+ SET_LEVEL(GNUTLS_SEC_PARAM_VERY_WEAK);
return 1;
}
else if (strcasecmp (level, LEVEL_PFS) == 0)
sign_priority_default);
func (&priority_cache->supported_ecc, supported_ecc_normal);
- if (priority_cache->level == 0)
- priority_cache->level = GNUTLS_SEC_PARAM_VERY_WEAK;
+ SET_LEVEL(GNUTLS_SEC_PARAM_VERY_WEAK);
return 1;
}
else if (strcasecmp (level, LEVEL_SECURE256) == 0
func (&priority_cache->supported_ecc, supported_ecc_secure192);
/* be conservative for now. Set the bits to correspond to 96-bit level */
- if (priority_cache->level == 0)
- priority_cache->level = GNUTLS_SEC_PARAM_LEGACY;
+ SET_LEVEL(GNUTLS_SEC_PARAM_LEGACY);
return 1;
}
else if (strcasecmp (level, LEVEL_SECURE128) == 0
func (&priority_cache->supported_ecc, supported_ecc_secure128);
/* be conservative for now. Set the bits to correspond to an 72-bit level */
- if (priority_cache->level == 0)
- priority_cache->level = GNUTLS_SEC_PARAM_WEAK;
+ SET_LEVEL(GNUTLS_SEC_PARAM_WEAK);
return 1;
}
else if (strcasecmp (level, LEVEL_SUITEB128) == 0)
sign_priority_suiteb128);
func (&priority_cache->supported_ecc, supported_ecc_suiteb128);
- if (priority_cache->level == 0)
- priority_cache->level = GNUTLS_SEC_PARAM_HIGH;
+ SET_LEVEL(GNUTLS_SEC_PARAM_HIGH);
return 1;
}
else if (strcasecmp (level, LEVEL_SUITEB192) == 0)
sign_priority_suiteb192);
func (&priority_cache->supported_ecc, supported_ecc_suiteb192);
- if (priority_cache->level == 0)
- priority_cache->level = GNUTLS_SEC_PARAM_ULTRA;
+ SET_LEVEL(GNUTLS_SEC_PARAM_ULTRA);
return 1;
}
else if (strcasecmp (level, LEVEL_EXPORT) == 0)
sign_priority_default);
func (&priority_cache->supported_ecc, supported_ecc_normal);
- if (priority_cache->level == 0)
- priority_cache->level = GNUTLS_SEC_PARAM_EXPORT;
+ SET_LEVEL(GNUTLS_SEC_PARAM_EXPORT);
return 1;
}
return 0;