chiark / gitweb /
asshelp.c: add a lot of debug logging
[gnupg2.git] / g10 / test-stubs.c
1 /* test-stubs.c - The GnuPG signature verify utility
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2006,
3  *               2008, 2009, 2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GnuPG.
6  *
7  * GnuPG is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * GnuPG is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, see <https://www.gnu.org/licenses/>.
19  */
20
21 #include <config.h>
22 #include <errno.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <ctype.h>
27 #include <unistd.h>
28
29 #define INCLUDED_BY_MAIN_MODULE 1
30 #include "gpg.h"
31 #include "util.h"
32 #include "packet.h"
33 #include "iobuf.h"
34 #include "main.h"
35 #include "options.h"
36 #include "keydb.h"
37 #include "trustdb.h"
38 #include "filter.h"
39 #include "ttyio.h"
40 #include "i18n.h"
41 #include "sysutils.h"
42 #include "status.h"
43 #include "call-agent.h"
44
45 int g10_errors_seen;
46
47
48 void
49 g10_exit( int rc )
50 {
51   rc = rc? rc : log_get_errorcount(0)? 2 : g10_errors_seen? 1 : 0;
52   exit(rc );
53 }
54
55
56 /* Stub:
57  * We have to override the trustcheck from pkclist.c because
58  * this utility assumes that all keys in the keyring are trustworthy
59  */
60 int
61 check_signatures_trust (ctrl_t ctrl, PKT_signature *sig)
62 {
63   (void)ctrl;
64   (void)sig;
65   return 0;
66 }
67
68 void
69 read_trust_options(byte *trust_model, ulong *created, ulong *nextcheck,
70                    byte *marginals, byte *completes, byte *cert_depth,
71                    byte *min_cert_level)
72 {
73   (void)trust_model;
74   (void)created;
75   (void)nextcheck;
76   (void)marginals;
77   (void)completes;
78   (void)cert_depth;
79   (void)min_cert_level;
80 }
81
82 /* Stub:
83  * We don't have the trustdb , so we have to provide some stub functions
84  * instead
85  */
86
87 int
88 cache_disabled_value(PKT_public_key *pk)
89 {
90   (void)pk;
91   return 0;
92 }
93
94 void
95 check_trustdb_stale (ctrl_t ctrl)
96 {
97   (void)ctrl;
98 }
99
100 int
101 get_validity_info (ctrl_t ctrl, kbnode_t kb, PKT_public_key *pk,
102                    PKT_user_id *uid)
103 {
104   (void)ctrl;
105   (void)kb;
106   (void)pk;
107   (void)uid;
108   return '?';
109 }
110
111 unsigned int
112 get_validity (ctrl_t ctrl, kbnode_t kb, PKT_public_key *pk, PKT_user_id *uid,
113               PKT_signature *sig, int may_ask)
114 {
115   (void)ctrl;
116   (void)kb;
117   (void)pk;
118   (void)uid;
119   (void)sig;
120   (void)may_ask;
121   return 0;
122 }
123
124 const char *
125 trust_value_to_string (unsigned int value)
126 {
127   (void)value;
128   return "err";
129 }
130
131 const char *
132 uid_trust_string_fixed (ctrl_t ctrl, PKT_public_key *key, PKT_user_id *uid)
133 {
134   (void)ctrl;
135   (void)key;
136   (void)uid;
137   return "err";
138 }
139
140 int
141 get_ownertrust_info (PKT_public_key *pk)
142 {
143   (void)pk;
144   return '?';
145 }
146
147 unsigned int
148 get_ownertrust (PKT_public_key *pk)
149 {
150   (void)pk;
151   return TRUST_UNKNOWN;
152 }
153
154
155 /* Stubs:
156  * Because we only work with trusted keys, it does not make sense to
157  * get them from a keyserver
158  */
159
160 struct keyserver_spec *
161 keyserver_match (struct keyserver_spec *spec)
162 {
163   (void)spec;
164   return NULL;
165 }
166
167 int
168 keyserver_any_configured (ctrl_t ctrl)
169 {
170   (void)ctrl;
171   return 0;
172 }
173
174 int
175 keyserver_import_keyid (u32 *keyid, void *dummy, int quick)
176 {
177   (void)keyid;
178   (void)dummy;
179   (void)quick;
180   return -1;
181 }
182
183 int
184 keyserver_import_fprint (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
185                          struct keyserver_spec *keyserver, int quick)
186 {
187   (void)ctrl;
188   (void)fprint;
189   (void)fprint_len;
190   (void)keyserver;
191   (void)quick;
192   return -1;
193 }
194
195 int
196 keyserver_import_cert (const char *name)
197 {
198   (void)name;
199   return -1;
200 }
201
202 int
203 keyserver_import_pka (const char *name,unsigned char *fpr)
204 {
205   (void)name;
206   (void)fpr;
207   return -1;
208 }
209
210 gpg_error_t
211 keyserver_import_wkd (ctrl_t ctrl, const char *name, int quick,
212                       unsigned char **fpr, size_t *fpr_len)
213 {
214   (void)ctrl;
215   (void)name;
216   (void)quick;
217   (void)fpr;
218   (void)fpr_len;
219   return GPG_ERR_BUG;
220 }
221
222 int
223 keyserver_import_name (const char *name,struct keyserver_spec *spec)
224 {
225   (void)name;
226   (void)spec;
227   return -1;
228 }
229
230 int
231 keyserver_import_ldap (const char *name)
232 {
233   (void)name;
234   return -1;
235 }
236
237 gpg_error_t
238 read_key_from_file (ctrl_t ctrl, const char *fname, kbnode_t *r_keyblock)
239 {
240   (void)ctrl;
241   (void)fname;
242   (void)r_keyblock;
243   return -1;
244 }
245
246 /* Stub:
247  * No encryption here but mainproc links to these functions.
248  */
249 gpg_error_t
250 get_session_key (ctrl_t ctrl, PKT_pubkey_enc *k, DEK *dek)
251 {
252   (void)ctrl;
253   (void)k;
254   (void)dek;
255   return GPG_ERR_GENERAL;
256 }
257
258 /* Stub: */
259 gpg_error_t
260 get_override_session_key (DEK *dek, const char *string)
261 {
262   (void)dek;
263   (void)string;
264   return GPG_ERR_GENERAL;
265 }
266
267 /* Stub: */
268 int
269 decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek)
270 {
271   (void)ctrl;
272   (void)procctx;
273   (void)ed;
274   (void)dek;
275   return GPG_ERR_GENERAL;
276 }
277
278
279 /* Stub:
280  * No interactive commands, so we don't need the helptexts
281  */
282 void
283 display_online_help (const char *keyword)
284 {
285   (void)keyword;
286 }
287
288 /* Stub:
289  * We don't use secret keys, but getkey.c links to this
290  */
291 int
292 check_secret_key (PKT_public_key *pk, int n)
293 {
294   (void)pk;
295   (void)n;
296   return GPG_ERR_GENERAL;
297 }
298
299 /* Stub:
300  * No secret key, so no passphrase needed
301  */
302 DEK *
303 passphrase_to_dek (int cipher_algo, STRING2KEY *s2k, int create, int nocache,
304                    const char *tmp, int *canceled)
305 {
306   (void)cipher_algo;
307   (void)s2k;
308   (void)create;
309   (void)nocache;
310   (void)tmp;
311
312   if (canceled)
313     *canceled = 0;
314   return NULL;
315 }
316
317 void
318 passphrase_clear_cache (const char *cacheid)
319 {
320   (void)cacheid;
321 }
322
323 struct keyserver_spec *
324 parse_preferred_keyserver(PKT_signature *sig)
325 {
326   (void)sig;
327   return NULL;
328 }
329
330 struct keyserver_spec *
331 parse_keyserver_uri (const char *uri, int require_scheme,
332                      const char *configname, unsigned int configlineno)
333 {
334   (void)uri;
335   (void)require_scheme;
336   (void)configname;
337   (void)configlineno;
338   return NULL;
339 }
340
341 void
342 free_keyserver_spec (struct keyserver_spec *keyserver)
343 {
344   (void)keyserver;
345 }
346
347 /* Stubs to avoid linking to photoid.c */
348 void
349 show_photos (const struct user_attribute *attrs, int count, PKT_public_key *pk)
350 {
351   (void)attrs;
352   (void)count;
353   (void)pk;
354 }
355
356 int
357 parse_image_header (const struct user_attribute *attr, byte *type, u32 *len)
358 {
359   (void)attr;
360   (void)type;
361   (void)len;
362   return 0;
363 }
364
365 char *
366 image_type_to_string (byte type, int string)
367 {
368   (void)type;
369   (void)string;
370   return NULL;
371 }
372
373 #ifdef ENABLE_CARD_SUPPORT
374 int
375 agent_scd_getattr (const char *name, struct agent_card_info_s *info)
376 {
377   (void)name;
378   (void)info;
379   return 0;
380 }
381 #endif /* ENABLE_CARD_SUPPORT */
382
383 /* We do not do any locking, so use these stubs here */
384 void
385 dotlock_disable (void)
386 {
387 }
388
389 dotlock_t
390 dotlock_create (const char *file_to_lock, unsigned int flags)
391 {
392   (void)file_to_lock;
393   (void)flags;
394   return NULL;
395 }
396
397 void
398 dotlock_destroy (dotlock_t h)
399 {
400   (void)h;
401 }
402
403 int
404 dotlock_take (dotlock_t h, long timeout)
405 {
406   (void)h;
407   (void)timeout;
408   return 0;
409 }
410
411 int
412 dotlock_release (dotlock_t h)
413 {
414   (void)h;
415   return 0;
416 }
417
418 void
419 dotlock_remove_lockfiles (void)
420 {
421 }
422
423 gpg_error_t
424 agent_probe_secret_key (ctrl_t ctrl, PKT_public_key *pk)
425 {
426   (void)ctrl;
427   (void)pk;
428   return gpg_error (GPG_ERR_NO_SECKEY);
429 }
430
431 gpg_error_t
432 agent_probe_any_secret_key (ctrl_t ctrl, kbnode_t keyblock)
433 {
434   (void)ctrl;
435   (void)keyblock;
436   return gpg_error (GPG_ERR_NO_SECKEY);
437 }
438
439 gpg_error_t
440 agent_get_keyinfo (ctrl_t ctrl, const char *hexkeygrip,
441                    char **r_serialno, int *r_cleartext)
442 {
443   (void)ctrl;
444   (void)hexkeygrip;
445   (void)r_cleartext;
446   *r_serialno = NULL;
447   return gpg_error (GPG_ERR_NO_SECKEY);
448 }
449
450 gpg_error_t
451 gpg_dirmngr_get_pka (ctrl_t ctrl, const char *userid,
452                      unsigned char **r_fpr, size_t *r_fprlen,
453                      char **r_url)
454 {
455   (void)ctrl;
456   (void)userid;
457   if (r_fpr)
458     *r_fpr = NULL;
459   if (r_fprlen)
460     *r_fprlen = 0;
461   if (r_url)
462     *r_url = NULL;
463   return gpg_error (GPG_ERR_NOT_FOUND);
464 }
465
466 gpg_error_t
467 export_pubkey_buffer (ctrl_t ctrl, const char *keyspec, unsigned int options,
468                       export_stats_t stats,
469                       kbnode_t *r_keyblock, void **r_data, size_t *r_datalen)
470 {
471   (void)ctrl;
472   (void)keyspec;
473   (void)options;
474   (void)stats;
475
476   *r_keyblock = NULL;
477   *r_data = NULL;
478   *r_datalen = 0;
479   return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
480 }
481
482 gpg_error_t
483 tofu_write_tfs_record (ctrl_t ctrl, estream_t fp,
484                        PKT_public_key *pk, const char *user_id)
485 {
486   (void)ctrl;
487   (void)fp;
488   (void)pk;
489   (void)user_id;
490   return gpg_error (GPG_ERR_GENERAL);
491 }
492
493 gpg_error_t
494 tofu_get_policy (ctrl_t ctrl, PKT_public_key *pk, PKT_user_id *user_id,
495                  enum tofu_policy *policy)
496 {
497   (void)ctrl;
498   (void)pk;
499   (void)user_id;
500   (void)policy;
501   return gpg_error (GPG_ERR_GENERAL);
502 }
503
504 const char *
505 tofu_policy_str (enum tofu_policy policy)
506 {
507   (void)policy;
508
509   return "unknown";
510 }
511
512 void
513 tofu_begin_batch_update (ctrl_t ctrl)
514 {
515   (void)ctrl;
516 }
517
518 void
519 tofu_end_batch_update (ctrl_t ctrl)
520 {
521   (void)ctrl;
522 }
523
524 gpg_error_t
525 tofu_notice_key_changed (ctrl_t ctrl, kbnode_t kb)
526 {
527   (void) ctrl;
528   (void) kb;
529
530   return 0;
531 }