xref: /freebsd/lib/libc/rpc/rpc_secure.3 (revision c6ff3a1bf74d96278726113478b2c66884aab584)
1e8636dfdSBill Paul.\" @(#)rpc_secure.3n	2.1 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
27f3dea24SPeter Wemm.\" $FreeBSD$
3fbc400a6SNik Clayton.\"
4125c8263SPhilippe Charnier.Dd February 16, 1988
5125c8263SPhilippe Charnier.Dt RPC 3
6125c8263SPhilippe Charnier.Sh NAME
7125c8263SPhilippe Charnier.Nm rpc_secure
8125c8263SPhilippe Charnier.Nd library routines for secure remote procedure calls
9125c8263SPhilippe Charnier.Sh SYNOPSIS
10125c8263SPhilippe Charnier.Fd #include <rpc/rpc.h>
11125c8263SPhilippe Charnier.Ft AUTH *
12125c8263SPhilippe Charnier.Fo authdes_create
13125c8263SPhilippe Charnier.Fa "char *name"
14125c8263SPhilippe Charnier.Fa "unsigned window"
15d142a33bSBruce Evans.Fa "struct sockaddr *addr"
16125c8263SPhilippe Charnier.Fa "des_block *ckey"
17125c8263SPhilippe Charnier.Fc
18d142a33bSBruce Evans.Ft int
19d142a33bSBruce Evans.Fn authdes_getucred "struct authdes_cred *adc" "uid_t *uid" "gid_t *gid" "int *grouplen" "gid_t *groups"
20d142a33bSBruce Evans.Ft int
21d142a33bSBruce Evans.Fn getnetname "char *name"
22d142a33bSBruce Evans.Ft int
23125c8263SPhilippe Charnier.Fn host2netname "char *name" "char *host" "char *domain"
24d142a33bSBruce Evans.Ft int
25d142a33bSBruce Evans.Fn key_decryptsession "const char *remotename" "des_block *deskey"
26d142a33bSBruce Evans.Ft int
27d142a33bSBruce Evans.Fn key_encryptsession "const char *remotename" "des_block *deskey"
28d142a33bSBruce Evans.Ft int
29125c8263SPhilippe Charnier.Fn key_gendes "des_block *deskey"
30d142a33bSBruce Evans.Ft int
31d142a33bSBruce Evans.Fn key_setsecret "const char *key"
32d142a33bSBruce Evans.Ft int
33125c8263SPhilippe Charnier.Fn netname2host "char *name" "char *host" "int hostlen"
34d142a33bSBruce Evans.Ft int
35d142a33bSBruce Evans.Fn netname2user "char *name" "uid_t *uidp" "gid_t *gidp" "int *gidlenp" "gid_t *gidlist"
36d142a33bSBruce Evans.Ft int
37d142a33bSBruce Evans.Fn user2netname "char *name" "uid_t uid" "char *domain"
38125c8263SPhilippe Charnier.Sh DESCRIPTION
39125c8263SPhilippe CharnierThese routines are part of the
40125c8263SPhilippe Charnier.Tn RPC
41125c8263SPhilippe Charnierlibrary.  They implement
42125c8263SPhilippe Charnier.Tn DES
43e8636dfdSBill PaulAuthentication.  See
44125c8263SPhilippe Charnier.Xr rpc 3
45125c8263SPhilippe Charnierfor further details about
46125c8263SPhilippe Charnier.Tn RPC .
47125c8263SPhilippe Charnier.Pp
48125c8263SPhilippe CharnierThe
49125c8263SPhilippe Charnier.Fn authdes_create
50e8636dfdSBill Paulis the first of two routines which interface to the
51125c8263SPhilippe Charnier.Tn RPC
52e8636dfdSBill Paulsecure authentication system, known as
53125c8263SPhilippe Charnier.Tn DES
54e8636dfdSBill Paulauthentication.
55e8636dfdSBill PaulThe second is
56125c8263SPhilippe Charnier.Fn authdes_getucred ,
57125c8263SPhilippe Charnierbelow.
58125c8263SPhilippe Charnier.Pp
59125c8263SPhilippe CharnierNote: the keyserver daemon
60125c8263SPhilippe Charnier.Xr keyserv 8
61e8636dfdSBill Paulmust be running for the
62125c8263SPhilippe Charnier.Tn DES
63e8636dfdSBill Paulauthentication system to work.
64125c8263SPhilippe Charnier.Pp
65125c8263SPhilippe Charnier.Fn Authdes_create ,
66e8636dfdSBill Paulused on the client side, returns an authentication handle that
67e8636dfdSBill Paulwill enable the use of the secure authentication system.
68e8636dfdSBill PaulThe first parameter
69125c8263SPhilippe Charnier.Fa name
70e8636dfdSBill Paulis the network name, or
71125c8263SPhilippe Charnier.Fa netname ,
72c6ff3a1bSSheldon Hearnof the owner of the server process.
73c6ff3a1bSSheldon HearnThis field usually
74e8636dfdSBill Paulrepresents a
75125c8263SPhilippe Charnier.Fa hostname
76e8636dfdSBill Paulderived from the utility routine
77125c8263SPhilippe Charnier.Fn host2netname ,
78e8636dfdSBill Paulbut could also represent a user name using
79125c8263SPhilippe Charnier.Fn user2netname .
80e8636dfdSBill PaulThe second field is window on the validity of
81e8636dfdSBill Paulthe client credential, given in seconds.  A small
82e8636dfdSBill Paulwindow is more secure than a large one, but choosing
83e8636dfdSBill Paultoo small of a window will increase the frequency of
84c6ff3a1bSSheldon Hearnresynchronizations because of clock drift.
85c6ff3a1bSSheldon HearnThe third
86e8636dfdSBill Paulparameter
87125c8263SPhilippe Charnier.Fa addr
88e8636dfdSBill Paulis optional.  If it is
89125c8263SPhilippe Charnier.Dv NULL ,
90e8636dfdSBill Paulthen the authentication system will assume
91e8636dfdSBill Paulthat the local clock is always in sync with the server's
92c6ff3a1bSSheldon Hearnclock, and will not attempt resynchronizations.
93c6ff3a1bSSheldon HearnIf an address
94e8636dfdSBill Paulis supplied, however, then the system will use the address
95e8636dfdSBill Paulfor consulting the remote time service whenever
96e8636dfdSBill Paulresynchronization
97c6ff3a1bSSheldon Hearnis required.
98c6ff3a1bSSheldon HearnThis parameter is usually the
99e8636dfdSBill Pauladdress of the
100125c8263SPhilippe Charnier.Tn RPC
101c6ff3a1bSSheldon Hearnserver itself.
102c6ff3a1bSSheldon HearnThe final parameter
103125c8263SPhilippe Charnier.Fa ckey
104e8636dfdSBill Paulis also optional.  If it is
105125c8263SPhilippe Charnier.Dv NULL ,
106e8636dfdSBill Paulthen the authentication system will
107e8636dfdSBill Paulgenerate a random
108125c8263SPhilippe Charnier.Tn DES
109e8636dfdSBill Paulkey to be used for the encryption of credentials.
110e8636dfdSBill PaulIf it is supplied, however, then it will be used instead.
111125c8263SPhilippe Charnier.Pp
112125c8263SPhilippe Charnier.Fn Authdes_getucred ,
113e8636dfdSBill Paulthe second of the two
114125c8263SPhilippe Charnier.Tn DES
115e8636dfdSBill Paulauthentication routines,
116e8636dfdSBill Paulis used on the server side for converting a
117125c8263SPhilippe Charnier.Tn DES
118e8636dfdSBill Paulcredential, which is
119e8636dfdSBill Pauloperating system independent, into a
120125c8263SPhilippe Charnier.Ux
121c6ff3a1bSSheldon Hearncredential.
122c6ff3a1bSSheldon HearnThis routine differs from utility routine
123125c8263SPhilippe Charnier.Fn netname2user
124e8636dfdSBill Paulin that
125125c8263SPhilippe Charnier.Fn authdes_getucred
126e8636dfdSBill Paulpulls its information from a cache, and does not have to do a
127e8636dfdSBill PaulYellow Pages lookup every time it is called to get its information.
128125c8263SPhilippe Charnier.Pp
129125c8263SPhilippe Charnier.Fn Getnetname
130125c8263SPhilippe Charnierinstalls the unique, operating-system independent netname of
131125c8263SPhilippe Charnierthe
132125c8263SPhilippe Charniercaller in the fixed-length array
133125c8263SPhilippe Charnier.Fa name .
134125c8263SPhilippe CharnierReturns
135125c8263SPhilippe Charnier.Dv TRUE
136e8636dfdSBill Paulif it succeeds and
137125c8263SPhilippe Charnier.Dv FALSE
138125c8263SPhilippe Charnierif it fails.
139125c8263SPhilippe Charnier.Pp
140125c8263SPhilippe Charnier.Fn Host2netname
141125c8263SPhilippe Charnierconverts from a domain-specific hostname to an
142c6ff3a1bSSheldon Hearnoperating-system independent netname.
143c6ff3a1bSSheldon HearnReturns
144125c8263SPhilippe Charnier.Dv TRUE
145125c8263SPhilippe Charnierif it succeeds and
146125c8263SPhilippe Charnier.Dv FALSE
147c6ff3a1bSSheldon Hearnif it fails.
148c6ff3a1bSSheldon HearnInverse of
149125c8263SPhilippe Charnier.Fn netname2host .
150125c8263SPhilippe Charnier.Pp
151125c8263SPhilippe Charnier.Fn Key_decryptsession
152e8636dfdSBill Paulis an interface to the keyserver daemon, which is associated
153e8636dfdSBill Paulwith
154125c8263SPhilippe Charnier.Tn RPC Ns 's
155125c8263SPhilippe Charniersecure authentication system (
156125c8263SPhilippe Charnier.Tn DES
157e8636dfdSBill Paulauthentication).
158e8636dfdSBill PaulUser programs rarely need to call it, or its associated routines
159125c8263SPhilippe Charnier.Fn key_encryptsession ,
160125c8263SPhilippe Charnier.Fn key_gendes
161e8636dfdSBill Pauland
162125c8263SPhilippe Charnier.Fn key_setsecret .
163e8636dfdSBill PaulSystem commands such as
164125c8263SPhilippe Charnier.Xr login 1
165e8636dfdSBill Pauland the
166125c8263SPhilippe Charnier.Tn RPC
167e8636dfdSBill Paullibrary are the main clients of these four routines.
168125c8263SPhilippe Charnier.Pp
169125c8263SPhilippe Charnier.Fn Key_decryptsession
170125c8263SPhilippe Charniertakes a server netname and a
171125c8263SPhilippe Charnier.Tn DES
172125c8263SPhilippe Charnierkey, and decrypts the key by
173e8636dfdSBill Paulusing the the public key of the the server and the secret key
174e8636dfdSBill Paulassociated with the effective uid of the calling process.  It
175e8636dfdSBill Paulis the inverse of
176125c8263SPhilippe Charnier.Fn key_encryptsession .
177125c8263SPhilippe Charnier.Pp
178125c8263SPhilippe Charnier.Fn Key_encryptsession
179c6ff3a1bSSheldon Hearnis a keyserver interface routine.
180c6ff3a1bSSheldon HearnIt
181e8636dfdSBill Paultakes a server netname and a des key, and encrypts
182e8636dfdSBill Paulit using the public key of the the server and the secret key
183e8636dfdSBill Paulassociated with the effective uid of the calling process.  It
184e8636dfdSBill Paulis the inverse of
185125c8263SPhilippe Charnier.Fn key_decryptsession .
186125c8263SPhilippe Charnier.Pp
187125c8263SPhilippe Charnier.Fn Key_gendes
188c6ff3a1bSSheldon Hearnis a keyserver interface routine.
189c6ff3a1bSSheldon HearnIt
190e8636dfdSBill Paulis used to ask the keyserver for a secure conversation key.
191125c8263SPhilippe CharnierChoosing one
192125c8263SPhilippe Charnier.Qq random
193125c8263SPhilippe Charnieris usually not good enough,
194e8636dfdSBill Paulbecause
195e8636dfdSBill Paulthe common ways of choosing random numbers, such as using the
196e8636dfdSBill Paulcurrent time, are very easy to guess.
197125c8263SPhilippe Charnier.Pp
198125c8263SPhilippe Charnier.Fn Key_setsecret
199c6ff3a1bSSheldon Hearnis a keyserver interface routine.
200c6ff3a1bSSheldon HearnIt is used to set the key for
201e8636dfdSBill Paulthe effective
202125c8263SPhilippe Charnier.Fa uid
203e8636dfdSBill Paulof the calling process.
204125c8263SPhilippe Charnier.Pp
205125c8263SPhilippe Charnier.Fn Netname2host
206125c8263SPhilippe Charnierconverts from an operating-system independent netname to a
207c6ff3a1bSSheldon Hearndomain-specific hostname.
208c6ff3a1bSSheldon HearnReturns
209125c8263SPhilippe Charnier.Dv TRUE
210e8636dfdSBill Paulif it succeeds and
211125c8263SPhilippe Charnier.Dv FALSE
212e8636dfdSBill Paulif it fails.  Inverse of
213125c8263SPhilippe Charnier.Fn host2netname .
214125c8263SPhilippe Charnier.Pp
215125c8263SPhilippe Charnier.Fn Netname2user
216125c8263SPhilippe Charnierconverts from an operating-system independent netname to a
217125c8263SPhilippe Charnierdomain-specific user ID.
218e8636dfdSBill PaulReturns
219125c8263SPhilippe Charnier.Dv TRUE
220e8636dfdSBill Paulif it succeeds and
221125c8263SPhilippe Charnier.Dv FALSE
222c6ff3a1bSSheldon Hearnif it fails.
223c6ff3a1bSSheldon HearnInverse of
224125c8263SPhilippe Charnier.Fn user2netname .
225125c8263SPhilippe Charnier.Pp
226125c8263SPhilippe Charnier.Fn User2netname
227125c8263SPhilippe Charnierconverts from a domain-specific username to an operating-system
228c6ff3a1bSSheldon Hearnindependent netname.
229c6ff3a1bSSheldon HearnReturns
230125c8263SPhilippe Charnier.Dv TRUE
231e8636dfdSBill Paulif it succeeds and
232125c8263SPhilippe Charnier.Dv FALSE
233c6ff3a1bSSheldon Hearnif it fails.
234c6ff3a1bSSheldon HearnInverse of
235125c8263SPhilippe Charnier.Fn netname2user .
236125c8263SPhilippe Charnier.Sh SEE ALSO
237125c8263SPhilippe Charnier.Xr rpc 3 ,
238125c8263SPhilippe Charnier.Xr xdr 3 ,
239125c8263SPhilippe Charnier.Xr keyserv 8
240125c8263SPhilippe Charnier.Pp
241e8636dfdSBill PaulThe following manuals:
242125c8263SPhilippe Charnier.Rs
243125c8263SPhilippe Charnier.%B Remote Procedure Calls: Protocol Specification
244125c8263SPhilippe Charnier.Re
245125c8263SPhilippe Charnier.Rs
246125c8263SPhilippe Charnier.%B Remote Procedure Call Programming Guide
247125c8263SPhilippe Charnier.Re
248125c8263SPhilippe Charnier.Rs
249125c8263SPhilippe Charnier.%B Rpcgen Programming Guide
250125c8263SPhilippe Charnier.Re
251125c8263SPhilippe Charnier.Rs
252125c8263SPhilippe Charnier.%B RPC: Remote Procedure Call Protocol Specification
253125c8263SPhilippe Charnier.%O RFC1050, Sun Microsystems Inc., USC-ISI
254125c8263SPhilippe Charnier.Re
255