dane

dane

Functions

Types and Values

Description

Functions

dane_state_init ()

int
dane_state_init (dane_state_t *s,
                 unsigned int flags);

This function will initialize the backend resolver. It is intended to be used in scenarios where multiple resolvings occur, to optimize against multiple re-initializations.

Parameters

s

The structure to be initialized

 

flags

flags from the dane_state_flags enumeration

 

Returns

On success, DANE_E_SUCCESS (0) is returned, otherwise a negative error value.


dane_state_set_dlv_file ()

int
dane_state_set_dlv_file (dane_state_t s,
                         const char *file);

This function will set a file with trusted keys for DLV (DNSSEC Lookaside Validation).

Parameters

s

The structure to be deinitialized

 

file

The file holding the DLV keys.

 

dane_state_deinit ()

void
dane_state_deinit (dane_state_t s);

This function will deinitialize a DANE query structure.

Parameters

s

The structure to be deinitialized

 

dane_raw_tlsa ()

int
dane_raw_tlsa (dane_state_t s,
               dane_query_t *r,
               char *const *dane_data,
               const int *dane_data_len,
               int secure,
               int bogus);

This function will fill in the TLSA (DANE) structure from the given raw DNS record data. The dane_data must be valid during the lifetime of the query.

Parameters

s

The DANE state structure

 

r

A structure to place the result

 

dane_data

array of DNS rdata items, terminated with a NULL pointer; caller must guarantee that the referenced data remains valid until dane_query_deinit() is called.

 

dane_data_len

the length n bytes of the dane_data items

 

secure

true if the result is validated securely, false if validation failed or the domain queried has no security info

 

bogus

if the result was not secure (secure = 0) due to a security failure, and the result is due to a security failure, bogus is true.

 

Returns

On success, DANE_E_SUCCESS (0) is returned, otherwise a negative error value.


dane_query_tlsa ()

int
dane_query_tlsa (dane_state_t s,
                 dane_query_t *r,
                 const char *host,
                 const char *proto,
                 unsigned int port);

This function will query the DNS server for the TLSA (DANE) data for the given host.

Parameters

s

The DANE state structure

 

r

A structure to place the result

 

host

The host name to resolve.

 

proto

The protocol type (tcp, udp, etc.)

 

port

The service port number (eg. 443).

 

Returns

On success, DANE_E_SUCCESS (0) is returned, otherwise a negative error value.


dane_query_status ()

dane_query_status_t
dane_query_status (dane_query_t q);

This function will return the status of the query response. See dane_query_status_t for the possible types.

Parameters

q

The query result structure

 

Returns

The status type.


dane_query_entries ()

unsigned int
dane_query_entries (dane_query_t q);

This function will return the number of entries in a query.

Parameters

q

The query result structure

 

Returns

The number of entries.


dane_query_data ()

int
dane_query_data (dane_query_t q,
                 unsigned int idx,
                 unsigned int *usage,
                 unsigned int *type,
                 unsigned int *match,
                 gnutls_datum_t *data);

This function will provide the DANE data from the query response.

Parameters

q

The query result structure

 

idx

The index of the query response.

 

usage

The certificate usage (see dane_cert_usage_t)

 

type

The certificate type (see dane_cert_type_t)

 

match

The DANE matching type (see dane_match_type_t)

 

data

The DANE data.

 

Returns

On success, DANE_E_SUCCESS (0) is returned, otherwise a negative error value.


dane_query_to_raw_tlsa ()

int
dane_query_to_raw_tlsa (dane_query_t q,
                        unsigned int *data_entries,
                        char ***dane_data,
                        int **dane_data_len,
                        int *secure,
                        int *bogus);

This function will provide the DANE data from the query response.

The pointers dane_data and dane_data_len are allocated with gnutls_malloc() to contain the data from the query result structure (individual dane_data items simply point to the original data and are not allocated separately). The returned dane_data are only valid during the lifetime of q .

Parameters

q

The query result structure

 

data_entries

Pointer set to the number of entries in the query

 

dane_data

Pointer to contain an array of DNS rdata items, terminated with a NULL pointer; caller must guarantee that the referenced data remains valid until dane_query_deinit() is called.

 

dane_data_len

Pointer to contain the length n bytes of the dane_data items

 

secure

Pointer set true if the result is validated securely, false if validation failed or the domain queried has no security info

 

bogus

Pointer set true if the result was not secure due to a security failure

 

Returns

On success, DANE_E_SUCCESS (0) is returned, otherwise a negative error value.


dane_query_deinit ()

void
dane_query_deinit (dane_query_t q);

This function will deinitialize a DANE query result structure.

Parameters

q

The structure to be deinitialized

 

dane_cert_type_name ()

const char *
dane_cert_type_name (dane_cert_type_t type);

Convert a dane_cert_type_t value to a string.

Parameters

type

is a DANE match type

 

Returns

a string that contains the name of the specified type, or NULL.


dane_match_type_name ()

const char *
dane_match_type_name (dane_match_type_t type);

Convert a dane_match_type_t value to a string.

Parameters

type

is a DANE match type

 

Returns

a string that contains the name of the specified type, or NULL.


dane_cert_usage_name ()

const char *
dane_cert_usage_name (dane_cert_usage_t usage);

Convert a dane_cert_usage_t value to a string.

Parameters

usage

is a DANE certificate usage

 

Returns

a string that contains the name of the specified type, or NULL.


dane_verification_status_print ()

int
dane_verification_status_print (unsigned int status,
                                gnutls_datum_t *out,
                                unsigned int flags);

This function will pretty print the status of a verification process -- eg. the one obtained by dane_verify_crt().

The output out needs to be deallocated using gnutls_free().

Parameters

status

The status flags to be printed

 

type

The certificate type

 

out

Newly allocated datum with (0) terminated string.

 

flags

should be zero

 

Returns

On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a negative error value.


dane_verify_crt_raw ()

int
dane_verify_crt_raw (dane_state_t s,
                     const gnutls_datum_t *chain,
                     unsigned  chain_size,
                     gnutls_certificate_type_t chain_type,
                     dane_query_t r,
                     unsigned int sflags,
                     unsigned int vflags,
                     unsigned int *verify);

This is the low-level function of dane_verify_crt(). See the high level function for documentation.

This function does not perform any resolving, it utilizes cached entries from r .

Parameters

s

A DANE state structure (may be NULL)

 

chain

A certificate chain

 

chain_size

The size of the chain

 

chain_type

The type of the certificate chain

 

r

DANE data to check against

 

sflags

Flags for the initialization of s (if NULL)

 

vflags

Verification flags; an OR'ed list of dane_verify_flags_t.

 

verify

An OR'ed list of dane_verify_status_t.

 

Returns

a negative error code on error and DANE_E_SUCCESS (0) when the DANE entries were successfully parsed, irrespective of whether they were verified (see verify for that information). If no usable entries were encountered DANE_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.


dane_verify_crt ()

int
dane_verify_crt (dane_state_t s,
                 const gnutls_datum_t *chain,
                 unsigned  chain_size,
                 gnutls_certificate_type_t chain_type,
                 const char *hostname,
                 const char *proto,
                 unsigned int port,
                 unsigned int sflags,
                 unsigned int vflags,
                 unsigned int *verify);

This function will verify the given certificate chain against the CA constrains and/or the certificate available via DANE. If no information via DANE can be obtained the flag DANE_VERIFY_NO_DANE_INFO is set. If a DNSSEC signature is not available for the DANE record then the verify flag DANE_VERIFY_NO_DNSSEC_DATA is set.

Due to the many possible options of DANE, there is no single threat model countered. When notifying the user about DANE verification results it may be better to mention: DANE verification did not reject the certificate, rather than mentioning a successful DANE verication.

Note that this function is designed to be run in addition to PKIX - certificate chain - verification. To be run independently the DANE_VFLAG_ONLY_CHECK_EE_USAGE flag should be specified; then the function will check whether the key of the peer matches the key advertized in the DANE entry.

Parameters

s

A DANE state structure (may be NULL)

 

chain

A certificate chain

 

chain_size

The size of the chain

 

chain_type

The type of the certificate chain

 

hostname

The hostname associated with the chain

 

proto

The protocol of the service connecting (e.g. tcp)

 

port

The port of the service connecting (e.g. 443)

 

sflags

Flags for the initialization of s (if NULL)

 

vflags

Verification flags; an OR'ed list of dane_verify_flags_t.

 

verify

An OR'ed list of dane_verify_status_t.

 

Returns

a negative error code on error and DANE_E_SUCCESS (0) when the DANE entries were successfully parsed, irrespective of whether they were verified (see verify for that information). If no usable entries were encountered DANE_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.


dane_verify_session_crt ()

int
dane_verify_session_crt (dane_state_t s,
                         gnutls_session_t session,
                         const char *hostname,
                         const char *proto,
                         unsigned int port,
                         unsigned int sflags,
                         unsigned int vflags,
                         unsigned int *verify);

This function will verify session's certificate chain against the CA constrains and/or the certificate available via DANE. See dane_verify_crt() for more information.

This will not verify the chain for validity; unless the DANE verification is restricted to end certificates, this must be be performed separately using gnutls_certificate_verify_peers3().

Parameters

s

A DANE state structure (may be NULL)

 

session

A gnutls session

 

hostname

The hostname associated with the chain

 

proto

The protocol of the service connecting (e.g. tcp)

 

port

The port of the service connecting (e.g. 443)

 

sflags

Flags for the initialization of s (if NULL)

 

vflags

Verification flags; an OR'ed list of dane_verify_flags_t.

 

verify

An OR'ed list of dane_verify_status_t.

 

Returns

a negative error code on error and DANE_E_SUCCESS (0) when the DANE entries were successfully parsed, irrespective of whether they were verified (see verify for that information). If no usable entries were encountered DANE_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.


dane_strerror ()

const char *
dane_strerror (int error);

This function is similar to strerror. The difference is that it accepts an error number returned by a gnutls function; In case of an unknown error a descriptive string is sent instead of NULL.

Error codes are always a negative error code.

Parameters

error

is a DANE error code, a negative error code

 

Returns

A string explaining the DANE error message.

Types and Values

enum dane_cert_usage_t

Enumeration of different certificate usage types.

Members

DANE_CERT_USAGE_CA

CA constraint. The certificate/key presented must have signed the verified key.

 

DANE_CERT_USAGE_EE

The key or the certificate of the end entity.

 

DANE_CERT_USAGE_LOCAL_CA

The remote CA is local and possibly untrusted by the verifier.

 

DANE_CERT_USAGE_LOCAL_EE

The remote end-entity key is local and possibly untrusted by the verifier (not signed by a CA).

 

enum dane_cert_type_t

Enumeration of different certificate types.

Members

DANE_CERT_X509

An X.509 certificate.

 

DANE_CERT_PK

A public key.

 

enum dane_match_type_t

Enumeration of different content matching types.

Members

DANE_MATCH_EXACT

The full content.

 

DANE_MATCH_SHA2_256

A SHA-256 hash of the content.

 

DANE_MATCH_SHA2_512

A SHA-512 hash of the content.

 

enum dane_query_status_t

Enumeration of different certificate types.

Members

DANE_QUERY_UNKNOWN

There was no query.

 

DANE_QUERY_DNSSEC_VERIFIED

The query was verified using DNSSEC.

 

DANE_QUERY_BOGUS

The query has wrong DNSSEC signature.

 

DANE_QUERY_NO_DNSSEC

The query has no DNSSEC data.

 

dane_state_t

typedef struct dane_state_st *dane_state_t;

dane_query_t

typedef struct dane_query_st *dane_query_t;

enum dane_state_flags_t

Enumeration of different verification flags.

Members

DANE_F_IGNORE_LOCAL_RESOLVER

Many systems are not DNSSEC-ready. In that case the local resolver is ignored, and a direct recursive resolve occurs.

 

DANE_F_INSECURE

Ignore any DNSSEC signature verification errors.

 

DANE_F_IGNORE_DNSSEC

Do not try to initialize DNSSEC as we will not use it (will then not try to load the DNSSEC root certificate). Useful if the TLSA data does not come from DNS.

 

enum dane_verify_flags_t

Enumeration of different verification status flags.

Members

DANE_VFLAG_FAIL_IF_NOT_CHECKED

If irrelevant to this certificate DANE entries are received fail instead of succeeding.

 

DANE_VFLAG_ONLY_CHECK_EE_USAGE

The provided certificates will be verified only against any EE field. Combine with DANE_VFLAG_FAIL_IF_NOT_CHECKED to fail if EE entries are not present.

 

DANE_VFLAG_ONLY_CHECK_CA_USAGE

The provided certificates will be verified only against any CA field. Combine with DANE_VFLAG_FAIL_IF_NOT_CHECKED to fail if CA entries are not present.

 

enum dane_verify_status_t

Enumeration of different verification status flags.

Members

DANE_VERIFY_CA_CONSTRAINTS_VIOLATED

The CA constraints were violated.

 

DANE_VERIFY_CERT_DIFFERS

The certificate obtained via DNS differs.

 

DANE_VERIFY_UNKNOWN_DANE_INFO

No known DANE data was found in the DNS record.

 

DANE_VERIFY_CA_CONSTRAINS_VIOLATED

#define DANE_VERIFY_CA_CONSTRAINS_VIOLATED DANE_VERIFY_CA_CONSTRAINTS_VIOLATED

DANE_VERIFY_NO_DANE_INFO

#define DANE_VERIFY_NO_DANE_INFO DANE_VERIFY_UNKNOWN_DANE_INFO

DANE_E_SUCCESS

#define DANE_E_SUCCESS 0

DANE_E_INITIALIZATION_ERROR

#define DANE_E_INITIALIZATION_ERROR -1

DANE_E_RESOLVING_ERROR

#define DANE_E_RESOLVING_ERROR -2

DANE_E_NO_DANE_DATA

#define DANE_E_NO_DANE_DATA -3

DANE_E_RECEIVED_CORRUPT_DATA

#define DANE_E_RECEIVED_CORRUPT_DATA -4

DANE_E_INVALID_DNSSEC_SIG

#define DANE_E_INVALID_DNSSEC_SIG -5

DANE_E_NO_DNSSEC_SIG

#define DANE_E_NO_DNSSEC_SIG -6

DANE_E_MEMORY_ERROR

#define DANE_E_MEMORY_ERROR -7

DANE_E_REQUESTED_DATA_NOT_AVAILABLE

#define DANE_E_REQUESTED_DATA_NOT_AVAILABLE -8

DANE_E_INVALID_REQUEST

#define DANE_E_INVALID_REQUEST -9

DANE_E_PUBKEY_ERROR

#define DANE_E_PUBKEY_ERROR -10

DANE_E_NO_CERT

#define DANE_E_NO_CERT -11

DANE_E_FILE_ERROR

#define DANE_E_FILE_ERROR -12

DANE_E_CERT_ERROR

#define DANE_E_CERT_ERROR -13

DANE_E_UNKNOWN_DANE_DATA

#define DANE_E_UNKNOWN_DANE_DATA -14