1998-07-09 15:37:17 +02:00
|
|
|
/* tdbio.h - Trust database I/O functions
|
2012-01-20 04:33:51 +01:00
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2012 Free Software Foundation, Inc.
|
1998-07-09 15:37:17 +02:00
|
|
|
*
|
1998-12-23 13:41:40 +01:00
|
|
|
* This file is part of GnuPG.
|
1998-07-09 15:37:17 +02:00
|
|
|
*
|
1998-12-23 13:41:40 +01:00
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
1998-07-09 15:37:17 +02:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-04 21:49:40 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1998-07-09 15:37:17 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
1998-12-23 13:41:40 +01:00
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
1998-07-09 15:37:17 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
1998-07-09 15:37:17 +02:00
|
|
|
*/
|
|
|
|
|
2002-06-29 15:46:34 +02:00
|
|
|
#ifndef G10_TDBIO_H
|
|
|
|
#define G10_TDBIO_H
|
1998-07-09 15:37:17 +02:00
|
|
|
|
2017-03-07 12:21:23 +01:00
|
|
|
#include "../common/host2net.h"
|
1998-07-09 15:37:17 +02:00
|
|
|
|
|
|
|
#define TRUST_RECORD_LEN 40
|
|
|
|
#define SIGS_PER_RECORD ((TRUST_RECORD_LEN-10)/5)
|
|
|
|
#define ITEMS_PER_HTBL_RECORD ((TRUST_RECORD_LEN-2)/4)
|
|
|
|
#define ITEMS_PER_HLST_RECORD ((TRUST_RECORD_LEN-6)/5)
|
1998-08-05 18:51:59 +02:00
|
|
|
#define ITEMS_PER_PREF_RECORD (TRUST_RECORD_LEN-10)
|
|
|
|
#if ITEMS_PER_PREF_RECORD % 2
|
* armor.c, g10.c, kbnode.c, misc.c, pkclist.c, sign.c, build-packet.c,
getkey.c, keydb.c, openfile.c, plaintext.c, status.c, gpgv.c, keygen.c,
options.h, sig-check.c, tdbio.h, encode.c, mainproc.c, parse-packet.c,
signal.c, textfilter.c: Edit all preprocessor instructions to remove
whitespace before the '#'. This is not required by C89, but there are some
compilers out there that don't like it.
2003-05-24 23:50:33 +02:00
|
|
|
#error ITEMS_PER_PREF_RECORD must be even
|
1998-08-05 18:51:59 +02:00
|
|
|
#endif
|
1998-07-09 15:37:17 +02:00
|
|
|
#define MAX_LIST_SIGS_DEPTH 20
|
|
|
|
|
|
|
|
|
|
|
|
#define RECTYPE_VER 1
|
1998-07-14 19:10:28 +02:00
|
|
|
#define RECTYPE_HTBL 10
|
|
|
|
#define RECTYPE_HLST 11
|
2002-06-29 15:46:34 +02:00
|
|
|
#define RECTYPE_TRUST 12
|
|
|
|
#define RECTYPE_VALID 13
|
1998-10-07 15:30:43 +02:00
|
|
|
#define RECTYPE_FREE 254
|
1998-07-09 15:37:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
struct trust_record {
|
|
|
|
int rectype;
|
1998-07-15 20:05:01 +02:00
|
|
|
int mark;
|
1998-10-12 22:16:38 +02:00
|
|
|
int dirty; /* for now only used internal by functions */
|
1998-10-07 15:30:43 +02:00
|
|
|
struct trust_record *next; /* help pointer to build lists in memory */
|
1998-07-15 20:05:01 +02:00
|
|
|
ulong recnum;
|
1998-07-09 15:37:17 +02:00
|
|
|
union {
|
1998-07-29 21:35:05 +02:00
|
|
|
struct { /* version record: */
|
2003-01-06 23:56:08 +01:00
|
|
|
byte version; /* should be 3 */
|
1998-11-13 20:41:41 +01:00
|
|
|
byte marginals;
|
|
|
|
byte completes;
|
|
|
|
byte cert_depth;
|
2002-12-04 01:05:11 +01:00
|
|
|
byte trust_model;
|
2012-01-20 04:33:51 +01:00
|
|
|
byte min_cert_level;
|
1998-07-09 15:37:17 +02:00
|
|
|
ulong created; /* timestamp of trustdb creation */
|
2002-06-29 15:46:34 +02:00
|
|
|
ulong nextcheck; /* timestamp of next scheduled check */
|
2011-02-04 12:57:53 +01:00
|
|
|
ulong reserved;
|
2002-06-29 15:46:34 +02:00
|
|
|
ulong reserved2;
|
1998-10-07 15:30:43 +02:00
|
|
|
ulong firstfree;
|
2002-06-29 15:46:34 +02:00
|
|
|
ulong reserved3;
|
|
|
|
ulong trusthashtbl;
|
1998-07-09 15:37:17 +02:00
|
|
|
} ver;
|
1998-10-07 15:30:43 +02:00
|
|
|
struct { /* free record */
|
|
|
|
ulong next;
|
|
|
|
} free;
|
1998-07-09 15:37:17 +02:00
|
|
|
struct {
|
|
|
|
ulong item[ITEMS_PER_HTBL_RECORD];
|
|
|
|
} htbl;
|
|
|
|
struct {
|
1998-07-14 19:10:28 +02:00
|
|
|
ulong next;
|
1998-10-12 22:16:38 +02:00
|
|
|
ulong rnum[ITEMS_PER_HLST_RECORD]; /* of another record */
|
1998-07-09 15:37:17 +02:00
|
|
|
} hlst;
|
2002-06-29 15:46:34 +02:00
|
|
|
struct {
|
|
|
|
byte fingerprint[20];
|
|
|
|
byte ownertrust;
|
|
|
|
byte depth;
|
|
|
|
ulong validlist;
|
* keyedit.c (print_and_check_one_sig, show_key_and_fingerprint,
menu_addrevoker), keylist.c (list_keyblock_print, print_fingerprint): Show
"T" or the trust depth for trust signatures, and add spaces to some
strings to make room for it.
* packet.h, parse-packet.c (dump_sig_subpkt, parse_one_sig_subpkt,
parse_signature): Parse trust signature values.
* tdbio.h, tdbio.c (tdbio_read_record, tdbio_write_record): Reserve a byte
for the minimum ownertrust value (for use with trust signatures).
2002-10-29 19:00:07 +01:00
|
|
|
byte min_ownertrust;
|
2021-11-13 20:34:06 +01:00
|
|
|
byte flags;
|
2002-06-29 15:46:34 +02:00
|
|
|
} trust;
|
|
|
|
struct {
|
|
|
|
byte namehash[20];
|
2011-02-04 12:57:53 +01:00
|
|
|
ulong next;
|
2002-06-29 15:46:34 +02:00
|
|
|
byte validity;
|
2003-01-06 23:56:08 +01:00
|
|
|
byte full_count;
|
|
|
|
byte marginal_count;
|
2002-06-29 15:46:34 +02:00
|
|
|
} valid;
|
1998-07-09 15:37:17 +02:00
|
|
|
} r;
|
|
|
|
};
|
|
|
|
typedef struct trust_record TRUSTREC;
|
|
|
|
|
|
|
|
/*-- tdbio.c --*/
|
2017-03-31 20:03:52 +02:00
|
|
|
int tdbio_update_version_record (ctrl_t ctrl);
|
|
|
|
int tdbio_set_dbname (ctrl_t ctrl, const char *new_dbname,
|
|
|
|
int create, int *r_nofile);
|
1998-07-09 15:37:17 +02:00
|
|
|
const char *tdbio_get_dbname(void);
|
2015-02-19 17:22:27 +01:00
|
|
|
void tdbio_dump_record( TRUSTREC *rec, estream_t fp );
|
1998-07-09 15:37:17 +02:00
|
|
|
int tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected );
|
2017-03-31 20:03:52 +02:00
|
|
|
int tdbio_write_record (ctrl_t ctrl, TRUSTREC *rec);
|
1998-11-13 20:41:41 +01:00
|
|
|
int tdbio_db_matches_options(void);
|
2003-04-26 22:38:16 +02:00
|
|
|
byte tdbio_read_model(void);
|
2002-06-29 15:46:34 +02:00
|
|
|
ulong tdbio_read_nextcheck (void);
|
2017-03-31 20:03:52 +02:00
|
|
|
int tdbio_write_nextcheck (ctrl_t ctrl, ulong stamp);
|
1998-10-25 20:00:01 +01:00
|
|
|
int tdbio_is_dirty(void);
|
1998-10-16 18:00:17 +02:00
|
|
|
int tdbio_sync(void);
|
1998-10-25 20:00:01 +01:00
|
|
|
int tdbio_begin_transaction(void);
|
|
|
|
int tdbio_end_transaction(void);
|
|
|
|
int tdbio_cancel_transaction(void);
|
2017-03-31 20:03:52 +02:00
|
|
|
int tdbio_delete_record (ctrl_t ctrl, ulong recnum);
|
|
|
|
ulong tdbio_new_recnum (ctrl_t ctrl);
|
2024-03-04 14:22:42 +01:00
|
|
|
gpg_error_t tdbio_search_trust_byfpr (ctrl_t ctrl,
|
|
|
|
const byte *fpr, unsigned int fprlen,
|
2018-03-26 18:06:43 +02:00
|
|
|
TRUSTREC *rec);
|
|
|
|
gpg_error_t tdbio_search_trust_bypk (ctrl_t ctrl, PKT_public_key *pk,
|
|
|
|
TRUSTREC *rec);
|
1998-07-09 15:37:17 +02:00
|
|
|
|
2009-07-22 11:43:10 +02:00
|
|
|
void tdbio_how_to_fix (void);
|
1999-03-11 16:42:06 +01:00
|
|
|
void tdbio_invalid(void);
|
1998-07-09 15:37:17 +02:00
|
|
|
|
2002-06-29 15:46:34 +02:00
|
|
|
#endif /*G10_TDBIO_H*/
|