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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
/*
* Copyright (C) 2003, 2004, 2005 Free Software Foundation
*
* Author: Nikos Mavroyanopoulos
*
* This file is part of GNUTLS.
*
* The GNUTLS library 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 2.1 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
*/
/* This file contains the types and prototypes for the OpenPGP
* key and private key parsing functions.
*/
#ifndef GNUTLS_OPENPGP_H
# define GNUTLS_OPENPGP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gnutls/gnutls.h>
#include <gnutls/extra.h>
/* gnutls_openpgp_key_t should be defined in gnutls.h
*/
typedef enum gnutls_openpgp_key_fmt { GNUTLS_OPENPGP_FMT_RAW,
GNUTLS_OPENPGP_FMT_BASE64 } gnutls_openpgp_key_fmt;
int gnutls_openpgp_key_init( gnutls_openpgp_key* key); /* initializes the memory for gnutls_openpgp_key_t struct */
void gnutls_openpgp_key_deinit(gnutls_openpgp_key_t key); /* frees all memory */
int gnutls_openpgp_key_import(gnutls_openpgp_key_t key,
const gnutls_datum_t* data, gnutls_openpgp_key_fmt format);
int gnutls_openpgp_key_export (gnutls_openpgp_key_t key,
gnutls_openpgp_key_fmt_t format,
void *output_data, size_t * output_data_size);
/* The key_usage flags are defined in gnutls.h. They are
* the GNUTLS_KEY_* definitions.
*/
int gnutls_openpgp_key_get_key_usage( gnutls_openpgp_key_t cert, unsigned int* key_usage);
int gnutls_openpgp_key_get_fingerprint(gnutls_openpgp_key_t key,
void *fpr, size_t * fprlen);
int gnutls_openpgp_key_get_name( gnutls_openpgp_key_t key,
int idx, char *buf, size_t *sizeof_buf);
int gnutls_openpgp_key_get_pk_algorithm(gnutls_openpgp_key_t key,
unsigned int *r_bits);
int gnutls_openpgp_key_get_version( gnutls_openpgp_key_t key );
time_t gnutls_openpgp_key_get_creation_time( gnutls_openpgp_key_t key );
time_t gnutls_openpgp_key_get_expiration_time( gnutls_openpgp_key_t key );
int gnutls_openpgp_key_get_id( gnutls_openpgp_key_t key, unsigned char keyid[8]);
int gnutls_openpgp_key_check_hostname( gnutls_openpgp_key_t key, const char *hostname);
int gnutls_openpgp_key_to_xml( gnutls_openpgp_key_t key, gnutls_datum_t *xmlkey,
int ext);
/* privkey stuff.
*/
int gnutls_openpgp_privkey_init(gnutls_openpgp_privkey_t * key);
void gnutls_openpgp_privkey_deinit(gnutls_openpgp_privkey_t key);
int gnutls_openpgp_privkey_get_pk_algorithm( gnutls_openpgp_privkey_t key, unsigned int *bits);
int gnutls_openpgp_privkey_import(gnutls_openpgp_privkey_t key,
const gnutls_datum_t * data, gnutls_openpgp_key_fmt format,
const char* pass, unsigned int flags);
/* Keyring stuff.
*/
struct gnutls_openpgp_keyring_int; /* object to hold (parsed) openpgp keyrings */
typedef struct gnutls_openpgp_keyring_int* gnutls_openpgp_keyring;
int gnutls_openpgp_keyring_init( gnutls_openpgp_keyring* ring);
void gnutls_openpgp_keyring_deinit(gnutls_openpgp_keyring_t ring);
int gnutls_openpgp_keyring_import(gnutls_openpgp_keyring_t ring,
const gnutls_datum_t* data, gnutls_openpgp_key_fmt format);
int gnutls_openpgp_keyring_check_id( gnutls_openpgp_keyring_t ring,
const unsigned char keyid[8], unsigned int flags);
/* Trustdb functions.
*/
struct gnutls_openpgp_trustdb_int; /* object to hold (parsed) openpgp trustdbs */
typedef struct gnutls_openpgp_trustdb_int* gnutls_openpgp_trustdb;
int gnutls_openpgp_trustdb_init( gnutls_openpgp_trustdb* db);
void gnutls_openpgp_trustdb_deinit(gnutls_openpgp_trustdb_t db);
int gnutls_openpgp_trustdb_import(gnutls_openpgp_trustdb_t db,
const char* file);
int gnutls_openpgp_key_verify_ring(
gnutls_openpgp_key_t key,
gnutls_openpgp_keyring_t ring,
unsigned int flags,
unsigned int * verify /* the output of the verification */);
int gnutls_openpgp_key_verify_self( gnutls_openpgp_key_t key,
unsigned int flags, unsigned int *verify);
int gnutls_openpgp_key_verify_trustdb(
gnutls_openpgp_key_t key,
gnutls_openpgp_trustdb_t db,
unsigned int flags,
unsigned int * verify /* the output of the verification */);
/* certificate authentication stuff.
*/
int gnutls_certificate_set_openpgp_key(gnutls_certificate_credentials_t res,
gnutls_openpgp_key_t key, gnutls_openpgp_privkey_t pkey);
#ifdef __cplusplus
}
#endif
#endif /* GNUTLS_OPENPGP_H */
|