Initial import from FreeBSD RELENG_4:
[dragonfly.git] / crypto / kerberosIV / lib / kdb / krb_db.h
1 /*
2  * $Id: krb_db.h,v 1.15 1996/12/17 20:34:32 assar Exp $ 
3  * $FreeBSD: src/crypto/kerberosIV/lib/kdb/krb_db.h,v 1.3 1999/09/19 21:56:06 markm Exp $ 
4  *
5  * Copyright 1987, 1988 by the Massachusetts Institute of Technology. 
6  *
7  * For copying and distribution information, please see the file
8  * <mit-copyright.h>. 
9  *
10  * spm          Project Athena  8/85 
11  *
12  * This file defines data structures for the kerberos
13  * authentication/authorization database. 
14  *
15  * They MUST correspond to those defined in *.rel 
16  */
17
18 #ifndef KRB_DB_DEFS
19 #define KRB_DB_DEFS
20
21 #include <stdio.h>
22
23 #define KERB_M_NAME             "K"     /* Kerberos */
24 #define KERB_M_INST             "M"     /* Master */
25 #define KERB_DEFAULT_NAME       "default"
26 #define KERB_DEFAULT_INST       ""
27 #ifndef DB_DIR
28 #define DB_DIR                  "/var/db/kerberos"
29 #endif
30 #ifndef DBM_FILE
31 #define DBM_FILE                DB_DIR "/principal"
32 #endif
33
34 /* this also defines the number of queue headers */
35 #define KERB_DB_HASH_MODULO 64
36
37
38 /* Arguments to kerb_dbl_lock() */
39
40 #define KERB_DBL_EXCLUSIVE 1
41 #define KERB_DBL_SHARED 0
42
43 /* arguments to kerb_db_set_lockmode() */
44
45 #define KERB_DBL_BLOCKING 0
46 #define KERB_DBL_NONBLOCKING 1
47
48 /* arguments to kdb_get_master_key */
49
50 #define KDB_GET_PROMPT 1
51 #define KDB_GET_TWICE  2
52
53 /* Principal defines the structure of a principal's name */
54
55 typedef struct {
56     char    name[ANAME_SZ];
57     char    instance[INST_SZ];
58
59     u_int32_t key_low;
60     u_int32_t key_high;
61     u_int32_t exp_date;
62     char    exp_date_txt[DATE_SZ];
63     u_int32_t mod_date;
64     char    mod_date_txt[DATE_SZ];
65     u_int16_t attributes;
66     u_int8_t max_life;
67     u_int8_t kdc_key_ver;
68     u_int8_t key_version;
69
70     char    mod_name[ANAME_SZ];
71     char    mod_instance[INST_SZ];
72     char   *old;                /* cast to (Principal *); not in db,
73                                  * ptr to old vals */
74 } Principal;
75
76 typedef struct {
77     int32_t    cpu;
78     int32_t    elapsed;
79     int32_t    dio;
80     int32_t    pfault;
81     int32_t    t_stamp;
82     int32_t    n_retrieve;
83     int32_t    n_replace;
84     int32_t    n_append;
85     int32_t    n_get_stat;
86     int32_t    n_put_stat;
87 } DB_stat;
88
89 /* Dba defines the structure of a database administrator */
90
91 typedef struct {
92     char    name[ANAME_SZ];
93     char    instance[INST_SZ];
94     u_int16_t attributes;
95     u_int32_t exp_date;
96     char    exp_date_txt[DATE_SZ];
97     char   *old;        /*
98                          * cast to (Dba *); not in db, ptr to
99                          * old vals
100                          */
101 } Dba;
102
103 typedef int (*k_iter_proc_t)(void*, Principal*);
104
105 void copy_from_key __P((des_cblock in, u_int32_t *lo, u_int32_t *hi));
106 void copy_to_key __P((u_int32_t *lo, u_int32_t *hi, des_cblock out));
107
108 void kdb_encrypt_key __P((des_cblock *, des_cblock *, des_cblock *,
109                           des_key_schedule, int));
110 int kdb_get_master_key __P((int prompt, des_cblock *master_key,
111                             des_key_schedule master_key_sched));
112 int kdb_get_new_master_key __P((des_cblock *, des_key_schedule, int));
113 int kdb_kstash __P((des_cblock *, char *));
114 int kdb_new_get_master_key __P((des_cblock *, des_key_schedule));
115 int kdb_new_get_new_master_key __P((des_cblock *key, des_key_schedule schedule, int verify));
116 long kdb_verify_master_key __P((des_cblock *, des_key_schedule, FILE *));
117 long *kerb_db_begin_update __P((void));
118 int kerb_db_create __P((char *db_name));
119 int kerb_db_delete_principal (char *name, char *inst);
120 void kerb_db_end_update __P((long *db));
121 int kerb_db_get_dba __P((char *, char *, Dba *, unsigned, int *));
122 void kerb_db_get_stat __P((DB_stat *));
123 int kerb_db_iterate __P((k_iter_proc_t, void*));
124 int kerb_db_put_principal __P((Principal *, unsigned int));
125 void kerb_db_put_stat __P((DB_stat *));
126 int kerb_db_rename __P((char *, char *));
127 int kerb_db_set_lockmode __P((int));
128 int kerb_db_set_name __P((char *));
129 int kerb_db_update __P((long *db, Principal *principal, unsigned int max));
130 int kerb_delete_principal __P((char *name, char *inst));
131 void kerb_fini __P((void));
132 int kerb_get_dba __P((char *, char *, Dba *, unsigned int, int *));
133 time_t kerb_get_db_age __P((void));
134 int kerb_get_principal __P((char *, char *, Principal *, unsigned int, int *));
135 int kerb_init __P((void));
136 int kerb_put_principal __P((Principal *, unsigned int));
137
138 #endif /* KRB_DB_DEFS */