src/cbor.c
/*
 * Validate CTAP2 canonical CBOR encoding rules for maps.
 */
Validate CTAP2 canonical CBOR encoding rules for maps.
Validate CTAP2 canonical CBOR encoding rules for maps .
static int
ctap_check_cbor(cbor_item_t *prev, cbor_item_t *curr)
{
	size_t	curr_len;
	size_t	prev_len;
	if (check_key_type(prev) < 0 || check_key_type(curr) < 0)
		return (-1);
	if (prev->type != curr->type) {
		if (prev->type < curr->type)
			return (0);
		fido_log_debug("%s: unsorted types", __func__);
		return (-1);
	}
	if (curr->type == CBOR_TYPE_UINT || curr->type == CBOR_TYPE_NEGINT) {
		if (cbor_int_get_width(curr) >= cbor_int_get_width(prev) &&
		    cbor_get_int(curr) > cbor_get_int(prev))
			return (0);
	} else {
		curr_len = cbor_string_length(curr);
		prev_len = cbor_string_length(prev);
		if (curr_len > prev_len || (curr_len == prev_len &&
		    memcmp(cbor_string_handle(prev), cbor_string_handle(curr),
		    curr_len) < 0))
			return (0);
	}
	fido_log_debug("%s: invalid cbor", __func__);
	return (-1);
}
static int ctap_check_cbor ( cbor_item_t * prev , cbor_item_t * curr ) { size_t curr_len ; size_t prev_len ; if ( check_key_type ( prev ) < 0 || check_key_type ( curr ) < 0 ) return ( -1 ) ; if ( prev -> type != curr -> type ) { if ( prev -> type < curr -> type ) return ( 0 ) ; fido_log_debug ( " " , __func__ ) ; return ( -1 ) ; } if ( curr -> type == CBOR_TYPE_UINT || curr -> type == CBOR_TYPE_NEGINT ) { if ( cbor_int_get_width ( curr ) >= cbor_int_get_width ( prev ) && cbor_get_int ( curr ) > cbor_get_int ( prev ) ) return ( 0 ) ; } else { curr_len = cbor_string_length ( curr ) ; prev_len = cbor_string_length ( prev ) ; if ( curr_len > prev_len || ( curr_len == prev_len && memcmp ( cbor_string_handle ( prev ) , cbor_string_handle ( curr ) , curr_len ) < 0 ) ) return ( 0 ) ; } fido_log_debug ( " " , __func__ ) ; return ( -1 ) ; }
Validate CTAP2 canonical CBOR encoding rules for maps.
Validate CTAP2 canonical CBOR encoding rules for maps .