Tizen 2.0 Release
[external/libgnutls26.git] / lib / openpgp / openpgp_int.h
1 #ifndef OPENPGP_LOCAL_H
2 #define OPENPGP_LOCAL_H
3
4 #ifdef HAVE_CONFIG_H
5 #include <config.h>
6 #endif
7
8 #ifdef ENABLE_OPENPGP
9
10 #include <opencdk.h>
11 #include <gnutls/openpgp.h>
12
13 #define KEYID_IMPORT(dst, src) { \
14         dst[0] = _gnutls_read_uint32( src); \
15         dst[1] = _gnutls_read_uint32( src+4); }
16
17 /* Internal context to store the OpenPGP key. */
18 typedef struct gnutls_openpgp_crt_int
19 {
20   cdk_kbnode_t knode;
21   uint8_t preferred_keyid[GNUTLS_OPENPGP_KEYID_SIZE];
22   int preferred_set;
23 } gnutls_openpgp_crt_int;
24
25 /* Internal context to store the private OpenPGP key. */
26 typedef struct gnutls_openpgp_privkey_int
27 {
28   cdk_kbnode_t knode;
29   gnutls_openpgp_keyid_t preferred_keyid;
30   int preferred_set;
31 } gnutls_openpgp_privkey_int;
32
33
34 typedef struct gnutls_openpgp_keyring_int
35 {
36   cdk_keydb_hd_t db;
37 } gnutls_openpgp_keyring_int;
38
39 int _gnutls_map_cdk_rc (int rc);
40
41 int _gnutls_openpgp_export (cdk_kbnode_t node,
42                             gnutls_openpgp_crt_fmt_t format,
43                             void *output_data, size_t * output_data_size,
44                             int private);
45
46 int _gnutls_openpgp_crt_to_gcert (gnutls_cert * gcert,
47                                   gnutls_openpgp_crt_t cert);
48
49 cdk_packet_t _gnutls_get_valid_subkey (cdk_kbnode_t knode, int key_type);
50
51 unsigned int _gnutls_get_pgp_key_usage (unsigned int pgp_usage);
52
53 int
54 _gnutls_openpgp_crt_get_mpis (gnutls_openpgp_crt_t cert, uint32_t keyid[2],
55                               bigint_t * params, int *params_size);
56
57 int
58 _gnutls_openpgp_privkey_get_mpis (gnutls_openpgp_privkey_t pkey,
59                                   uint32_t keyid[2], bigint_t * params,
60                                   int *params_size);
61
62 cdk_packet_t _gnutls_openpgp_find_key (cdk_kbnode_t knode, uint32_t keyid[2],
63                                        unsigned int priv);
64
65 int _gnutls_read_pgp_mpi (cdk_packet_t pkt, unsigned int priv, size_t idx,
66                           bigint_t * m);
67
68 int _gnutls_openpgp_find_subkey_idx (cdk_kbnode_t knode, uint32_t keyid[2],
69                                      unsigned int priv);
70
71 int _gnutls_openpgp_get_algo (int cdk_algo);
72
73 #endif /* ENABLE_OPENPGP */
74
75 #endif /* OPENPGP_LOCAL_H */