/*-
* _gnutls_x509_name_constraints_is_empty:
* @nc: name constraints structure
- * @type: type (gnutls_x509_subject_alt_name_t or 0)
*
* Test whether given name constraints structure has any constraints (permitted
- * or excluded) of a given type. @nc must be allocated (not NULL) before the call.
- * If @type is 0, type checking will be skipped.
+ * or excluded). @nc must be allocated (not NULL) before the call.
*
- * Returns: false if @nc contains constraints of type @type, true otherwise
+ * Returns: true if @nc contains no constraints, false otherwise
-*/
-bool _gnutls_x509_name_constraints_is_empty(gnutls_x509_name_constraints_t nc,
- unsigned type)
+bool _gnutls_x509_name_constraints_is_empty(gnutls_x509_name_constraints_t nc)
{
- if (gl_list_size(nc->permitted.items) == 0 &&
- gl_list_size(nc->excluded.items) == 0)
- return true;
-
- if (type == 0)
- return false;
+ return gl_list_size(nc->permitted.items) == 0 &&
+ gl_list_size(nc->excluded.items) == 0;
+}
+static bool name_constraints_contains_type(gnutls_x509_name_constraints_t nc,
+ gnutls_x509_subject_alt_name_t type)
+{
const struct name_constraints_node_st *node;
gl_list_iterator_t iter;
while (gl_list_iterator_next(&iter, (const void **)&node, NULL)) {
if (node->type == type) {
gl_list_iterator_free(&iter);
- return false;
+ return true;
}
}
gl_list_iterator_free(&iter);
while (gl_list_iterator_next(&iter, (const void **)&node, NULL)) {
if (node->type == type) {
gl_list_iterator_free(&iter);
- return false;
+ return true;
}
}
gl_list_iterator_free(&iter);
/* no constraint for that type exists */
- return true;
+ return false;
}
/*-
unsigned found_one;
size_t checks;
- if (_gnutls_x509_name_constraints_is_empty(nc, type) != 0)
+ if (!name_constraints_contains_type(nc, type))
return 1; /* shortcut; no constraints to check */
if (!INT_ADD_OK(gl_list_size(nc->permitted.items),
}
if (flags & GNUTLS_NAME_CONSTRAINTS_FLAG_APPEND &&
- !_gnutls_x509_name_constraints_is_empty(nc, 0)) {
+ !_gnutls_x509_name_constraints_is_empty(nc)) {
ret = gnutls_x509_name_constraints_init(&nc2);
if (ret < 0) {
gnutls_assert();
unsigned rtype;
gnutls_datum_t rname;
- if (_gnutls_x509_name_constraints_is_empty(nc, 0))
+ if (_gnutls_x509_name_constraints_is_empty(nc))
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
result = asn1_create_element(_gnutls_get_pkix(),
int crl_list_length,
gnutls_verify_output_function func);
-bool _gnutls_x509_name_constraints_is_empty(gnutls_x509_name_constraints_t nc,
- unsigned type);
+bool _gnutls_x509_name_constraints_is_empty(gnutls_x509_name_constraints_t nc);
int _gnutls_x509_name_constraints_extract(asn1_node c2,
const char *permitted_name,
const char *excluded_name,