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 688544700SRuslan Ermilov.Os 7125c8263SPhilippe Charnier.Sh NAME 8125c8263SPhilippe Charnier.Nm rpc_secure 9125c8263SPhilippe Charnier.Nd library routines for secure remote procedure calls 10125c8263SPhilippe Charnier.Sh SYNOPSIS 1132eef9aeSRuslan Ermilov.In rpc/rpc.h 12125c8263SPhilippe Charnier.Ft AUTH * 13125c8263SPhilippe Charnier.Fo authdes_create 14125c8263SPhilippe Charnier.Fa "char *name" 15125c8263SPhilippe Charnier.Fa "unsigned window" 16d142a33bSBruce Evans.Fa "struct sockaddr *addr" 17125c8263SPhilippe Charnier.Fa "des_block *ckey" 18125c8263SPhilippe Charnier.Fc 19d142a33bSBruce Evans.Ft int 20d142a33bSBruce Evans.Fn authdes_getucred "struct authdes_cred *adc" "uid_t *uid" "gid_t *gid" "int *grouplen" "gid_t *groups" 21d142a33bSBruce Evans.Ft int 22d142a33bSBruce Evans.Fn getnetname "char *name" 23d142a33bSBruce Evans.Ft int 24db7534cfSBruce Evans.Fn host2netname "char *name" "const char *host" "const char *domain" 25d142a33bSBruce Evans.Ft int 26d142a33bSBruce Evans.Fn key_decryptsession "const char *remotename" "des_block *deskey" 27d142a33bSBruce Evans.Ft int 28d142a33bSBruce Evans.Fn key_encryptsession "const char *remotename" "des_block *deskey" 29d142a33bSBruce Evans.Ft int 30125c8263SPhilippe Charnier.Fn key_gendes "des_block *deskey" 31d142a33bSBruce Evans.Ft int 32d142a33bSBruce Evans.Fn key_setsecret "const char *key" 33d142a33bSBruce Evans.Ft int 34125c8263SPhilippe Charnier.Fn netname2host "char *name" "char *host" "int hostlen" 35d142a33bSBruce Evans.Ft int 36d142a33bSBruce Evans.Fn netname2user "char *name" "uid_t *uidp" "gid_t *gidp" "int *gidlenp" "gid_t *gidlist" 37d142a33bSBruce Evans.Ft int 38db7534cfSBruce Evans.Fn user2netname "char *name" "const uid_t uid" "const char *domain" 39125c8263SPhilippe Charnier.Sh DESCRIPTION 40125c8263SPhilippe CharnierThese routines are part of the 41125c8263SPhilippe Charnier.Tn RPC 42125c8263SPhilippe Charnierlibrary. They implement 43125c8263SPhilippe Charnier.Tn DES 44e8636dfdSBill PaulAuthentication. See 45125c8263SPhilippe Charnier.Xr rpc 3 46125c8263SPhilippe Charnierfor further details about 47125c8263SPhilippe Charnier.Tn RPC . 48125c8263SPhilippe Charnier.Pp 49125c8263SPhilippe CharnierThe 50125c8263SPhilippe Charnier.Fn authdes_create 51e8636dfdSBill Paulis the first of two routines which interface to the 52125c8263SPhilippe Charnier.Tn RPC 53e8636dfdSBill Paulsecure authentication system, known as 54125c8263SPhilippe Charnier.Tn DES 55e8636dfdSBill Paulauthentication. 56e8636dfdSBill PaulThe second is 57125c8263SPhilippe Charnier.Fn authdes_getucred , 58125c8263SPhilippe Charnierbelow. 59125c8263SPhilippe Charnier.Pp 60125c8263SPhilippe CharnierNote: the keyserver daemon 61125c8263SPhilippe Charnier.Xr keyserv 8 62e8636dfdSBill Paulmust be running for the 63125c8263SPhilippe Charnier.Tn DES 64e8636dfdSBill Paulauthentication system to work. 65125c8263SPhilippe Charnier.Pp 66125c8263SPhilippe Charnier.Fn Authdes_create , 67e8636dfdSBill Paulused on the client side, returns an authentication handle that 68e8636dfdSBill Paulwill enable the use of the secure authentication system. 69e8636dfdSBill PaulThe first parameter 70125c8263SPhilippe Charnier.Fa name 71e8636dfdSBill Paulis the network name, or 72125c8263SPhilippe Charnier.Fa netname , 73c6ff3a1bSSheldon Hearnof the owner of the server process. 74c6ff3a1bSSheldon HearnThis field usually 75e8636dfdSBill Paulrepresents a 76125c8263SPhilippe Charnier.Fa hostname 77e8636dfdSBill Paulderived from the utility routine 78125c8263SPhilippe Charnier.Fn host2netname , 79e8636dfdSBill Paulbut could also represent a user name using 80125c8263SPhilippe Charnier.Fn user2netname . 81e8636dfdSBill PaulThe second field is window on the validity of 82e8636dfdSBill Paulthe client credential, given in seconds. A small 83e8636dfdSBill Paulwindow is more secure than a large one, but choosing 84e8636dfdSBill Paultoo small of a window will increase the frequency of 85c6ff3a1bSSheldon Hearnresynchronizations because of clock drift. 86c6ff3a1bSSheldon HearnThe third 87e8636dfdSBill Paulparameter 88125c8263SPhilippe Charnier.Fa addr 89e8636dfdSBill Paulis optional. If it is 90125c8263SPhilippe Charnier.Dv NULL , 91e8636dfdSBill Paulthen the authentication system will assume 92e8636dfdSBill Paulthat the local clock is always in sync with the server's 93c6ff3a1bSSheldon Hearnclock, and will not attempt resynchronizations. 94c6ff3a1bSSheldon HearnIf an address 95e8636dfdSBill Paulis supplied, however, then the system will use the address 96e8636dfdSBill Paulfor consulting the remote time service whenever 97e8636dfdSBill Paulresynchronization 98c6ff3a1bSSheldon Hearnis required. 99c6ff3a1bSSheldon HearnThis parameter is usually the 100e8636dfdSBill Pauladdress of the 101125c8263SPhilippe Charnier.Tn RPC 102c6ff3a1bSSheldon Hearnserver itself. 103c6ff3a1bSSheldon HearnThe final parameter 104125c8263SPhilippe Charnier.Fa ckey 105e8636dfdSBill Paulis also optional. If it is 106125c8263SPhilippe Charnier.Dv NULL , 107e8636dfdSBill Paulthen the authentication system will 108e8636dfdSBill Paulgenerate a random 109125c8263SPhilippe Charnier.Tn DES 110e8636dfdSBill Paulkey to be used for the encryption of credentials. 111e8636dfdSBill PaulIf it is supplied, however, then it will be used instead. 112125c8263SPhilippe Charnier.Pp 113125c8263SPhilippe Charnier.Fn Authdes_getucred , 114e8636dfdSBill Paulthe second of the two 115125c8263SPhilippe Charnier.Tn DES 116e8636dfdSBill Paulauthentication routines, 117e8636dfdSBill Paulis used on the server side for converting a 118125c8263SPhilippe Charnier.Tn DES 119e8636dfdSBill Paulcredential, which is 120e8636dfdSBill Pauloperating system independent, into a 121125c8263SPhilippe Charnier.Ux 122c6ff3a1bSSheldon Hearncredential. 123c6ff3a1bSSheldon HearnThis routine differs from utility routine 124125c8263SPhilippe Charnier.Fn netname2user 125e8636dfdSBill Paulin that 126125c8263SPhilippe Charnier.Fn authdes_getucred 127e8636dfdSBill Paulpulls its information from a cache, and does not have to do a 128e8636dfdSBill PaulYellow Pages lookup every time it is called to get its information. 129125c8263SPhilippe Charnier.Pp 130125c8263SPhilippe Charnier.Fn Getnetname 131125c8263SPhilippe Charnierinstalls the unique, operating-system independent netname of 132125c8263SPhilippe Charnierthe 133125c8263SPhilippe Charniercaller in the fixed-length array 134125c8263SPhilippe Charnier.Fa name . 135125c8263SPhilippe CharnierReturns 136125c8263SPhilippe Charnier.Dv TRUE 137e8636dfdSBill Paulif it succeeds and 138125c8263SPhilippe Charnier.Dv FALSE 139125c8263SPhilippe Charnierif it fails. 140125c8263SPhilippe Charnier.Pp 141125c8263SPhilippe Charnier.Fn Host2netname 142125c8263SPhilippe Charnierconverts from a domain-specific hostname to an 143c6ff3a1bSSheldon Hearnoperating-system independent netname. 144c6ff3a1bSSheldon HearnReturns 145125c8263SPhilippe Charnier.Dv TRUE 146125c8263SPhilippe Charnierif it succeeds and 147125c8263SPhilippe Charnier.Dv FALSE 148c6ff3a1bSSheldon Hearnif it fails. 149c6ff3a1bSSheldon HearnInverse of 150125c8263SPhilippe Charnier.Fn netname2host . 151125c8263SPhilippe Charnier.Pp 152125c8263SPhilippe Charnier.Fn Key_decryptsession 153e8636dfdSBill Paulis an interface to the keyserver daemon, which is associated 154e8636dfdSBill Paulwith 155125c8263SPhilippe Charnier.Tn RPC Ns 's 15694ba280cSRuslan Ermilovsecure authentication system 15794ba280cSRuslan Ermilov.Tn ( DES 158e8636dfdSBill Paulauthentication). 159e8636dfdSBill PaulUser programs rarely need to call it, or its associated routines 160125c8263SPhilippe Charnier.Fn key_encryptsession , 161125c8263SPhilippe Charnier.Fn key_gendes 162e8636dfdSBill Pauland 163125c8263SPhilippe Charnier.Fn key_setsecret . 164e8636dfdSBill PaulSystem commands such as 165125c8263SPhilippe Charnier.Xr login 1 166e8636dfdSBill Pauland the 167125c8263SPhilippe Charnier.Tn RPC 168e8636dfdSBill Paullibrary are the main clients of these four routines. 169125c8263SPhilippe Charnier.Pp 170125c8263SPhilippe Charnier.Fn Key_decryptsession 171125c8263SPhilippe Charniertakes a server netname and a 172125c8263SPhilippe Charnier.Tn DES 173125c8263SPhilippe Charnierkey, and decrypts the key by 174a910f192SDima Dorfmanusing the public key of the server and the secret key 175e8636dfdSBill Paulassociated with the effective uid of the calling process. It 176e8636dfdSBill Paulis the inverse of 177125c8263SPhilippe Charnier.Fn key_encryptsession . 178125c8263SPhilippe Charnier.Pp 179125c8263SPhilippe Charnier.Fn Key_encryptsession 180c6ff3a1bSSheldon Hearnis a keyserver interface routine. 181c6ff3a1bSSheldon HearnIt 182e8636dfdSBill Paultakes a server netname and a des key, and encrypts 1831d8ffb44SSheldon Hearnit using the public key of the server and the secret key 184e8636dfdSBill Paulassociated with the effective uid of the calling process. It 185e8636dfdSBill Paulis the inverse of 186125c8263SPhilippe Charnier.Fn key_decryptsession . 187125c8263SPhilippe Charnier.Pp 188125c8263SPhilippe Charnier.Fn Key_gendes 189c6ff3a1bSSheldon Hearnis a keyserver interface routine. 190c6ff3a1bSSheldon HearnIt 191e8636dfdSBill Paulis used to ask the keyserver for a secure conversation key. 192125c8263SPhilippe CharnierChoosing one 193125c8263SPhilippe Charnier.Qq random 194125c8263SPhilippe Charnieris usually not good enough, 195e8636dfdSBill Paulbecause 196e8636dfdSBill Paulthe common ways of choosing random numbers, such as using the 197e8636dfdSBill Paulcurrent time, are very easy to guess. 198125c8263SPhilippe Charnier.Pp 199125c8263SPhilippe Charnier.Fn Key_setsecret 200c6ff3a1bSSheldon Hearnis a keyserver interface routine. 201c6ff3a1bSSheldon HearnIt is used to set the key for 202e8636dfdSBill Paulthe effective 203125c8263SPhilippe Charnier.Fa uid 204e8636dfdSBill Paulof the calling process. 205125c8263SPhilippe Charnier.Pp 206125c8263SPhilippe Charnier.Fn Netname2host 207125c8263SPhilippe Charnierconverts from an operating-system independent netname to a 208c6ff3a1bSSheldon Hearndomain-specific hostname. 209c6ff3a1bSSheldon HearnReturns 210125c8263SPhilippe Charnier.Dv TRUE 211e8636dfdSBill Paulif it succeeds and 212125c8263SPhilippe Charnier.Dv FALSE 213e8636dfdSBill Paulif it fails. Inverse of 214125c8263SPhilippe Charnier.Fn host2netname . 215125c8263SPhilippe Charnier.Pp 216125c8263SPhilippe Charnier.Fn Netname2user 217125c8263SPhilippe Charnierconverts from an operating-system independent netname to a 218125c8263SPhilippe Charnierdomain-specific user ID. 219e8636dfdSBill PaulReturns 220125c8263SPhilippe Charnier.Dv TRUE 221e8636dfdSBill Paulif it succeeds and 222125c8263SPhilippe Charnier.Dv FALSE 223c6ff3a1bSSheldon Hearnif it fails. 224c6ff3a1bSSheldon HearnInverse of 225125c8263SPhilippe Charnier.Fn user2netname . 226125c8263SPhilippe Charnier.Pp 227125c8263SPhilippe Charnier.Fn User2netname 228125c8263SPhilippe Charnierconverts from a domain-specific username to an operating-system 229c6ff3a1bSSheldon Hearnindependent netname. 230c6ff3a1bSSheldon HearnReturns 231125c8263SPhilippe Charnier.Dv TRUE 232e8636dfdSBill Paulif it succeeds and 233125c8263SPhilippe Charnier.Dv FALSE 234c6ff3a1bSSheldon Hearnif it fails. 235c6ff3a1bSSheldon HearnInverse of 236125c8263SPhilippe Charnier.Fn netname2user . 237125c8263SPhilippe Charnier.Sh SEE ALSO 238125c8263SPhilippe Charnier.Xr rpc 3 , 239125c8263SPhilippe Charnier.Xr xdr 3 , 240125c8263SPhilippe Charnier.Xr keyserv 8 241125c8263SPhilippe Charnier.Pp 242e8636dfdSBill PaulThe following manuals: 243125c8263SPhilippe Charnier.Rs 244125c8263SPhilippe Charnier.%B Remote Procedure Calls: Protocol Specification 245125c8263SPhilippe Charnier.Re 246125c8263SPhilippe Charnier.Rs 247125c8263SPhilippe Charnier.%B Remote Procedure Call Programming Guide 248125c8263SPhilippe Charnier.Re 249125c8263SPhilippe Charnier.Rs 250125c8263SPhilippe Charnier.%B Rpcgen Programming Guide 251125c8263SPhilippe Charnier.Re 252125c8263SPhilippe Charnier.Rs 253125c8263SPhilippe Charnier.%B RPC: Remote Procedure Call Protocol Specification 254125c8263SPhilippe Charnier.%O RFC1050, Sun Microsystems Inc., USC-ISI 255125c8263SPhilippe Charnier.Re 256