summaryrefslogtreecommitdiffstats
path: root/g10/tdbio.h
diff options
context:
space:
mode:
Diffstat (limited to 'g10/tdbio.h')
-rw-r--r--g10/tdbio.h141
1 files changed, 27 insertions, 114 deletions
diff --git a/g10/tdbio.h b/g10/tdbio.h
index a2e5404f6..f2c6bec1b 100644
--- a/g10/tdbio.h
+++ b/g10/tdbio.h
@@ -1,5 +1,5 @@
/* tdbio.h - Trust database I/O functions
- * Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -18,8 +18,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#ifndef GPG_TDBIO_H
-#define GPG_TDBIO_H
+#ifndef G10_TDBIO_H
+#define G10_TDBIO_H
#include "host2net.h"
@@ -35,41 +35,13 @@
#define RECTYPE_VER 1
-#define RECTYPE_DIR 2
-#define RECTYPE_KEY 3
-#define RECTYPE_UID 4
-#define RECTYPE_PREF 5
-#define RECTYPE_SIG 6
-#define RECTYPE_SDIR 8
-#define RECTYPE_CACH 9
#define RECTYPE_HTBL 10
#define RECTYPE_HLST 11
+#define RECTYPE_TRUST 12
+#define RECTYPE_VALID 13
#define RECTYPE_FREE 254
-#define DIRF_CHECKED 1 /* has been checked - bits 1,2,3 are valid */
-#define DIRF_VALID 2 /* This key is valid: There is at least */
- /* one uid with a selfsignature or an revocation */
-#define DIRF_EXPIRED 4 /* the complete key has expired */
-#define DIRF_REVOKED 8 /* the complete key has been revoked */
-#define DIRF_NEWKEYS 128 /* new keys are available: we can check the sigs */
-
-#define KEYF_CHECKED 1 /* This key has been checked */
-#define KEYF_VALID 2 /* This is a valid (sub)key */
-#define KEYF_EXPIRED 4 /* this key is expired */
-#define KEYF_REVOKED 8 /* this key has been revoked */
-
-#define UIDF_CHECKED 1 /* user id has been checked - other bits are valid */
-#define UIDF_VALID 2 /* this is a valid user id */
-#define UIDF_REVOKED 8 /* this user id has been revoked */
-
-#define SIGF_CHECKED 1 /* signature has been checked - bits 0..6 are valid */
-#define SIGF_VALID 2 /* the signature is valid */
-#define SIGF_EXPIRED 4 /* the key of this signature has expired */
-#define SIGF_REVOKED 8 /* this signature has been revoked */
-#define SIGF_IGNORED 64 /* this signature is ignored by the system */
-#define SIGF_NOPUBKEY 128 /* there is no pubkey for this sig */
-
struct trust_record {
int rectype;
int mark;
@@ -78,73 +50,21 @@ struct trust_record {
ulong recnum;
union {
struct { /* version record: */
- byte version; /* should be 2 */
+ byte version; /* should be 3 */
byte marginals;
byte completes;
byte cert_depth;
ulong created; /* timestamp of trustdb creation */
- ulong mod_down; /* timestamp of last modification downward */
- ulong mod_up; /* timestamp of last modification upward */
- ulong keyhashtbl;
+ ulong nextcheck; /* timestamp of next scheduled check */
+ ulong reserved;
+ ulong reserved2;
ulong firstfree;
- ulong sdirhashtbl;
+ ulong reserved3;
+ ulong trusthashtbl;
} ver;
struct { /* free record */
ulong next;
} free;
- struct { /* directory record */
- ulong lid;
- ulong keylist; /* List of keys (the first is the primary key)*/
- ulong uidlist; /* list of uid records */
- ulong cacherec; /* the cache record */
- byte ownertrust;
- byte dirflags;
- byte validity; /* calculated trustlevel over all uids */
- ulong valcheck; /* timestamp of last validation check */
- ulong checkat; /* Check key when this time has been reached*/
- } dir;
- struct { /* primary public key record */
- ulong lid;
- ulong next; /* next key */
- byte keyflags;
- byte pubkey_algo;
- byte fingerprint_len;
- byte fingerprint[20];
- } key;
- struct { /* user id reord */
- ulong lid; /* point back to the directory record */
- ulong next; /* points to next user id record */
- ulong prefrec; /* recno of preference record */
- ulong siglist; /* list of valid signatures (w/o self-sig)*/
- byte uidflags;
- byte validity; /* calculated trustlevel of this uid */
- byte namehash[20]; /* ripemd hash of the username */
- } uid;
- struct { /* preference record */
- ulong lid; /* point back to the directory record */
- /* or 0 for a global pref record */
- ulong next; /* points to next pref record */
- byte data[ITEMS_PER_PREF_RECORD];
- } pref;
- struct { /* signature record */
- ulong lid;
- ulong next; /* recnno of next record or NULL for last one */
- struct {
- ulong lid; /* of pubkey record of signator (0=unused) */
- byte flag; /* SIGF_xxxxx */
- } sig[SIGS_PER_RECORD];
- } sig;
- struct {
- ulong lid;
- u32 keyid[2];
- byte pubkey_algo;
- u32 hintlist;
- } sdir;
- struct { /* cache record */
- ulong lid;
- byte blockhash[20];
- byte trustlevel; /* calculated trustlevel */
- } cache;
struct {
ulong item[ITEMS_PER_HTBL_RECORD];
} htbl;
@@ -152,25 +72,21 @@ struct trust_record {
ulong next;
ulong rnum[ITEMS_PER_HLST_RECORD]; /* of another record */
} hlst;
+ struct {
+ byte fingerprint[20];
+ byte ownertrust;
+ byte depth;
+ ulong validlist;
+ } trust;
+ struct {
+ byte namehash[20];
+ ulong next;
+ byte validity;
+ } valid;
} r;
};
typedef struct trust_record TRUSTREC;
-typedef struct {
- ulong lid; /* localid */
- ulong sigrec;
- ulong sig_lid; /* returned signatures LID */
- unsigned sig_flag; /* returned signature record flag */
- struct { /* internal data */
- int init_done;
- int eof;
- TRUSTREC rec;
- ulong nextuid;
- int index;
- } ctl;
-} SIGREC_CONTEXT;
-
-
/*-- tdbio.c --*/
int tdbio_set_dbname( const char *new_dbname, int create );
const char *tdbio_get_dbname(void);
@@ -178,8 +94,8 @@ void tdbio_dump_record( TRUSTREC *rec, FILE *fp );
int tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected );
int tdbio_write_record( TRUSTREC *rec );
int tdbio_db_matches_options(void);
-ulong tdbio_read_modify_stamp( int modify_down );
-void tdbio_write_modify_stamp( int up, int down );
+ulong tdbio_read_nextcheck (void);
+int tdbio_write_nextcheck (ulong stamp);
int tdbio_is_dirty(void);
int tdbio_sync(void);
int tdbio_begin_transaction(void);
@@ -187,12 +103,9 @@ int tdbio_end_transaction(void);
int tdbio_cancel_transaction(void);
int tdbio_delete_record( ulong recnum );
ulong tdbio_new_recnum(void);
-int tdbio_search_dir_bypk( PKT_public_key *pk, TRUSTREC *rec );
-int tdbio_search_dir_byfpr( const byte *fingerprint, size_t fingerlen,
- int pubkey_algo, TRUSTREC *rec );
-int tdbio_search_dir( u32 *keyid, int pubkey_algo, TRUSTREC *rec );
-int tdbio_search_sdir( u32 *keyid, int pubkey_algo, TRUSTREC *rec );
+int tdbio_search_trust_byfpr(const byte *fingerprint, TRUSTREC *rec );
+int tdbio_search_trust_bypk(PKT_public_key *pk, TRUSTREC *rec );
void tdbio_invalid(void);
-#endif /*GPG_TDBIO_H*/
+#endif /*G10_TDBIO_H*/