xref: /freebsd/lib/libc/rpc/rpc_secure.3 (revision a90b9d0159070121c221b966469c3e36d912bf82)
1.\"
2.Dd February 16, 1988
3.Dt RPC 3
4.Os
5.Sh NAME
6.Nm rpc_secure
7.Nd library routines for secure remote procedure calls
8.Sh SYNOPSIS
9.In rpc/rpc.h
10.Ft AUTH *
11.Fo authdes_create
12.Fa "char *name"
13.Fa "unsigned window"
14.Fa "struct sockaddr *addr"
15.Fa "des_block *ckey"
16.Fc
17.Ft int
18.Fn authdes_getucred "struct authdes_cred *adc" "uid_t *uid" "gid_t *gid" "int *grouplen" "gid_t *groups"
19.Ft int
20.Fn getnetname "char *name"
21.Ft int
22.Fn host2netname "char *name" "const char *host" "const char *domain"
23.Ft int
24.Fn key_decryptsession "const char *remotename" "des_block *deskey"
25.Ft int
26.Fn key_encryptsession "const char *remotename" "des_block *deskey"
27.Ft int
28.Fn key_gendes "des_block *deskey"
29.Ft int
30.Fn key_setsecret "const char *key"
31.Ft int
32.Fn netname2host "char *name" "char *host" "int hostlen"
33.Ft int
34.Fn netname2user "char *name" "uid_t *uidp" "gid_t *gidp" "int *gidlenp" "gid_t *gidlist"
35.Ft int
36.Fn user2netname "char *name" "const uid_t uid" "const char *domain"
37.Sh DESCRIPTION
38These routines are part of the
39.Tn RPC
40library.
41They implement
42.Tn DES
43Authentication.
44See
45.Xr rpc 3
46for further details about
47.Tn RPC .
48.Pp
49The
50.Fn authdes_create
51is the first of two routines which interface to the
52.Tn RPC
53secure authentication system, known as
54.Tn DES
55authentication.
56The second is
57.Fn authdes_getucred ,
58below.
59.Pp
60Note: the keyserver daemon
61.Xr keyserv 8
62must be running for the
63.Tn DES
64authentication system to work.
65.Pp
66The
67.Fn authdes_create
68function,
69used on the client side, returns an authentication handle that
70will enable the use of the secure authentication system.
71The first argument
72.Fa name
73is the network name, or
74.Fa netname ,
75of the owner of the server process.
76This field usually
77represents a
78.Fa hostname
79derived from the utility routine
80.Fn host2netname ,
81but could also represent a user name using
82.Fn user2netname .
83The second field is window on the validity of
84the client credential, given in seconds.
85A small
86window is more secure than a large one, but choosing
87too small of a window will increase the frequency of
88resynchronizations because of clock drift.
89The third
90argument
91.Fa addr
92is optional.
93If it is
94.Dv NULL ,
95then the authentication system will assume
96that the local clock is always in sync with the server's
97clock, and will not attempt resynchronizations.
98If an address
99is supplied, however, then the system will use the address
100for consulting the remote time service whenever
101resynchronization
102is required.
103This argument is usually the
104address of the
105.Tn RPC
106server itself.
107The final argument
108.Fa ckey
109is also optional.
110If it is
111.Dv NULL ,
112then the authentication system will
113generate a random
114.Tn DES
115key to be used for the encryption of credentials.
116If it is supplied, however, then it will be used instead.
117.Pp
118The
119.Fn authdes_getucred
120function,
121the second of the two
122.Tn DES
123authentication routines,
124is used on the server side for converting a
125.Tn DES
126credential, which is
127operating system independent, into a
128.Ux
129credential.
130This routine differs from utility routine
131.Fn netname2user
132in that
133.Fn authdes_getucred
134pulls its information from a cache, and does not have to do a
135Yellow Pages lookup every time it is called to get its information.
136.Pp
137The
138.Fn getnetname
139function
140installs the unique, operating-system independent netname of
141the
142caller in the fixed-length array
143.Fa name .
144Returns
145.Dv TRUE
146if it succeeds and
147.Dv FALSE
148if it fails.
149.Pp
150The
151.Fn host2netname
152function
153converts from a domain-specific hostname to an
154operating-system independent netname.
155Returns
156.Dv TRUE
157if it succeeds and
158.Dv FALSE
159if it fails.
160Inverse of
161.Fn netname2host .
162.Pp
163The
164.Fn key_decryptsession
165function
166is an interface to the keyserver daemon, which is associated
167with
168.Tn RPC Ns 's
169secure authentication system
170.Tn ( DES
171authentication).
172User programs rarely need to call it, or its associated routines
173.Fn key_encryptsession ,
174.Fn key_gendes
175and
176.Fn key_setsecret .
177System commands such as
178.Xr login 1
179and the
180.Tn RPC
181library are the main clients of these four routines.
182.Pp
183The
184.Fn key_decryptsession
185function
186takes a server netname and a
187.Tn DES
188key, and decrypts the key by
189using the public key of the server and the secret key
190associated with the effective uid of the calling process.
191It
192is the inverse of
193.Fn key_encryptsession .
194.Pp
195The
196.Fn key_encryptsession
197function
198is a keyserver interface routine.
199It
200takes a server netname and a des key, and encrypts
201it using the public key of the server and the secret key
202associated with the effective uid of the calling process.
203It
204is the inverse of
205.Fn key_decryptsession .
206.Pp
207The
208.Fn key_gendes
209function
210is a keyserver interface routine.
211It
212is used to ask the keyserver for a secure conversation key.
213Choosing one
214.Qq random
215is usually not good enough,
216because
217the common ways of choosing random numbers, such as using the
218current time, are very easy to guess.
219.Pp
220The
221.Fn key_setsecret
222function
223is a keyserver interface routine.
224It is used to set the key for
225the effective
226.Fa uid
227of the calling process.
228.Pp
229The
230.Fn netname2host
231function
232converts from an operating-system independent netname to a
233domain-specific hostname.
234Returns
235.Dv TRUE
236if it succeeds and
237.Dv FALSE
238if it fails.
239Inverse of
240.Fn host2netname .
241.Pp
242The
243.Fn netname2user
244function
245converts from an operating-system independent netname to a
246domain-specific user ID.
247Returns
248.Dv TRUE
249if it succeeds and
250.Dv FALSE
251if it fails.
252Inverse of
253.Fn user2netname .
254.Pp
255The
256.Fn user2netname
257function
258converts from a domain-specific username to an operating-system
259independent netname.
260Returns
261.Dv TRUE
262if it succeeds and
263.Dv FALSE
264if it fails.
265Inverse of
266.Fn netname2user .
267.Sh SEE ALSO
268.Xr rpc 3 ,
269.Xr xdr 3 ,
270.Xr keyserv 8
271.Pp
272The following manuals:
273.Rs
274.%B Remote Procedure Calls: Protocol Specification
275.Re
276.Rs
277.%B Remote Procedure Call Programming Guide
278.Re
279.Rs
280.%B Rpcgen Programming Guide
281.Re
282.Rs
283.%B RPC: Remote Procedure Call Protocol Specification
284.%O RFC1050, Sun Microsystems Inc., USC-ISI
285.Re
286