1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
* Copyright (C) 2011 Free Software Foundation, Inc.
*
* Author: Nikos Mavrogiannopoulos
*
* This file is part of GnuTLS.
*
* The GnuTLS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
#include <gnutls_int.h>
#include <algorithms.h>
#include <gnutls_errors.h>
#include <x509/common.h>
/**
* gnutls_certificate_type_get_name:
* @type: is a certificate type
*
* Convert a #gnutls_certificate_type_t type to a string.
*
* Returns: a string that contains the name of the specified
* certificate type, or %NULL in case of unknown types.
**/
const char *
gnutls_certificate_type_get_name (gnutls_certificate_type_t type)
{
const char *ret = NULL;
if (type == GNUTLS_CRT_X509)
ret = "X.509";
if (type == GNUTLS_CRT_OPENPGP)
ret = "OPENPGP";
return ret;
}
/**
* gnutls_certificate_type_get_id:
* @name: is a certificate type name
*
* The names are compared in a case insensitive way.
*
* Returns: a #gnutls_certificate_type_t for the specified in a
* string certificate type, or %GNUTLS_CRT_UNKNOWN on error.
**/
gnutls_certificate_type_t
gnutls_certificate_type_get_id (const char *name)
{
gnutls_certificate_type_t ret = GNUTLS_CRT_UNKNOWN;
if (strcasecmp (name, "X.509") == 0 || strcasecmp (name, "X509") == 0)
return GNUTLS_CRT_X509;
if (strcasecmp (name, "OPENPGP") == 0)
return GNUTLS_CRT_OPENPGP;
return ret;
}
static const gnutls_certificate_type_t supported_certificate_types[] = {
GNUTLS_CRT_X509,
GNUTLS_CRT_OPENPGP,
0
};
/**
* gnutls_certificate_type_list:
*
* Get a list of certificate types. Note that to be able to use
* OpenPGP certificates, you must link to libgnutls-extra and call
* gnutls_global_init_extra().
*
* Returns: a (0)-terminated list of #gnutls_certificate_type_t
* integers indicating the available certificate types.
**/
const gnutls_certificate_type_t *
gnutls_certificate_type_list (void)
{
return supported_certificate_types;
}
|