aboutsummaryrefslogtreecommitdiff
path: root/doc/implement/kdb-i.tex
blob: 9583f5a12f854b50f43821599d0bc9e739a39ecf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
The \libname{libkdb.a} library provides a principal database interface
to be used by the Key Distribution center and other database
manipulation tools.


\begin{funcdecl}{krb5_db_set_name}{krb5_error_code}{\funcin}
\funcarg{char *}{name}
\end{funcdecl}

Set the name of the database to \funcparam{name}.  If it doesn't exist,
an error code is returned.

Must be called before \funcname{krb5_db_init} or after
\funcname{krb5_db_fini}; must not be called while db functions are active.

\begin{funcdecl}{krb5_db_set_nonblocking}{krb5_error_code}{\funcin}
\funcarg{krb5_boolean}{newmode}
\funcout
\funcarg{krb5_boolean *}{oldmode}
\end{funcdecl}

Changes the locking mode of the database functions, returning the previous
mode in \funcparam{*oldmode}.

If \funcparam{newmode} is TRUE, then the database is put into
non-blocking mode, which may result in "database busy" error codes from
the get, put, and iterate routines.

If \funcparam{newmode} is FALSE, then the database is put into blocking mode,
which may result in delays from the get, put and iterate routines.

The default database mode is blocking mode.

\begin{funcdecl}{krb5_db_init}{krb5_error_code}{\funcvoid}
\end{funcdecl}

Called before using \funcname{krb5_db_get_principal},
\funcname{krb5_db_put_principal}, \funcname{krb5_db_iterate}, and
\funcname{krb5_db_set_nonblocking}.

Does any required initialization.

Errors: init errors, system errors.

\begin{funcdecl}{krb5_db_fini}{krb5_error_code}{\funcvoid}
\end{funcdecl}

Called after all database operations are complete, to perform any required
clean-up.

Errors: sysytem errors.


\begin{funcdecl}{krb5_db_get_age}{krb5_error_code}{\funcin}
\funcarg{char *}{db_name}
\funcout
\funcarg{time_t *}{age}
\end{funcdecl}

Retrieves the age of the database \funcname{db_name} (or the current
default database if \funcname{db_name} is NULL).

\funcparam{*age} is filled in in local system time units, and represents
the last modification time of the database.

Errors: system errors.


\begin{funcdecl}{krb5_db_create}{krb5_error_code}{\funcin}
\funcarg{char *}{db_name}
\end{funcdecl}

Creates a new database named \funcname{db_name}.  Will not create a
database by that name if it already exists.  The database must be
populated by the caller by using \funcname{krb5_db_put_principal}.

Errors: db exists, system errors.

\begin{funcdecl}{krb5_db_rename}{krb5_error_code}{\funcin}
\funcarg{char *}{source}
\funcarg{char *}{dest}
\end{funcdecl}
Renames the database \funcarg{source} to \funcarg{dest}

Any database named \funcarg{dest} is destroyed.

Errors: system errors.

\begin{funcdecl}{krb5_db_get_principal}{krb5_error_code}{\funcin}
\funcarg{krb5_principal}{searchfor}
\funcout
\funcarg{krb5_db_entry *}{entries}
\funcinout
\funcarg{int *}{nentries}
\funcout
\funcarg{krb5_boolean *}{more}
\end{funcdecl}

Retrieves the principal records named by \funcparam{searchfor}.

\funcparam{entries} must point to an array of \funcparam{*nentries}
krb5_db_entry structures.
At most \funcparam{*nentries} structures are filled in, and
\funcparam{*nentries} is modified to reflect the number actually returned.

\funcparam{*nentries} must be at least one (1) when this function is called.

\funcparam{*more} is set to TRUE if there are more records that wouldn't fit
in the available space, and FALSE otherwise.

The principal structures filled in have pointers to allocated storage;
\funcname{krb5_db_free_principal} should be called with
\funcparam{entries} and \funcparam{*nentries}
in order to free this storage when no longer needed.


\begin{funcdecl}{krb5_db_free_principal}{void}{\funcin}
\funcarg{krb5_db_entry *}{entries}
\funcarg{int}{nentries}
\end{funcdecl}

Frees allocated storage held by \funcparam{entries} as filled in by
\funcname{krb5_db_get_principal}.


\begin{funcdecl}{krb5_db_put_principal}{krb5_error_code}{\funcin}
\funcarg{krb5_db_entry *}{entries}
\funcarg{int *}{nentries}
\end{funcdecl}

Stores the \funcparam{*nentries} principal structures pointed to by
\funcparam{entries} in the database.

\funcparam{*nentries} is updated upon return to reflect the number of records
acutally stored; the first \funcparam{*nentries} records will have been
stored in the database.

Returns error code if not all entries were stored.

\begin{funcdecl}{krb5_db_iterate}{krb5_error_code}{\funcin}
\funcfuncarg{krb5_error_code}{(*func)}
\funcarg{krb5_pointer}{}
\funcarg{krb5_db_entry *}{}
\funcendfuncarg
\funcarg{krb5_pointer}{iterate_arg}
\end{funcdecl}

Iterates over the database, fetching every entry in an unspecified order
and calling \funcparam{(*func)}(\funcparam{iterate_arg},
{\sl principal}) where {\sl principal} points to a record from the database.

If \funcparam{(*func)}() ever returns an error code, the iteration is
aborted and that error code is returned by this function.

\begin{funcdecl}{krb5_db_store_mkey}{krb5_error_code}{\funcin}
\funcarg{char *}{keyfile}
\funcarg{krb5_principal}{mname}
\funcarg{krb5_keyblock *}{key}
\end{funcdecl}

Put the KDC database master key into the file \funcparam{keyfile}. If
\funcparam{keyfile} is NULL, then a default file name derived from the
principal name \funcparam{mname} is used.

\begin{funcdecl}{krb5_db_fetch_mkey}{krb5_error_code}{\funcin}
\funcarg{krb5_principal}{mname}
\funcarg{krb5_encrypt_block *}{eblock}
\funcarg{krb5_boolean}{fromkeyboard}
\funcarg{krb5_boolean}{twice}
\funcinout
\funcarg{krb5_keyblock *}{key}
\end{funcdecl}

Get the KDC database master key from somewhere, filling it into
\funcparam{*key}. 
\funcparam{key{\ptsto}keytype} should be set to the desired key type.
If \funcparam{fromkeyboard} is TRUE, then the master key is read as a password
from the user's terminal.  In this case,
\funcparam{eblock} should point to a block with an appropriate
\funcname{string_to_key}  function.
If \funcparam{twice} is TRUE, the password is read twice for verification.

If \funcparam{fromkeyboard} is false, then the key is read from
a file whose name is derived from the principal name \funcparam{mname}.

\funcparam{mname} is the name of the key sought; this is often used by
\funcname{string_to_key} to aid in conversion of the password to a key. 

\begin{funcdecl}{krb5_kdb_encrypt_key}{krb5_error_code}{\funcin}
\funcarg{krb5_encrypt_block *}{eblock}
\funcarg{krb5_keyblock *}{in}
\funcinout
\funcarg{krb5_keyblock *}{out}
\end{funcdecl}

Encrypt a key for storage in the database.  \funcparam{eblock} is used
to encrypt the key in \funcparam{in} into \funcparam{out}; the storage
pointed to by \funcparam{*out} is allocated before use and should be
freed when the caller is finished with it.

\begin{funcdecl}{krb5_kdb_decrypt_key}{krb5_error_code}{\funcin}
\funcarg{krb5_encrypt_block *}{eblock}
\funcarg{krb5_keyblock *}{in}
\funcinout
\funcarg{krb5_keyblock *}{out}
\end{funcdecl}

Decrypt a key from storage in the database.  \funcparam{eblock} is used
to decrypt the key in \funcparam{in} into \funcparam{out}; the storage
pointed to by \funcparam{*out} is allocated before use and should be
freed when the caller is finished with it.

\begin{funcdecl}{krb5_db_setup_mkey_name}{krb5_error_code}{\funcin}
\funcarg{const}{char *keyname}
\funcarg{const}{char *realm}
\funcout
\funcarg{char **}{fullname}
\funcarg{krb5_principal *}{principal}
\end{funcdecl}

Given a key name \funcparam{keyname} and a realm name \funcparam{realm},
construct a principal which can be used to fetch the master key from the
database.  This principal is filled into \funcparam{*principal};
\funcparam{*principal} should be freed by \funcname{krb5_free_principal}
when the caller is finished.

If \funcparam{keyname} is NULL, the default key name will be used.

If \funcparam{fullname} is not NULL, it is set to point to a string
representation of the complete principal name; its storage may be freed
by calling \funcname{free} on \funcparam{*fullname}.