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