xref: /freebsd/lib/libc/rpc/rpc_secure.3 (revision a8445737e740901f5f2c8d24c12ef7fc8b00134e)
1.\" @(#)rpc_secure.3n	2.1 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
2.\" $Id: rpc_secure.3,v 1.2 1998/01/05 07:12:16 charnier Exp $
3.Dd February 16, 1988
4.Dt RPC 3
5.Sh NAME
6.Nm rpc_secure
7.Nd library routines for secure remote procedure calls
8.Sh SYNOPSIS
9.Fd #include <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" "char *host" "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" "uid_t uid" "char *domain"
37.Sh DESCRIPTION
38These routines are part of the
39.Tn RPC
40library.  They implement
41.Tn DES
42Authentication.  See
43.Xr rpc 3
44for further details about
45.Tn RPC .
46.Pp
47The
48.Fn authdes_create
49is the first of two routines which interface to the
50.Tn RPC
51secure authentication system, known as
52.Tn DES
53authentication.
54The second is
55.Fn authdes_getucred ,
56below.
57.Pp
58Note: the keyserver daemon
59.Xr keyserv 8
60must be running for the
61.Tn DES
62authentication system to work.
63.Pp
64.Fn Authdes_create ,
65used on the client side, returns an authentication handle that
66will enable the use of the secure authentication system.
67The first parameter
68.Fa name
69is the network name, or
70.Fa netname ,
71of the owner of the server process. This field usually
72represents a
73.Fa hostname
74derived from the utility routine
75.Fn host2netname ,
76but could also represent a user name using
77.Fn user2netname .
78The second field is window on the validity of
79the client credential, given in seconds.  A small
80window is more secure than a large one, but choosing
81too small of a window will increase the frequency of
82resynchronizations because of clock drift. The third
83parameter
84.Fa addr
85is optional.  If it is
86.Dv NULL ,
87then the authentication system will assume
88that the local clock is always in sync with the server's
89clock, and will not attempt resynchronizations. If an address
90is supplied, however, then the system will use the address
91for consulting the remote time service whenever
92resynchronization
93is required. This parameter is usually the
94address of the
95.Tn RPC
96server itself. The final parameter
97.Fa ckey
98is also optional.  If it is
99.Dv NULL ,
100then the authentication system will
101generate a random
102.Tn DES
103key to be used for the encryption of credentials.
104If it is supplied, however, then it will be used instead.
105.Pp
106.Fn Authdes_getucred ,
107the second of the two
108.Tn DES
109authentication routines,
110is used on the server side for converting a
111.Tn DES
112credential, which is
113operating system independent, into a
114.Ux
115credential. This routine differs from utility routine
116.Fn netname2user
117in that
118.Fn authdes_getucred
119pulls its information from a cache, and does not have to do a
120Yellow Pages lookup every time it is called to get its information.
121.Pp
122.Fn Getnetname
123installs the unique, operating-system independent netname of
124the
125caller in the fixed-length array
126.Fa name .
127Returns
128.Dv TRUE
129if it succeeds and
130.Dv FALSE
131if it fails.
132.Pp
133.Fn Host2netname
134converts from a domain-specific hostname to an
135operating-system independent netname. Returns
136.Dv TRUE
137if it succeeds and
138.Dv FALSE
139if it fails. Inverse of
140.Fn netname2host .
141.Pp
142.Fn Key_decryptsession
143is an interface to the keyserver daemon, which is associated
144with
145.Tn RPC Ns 's
146secure authentication system (
147.Tn DES
148authentication).
149User programs rarely need to call it, or its associated routines
150.Fn key_encryptsession ,
151.Fn key_gendes
152and
153.Fn key_setsecret .
154System commands such as
155.Xr login 1
156and the
157.Tn RPC
158library are the main clients of these four routines.
159.Pp
160.Fn Key_decryptsession
161takes a server netname and a
162.Tn DES
163key, and decrypts the key by
164using the the public key of the the server and the secret key
165associated with the effective uid of the calling process.  It
166is the inverse of
167.Fn key_encryptsession .
168.Pp
169.Fn Key_encryptsession
170is a keyserver interface routine. It
171takes a server netname and a des key, and encrypts
172it using the public key of the the server and the secret key
173associated with the effective uid of the calling process.  It
174is the inverse of
175.Fn key_decryptsession .
176.Pp
177.Fn Key_gendes
178is a keyserver interface routine. It
179is used to ask the keyserver for a secure conversation key.
180Choosing one
181.Qq random
182is usually not good enough,
183because
184the common ways of choosing random numbers, such as using the
185current time, are very easy to guess.
186.Pp
187.Fn Key_setsecret
188is a keyserver interface routine. It is used to set the key for
189the effective
190.Fa uid
191of the calling process.
192.Pp
193.Fn Netname2host
194converts from an operating-system independent netname to a
195domain-specific hostname. Returns
196.Dv TRUE
197if it succeeds and
198.Dv FALSE
199if it fails.  Inverse of
200.Fn host2netname .
201.Pp
202.Fn Netname2user
203converts from an operating-system independent netname to a
204domain-specific user ID.
205Returns
206.Dv TRUE
207if it succeeds and
208.Dv FALSE
209if it fails. Inverse of
210.Fn user2netname .
211.Pp
212.Fn User2netname
213converts from a domain-specific username to an operating-system
214independent netname. Returns
215.Dv TRUE
216if it succeeds and
217.Dv FALSE
218if it fails. Inverse of
219.Fn netname2user .
220.Sh SEE ALSO
221.Xr rpc 3 ,
222.Xr xdr 3 ,
223.Xr keyserv 8
224.Pp
225The following manuals:
226.Rs
227.%B Remote Procedure Calls: Protocol Specification
228.Re
229.Rs
230.%B Remote Procedure Call Programming Guide
231.Re
232.Rs
233.%B Rpcgen Programming Guide
234.Re
235.Rs
236.%B RPC: Remote Procedure Call Protocol Specification
237.%O RFC1050, Sun Microsystems Inc., USC-ISI
238.Re
239