NetSurf
Data Structures | Typedefs | Functions
strict-transport-security.c File Reference
#include <limits.h>
#include <stdlib.h>
#include "utils/corestrings.h"
#include "utils/http.h"
#include "utils/http/generics.h"
#include "utils/http/primitives.h"
Include dependency graph for strict-transport-security.c:

Go to the source code of this file.

Data Structures

struct  http_strict_transport_security
 Representation of a Strict-Transport-Security. More...
 
struct  http_directive
 Representation of a directive. More...
 

Typedefs

typedef struct http_directive http_directive
 Representation of a directive. More...
 

Functions

static void http_destroy_directive (http_directive *self)
 
static nserror http__parse_directive (const char **input, http_directive **result)
 
static void http_directive_list_destroy (http_directive *list)
 
static nserror http_directive_list_find_item (const http_directive *list, lwc_string *name, lwc_string **value)
 
static const http_directivehttp_directive_list_iterate (const http_directive *cur, lwc_string **name, lwc_string **value)
 
static uint32_t count (const http_directive *list, lwc_string *key)
 
static bool check_duplicates (const http_directive *directives)
 
static nserror parse_max_age (lwc_string *value, uint32_t *result)
 
nserror http_parse_strict_transport_security (const char *header_value, http_strict_transport_security **result)
 Parse an HTTP Strict-Transport-Security header value. More...
 
void http_strict_transport_security_destroy (http_strict_transport_security *victim)
 Destroy a strict transport security object. More...
 
uint32_t http_strict_transport_security_max_age (http_strict_transport_security *sts)
 Get the value of a strict transport security's max-age. More...
 
bool http_strict_transport_security_include_subdomains (http_strict_transport_security *sts)
 Get the value of a strict transport security's includeSubDomains flag. More...
 

Typedef Documentation

◆ http_directive

Representation of a directive.

Function Documentation

◆ check_duplicates()

static bool check_duplicates ( const http_directive directives)
static

Definition at line 172 of file strict-transport-security.c.

References count(), http_directive_list_iterate(), and result.

Referenced by http_parse_strict_transport_security().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ count()

static uint32_t count ( const http_directive list,
lwc_string *  key 
)
static

Definition at line 155 of file strict-transport-security.c.

References http_directive::base, count(), http_directive::name, and http__item::next.

Referenced by check_duplicates(), and count().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ http__parse_directive()

static nserror http__parse_directive ( const char **  input,
http_directive **  result 
)
static

Definition at line 56 of file strict-transport-security.c.

References HTTP__ITEM_INIT, http__parse_quoted_string(), http__parse_token(), http__skip_LWS(), http_destroy_directive(), http_directive::name, NSERROR_NOMEM, NSERROR_OK, result, and http_directive::value.

Referenced by http_parse_strict_transport_security().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_destroy_directive()

static void http_destroy_directive ( http_directive self)
static

Definition at line 47 of file strict-transport-security.c.

References http_directive::name, and http_directive::value.

Referenced by http__parse_directive().

Here is the caller graph for this function:

◆ http_directive_list_destroy()

static void http_directive_list_destroy ( http_directive list)
static

Definition at line 108 of file strict-transport-security.c.

References http__item_list_destroy.

Referenced by http_parse_strict_transport_security().

Here is the caller graph for this function:

◆ http_directive_list_find_item()

static nserror http_directive_list_find_item ( const http_directive list,
lwc_string *  name,
lwc_string **  value 
)
static

Definition at line 113 of file strict-transport-security.c.

References http_directive::base, http_directive::name, http__item::next, NSERROR_NOT_FOUND, NSERROR_OK, and http_directive::value.

Referenced by http_parse_strict_transport_security().

Here is the caller graph for this function:

◆ http_directive_list_iterate()

static const http_directive * http_directive_list_iterate ( const http_directive cur,
lwc_string **  name,
lwc_string **  value 
)
static

Definition at line 138 of file strict-transport-security.c.

References http_directive::base, http_directive::name, http__item::next, and http_directive::value.

Referenced by check_duplicates().

Here is the caller graph for this function:

◆ http_parse_strict_transport_security()

nserror http_parse_strict_transport_security ( const char *  header_value,
http_strict_transport_security **  result 
)

Parse an HTTP Strict-Transport-Security header value.

Parameters
header_valueHeader value to parse
resultPointer to location to receive result
Returns
NSERROR_OK on success, NSERROR_NOMEM on memory exhaustion, appropriate error otherwise

Definition at line 233 of file strict-transport-security.c.

References check_duplicates(), http__item_list_parse, http__parse_directive(), http__skip_LWS(), http_directive_list_destroy(), http_directive_list_find_item(), http_strict_transport_security::include_sub_domains, http_strict_transport_security::max_age, NSERROR_NOMEM, NSERROR_NOT_FOUND, NSERROR_OK, parse_max_age(), and result.

Referenced by urldb_set_hsts_policy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_strict_transport_security_destroy()

void http_strict_transport_security_destroy ( http_strict_transport_security victim)

Destroy a strict transport security object.

Parameters
victimObject to destroy

Definition at line 322 of file strict-transport-security.c.

Referenced by urldb_set_hsts_policy().

Here is the caller graph for this function:

◆ http_strict_transport_security_include_subdomains()

bool http_strict_transport_security_include_subdomains ( http_strict_transport_security sts)

Get the value of a strict transport security's includeSubDomains flag.

Parameters
stsObject to inspect
Returns
Whether subdomains should be included

Definition at line 336 of file strict-transport-security.c.

References http_strict_transport_security::include_sub_domains.

Referenced by urldb_set_hsts_policy().

Here is the caller graph for this function:

◆ http_strict_transport_security_max_age()

uint32_t http_strict_transport_security_max_age ( http_strict_transport_security sts)

Get the value of a strict transport security's max-age.

Parameters
stsObject to inspect
Returns
Max age, in delta-seconds

Definition at line 329 of file strict-transport-security.c.

References http_strict_transport_security::max_age.

Referenced by urldb_set_hsts_policy().

Here is the caller graph for this function:

◆ parse_max_age()

static nserror parse_max_age ( lwc_string *  value,
uint32_t *  result 
)
static

Definition at line 198 of file strict-transport-security.c.

References NSERROR_NOT_FOUND, NSERROR_OK, and result.

Referenced by http_parse_strict_transport_security().

Here is the caller graph for this function: