gnutls_srtp_get_profile_by_name -> gnutls_srtp_get_profile_id
[gnutls.git] / libdane / dane-params.c
blob53d84730caf8f3e7474ce100889f3a3c266b8cca
1 /*
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/>
23 #include <config.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <errno.h>
29 #include <arpa/inet.h>
30 #include <unbound.h>
31 #include <gnutls/dane.h>
32 #include <gnutls/x509.h>
33 #include <gnutls/abstract.h>
35 typedef struct cert_type_entry
37 const char* name;
38 dane_cert_type_t type;
39 } cert_type_entry;
41 static const cert_type_entry dane_cert_types[] =
43 {"X.509", DANE_CERT_X509},
44 {"SubjectPublicKeyInfo", DANE_CERT_PK},
45 {NULL, 0}
48 typedef struct match_type_entry
50 const char* name;
51 dane_match_type_t type;
52 } match_type_entry;
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},
59 {NULL, 0}
62 typedef struct cert_usage_entry
64 const char* name;
65 dane_cert_usage_t usage;
66 } cert_usage_entry;
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},
74 {NULL, 0}
79 /**
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
86 * type, or %NULL.
87 **/
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)
94 if (e->type == type)
95 return e->name;
96 e++;
99 return 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
109 * type, or %NULL.
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)
117 if (e->type == type)
118 return e->name;
119 e++;
122 return 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
132 * type, or %NULL.
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)
141 return e->name;
142 e++;
145 return NULL;