2 * Copyright (C) 2012 KU Leuven
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of libdane.
8 * libdane is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * 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
38 dane_cert_type_t type
;
41 static const cert_type_entry dane_cert_types
[] =
43 {"X.509", DANE_CERT_X509
},
44 {"SubjectPublicKeyInfo", DANE_CERT_PK
},
48 typedef struct match_type_entry
51 dane_match_type_t type
;
54 static const match_type_entry dane_match_types
[] =
56 {"Exact match", DANE_MATCH_EXACT
},
57 {"SHA2-256 hash", DANE_MATCH_SHA2_256
},
58 {"SHA2-512 hash", DANE_MATCH_SHA2_512
},
62 typedef struct cert_usage_entry
65 dane_cert_usage_t usage
;
68 static const cert_usage_entry dane_cert_usages
[] =
70 {"CA", DANE_CERT_USAGE_CA
},
71 {"End-entity", DANE_CERT_USAGE_EE
},
72 {"Local CA", DANE_CERT_USAGE_LOCAL_CA
},
73 {"Local end-entity", DANE_CERT_USAGE_LOCAL_EE
},
80 * dane_cert_type_name:
81 * @type: is a DANE match type
83 * Convert a #dane_cert_type_t value to a string.
85 * Returns: a string that contains the name of the specified
88 const char* dane_cert_type_name(dane_cert_type_t type
)
90 const cert_type_entry
* e
= dane_cert_types
;
92 while(e
->name
!= NULL
)
103 * dane_match_type_name:
104 * @type: is a DANE match type
106 * Convert a #dane_match_type_t value to a string.
108 * Returns: a string that contains the name of the specified
111 const char* dane_match_type_name(dane_match_type_t type
)
113 const match_type_entry
* e
= dane_match_types
;
115 while(e
->name
!= NULL
)
126 * dane_cert_usage_name:
127 * @type: is a DANE match type
129 * Convert a #dane_cert_usage_t value to a string.
131 * Returns: a string that contains the name of the specified
134 const char* dane_cert_usage_name(dane_cert_usage_t usage
)
136 const cert_usage_entry
* e
= dane_cert_usages
;
138 while(e
->name
!= NULL
)
140 if (e
->usage
== usage
)