Dillo v3.1.1-98-g318d1f14
Loading...
Searching...
No Matches
hsts.c File Reference

HTTP Strict Transport Security. More...

#include <time.h>
#include <errno.h>
#include <limits.h>
#include <ctype.h>
#include <stdlib.h>
#include "hsts.h"
#include "msg.h"
#include "../dlib/dlib.h"
#include "IO/tls.h"
Include dependency graph for hsts.c:

Go to the source code of this file.

Functions

static void Hsts_free_policy (HstsData_t *p)
 
void a_Hsts_freeall (void)
 
static int Domain_node_domain_str_cmp (const void *v1, const void *v2)
 Compare function for searching a domain node by domain string.
 
static HstsData_t * Hsts_get_policy (const char *host)
 
static void Hsts_remove_policy (HstsData_t *policy)
 
static time_t Hsts_future_time (long seconds_from_now)
 Return the time_t for a future time.
 
static int Domain_node_cmp (const void *v1, const void *v2)
 Compare function for searching domains.
 
static void Hsts_set_policy (const char *host, long max_age, bool_t subdomains)
 
static char * Hsts_parse_attr (const char **header_str)
 Read the next attribute.
 
static char * Hsts_parse_value (const char **header_str)
 Get the value in *header_str.
 
static void Hsts_eat_value (const char **str)
 Advance past any value.
 
void a_Hsts_set (const char *header, const DilloUrl *url)
 The reponse for this url had an HSTS header, so let's take action.
 
static bool_t Hsts_expired (HstsData_t *policy)
 
bool_t a_Hsts_require_https (const char *host)
 
static void Hsts_preload (FILE *stream)
 
void a_Hsts_init (FILE *preload_file)
 

Variables

static time_t hsts_latest_representable_time
 
static Dlistdomains
 

Detailed Description

HTTP Strict Transport Security.

Definition in file hsts.c.

Function Documentation

◆ a_Hsts_freeall()

void a_Hsts_freeall ( void  )

◆ a_Hsts_init()

void a_Hsts_init ( FILE *  preload_file)

◆ a_Hsts_require_https()

bool_t a_Hsts_require_https ( const char *  host)

Definition at line 271 of file hsts.c.

References _MSG, FALSE, Hsts_expired(), Hsts_get_policy(), Hsts_remove_policy(), and TRUE.

Referenced by a_Url_new().

◆ a_Hsts_set()

void a_Hsts_set ( const char *  header,
const DilloUrl url 
)

The reponse for this url had an HSTS header, so let's take action.

Definition at line 201 of file hsts.c.

References _MSG, a_Tls_certificate_is_clean(), dFree(), dStrAsciiCasecmp(), FALSE, Hsts_eat_value(), Hsts_get_policy(), Hsts_parse_attr(), Hsts_parse_value(), Hsts_remove_policy(), Hsts_set_policy(), MSG, TRUE, and URL_HOST.

Referenced by Cache_parse_header().

◆ Domain_node_cmp()

static int Domain_node_cmp ( const void *  v1,
const void *  v2 
)
static

Compare function for searching domains.

Definition at line 117 of file hsts.c.

References dStrAsciiCasecmp().

Referenced by Hsts_set_policy().

◆ Domain_node_domain_str_cmp()

static int Domain_node_domain_str_cmp ( const void *  v1,
const void *  v2 
)
static

Compare function for searching a domain node by domain string.

Definition at line 72 of file hsts.c.

References dStrAsciiCasecmp().

Referenced by Hsts_get_policy().

◆ Hsts_eat_value()

static void Hsts_eat_value ( const char **  str)
static

Advance past any value.

Definition at line 192 of file hsts.c.

Referenced by a_Hsts_set().

◆ Hsts_expired()

static bool_t Hsts_expired ( HstsData_t *  policy)
static

Definition at line 260 of file hsts.c.

References _MSG, FALSE, and TRUE.

Referenced by a_Hsts_require_https().

◆ Hsts_free_policy()

static void Hsts_free_policy ( HstsData_t *  p)
static

Definition at line 49 of file hsts.c.

References dFree().

Referenced by a_Hsts_freeall(), and Hsts_remove_policy().

◆ Hsts_future_time()

static time_t Hsts_future_time ( long  seconds_from_now)
static

Return the time_t for a future time.

Definition at line 97 of file hsts.c.

References hsts_latest_representable_time.

Referenced by Hsts_set_policy().

◆ Hsts_get_policy()

static HstsData_t * Hsts_get_policy ( const char *  host)
static

Definition at line 80 of file hsts.c.

References dList_find_sorted(), Domain_node_domain_str_cmp(), and domains.

Referenced by a_Hsts_require_https(), a_Hsts_set(), and Hsts_set_policy().

◆ Hsts_parse_attr()

static char * Hsts_parse_attr ( const char **  header_str)
static

Read the next attribute.

Definition at line 144 of file hsts.c.

References dIsspace, and dStrndup().

Referenced by a_Hsts_set().

◆ Hsts_parse_value()

static char * Hsts_parse_value ( const char **  header_str)
static

Get the value in *header_str.

Definition at line 165 of file hsts.c.

References dIsspace, and dStrndup().

Referenced by a_Hsts_set().

◆ Hsts_preload()

static void Hsts_preload ( FILE *  stream)
static

Definition at line 309 of file hsts.c.

References dIsspace, dStrAsciiCasecmp(), dStrerror, dStrstrip(), FALSE, Hsts_set_policy(), LINE_MAXLEN, MSG_WARN, and TRUE.

Referenced by a_Hsts_init().

◆ Hsts_remove_policy()

static void Hsts_remove_policy ( HstsData_t *  policy)
static

Definition at line 85 of file hsts.c.

References _MSG, dList_remove(), domains, and Hsts_free_policy().

Referenced by a_Hsts_require_https(), and a_Hsts_set().

◆ Hsts_set_policy()

static void Hsts_set_policy ( const char *  host,
long  max_age,
bool_t  subdomains 
)
static

Variable Documentation

◆ domains

Dlist* domains
static

◆ hsts_latest_representable_time

time_t hsts_latest_representable_time
static

Definition at line 46 of file hsts.c.

Referenced by a_Hsts_init(), and Hsts_future_time().