~ubuntu-branches/ubuntu/lucid/gnutls26/lucid-proposed

« back to all changes in this revision

Viewing changes to libextra/opencdk/main.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2008-06-24 19:13:25 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080624191325-33rewwn0p11jzdvq
Tags: 2.4.0-2
* Standards version 3.8.0. Rename README.source_and_patches to README.source.
* Upload to unstable.
* Point watchfile to stable releases again.
* Merge experimental and unstable changelog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* main.h
2
 
 *       Copyright (C) 2002, 2003, 2007 Timo Schulz
3
 
 *
4
 
 * This file is part of OpenCDK.
5
 
 *
6
 
 * OpenCDK is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * OpenCDK is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 */
16
 
#ifndef CDK_MAIN_H
17
 
#define CDK_MAIN_H
18
 
 
19
 
#include <gcrypt.h>
20
 
#include "types.h"
21
 
 
22
 
/* The general size of a buffer for the variou modules. */
23
 
#define BUFSIZE 8192
24
 
 
25
 
/* This is the default block size for the partial length packet mode. */
26
 
#define DEF_BLOCKSIZE 8192
27
 
#define DEF_BLOCKBITS   13 /* 2^13 = 8192 */
28
 
 
29
 
/* For now SHA-1 is used to create fingerprint for keys.
30
 
   But if this will ever change, it is a good idea to
31
 
   have a constant for it to avoid to change it in all files. */
32
 
#define KEY_FPR_LEN 20
33
 
 
34
 
#include "context.h"
35
 
 
36
 
/* The maximal amount of bits a multi precsion integer can have. */
37
 
#define MAX_MPI_BITS 16384
38
 
#define MAX_MPI_BYTES (MAX_MPI_BITS/8)
39
 
 
40
 
 
41
 
/* Because newer DSA variants are not limited to SHA-1, we must consider 
42
 
 that SHA-512 is used and increase the buffer size of the digest. */
43
 
#define MAX_DIGEST_LEN 64
44
 
 
45
 
/* Helper to find out if the signature were made over a user ID
46
 
   or if the signature revokes a previous user ID. */
47
 
#define IS_UID_SIG(s) (((s)->sig_class & ~3) == 0x10)
48
 
#define IS_UID_REV(s) ((s)->sig_class == 0x30)
49
 
 
50
 
#define DEBUG_PKT (_cdk_get_log_level () == (CDK_LOG_DEBUG+1))
51
 
 
52
 
/* Helper to find out if a key has the requested capability. */
53
 
#define KEY_CAN_ENCRYPT(a) (_cdk_pk_algo_usage ((a)) & CDK_KEY_USG_ENCR)
54
 
#define KEY_CAN_SIGN(a)    (_cdk_pk_algo_usage ((a)) & CDK_KEY_USG_SIGN)
55
 
#define KEY_CAN_AUTH(a)    (_cdk_pk_algo_usage ((a)) & CDK_KEY_USG_AUTH)
56
 
 
57
 
/* Helper macro to make sure the buffer is overwritten. */
58
 
#define wipemem(_ptr,_len) do { \
59
 
  volatile char *_vptr = (volatile char *)(_ptr); \
60
 
  size_t _vlen = (_len); \
61
 
  while (_vlen) \
62
 
    { \
63
 
      *_vptr = 0; \
64
 
      _vptr++; \
65
 
      _vlen--; \
66
 
    } } while (0)
67
 
 
68
 
/*-- armor.c --*/
69
 
const char * _cdk_armor_get_lineend (void);
70
 
     
71
 
/*-- main.c --*/
72
 
int _cdk_get_log_level (void);
73
 
void _cdk_log_info (const char * fmt, ...);
74
 
void _cdk_log_debug (const char * fmt, ...);
75
 
char * _cdk_passphrase_get (cdk_ctx_t hd, const char *prompt);
76
 
 
77
 
/*-- misc.c --*/
78
 
int _cdk_check_args( int overwrite, const char * in, const char * out );
79
 
u32 _cdk_buftou32 (const byte * buf);
80
 
void _cdk_u32tobuf (u32 u, byte * buf);
81
 
const char *_cdk_memistr (const char * buf, size_t buflen, const char * sub);
82
 
cdk_error_t _cdk_map_gcry_error (gcry_error_t err);
83
 
#define map_gcry_error(err) _cdk_map_gcry_error (err)
84
 
 
85
 
/* Helper to provide case insentensive strstr version. */
86
 
#define stristr(haystack, needle) \
87
 
    _cdk_memistr((haystack), strlen (haystack), (needle))
88
 
 
89
 
/*-- proc-packet.c --*/
90
 
cdk_error_t _cdk_proc_packets (cdk_ctx_t hd, cdk_stream_t inp,
91
 
                               cdk_stream_t data,
92
 
                               const char *output, cdk_stream_t outstream,
93
 
                               gcry_md_hd_t md);
94
 
cdk_error_t _cdk_pkt_write2 (cdk_stream_t out, int pkttype, void *pktctx);
95
 
 
96
 
/*-- pubkey.c --*/
97
 
u32 _cdk_pkt_get_keyid (cdk_packet_t pkt, u32 * keyid);
98
 
cdk_error_t _cdk_pkt_get_fingerprint (cdk_packet_t pkt, byte *fpr);
99
 
int _cdk_pk_algo_usage (int algo);
100
 
int _cdk_pk_test_algo (int algo, unsigned int usage);
101
 
int _cdk_sk_get_csum (cdk_pkt_seckey_t sk);
102
 
 
103
 
/*-- new-packet.c --*/
104
 
byte * _cdk_subpkt_get_array (cdk_subpkt_t s, int count, size_t * r_nbytes);
105
 
cdk_error_t _cdk_subpkt_copy (cdk_subpkt_t * r_dst, cdk_subpkt_t src);
106
 
void _cdk_pkt_detach_free (cdk_packet_t pkt, int *r_pkttype, void **ctx);
107
 
 
108
 
/*-- sig-check.c --*/
109
 
cdk_error_t _cdk_sig_check (cdk_pkt_pubkey_t pk, cdk_pkt_signature_t sig,
110
 
                            gcry_md_hd_t digest, int * r_expired);
111
 
cdk_error_t _cdk_hash_sig_data (cdk_pkt_signature_t sig, gcry_md_hd_t hd);
112
 
cdk_error_t _cdk_hash_userid (cdk_pkt_userid_t uid, int sig_version, gcry_md_hd_t md);
113
 
cdk_error_t _cdk_hash_pubkey (cdk_pkt_pubkey_t pk, gcry_md_hd_t md, 
114
 
                              int use_fpr);
115
 
cdk_error_t _cdk_pk_check_sig (cdk_keydb_hd_t hd,
116
 
                               cdk_kbnode_t knode, 
117
 
                               cdk_kbnode_t snode, int *is_selfsig);
118
 
 
119
 
/*-- kbnode.c --*/
120
 
void _cdk_kbnode_add (cdk_kbnode_t root, cdk_kbnode_t node);
121
 
void _cdk_kbnode_clone (cdk_kbnode_t node);
122
 
 
123
 
/*-- sesskey.c --*/
124
 
cdk_error_t _cdk_digest_encode_pkcs1 (byte **r_md, size_t *r_mdlen, 
125
 
                                      int pk_algo,
126
 
                                      const byte * md,
127
 
                                      int digest_algo, unsigned nbits);
128
 
cdk_error_t _cdk_sk_unprotect_auto (cdk_ctx_t hd, cdk_pkt_seckey_t sk);
129
 
 
130
 
/*-- keydb.c --*/
131
 
int _cdk_keydb_is_secret (cdk_keydb_hd_t db);   
132
 
cdk_error_t _cdk_keydb_get_pk_byusage (cdk_keydb_hd_t hd, const char * name,
133
 
                               cdk_pkt_pubkey_t * ret_pk, int usage);
134
 
cdk_error_t _cdk_keydb_get_sk_byusage (cdk_keydb_hd_t hd, const char * name,
135
 
                               cdk_pkt_seckey_t * ret_sk, int usage);
136
 
cdk_error_t _cdk_keydb_check_userid (cdk_keydb_hd_t hd, u32 * keyid, 
137
 
                                     const char * id);
138
 
 
139
 
/*-- sign.c --*/
140
 
int _cdk_sig_hash_for (cdk_pkt_pubkey_t pk);
141
 
void _cdk_trim_string (char * s, int canon);
142
 
cdk_error_t _cdk_sig_create (cdk_pkt_pubkey_t pk, cdk_pkt_signature_t sig);
143
 
cdk_error_t _cdk_sig_complete (cdk_pkt_signature_t sig, cdk_pkt_seckey_t sk,
144
 
                               gcry_md_hd_t hd);
145
 
 
146
 
/*-- stream.c --*/
147
 
void _cdk_stream_set_compress_algo (cdk_stream_t s, int algo);   
148
 
cdk_error_t _cdk_stream_open_mode (const char *file, const char *mode, 
149
 
                                   cdk_stream_t *ret_s);   
150
 
void * _cdk_stream_get_opaque( cdk_stream_t s, int fid );
151
 
const char * _cdk_stream_get_fname( cdk_stream_t s );
152
 
FILE * _cdk_stream_get_fp( cdk_stream_t s );
153
 
int _cdk_stream_gets( cdk_stream_t s, char * buf, size_t count );
154
 
cdk_error_t _cdk_stream_append( const char * file, cdk_stream_t * ret_s );
155
 
int _cdk_stream_get_errno( cdk_stream_t s );
156
 
cdk_error_t _cdk_stream_set_blockmode( cdk_stream_t s, size_t nbytes );
157
 
int _cdk_stream_get_blockmode( cdk_stream_t s );
158
 
int _cdk_stream_puts( cdk_stream_t s, const char * buf );
159
 
cdk_error_t _cdk_stream_fpopen (FILE * fp, unsigned write_mode, 
160
 
                                cdk_stream_t *ret_out);
161
 
 
162
 
/*-- verify.c --*/
163
 
void _cdk_result_verify_free (cdk_verify_result_t res);
164
 
cdk_verify_result_t _cdk_result_verify_new (void);
165
 
 
166
 
 
167
 
/*-- read-packet.c --*/
168
 
size_t _cdk_pkt_read_len (FILE * inp, size_t *ret_partial);
169
 
 
170
 
/*-- write-packet.c --*/
171
 
cdk_error_t _cdk_pkt_write_fp( FILE * out, cdk_packet_t pkt );
172
 
 
173
 
/*-- seskey.c --*/
174
 
cdk_error_t _cdk_s2k_copy (cdk_s2k_t *r_dst, cdk_s2k_t src);
175
 
    
176
 
cdk_error_t cdk_dek_encode_pkcs1 (cdk_dek_t dek, size_t nbits, 
177
 
                                  gcry_mpi_t *r_enc);
178
 
cdk_error_t cdk_dek_decode_pkcs1 (cdk_dek_t * ret_dek, gcry_mpi_t esk);
179
 
cdk_error_t cdk_dek_extract (cdk_dek_t * ret_dek, cdk_ctx_t hd,
180
 
                             cdk_pkt_pubkey_enc_t enc,
181
 
                             cdk_pkt_seckey_t sk );
182
 
 
183
 
#endif /* CDK_MAIN_H */