2 * Copyright (C) 2012 KU Leuven
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of libdane.
8 * The libdane library is free software; you can redistribute it
9 * and/or modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
29 #include <arpa/inet.h>
31 #include <gnutls/dane.h>
32 #include <gnutls/x509.h>
33 #include <gnutls/abstract.h>
35 typedef struct cert_type_entry {
37 dane_cert_type_t type;
40 static const cert_type_entry dane_cert_types[] = {
41 {"X.509", DANE_CERT_X509},
42 {"SubjectPublicKeyInfo", DANE_CERT_PK},
46 typedef struct match_type_entry {
48 dane_match_type_t type;
51 static const match_type_entry dane_match_types[] = {
52 {"Exact match", DANE_MATCH_EXACT},
53 {"SHA2-256 hash", DANE_MATCH_SHA2_256},
54 {"SHA2-512 hash", DANE_MATCH_SHA2_512},
58 typedef struct cert_usage_entry {
60 dane_cert_usage_t usage;
63 static const cert_usage_entry dane_cert_usages[] = {
64 {"CA", DANE_CERT_USAGE_CA},
65 {"End-entity", DANE_CERT_USAGE_EE},
66 {"Local CA", DANE_CERT_USAGE_LOCAL_CA},
67 {"Local end-entity", DANE_CERT_USAGE_LOCAL_EE},
74 * dane_cert_type_name:
75 * @type: is a DANE match type
77 * Convert a #dane_cert_type_t value to a string.
79 * Returns: a string that contains the name of the specified
82 const char *dane_cert_type_name(dane_cert_type_t type)
84 const cert_type_entry *e = dane_cert_types;
86 while (e->name != NULL) {
96 * dane_match_type_name:
97 * @type: is a DANE match type
99 * Convert a #dane_match_type_t value to a string.
101 * Returns: a string that contains the name of the specified
104 const char *dane_match_type_name(dane_match_type_t type)
106 const match_type_entry *e = dane_match_types;
108 while (e->name != NULL) {
118 * dane_cert_usage_name:
119 * @type: is a DANE match type
121 * Convert a #dane_cert_usage_t value to a string.
123 * Returns: a string that contains the name of the specified
126 const char *dane_cert_usage_name(dane_cert_usage_t usage)
128 const cert_usage_entry *e = dane_cert_usages;
130 while (e->name != NULL) {
131 if (e->usage == usage)