summaryrefslogtreecommitdiff
path: root/lib/openpgp/openpgp_int.h
blob: fa55e3e28f66896635d42bdb8d5088c11d1834f7 (plain)
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) 2002-2012 Free Software Foundation, Inc.
 *
 * Author: Timo Schulz, 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 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 program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

#ifndef OPENPGP_LOCAL_H
#define OPENPGP_LOCAL_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifdef ENABLE_OPENPGP

#include <opencdk/opencdk.h>
#include <gnutls/openpgp.h>

#define KEYID_IMPORT(dst, src) { \
	dst[0] = _gnutls_read_uint32( src); \
	dst[1] = _gnutls_read_uint32( src+4); }

/* Internal context to store the OpenPGP key. */
typedef struct gnutls_openpgp_crt_int {
	cdk_kbnode_t knode;
	uint8_t preferred_keyid[GNUTLS_OPENPGP_KEYID_SIZE];
	int preferred_set;
} gnutls_openpgp_crt_int;

/* Internal context to store the private OpenPGP key. */
typedef struct gnutls_openpgp_privkey_int {
	cdk_kbnode_t knode;
	uint8_t preferred_keyid[GNUTLS_OPENPGP_KEYID_SIZE];
	int preferred_set;
} gnutls_openpgp_privkey_int;


typedef struct gnutls_openpgp_keyring_int {
	cdk_keydb_hd_t db;
} gnutls_openpgp_keyring_int;

int _gnutls_map_cdk_rc(int rc);

int _gnutls_openpgp_export(cdk_kbnode_t node,
			   gnutls_openpgp_crt_fmt_t format,
			   void *output_data, size_t * output_data_size,
			   int priv);

int _gnutls_openpgp_export2(cdk_kbnode_t node,
			    gnutls_openpgp_crt_fmt_t format,
			    gnutls_datum_t * out, int priv);

cdk_packet_t _gnutls_get_valid_subkey(cdk_kbnode_t knode, int key_type);

unsigned int _gnutls_get_pgp_key_usage(unsigned int pgp_usage);

int
_gnutls_openpgp_crt_get_mpis(gnutls_openpgp_crt_t cert, uint32_t keyid[2],
			     gnutls_pk_params_st * params);

int
_gnutls_openpgp_privkey_get_mpis(gnutls_openpgp_privkey_t pkey,
				 uint32_t keyid[2],
				 gnutls_pk_params_st * params);

cdk_packet_t _gnutls_openpgp_find_key(cdk_kbnode_t knode,
				      uint32_t keyid[2],
				      unsigned int priv);

int _gnutls_read_pgp_mpi(cdk_packet_t pkt, unsigned int priv, size_t idx,
			 bigint_t * m);

int _gnutls_openpgp_find_subkey_idx(cdk_kbnode_t knode, uint32_t keyid[2],
				    unsigned int priv);

int _gnutls_openpgp_get_algo(int cdk_algo);

#endif				/* ENABLE_OPENPGP */

#endif				/* OPENPGP_LOCAL_H */